{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hairline-shell",
  "type": "registry:block",
  "title": "Hairline Shell",
  "description": "An app frame drawn edge to edge on single hairlines, with header and footer rules running straight across, a marker that slides along the edge to the current page and a dense issue list you can walk with J and K.",
  "categories": [
    "screen",
    "Shells"
  ],
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/avatar.json",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/kbd.json",
    "https://coss.com/ui/r/menu.json",
    "https://coss.com/ui/r/tooltip.json"
  ],
  "files": [
    {
      "path": "registry/devl/hairline-shell.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { AnimatePresence, LayoutGroup, MotionConfig, motion } from \"motion/react\";\nimport {\n  ChevronDownIcon,\n  ChevronRightIcon,\n  ChevronsUpDownIcon,\n  CircleDashedIcon,\n  CircleDotIcon,\n  CircleIcon,\n  FilterIcon,\n  HouseIcon,\n  InboxIcon,\n  KeyboardIcon,\n  LayersIcon,\n  LogOutIcon,\n  type LucideIcon,\n  MenuIcon,\n  PanelLeftIcon,\n  PlusIcon,\n  RefreshCwIcon,\n  SearchIcon,\n  SettingsIcon,\n  SignalHighIcon,\n  SignalLowIcon,\n  SignalMediumIcon,\n  SquarePenIcon,\n  UserRoundIcon,\n  XIcon,\n} from \"lucide-react\";\nimport { type KeyboardEvent, type ReactElement, type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\";\nimport { Button } from \"@/components/ui/button\";\nimport { Kbd } from \"@/components/ui/kbd\";\nimport {\n  Menu,\n  MenuGroup,\n  MenuGroupLabel,\n  MenuItem,\n  MenuPopup,\n  MenuRadioGroup,\n  MenuRadioItem,\n  MenuSeparator,\n  MenuShortcut,\n  MenuTrigger,\n} from \"@/components/ui/menu\";\nimport { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from \"@/components/ui/tooltip\";\nimport { cn } from \"@/lib/utils\";\n\nexport type HairlineTone = \"orange\" | \"teal\" | \"cyan\" | \"violet\" | \"rose\" | \"info\" | \"success\" | \"warning\";\n\nexport interface HairlineWorkspace {\n  id: string;\n  name: string;\n  initial: string;\n  tone: HairlineTone;\n}\n\nexport interface HairlineNavItem {\n  id: string;\n  label: string;\n  icon: LucideIcon;\n  count?: number;\n}\n\nexport interface HairlineProject {\n  id: string;\n  name: string;\n  tone: HairlineTone;\n  prefix?: string;\n  open?: number;\n}\n\nexport interface HairlineIssue {\n  id: string;\n  title: string;\n  status: \"progress\" | \"todo\" | \"backlog\";\n  priority: \"high\" | \"medium\" | \"low\";\n  label?: { name: string; tone: HairlineTone };\n  assignee: string;\n  due?: string;\n  project?: string;\n  unread?: boolean;\n}\n\nexport interface HairlineShellProps {\n  workspaces?: HairlineWorkspace[];\n  nav?: HairlineNavItem[];\n  projects?: HairlineProject[];\n  issues?: HairlineIssue[];\n  user?: { name: string; initials: string };\n  defaultCollapsed?: boolean;\n  children?: ReactNode;\n  className?: string;\n}\n\nconst swatch: Record<HairlineTone, string> = {\n  \"orange\": \"bg-orange-500\",\n  \"teal\": \"bg-teal-500\",\n  \"cyan\": \"bg-cyan-500\",\n  \"violet\": \"bg-violet-500\",\n  \"rose\": \"bg-rose-500\",\n  info: \"bg-info\",\n  success: \"bg-success\",\n  warning: \"bg-warning\",\n};\n\nconst text: Record<HairlineTone, string> = {\n  \"orange\": \"text-orange-600 dark:text-orange-400\",\n  \"teal\": \"text-teal-600 dark:text-teal-400\",\n  \"cyan\": \"text-cyan-600 dark:text-cyan-400\",\n  \"violet\": \"text-violet-600 dark:text-violet-400\",\n  \"rose\": \"text-rose-600 dark:text-rose-400\",\n  info: \"text-info-foreground\",\n  success: \"text-success-foreground\",\n  warning: \"text-warning-foreground\",\n};\n\nconst spring = { type: \"spring\", stiffness: 500, damping: 40 } as const;\n\nconst defaultWorkspaces: HairlineWorkspace[] = [\n  { id: \"northwind\", name: \"Northwind\", initial: \"N\", tone: \"info\" },\n  { id: \"pilot\", name: \"Pilot Studio\", initial: \"P\", tone: \"teal\" },\n];\n\nconst defaultNav: HairlineNavItem[] = [\n  { id: \"home\", label: \"Home\", icon: HouseIcon },\n  { id: \"inbox\", label: \"Inbox\", icon: InboxIcon, count: 4 },\n  { id: \"mine\", label: \"My issues\", icon: CircleDotIcon },\n  { id: \"views\", label: \"Views\", icon: LayersIcon },\n];\n\nconst defaultProjects: HairlineProject[] = [\n  { id: \"billing\", name: \"Billing v2\", tone: \"teal\", prefix: \"BIL\" },\n  { id: \"atlas\", name: \"Atlas redesign\", tone: \"orange\", prefix: \"ATL\" },\n  { id: \"mobile\", name: \"Mobile beta\", tone: \"info\", prefix: \"MOB\" },\n  { id: \"growth\", name: \"Growth\", tone: \"violet\", prefix: \"GRO\" },\n  { id: \"infra\", name: \"Infra\", tone: \"rose\", prefix: \"INF\" },\n];\n\nconst defaultIssues: HairlineIssue[] = [\n  { id: \"BIL-142\", title: \"Prorate seat changes mid-cycle\", status: \"progress\", priority: \"high\", label: { name: \"Pricing\", tone: \"orange\" }, assignee: \"IM\", due: \"Oct 28\" },\n  { id: \"BIL-139\", title: \"Retry failed card charges with backoff\", status: \"progress\", priority: \"high\", label: { name: \"Payments\", tone: \"teal\" }, assignee: \"KT\", due: \"Oct 30\" },\n  { id: \"BIL-151\", title: \"Invoice PDF uses workspace logo\", status: \"progress\", priority: \"medium\", assignee: \"RL\" },\n  { id: \"BIL-128\", title: \"Usage meter rounds to two decimals\", status: \"progress\", priority: \"low\", label: { name: \"Bug\", tone: \"warning\" }, assignee: \"TB\", due: \"Nov 2\" },\n  { id: \"BIL-155\", title: \"Tax ID field for EU workspaces\", status: \"todo\", priority: \"high\", label: { name: \"Compliance\", tone: \"info\" }, assignee: \"IM\", due: \"Nov 6\", unread: true },\n  { id: \"BIL-157\", title: \"Show next invoice estimate on plan page\", status: \"todo\", priority: \"medium\", label: { name: \"Pricing\", tone: \"orange\" }, assignee: \"RL\" },\n  { id: \"BIL-160\", title: \"Webhook for subscription.paused\", status: \"todo\", priority: \"medium\", label: { name: \"API\", tone: \"violet\" }, assignee: \"KT\" },\n  { id: \"BIL-161\", title: \"Downgrade flow keeps annual discount\", status: \"todo\", priority: \"low\", assignee: \"TB\", due: \"Nov 9\" },\n  { id: \"BIL-163\", title: \"Copy pass on failed payment emails\", status: \"todo\", priority: \"low\", assignee: \"RL\" },\n  { id: \"BIL-118\", title: \"Credit notes for partial refunds\", status: \"backlog\", priority: \"medium\", label: { name: \"Payments\", tone: \"teal\" }, assignee: \"KT\" },\n  { id: \"BIL-121\", title: \"Multi-currency price books\", status: \"backlog\", priority: \"low\", label: { name: \"Pricing\", tone: \"orange\" }, assignee: \"IM\" },\n  { id: \"BIL-124\", title: \"Export invoices as CSV\", status: \"backlog\", priority: \"low\", assignee: \"TB\" },\n  { id: \"ATL-212\", title: \"Collapse sidebar to an icon rail\", status: \"progress\", priority: \"high\", label: { name: \"Design\", tone: \"violet\" }, assignee: \"IM\", due: \"Oct 29\", project: \"atlas\", unread: true },\n  { id: \"ATL-208\", title: \"Breadcrumb overflow on narrow screens\", status: \"progress\", priority: \"medium\", label: { name: \"Bug\", tone: \"warning\" }, assignee: \"RL\", project: \"atlas\" },\n  { id: \"ATL-219\", title: \"Keyboard map for navigation\", status: \"todo\", priority: \"medium\", assignee: \"KT\", project: \"atlas\" },\n  { id: \"ATL-224\", title: \"Empty states for project pages\", status: \"todo\", priority: \"low\", label: { name: \"Design\", tone: \"violet\" }, assignee: \"TB\", project: \"atlas\" },\n  { id: \"ATL-190\", title: \"Audit icon sizes in the sidebar\", status: \"backlog\", priority: \"low\", assignee: \"KT\", project: \"atlas\" },\n  { id: \"MOB-88\", title: \"Push notifications for mentions only\", status: \"progress\", priority: \"high\", label: { name: \"API\", tone: \"violet\" }, assignee: \"KT\", due: \"Nov 4\", project: \"mobile\" },\n  { id: \"MOB-91\", title: \"Offline drafts survive app restarts\", status: \"todo\", priority: \"medium\", assignee: \"IM\", project: \"mobile\", unread: true },\n  { id: \"MOB-95\", title: \"Deep links open the right workspace\", status: \"todo\", priority: \"low\", assignee: \"RL\", project: \"mobile\" },\n  { id: \"MOB-73\", title: \"Haptics on swipe actions\", status: \"backlog\", priority: \"low\", assignee: \"TB\", project: \"mobile\" },\n  { id: \"GRO-31\", title: \"Guided first project checklist\", status: \"progress\", priority: \"medium\", label: { name: \"Onboarding\", tone: \"teal\" }, assignee: \"IM\", project: \"growth\" },\n  { id: \"GRO-34\", title: \"Test invite email subject lines\", status: \"todo\", priority: \"low\", assignee: \"RL\", project: \"growth\" },\n  { id: \"GRO-22\", title: \"Drop company size from signup\", status: \"backlog\", priority: \"low\", assignee: \"KT\", project: \"growth\" },\n  { id: \"INF-57\", title: \"Alert on p95 latency, not p50\", status: \"progress\", priority: \"high\", label: { name: \"Reliability\", tone: \"rose\" }, assignee: \"TB\", due: \"Oct 31\", project: \"infra\" },\n  { id: \"INF-61\", title: \"Runbook for the failover drill\", status: \"todo\", priority: \"medium\", assignee: \"IM\", project: \"infra\", unread: true },\n];\n\nconst people: Record<string, string> = {\n  IM: \"bg-teal-500/16 text-teal-700 dark:text-teal-400\",\n  KT: \"bg-info/16 text-info-foreground\",\n  RL: \"bg-orange-500/16 text-orange-800 dark:text-orange-400\",\n  TB: \"bg-violet-500/20 text-violet-600 dark:text-violet-400\",\n};\n\nconst groups = [\n  { id: \"progress\", label: \"In progress\", icon: CircleDotIcon, tone: \"text-warning-foreground\" },\n  { id: \"todo\", label: \"Todo\", icon: CircleIcon, tone: \"text-muted-foreground\" },\n  { id: \"backlog\", label: \"Backlog\", icon: CircleDashedIcon, tone: \"text-muted-foreground/72\" },\n] as const;\n\nconst priorityIcon = { high: SignalHighIcon, medium: SignalMediumIcon, low: SignalLowIcon };\n\nfunction RailTip({ collapsed, label, children }: { collapsed: boolean; label: ReactNode; children: ReactElement }) {\n  return (\n    <Tooltip disabled={!collapsed}>\n      <TooltipTrigger render={children} />\n      <TooltipPopup side=\"right\" sideOffset={8}>\n        {label}\n      </TooltipPopup>\n    </Tooltip>\n  );\n}\n\ninterface SidebarProps {\n  collapsed: boolean;\n  workspaces: HairlineWorkspace[];\n  nav: HairlineNavItem[];\n  projects: HairlineProject[];\n  user: { name: string; initials: string };\n  active: string;\n  onNavigate: (id: string) => void;\n  onToggle?: () => void;\n  onClose?: () => void;\n  onNew?: () => void;\n}\n\nfunction HairlineSidebar({ collapsed, workspaces, nav, projects, user, active, onNavigate, onToggle, onClose, onNew }: SidebarProps) {\n  const [workspace, setWorkspace] = useState(workspaces[0]?.id ?? \"\");\n  const [open, setOpen] = useState(true);\n  const ws = workspaces.find((w) => w.id === workspace) ?? workspaces[0];\n  const group = useId();\n  const fade = cn(\"transition-opacity duration-150\", collapsed && \"pointer-events-none opacity-0\");\n  const row =\n    \"group/row relative flex h-7 w-full cursor-pointer items-center gap-2 overflow-hidden rounded-md px-2.5 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\";\n\n  const item = (id: string, label: string, icon: ReactNode, trailing?: ReactNode) => {\n    const on = active === id;\n    return (\n      <RailTip collapsed={collapsed} key={id} label={label}>\n        <button\n          aria-current={on ? \"page\" : undefined}\n          aria-label={collapsed ? label : undefined}\n          className={cn(row, on ? \"bg-accent text-foreground\" : \"text-muted-foreground hover:bg-accent/60 hover:text-foreground\")}\n          onClick={() => onNavigate(id)}\n          type=\"button\"\n        >\n          {on && (\n            <motion.span\n              className=\"absolute top-1.5 bottom-1.5 left-0 w-0.5 rounded-full bg-foreground\"\n              layoutId=\"hairline-active\"\n              transition={spring}\n            />\n          )}\n          {icon}\n          <span className={cn(\"min-w-0 flex-1 truncate\", fade)}>{label}</span>\n          {trailing && <span className={fade}>{trailing}</span>}\n        </button>\n      </RailTip>\n    );\n  };\n\n  return (\n    <LayoutGroup id={group}>\n      <div className=\"flex h-full min-h-0 flex-col whitespace-nowrap\">\n        <div className=\"flex h-11 shrink-0 items-center gap-1 border-b px-1.5\">\n          <Menu>\n            <MenuTrigger\n              aria-label={`Workspace: ${ws.name}`}\n              className=\"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 overflow-hidden rounded-md px-2 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent\"\n            >\n              <span\n                className={cn(\n                  \"flex size-5 shrink-0 items-center justify-center rounded-[calc(var(--radius)*0.5)] font-semibold text-[11px] text-white\",\n                  swatch[ws.tone],\n                )}\n              >\n                {ws.initial}\n              </span>\n              <span className={cn(\"min-w-0 truncate font-medium\", fade)}>{ws.name}</span>\n              <ChevronDownIcon className={cn(\"size-3.5 shrink-0 text-muted-foreground\", fade)} />\n            </MenuTrigger>\n            <MenuPopup align=\"start\" className=\"w-56\">\n              <MenuGroup>\n                <MenuGroupLabel>Switch workspace</MenuGroupLabel>\n                <MenuRadioGroup onValueChange={(v) => setWorkspace(v as string)} value={workspace}>\n                  {workspaces.map((w) => (\n                    <MenuRadioItem key={w.id} value={w.id}>\n                      {w.name}\n                    </MenuRadioItem>\n                  ))}\n                </MenuRadioGroup>\n              </MenuGroup>\n              <MenuSeparator />\n              <MenuItem>\n                <PlusIcon />\n                New workspace\n              </MenuItem>\n            </MenuPopup>\n          </Menu>\n          {onClose ? (\n            <Button aria-label=\"Close navigation\" onClick={onClose} size=\"icon-sm\" variant=\"ghost\">\n              <XIcon />\n            </Button>\n          ) : (\n            <Button onClick={onNew} aria-label=\"New issue\" className={cn(collapsed && \"hidden\")} size=\"icon-sm\" variant=\"ghost\">\n              <SquarePenIcon />\n            </Button>\n          )}\n        </div>\n\n        <div className=\"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-1.5 py-2 [scrollbar-width:thin]\">\n          <div className=\"flex flex-col gap-px\">\n            {item(\n              \"search\",\n              \"Search\",\n              <SearchIcon className=\"size-4 shrink-0\" />,\n              <Kbd className=\"h-4.5 min-w-4.5 text-[10px]\">/</Kbd>,\n            )}\n            {nav.map((n) =>\n              item(\n                n.id,\n                n.label,\n                <span className=\"relative shrink-0\">\n                  <n.icon className=\"size-4\" />\n                  {collapsed && n.count ? (\n                    <span className=\"absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-info ring-2 ring-background\" />\n                  ) : null}\n                </span>,\n                n.count ? <span className=\"text-muted-foreground text-xs tabular-nums\">{n.count}</span> : undefined,\n              ),\n            )}\n          </div>\n\n          <div className=\"relative mt-4 mb-1 flex h-6 items-center px-2.5\">\n            <button\n              aria-expanded={open}\n              className={cn(\n                \"flex cursor-pointer items-center gap-1 rounded text-muted-foreground text-xs outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n                fade,\n              )}\n              onClick={() => setOpen((o) => !o)}\n              tabIndex={collapsed ? -1 : 0}\n              type=\"button\"\n            >\n              Projects\n              <ChevronRightIcon className={cn(\"size-3 transition-transform duration-200\", open && \"rotate-90\")} />\n            </button>\n            {collapsed && <span className=\"absolute inset-x-3 top-1/2 h-px bg-border\" />}\n          </div>\n          <AnimatePresence initial={false}>\n            {(open || collapsed) && (\n              <motion.div\n                animate={{ height: \"auto\", opacity: 1 }}\n                className=\"flex flex-col gap-px overflow-hidden\"\n                exit={{ height: 0, opacity: 0 }}\n                initial={{ height: 0, opacity: 0 }}\n                transition={spring}\n              >\n                {projects.map((p) =>\n                  item(\n                    p.id,\n                    p.name,\n                    <span className=\"flex size-4 shrink-0 items-center justify-center\">\n                      <span className={cn(\"size-2.5 rounded-[calc(var(--radius)*0.3)]\", swatch[p.tone])} />\n                    </span>,\n                    <span className=\"text-muted-foreground text-xs tabular-nums\">{p.open}</span>,\n                  ),\n                )}\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </div>\n\n        <div className=\"flex h-10 shrink-0 items-center gap-1 border-t px-1.5\">\n          <Menu>\n            <MenuTrigger\n              aria-label={`Account: ${user.name}`}\n              className=\"flex h-7 min-w-0 flex-1 cursor-pointer items-center gap-2 overflow-hidden rounded-md px-2 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent\"\n            >\n              <Avatar className=\"size-5 shrink-0\">\n                <AvatarFallback className={cn(\"text-[9px]\", people[user.initials] ?? \"bg-muted\")}>{user.initials}</AvatarFallback>\n              </Avatar>\n              <span className={cn(\"min-w-0 flex-1 truncate\", fade)}>{user.name}</span>\n              <ChevronsUpDownIcon className={cn(\"size-3.5 shrink-0 text-muted-foreground\", fade)} />\n            </MenuTrigger>\n            <MenuPopup align=\"start\" className=\"w-52\" side=\"top\">\n              <MenuItem>\n                <UserRoundIcon />\n                Profile\n              </MenuItem>\n              <MenuItem>\n                <SettingsIcon />\n                Settings\n                <MenuShortcut>G S</MenuShortcut>\n              </MenuItem>\n              <MenuItem>\n                <KeyboardIcon />\n                Shortcuts\n                <MenuShortcut>?</MenuShortcut>\n              </MenuItem>\n              <MenuSeparator />\n              <MenuItem>\n                <LogOutIcon />\n                Log out\n              </MenuItem>\n            </MenuPopup>\n          </Menu>\n          {onToggle && (\n            <RailTip\n              collapsed\n              label={\n                <span className=\"flex items-center gap-1.5\">\n                  {collapsed ? \"Expand\" : \"Collapse\"}\n                  <Kbd className=\"h-4.5 min-w-4.5 text-[10px]\">[</Kbd>\n                </span>\n              }\n            >\n              <Button\n                aria-label={collapsed ? \"Expand sidebar\" : \"Collapse sidebar\"}\n                className={cn(collapsed && \"hidden\")}\n                onClick={onToggle}\n                size=\"icon-sm\"\n                variant=\"ghost\"\n              >\n                <PanelLeftIcon />\n              </Button>\n            </RailTip>\n          )}\n        </div>\n      </div>\n    </LayoutGroup>\n  );\n}\n\nfunction IssueList({ issues, fresh, onAdd }: { issues: HairlineIssue[]; fresh: string | null; onAdd: (status: HairlineIssue[\"status\"]) => void }) {\n  const [closed, setClosed] = useState<string[]>([]);\n  const [focus, setFocus] = useState<string | null>(null);\n  const listRef = useRef<HTMLDivElement>(null);\n  const issuesRef = useRef(issues);\n  issuesRef.current = issues;\n\n  useEffect(() => {\n    if (!fresh) return;\n    const status = issuesRef.current.find((i) => i.id === fresh)?.status;\n    setClosed((c) => c.filter((g) => g !== status));\n    setFocus(fresh);\n    const raf = requestAnimationFrame(() =>\n      listRef.current?.querySelector<HTMLButtonElement>(`[data-issue=\"${fresh}\"]`)?.focus(),\n    );\n    return () => cancelAnimationFrame(raf);\n  }, [fresh]);\n\n  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (![\"ArrowDown\", \"ArrowUp\", \"j\", \"k\"].includes(e.key)) return;\n    const rows = Array.from(listRef.current?.querySelectorAll<HTMLButtonElement>(\"[data-issue]\") ?? []);\n    const i = rows.indexOf(document.activeElement as HTMLButtonElement);\n    const next = e.key === \"ArrowDown\" || e.key === \"j\" ? Math.min(rows.length - 1, i + 1) : Math.max(0, i - 1);\n    rows[next]?.focus();\n    setFocus(rows[next]?.dataset.issue ?? null);\n    e.preventDefault();\n  };\n\n  return (\n    <div className=\"min-w-0\" onKeyDown={onKeyDown} ref={listRef}>\n      {groups.map((g) => {\n        const rows = issues.filter((i) => i.status === g.id);\n        if (rows.length === 0) return null;\n        const isOpen = !closed.includes(g.id);\n        return (\n          <section key={g.id}>\n            <div className=\"sticky top-0 z-10 flex h-9 items-center border-b bg-background pe-2\">\n              <button\n                aria-expanded={isOpen}\n                className=\"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2 ps-4 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset @3xl:ps-5\"\n                onClick={() => setClosed((c) => (isOpen ? [...c, g.id] : c.filter((x) => x !== g.id)))}\n                type=\"button\"\n              >\n                <ChevronRightIcon\n                  className={cn(\"size-3.5 text-muted-foreground transition-transform duration-200 ease-out\", isOpen && \"rotate-90\")}\n                />\n                <g.icon className={cn(\"size-3.5\", g.tone)} />\n                <span className=\"font-medium text-[13px]\">{g.label}</span>\n                <span className=\"text-muted-foreground text-xs tabular-nums\">{rows.length}</span>\n              </button>\n              <Tooltip>\n                <TooltipTrigger\n                  render={\n                    <Button aria-label={`New issue in ${g.label}`} onClick={() => onAdd(g.id)} size=\"icon-sm\" variant=\"ghost\" />\n                  }\n                >\n                  <PlusIcon />\n                </TooltipTrigger>\n                <TooltipPopup>New issue in {g.label}</TooltipPopup>\n              </Tooltip>\n            </div>\n            <AnimatePresence initial={false}>\n              {isOpen && (\n                <motion.ul\n                  animate={{ height: \"auto\" }}\n                  className=\"overflow-hidden\"\n                  exit={{ height: 0 }}\n                  initial={{ height: 0 }}\n                  transition={spring}\n                >\n                  <AnimatePresence initial={false}>\n                    {rows.map((issue) => {\n                      const P = priorityIcon[issue.priority];\n                      return (\n                        <motion.li\n                          animate={{ height: \"auto\", opacity: 1 }}\n                          className=\"border-b last:border-b-0\"\n                          initial={{ height: 0, opacity: 0 }}\n                          key={issue.id}\n                          transition={{ duration: 0.2, ease: [0.23, 1, 0.32, 1] }}\n                        >\n                          <button\n                            className={cn(\n                              \"group/issue relative flex h-10 w-full cursor-pointer items-center gap-3 px-4 text-left outline-none transition-colors duration-150 hover:bg-accent/60 focus-visible:bg-accent @3xl:h-9 @3xl:px-5\",\n                              focus === issue.id && \"bg-accent\",\n                            )}\n                            data-issue={issue.id}\n                            onClick={() => setFocus(issue.id)}\n                            onFocus={() => setFocus(issue.id)}\n                            type=\"button\"\n                          >\n                            {focus === issue.id && <span aria-hidden className=\"absolute inset-y-0 left-0 w-0.5 bg-foreground\" />}\n                            <P\n                              aria-label={`${issue.priority} priority`}\n                              className={cn(\n                                \"size-3.5 shrink-0\",\n                                issue.priority === \"high\" ? \"text-foreground\" : \"text-muted-foreground\",\n                              )}\n                            />\n                            <span className=\"hidden w-16 shrink-0 font-mono text-muted-foreground text-xs @md:block\">\n                              {issue.id}\n                            </span>\n                            <g.icon className={cn(\"size-3.5 shrink-0\", g.tone)} />\n                            <span className=\"min-w-0 flex-1 truncate text-[13px]\">\n                              {issue.title}\n                            </span>\n                            {issue.label && (\n                              <span className=\"hidden h-5 shrink-0 items-center gap-1.5 rounded-full border px-2 text-[11px] text-muted-foreground @2xl:inline-flex\">\n                                <span className={cn(\"size-1.5 rounded-full\", swatch[issue.label.tone])} />\n                                {issue.label.name}\n                              </span>\n                            )}\n                            <span className=\"hidden w-12 shrink-0 text-right text-muted-foreground text-xs tabular-nums @xl:block\">\n                              {issue.due ?? \"\"}\n                            </span>\n                            <Avatar className=\"size-5 shrink-0\">\n                              <AvatarFallback className={cn(\"text-[9px]\", people[issue.assignee] ?? \"bg-muted\")}>\n                                {issue.assignee}\n                              </AvatarFallback>\n                            </Avatar>\n                          </button>\n                        </motion.li>\n                      );\n                    })}\n                  </AnimatePresence>\n                </motion.ul>\n              )}\n            </AnimatePresence>\n          </section>\n        );\n      })}\n    </div>\n  );\n}\n\nfunction EmptyPane({ icon: Icon, title, body, action }: { icon: LucideIcon; title: string; body: string; action?: ReactNode }) {\n  return (\n    <div className=\"flex h-full flex-col items-center justify-center px-6 py-16 text-center\">\n      <span className=\"flex size-10 items-center justify-center rounded-xl border bg-card text-muted-foreground shadow-xs/5\">\n        <Icon className=\"size-5\" />\n      </span>\n      <p className=\"mt-4 font-medium\">{title}</p>\n      <p className=\"mt-1 max-w-xs text-pretty text-muted-foreground text-xs\">{body}</p>\n      {action && <div className=\"mt-4\">{action}</div>}\n    </div>\n  );\n}\n\nexport function HairlineShell({\n  workspaces = defaultWorkspaces,\n  nav = defaultNav,\n  projects = defaultProjects,\n  issues = defaultIssues,\n  user = { name: \"Ines Moreau\", initials: \"IM\" },\n  defaultCollapsed = false,\n  children,\n  className,\n}: HairlineShellProps) {\n  const [collapsed, setCollapsed] = useState(defaultCollapsed);\n  const [drawer, setDrawer] = useState(false);\n  const [active, setActive] = useState(projects[0]?.id ?? \"home\");\n  const [view, setView] = useState<\"list\" | \"board\">(\"list\");\n  const drawerRef = useRef<HTMLDivElement>(null);\n  const viewGroup = useId();\n\n  useEffect(() => {\n    if (drawer) drawerRef.current?.focus();\n  }, [drawer]);\n\n  const [items, setItems] = useState(issues);\n  const [fresh, setFresh] = useState<string | null>(null);\n  const [query, setQuery] = useState(\"\");\n\n  const project = projects.find((p) => p.id === active);\n  const navItem = nav.find((n) => n.id === active);\n  const title = project?.name ?? navItem?.label ?? \"Search\";\n  const scope = (i: HairlineIssue) => i.project ?? projects[0]?.id;\n  const q = query.trim().toLowerCase();\n  const visible = items.filter((i) => {\n    if (project) return scope(i) === project.id;\n    if (active === \"mine\") return i.assignee === user.initials;\n    if (active === \"inbox\") return i.unread;\n    if (active === \"views\") return false;\n    if (active === \"search\") return !q || i.title.toLowerCase().includes(q) || i.id.toLowerCase().includes(q);\n    return true;\n  });\n  const inProgress = visible.filter((i) => i.status === \"progress\").length;\n  const counted = projects.map((p) => ({ ...p, open: p.open ?? items.filter((i) => scope(i) === p.id).length }));\n  const navCounted = nav.map((n) => (n.id === \"inbox\" && n.count === undefined ? { ...n, count: items.filter((i) => i.unread).length } : n));\n\n  useEffect(() => {\n    if (!fresh) return;\n    const t = setTimeout(() => setFresh(null), 600);\n    return () => clearTimeout(t);\n  }, [fresh]);\n\n  const addIssue = (status: HairlineIssue[\"status\"] = \"todo\") => {\n    const target = project ?? projects[0];\n    if (!target) return;\n    const prefix = target.prefix ?? target.name.slice(0, 3).toUpperCase();\n    const top = Math.max(0, ...items.filter((i) => i.id.startsWith(`${prefix}-`)).map((i) => Number(i.id.split(\"-\")[1]) || 0));\n    const id = `${prefix}-${top + 1}`;\n    setItems((xs) => [{ id, title: \"Untitled issue\", status, priority: \"medium\", assignee: user.initials, project: target.id }, ...xs]);\n    setActive(target.id);\n    setFresh(id);\n  };\n\n  const sidebar = {\n    workspaces,\n    nav: navCounted,\n    projects: counted,\n    user,\n    active,\n    onNavigate: (id: string) => {\n      setActive(id);\n      setDrawer(false);\n    },\n    onNew: () => addIssue(),\n  };\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <TooltipProvider delay={400}>\n      <div\n        className={cn(\n          \"@container relative isolate flex h-[760px] w-full overflow-hidden bg-background text-foreground text-sm\",\n          className,\n        )}\n        onKeyDown={(e) => {\n          if (e.key === \"Escape\" && drawer) setDrawer(false);\n          if (e.target instanceof HTMLInputElement) return;\n          if (e.key === \"[\") setCollapsed((c) => !c);\n          if (e.key === \"/\") {\n            e.preventDefault();\n            setActive(\"search\");\n          }\n        }}\n      >\n        <motion.aside\n          animate={{ width: collapsed ? 48 : 232 }}\n          aria-label=\"Sidebar\"\n          className=\"hidden shrink-0 overflow-hidden border-e @3xl:block\"\n          initial={false}\n          transition={spring}\n        >\n          <HairlineSidebar {...sidebar} collapsed={collapsed} onToggle={() => setCollapsed((c) => !c)} />\n        </motion.aside>\n\n        <AnimatePresence>\n          {drawer && (\n            <>\n              <motion.div\n                animate={{ opacity: 1 }}\n                aria-hidden\n                className=\"absolute inset-0 z-40 bg-black/32 @3xl:hidden\"\n                exit={{ opacity: 0 }}\n                initial={{ opacity: 0 }}\n                onClick={() => setDrawer(false)}\n              />\n              <motion.div\n                animate={{ x: 0 }}\n                aria-label=\"Navigation\"\n                aria-modal=\"true\"\n                className=\"absolute inset-y-0 left-0 z-50 w-64 max-w-[85%] border-e bg-background outline-none @3xl:hidden\"\n                exit={{ x: \"-100%\" }}\n                initial={{ x: \"-100%\" }}\n                ref={drawerRef}\n                role=\"dialog\"\n                tabIndex={-1}\n                transition={spring}\n              >\n                <HairlineSidebar {...sidebar} collapsed={false} onClose={() => setDrawer(false)} />\n              </motion.div>\n            </>\n          )}\n        </AnimatePresence>\n\n        <main className=\"flex min-w-0 flex-1 flex-col\">\n          <header className=\"flex h-11 shrink-0 items-center gap-2 border-b px-2 @3xl:px-3\">\n            <Button\n              aria-label=\"Open navigation\"\n              className=\"@3xl:hidden\"\n              onClick={() => setDrawer(true)}\n              size=\"icon-sm\"\n              variant=\"ghost\"\n            >\n              <MenuIcon />\n            </Button>\n            {collapsed && (\n              <Button\n                aria-label=\"Expand sidebar\"\n                className=\"hidden @3xl:inline-flex\"\n                onClick={() => setCollapsed(false)}\n                size=\"icon-sm\"\n                variant=\"ghost\"\n              >\n                <PanelLeftIcon />\n              </Button>\n            )}\n            <nav aria-label=\"Breadcrumb\" className=\"flex min-w-0 flex-1 items-center gap-1 ps-1\">\n              <span className=\"hidden text-muted-foreground @md:inline\">Northwind</span>\n              <ChevronRightIcon aria-hidden className=\"hidden size-3.5 text-muted-foreground/60 @md:inline\" />\n              <span className=\"flex min-w-0 items-center gap-1.5\">\n                {project && <span className={cn(\"size-2 shrink-0 rounded-[calc(var(--radius)*0.3)]\", swatch[project.tone])} />}\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  <motion.span\n                    animate={{ opacity: 1, filter: \"blur(0px)\" }}\n                    aria-current=\"page\"\n                    className=\"truncate font-medium\"\n                    exit={{ opacity: 0, filter: \"blur(2px)\" }}\n                    initial={{ opacity: 0, filter: \"blur(2px)\" }}\n                    key={title}\n                    transition={{ duration: 0.18, ease: \"easeOut\" }}\n                  >\n                    {title}\n                  </motion.span>\n                </AnimatePresence>\n              </span>\n              {project && (\n                <>\n                  <ChevronRightIcon aria-hidden className=\"hidden size-3.5 text-muted-foreground/60 @lg:inline\" />\n                  <span className=\"hidden text-muted-foreground @lg:inline\">Issues</span>\n                </>\n              )}\n            </nav>\n\n            <LayoutGroup id={viewGroup}>\n              <div className=\"hidden items-center rounded-md border p-0.5 @lg:flex\" role=\"radiogroup\" aria-label=\"Layout\">\n                {([\"list\", \"board\"] as const).map((v) => (\n                  <button\n                    aria-checked={view === v}\n                    className={cn(\n                      \"relative h-6 cursor-pointer rounded-[calc(var(--radius)*0.5)] px-2 text-xs capitalize outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n                      view === v ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n                    )}\n                    key={v}\n                    onClick={() => setView(v)}\n                    role=\"radio\"\n                    type=\"button\"\n                  >\n                    {view === v && (\n                      <motion.span className=\"absolute inset-0 rounded-[calc(var(--radius)*0.5)] bg-accent\" layoutId=\"hairline-view\" transition={spring} />\n                    )}\n                    <span className=\"relative\">{v}</span>\n                  </button>\n                ))}\n              </div>\n            </LayoutGroup>\n            <Button aria-label=\"Filter\" size=\"icon-sm\" variant=\"ghost\">\n              <FilterIcon />\n            </Button>\n            <Button aria-label=\"New issue\" onClick={() => addIssue()} size=\"sm\">\n              <PlusIcon />\n              <span className=\"hidden @md:inline\">New issue</span>\n            </Button>\n          </header>\n\n          <div className=\"min-h-0 flex-1 overflow-y-auto\">\n            {children ?? (\n              <>\n                {active === \"search\" && (\n                  <div className=\"sticky top-0 z-20 flex h-11 items-center gap-2 border-b bg-background px-4 @3xl:px-5\">\n                    <SearchIcon className=\"size-4 shrink-0 text-muted-foreground\" />\n                    <input\n                      aria-label=\"Search issues\"\n                      autoFocus\n                      className=\"h-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground\"\n                      onChange={(e) => setQuery(e.target.value)}\n                      placeholder=\"Search by title or ID\"\n                      value={query}\n                    />\n                    {query && (\n                      <Button aria-label=\"Clear search\" onClick={() => setQuery(\"\")} size=\"icon-xs\" variant=\"ghost\">\n                        <XIcon />\n                      </Button>\n                    )}\n                  </div>\n                )}\n                {active === \"views\" ? (\n                  <EmptyPane\n                    action={\n                      <Button size=\"sm\" variant=\"outline\">\n                        <PlusIcon />\n                        New view\n                      </Button>\n                    }\n                    body=\"Save a filter, like high priority bugs due this week, and it will live here.\"\n                    icon={LayersIcon}\n                    title=\"No saved views yet\"\n                  />\n                ) : visible.length === 0 ? (\n                  active === \"search\" ? (\n                    <EmptyPane body=\"Try a shorter word, or an ID like BIL-142.\" icon={SearchIcon} title={`Nothing matches “${query.trim()}”`} />\n                  ) : active === \"inbox\" ? (\n                    <EmptyPane body=\"Mentions and assignments land here.\" icon={InboxIcon} title=\"You're all caught up\" />\n                  ) : (\n                    <EmptyPane\n                      action={\n                        <Button onClick={() => addIssue()} size=\"sm\" variant=\"outline\">\n                          <PlusIcon />\n                          New issue\n                        </Button>\n                      }\n                      body=\"Issues you create or are assigned will show up here.\"\n                      icon={CircleDashedIcon}\n                      title=\"No issues yet\"\n                    />\n                  )\n                ) : view === \"list\" ? (\n                  <IssueList fresh={fresh} issues={visible} onAdd={addIssue} />\n                ) : (\n                  <IssueBoard issues={visible} />\n                )}\n              </>\n            )}\n          </div>\n\n          <footer className=\"flex h-10 shrink-0 items-center gap-3 border-t px-4 text-muted-foreground text-xs @3xl:px-5\">\n            <span className=\"tabular-nums\">\n              {visible.length} {visible.length === 1 ? \"issue\" : \"issues\"} · {inProgress} in progress\n            </span>\n            <span className=\"ms-auto flex items-center gap-1.5\">\n              <span className=\"relative flex size-1.5\">\n                  <span className=\"relative size-1.5 rounded-full bg-success\" />\n              </span>\n              Synced\n              <RefreshCwIcon className=\"hidden size-3 @md:inline\" />\n            </span>\n            <span className=\"hidden items-center gap-1 @2xl:flex\">\n              <Kbd className=\"h-4.5 min-w-4.5 text-[10px]\">J</Kbd>\n              <Kbd className=\"h-4.5 min-w-4.5 text-[10px]\">K</Kbd>\n              to move\n              <Kbd className=\"ms-2 h-4.5 min-w-4.5 text-[10px]\">[</Kbd>\n              sidebar\n            </span>\n          </footer>\n        </main>\n      </div>\n    </TooltipProvider>\n    </MotionConfig>\n  );\n}\n\nfunction IssueBoard({ issues }: { issues: HairlineIssue[] }) {\n  return (\n    <div className=\"grid min-h-full grid-cols-1 divide-y @lg:grid-cols-3 @lg:divide-x @lg:divide-y-0\">\n      {groups.map((g) => {\n        const rows = issues.filter((i) => i.status === g.id);\n        return (\n          <div className=\"flex flex-col gap-1.5 p-2\" key={g.id}>\n            <div className=\"flex h-8 items-center gap-2 px-2\">\n              <g.icon className={cn(\"size-3.5\", g.tone)} />\n              <span className=\"font-medium\">{g.label}</span>\n              <span className=\"text-muted-foreground text-xs tabular-nums\">{rows.length}</span>\n            </div>\n            {rows.map((issue, i) => {\n              const P = priorityIcon[issue.priority];\n              return (\n                <motion.button\n                  animate={{ opacity: 1, y: 0 }}\n                  className=\"flex cursor-pointer flex-col gap-2 rounded-lg border bg-card p-2.5 text-left outline-none transition-[background-color,scale] duration-150 ease-out hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\"\n                  initial={{ opacity: 0, y: 6 }}\n                  key={issue.id}\n                  transition={{ ...spring, delay: i * 0.025 }}\n                  type=\"button\"\n                >\n                  <span className=\"flex items-center gap-2 text-muted-foreground text-xs\">\n                    <span className=\"font-mono\">{issue.id}</span>\n                    <Avatar className=\"ms-auto size-4.5\">\n                      <AvatarFallback className={cn(\"text-[8px]\", people[issue.assignee] ?? \"bg-muted\")}>\n                        {issue.assignee}\n                      </AvatarFallback>\n                    </Avatar>\n                  </span>\n                  <span className=\"line-clamp-2 leading-snug\">{issue.title}</span>\n                  <span className=\"flex items-center gap-2 text-muted-foreground text-xs\">\n                    <P className=\"size-3.5\" />\n                    {issue.label && (\n                      <span className=\"inline-flex items-center gap-1\">\n                        <span className={cn(\"size-1.5 rounded-full\", swatch[issue.label.tone])} />\n                        {issue.label.name}\n                      </span>\n                    )}\n                    {issue.due && <span className=\"ms-auto tabular-nums\">{issue.due}</span>}\n                  </span>\n                </motion.button>\n              );\n            })}\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ]
}