{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "drive",
  "type": "registry:block",
  "title": "Drive",
  "description": "A cloud drive home with a sidebar of places and quick access, start-from-template cards, and folders that glide between a card grid and a tidy table when you switch views, with search, sort and stars.",
  "categories": [
    "screen",
    "Product"
  ],
  "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/input-group.json",
    "https://coss.com/ui/r/kbd.json",
    "https://coss.com/ui/r/menu.json"
  ],
  "files": [
    {
      "path": "registry/devl/drive.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { AnimatePresence, LayoutGroup, MotionConfig, motion } from \"motion/react\";\nimport {\n  ArrowDownUpIcon,\n  ChevronsUpDownIcon,\n  ClockIcon,\n  CloudUploadIcon,\n  HouseIcon,\n  LayoutGridIcon,\n  ListIcon,\n  PlusIcon,\n  SearchIcon,\n  StarIcon,\n  Trash2Icon,\n  UsersRoundIcon,\n  XIcon,\n} from \"lucide-react\";\nimport { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\";\nimport { Button } from \"@/components/ui/button\";\nimport { InputGroup, InputGroupAddon, InputGroupInput } from \"@/components/ui/input-group\";\nimport { Kbd } from \"@/components/ui/kbd\";\nimport {\n  Menu,\n  MenuGroup,\n  MenuGroupLabel,\n  MenuPopup,\n  MenuRadioGroup,\n  MenuRadioItem,\n  MenuSeparator,\n  MenuTrigger,\n} from \"@/components/ui/menu\";\nimport { cn } from \"@/lib/utils\";\n\nexport type FolderTone = \"orange\" | \"yellow\" | \"lime\" | \"teal\" | \"blue\" | \"violet\" | \"rose\" | \"slate\" | \"neutral\";\n\nexport interface FileFolder {\n  id: string;\n  name: string;\n  files: number;\n  sizeMb: number;\n  tone: FolderTone;\n  editedMinutesAgo: number;\n  members: string[];\n  shared?: boolean;\n  starred?: boolean;\n}\n\nexport interface FileTemplate {\n  id: string;\n  name: string;\n  kind: \"doc\" | \"brief\" | \"sheet\" | \"roadmap\" | \"board\" | \"moodboard\";\n}\n\nexport interface DriveProps {\n  title?: string;\n  folders?: FileFolder[];\n  templates?: FileTemplate[];\n  usedGb?: number;\n  totalGb?: number;\n  defaultView?: \"grid\" | \"list\";\n  workspace?: string;\n  onOpenFolder?: (folder: FileFolder) => void;\n  className?: string;\n}\n\nconst tone: Record<FolderTone, string> = {\n  orange: \"text-orange-500 dark:text-orange-400\",\n  yellow: \"text-amber-500 dark:text-amber-400\",\n  lime: \"text-lime-600\",\n  teal: \"text-teal-600 dark:text-teal-500\",\n  blue: \"text-blue-500 dark:text-blue-400\",\n  violet: \"text-violet-500 dark:text-violet-400\",\n  rose: \"text-rose-500 dark:text-rose-400\",\n  slate: \"text-slate-500 dark:text-slate-400\",\n  neutral: \"text-muted-foreground/64\",\n};\n\nconst memberTone: Record<string, string> = {\n  AK: \"bg-orange-500/16 text-orange-800 dark:text-orange-300\",\n  JS: \"bg-teal-500/16 text-teal-700 dark:text-teal-300\",\n  MV: \"bg-blue-500/16 text-blue-700 dark:text-blue-300\",\n  LO: \"bg-violet-500/18 text-violet-700 dark:text-violet-300\",\n  RB: \"bg-rose-500/16 text-rose-700 dark:text-rose-300\",\n};\n\nconst spring = { type: \"spring\", stiffness: 380, damping: 34 } as const;\n\nconst defaultFolders: FileFolder[] = [\n  { id: \"brand\", name: \"Brand refresh\", files: 128, sizeMb: 2380, tone: \"orange\", editedMinutesAgo: 12, members: [\"AK\", \"JS\", \"MV\"], shared: true, starred: true },\n  { id: \"research\", name: \"User research\", files: 64, sizeMb: 912, tone: \"teal\", editedMinutesAgo: 95, members: [\"LO\", \"JS\"], shared: true },\n  { id: \"finance\", name: \"Finance 2026\", files: 37, sizeMb: 48, tone: \"lime\", editedMinutesAgo: 1440, members: [\"RB\"] },\n  { id: \"launch\", name: \"Orbit 3 launch\", files: 211, sizeMb: 5120, tone: \"rose\", editedMinutesAgo: 30, members: [\"AK\", \"MV\", \"LO\", \"RB\"], shared: true, starred: true },\n  { id: \"legal\", name: \"Contracts\", files: 19, sizeMb: 22, tone: \"slate\", editedMinutesAgo: 8640, members: [\"RB\", \"AK\"] },\n  { id: \"hiring\", name: \"Hiring loop\", files: 42, sizeMb: 156, tone: \"violet\", editedMinutesAgo: 300, members: [\"JS\", \"LO\"], shared: true },\n  { id: \"offsite\", name: \"Offsite photos\", files: 486, sizeMb: 14200, tone: \"yellow\", editedMinutesAgo: 20160, members: [\"MV\"] },\n  { id: \"eng\", name: \"Engineering RFCs\", files: 73, sizeMb: 31, tone: \"blue\", editedMinutesAgo: 180, members: [\"AK\", \"JS\"], starred: true },\n];\n\nconst defaultTemplates: FileTemplate[] = [\n  { id: \"notes\", name: \"Meeting notes\", kind: \"doc\" },\n  { id: \"brief\", name: \"Project brief\", kind: \"brief\" },\n  { id: \"budget\", name: \"Budget\", kind: \"sheet\" },\n  { id: \"roadmap\", name: \"Roadmap\", kind: \"roadmap\" },\n  { id: \"retro\", name: \"Retro board\", kind: \"board\" },\n  { id: \"mood\", name: \"Moodboard\", kind: \"moodboard\" },\n];\n\nfunction formatSize(mb: number) {\n  return mb >= 1000 ? `${(mb / 1024).toFixed(1)} GB` : `${mb} MB`;\n}\n\nfunction formatAgo(min: number) {\n  if (min < 1) return \"Just now\";\n  if (min < 60) return `${min}m ago`;\n  if (min < 1440) return `${Math.round(min / 60)}h ago`;\n  if (min < 10080) return `${Math.round(min / 1440)}d ago`;\n  return `${Math.round(min / 10080)}w ago`;\n}\n\nfunction FolderGlyph({ folderTone, className, layoutId }: { folderTone: FolderTone; className?: string; layoutId?: string }) {\n  return (\n    <motion.span aria-hidden className={cn(\"relative block shrink-0\", tone[folderTone], className)} layoutId={layoutId} transition={spring}>\n      <svg className=\"absolute inset-0 size-full\" fill=\"none\" preserveAspectRatio=\"none\" viewBox=\"0 0 20 16\">\n        <path d=\"M0 2.5A2.5 2.5 0 0 1 2.5 0h4.3a2 2 0 0 1 1.5.7L9.6 2.2h7.9A2.5 2.5 0 0 1 20 4.7v8.8a2.5 2.5 0 0 1-2.5 2.5h-15A2.5 2.5 0 0 1 0 13.5Z\" fill=\"currentColor\" opacity=\"0.45\" />\n        <path d=\"M0 6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v7.5a2.5 2.5 0 0 1-2.5 2.5h-15A2.5 2.5 0 0 1 0 13.5Z\" fill=\"currentColor\" />\n      </svg>\n    </motion.span>\n  );\n}\n\nfunction TemplatePreview({ kind }: { kind: FileTemplate[\"kind\"] }) {\n  const line = \"h-[3px] rounded-full bg-foreground/12\";\n  switch (kind) {\n    case \"doc\":\n      return (\n        <span className=\"flex flex-col gap-1\">\n          <span className=\"h-1 w-2/3 rounded-full bg-foreground/40\" />\n          {[92, 80, 86].map((w) => (\n            <span className={line} key={w} style={{ width: `${w}%` }} />\n          ))}\n        </span>\n      );\n    case \"brief\":\n      return (\n        <span className=\"flex flex-col gap-1\">\n          <span className=\"h-2.5 w-full rounded-[calc(var(--radius)*0.3)] bg-orange-500/20\" />\n          <span className=\"h-1 w-1/2 rounded-full bg-foreground/40\" />\n          <span className={line} style={{ width: \"80%\" }} />\n        </span>\n      );\n    case \"sheet\":\n      return (\n        <span className=\"grid grid-cols-4 gap-px overflow-hidden rounded-[calc(var(--radius)*0.3)]\">\n          {Array.from({ length: 12 }, (_, i) => (\n            <span className={cn(\"h-1.5\", i < 4 ? \"bg-foreground/20\" : i === 6 ? \"bg-emerald-500/40\" : \"bg-foreground/8\")} key={i} />\n          ))}\n        </span>\n      );\n    case \"roadmap\":\n      return (\n        <span className=\"flex flex-col gap-1\">\n          {[\n            [0, 50, \"bg-blue-500/40\"],\n            [24, 48, \"bg-teal-500/40\"],\n            [50, 44, \"bg-violet-500/40\"],\n          ].map(([l, w, c]) => (\n            <span className={cn(\"h-1.5 rounded-full\", c as string)} key={String(c)} style={{ marginLeft: `${l}%`, width: `${w}%` }} />\n          ))}\n        </span>\n      );\n    case \"board\":\n      return (\n        <span className=\"grid grid-cols-3 gap-1\">\n          {[\"bg-amber-400/40\", \"bg-teal-500/30\", \"bg-violet-500/30\", \"bg-violet-500/30\", \"bg-amber-400/40\", \"bg-foreground/10\"].map((c, i) => (\n            <span className={cn(\"h-2 rounded-[calc(var(--radius)*0.2)]\", c)} key={i} />\n          ))}\n        </span>\n      );\n    case \"moodboard\":\n      return (\n        <span className=\"grid h-full grid-cols-3 grid-rows-2 gap-0.5\">\n          <span className=\"row-span-2 rounded-[calc(var(--radius)*0.2)] bg-linear-to-b from-amber-400/60 to-rose-500/50\" />\n          <span className=\"rounded-[calc(var(--radius)*0.2)] bg-teal-500/40\" />\n          <span className=\"rounded-[calc(var(--radius)*0.2)] bg-foreground/16\" />\n          <span className=\"col-span-2 rounded-[calc(var(--radius)*0.2)] bg-blue-500/30\" />\n        </span>\n      );\n  }\n}\n\nfunction Members({ ids }: { ids: string[] }) {\n  if (ids.length === 0) return <span className=\"text-muted-foreground text-xs\">Only you</span>;\n  return (\n    <span className=\"flex -space-x-1\">\n      {ids.slice(0, 3).map((m) => (\n        <Avatar className=\"size-5 bg-card ring-2 ring-card\" key={m}>\n          <AvatarFallback className={cn(\"font-medium text-[8px]\", memberTone[m] ?? \"bg-muted\")}>{m}</AvatarFallback>\n        </Avatar>\n      ))}\n      {ids.length > 3 && (\n        <span className=\"flex size-5 items-center justify-center rounded-full bg-muted font-medium text-[8px] text-muted-foreground ring-2 ring-card tabular-nums\">\n          +{ids.length - 3}\n        </span>\n      )}\n    </span>\n  );\n}\n\ntype SortKey = \"name\" | \"edited\" | \"size\" | \"files\";\ntype Tab = \"all\" | \"recent\" | \"shared\" | \"starred\";\n\nfunction useThemeRadius(scale: number) {\n  const probe = useRef<HTMLSpanElement>(null);\n  const [radius, setRadius] = useState(scale * 10);\n  useLayoutEffect(() => {\n    const el = probe.current;\n    if (!el) return;\n    const read = () => setRadius(el.offsetWidth);\n    read();\n    const observer = new ResizeObserver(read);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n  const marker = (\n    <span\n      aria-hidden\n      className=\"pointer-events-none invisible absolute h-0\"\n      ref={probe}\n      style={{ width: `calc(var(--radius) * ${scale})` }}\n    />\n  );\n  return [radius, marker] as const;\n}\n\nexport function Drive({\n  title = \"Files\",\n  folders: initialFolders = defaultFolders,\n  templates = defaultTemplates,\n  usedGb = 42.6,\n  totalGb = 100,\n  defaultView = \"grid\",\n  workspace = \"Northwind\",\n  onOpenFolder,\n  className,\n}: DriveProps) {\n  const [radius, radiusProbe] = useThemeRadius(1.2);\n  const [folders, setFolders] = useState(initialFolders);\n  const [tab, setTab] = useState<Tab>(\"all\");\n  const [query, setQuery] = useState(\"\");\n  const [sort, setSort] = useState<SortKey>(\"edited\");\n  const [dir, setDir] = useState<\"asc\" | \"desc\">(\"desc\");\n  const [view, setView] = useState(defaultView);\n  const [created, setCreated] = useState<string | null>(null);\n  const group = useId();\n\n  useEffect(() => {\n    if (!created) return;\n    const t = setTimeout(() => setCreated(null), 2800);\n    return () => clearTimeout(t);\n  }, [created]);\n\n  const tabs = [\n    { id: \"all\", label: \"All files\", icon: HouseIcon, count: folders.length },\n    { id: \"recent\", label: \"Recent\", icon: ClockIcon, count: folders.filter((f) => f.editedMinutesAgo < 1440).length },\n    { id: \"shared\", label: \"Shared\", icon: UsersRoundIcon, count: folders.filter((f) => f.shared).length },\n    { id: \"starred\", label: \"Starred\", icon: StarIcon, count: folders.filter((f) => f.starred).length },\n  ] as const;\n\n  const visible = useMemo(() => {\n    const q = query.trim().toLowerCase();\n    const list = folders.filter((f) => {\n      if (tab === \"recent\" && f.editedMinutesAgo >= 1440) return false;\n      if (tab === \"shared\" && !f.shared) return false;\n      if (tab === \"starred\" && !f.starred) return false;\n      return !q || f.name.toLowerCase().includes(q);\n    });\n    const by: Record<SortKey, (a: FileFolder, b: FileFolder) => number> = {\n      name: (a, b) => a.name.localeCompare(b.name),\n      edited: (a, b) => b.editedMinutesAgo - a.editedMinutesAgo,\n      size: (a, b) => a.sizeMb - b.sizeMb,\n      files: (a, b) => a.files - b.files,\n    };\n    const sorted = [...list].sort(by[sort]);\n    return dir === \"desc\" ? sorted.reverse() : sorted;\n  }, [folders, tab, query, sort, dir]);\n\n  const newFolder = () => {\n    const n = folders.filter((f) => f.id.startsWith(\"new-\")).length + 1;\n    const name = n === 1 ? \"Untitled folder\" : `Untitled folder ${n}`;\n    setFolders((fs) => [{ id: `new-${n}`, name, files: 0, sizeMb: 0, tone: \"neutral\", editedMinutesAgo: 0, members: [] }, ...fs]);\n    setTab(\"all\");\n    setQuery(\"\");\n    setCreated(name);\n  };\n  const toggleStar = (id: string) => setFolders((fs) => fs.map((f) => (f.id === id ? { ...f, starred: !f.starred } : f)));\n  const sortLabel = { name: \"Name\", edited: \"Last edited\", size: \"Size\", files: \"File count\" }[sort];\n  const usedPct = Math.min(100, (usedGb / totalGb) * 100);\n  const grid = view === \"grid\";\n  const heading = tab === \"all\" ? title : tabs.find((t) => t.id === tab)?.label;\n  const starred = folders.filter((f) => f.starred);\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <div className={cn(\"@container relative flex h-[760px] w-full overflow-hidden bg-background text-foreground text-sm\", className)}>\n        <aside className=\"hidden w-56 shrink-0 flex-col border-r bg-muted/30 px-3 py-3 @3xl:flex\">\n          <button\n            className=\"flex h-9 cursor-pointer items-center gap-2 rounded-lg px-1.5 text-left outline-none hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-ring\"\n            type=\"button\"\n          >\n            <span className=\"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground\">\n              <svg aria-hidden className=\"size-3.5\" fill=\"none\" viewBox=\"0 0 16 16\">\n                <path d=\"M2 9.5c2 2.7 10 2.7 12 0\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeWidth=\"2\" />\n                <path d=\"M4 5h8\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeWidth=\"2\" />\n              </svg>\n            </span>\n            <span className=\"min-w-0 flex-1 truncate font-medium\">{workspace}</span>\n            <ChevronsUpDownIcon className=\"size-3.5 text-muted-foreground\" />\n          </button>\n\n          <LayoutGroup id={`${group}-nav`}>\n            <nav aria-label=\"Drive\" className=\"mt-4 flex flex-col gap-px\">\n              {tabs.map((t) => {\n                const on = tab === t.id;\n                return (\n                  <button\n                    aria-current={on ? \"page\" : undefined}\n                    className={cn(\n                      \"relative flex h-8 cursor-pointer items-center gap-2.5 rounded-md px-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n                      on ? \"font-medium text-foreground\" : \"text-muted-foreground hover:bg-accent/60 hover:text-foreground\",\n                    )}\n                    key={t.id}\n                    onClick={() => setTab(t.id)}\n                    type=\"button\"\n                  >\n                    {on && <motion.span className=\"absolute inset-0 rounded-md bg-accent\" layoutId={`${group}-nav-on`} transition={spring} />}\n                    <t.icon className=\"relative size-4 shrink-0 opacity-80\" />\n                    <span className=\"relative flex-1 truncate\">{t.label}</span>\n                    <span className=\"relative text-muted-foreground text-xs tabular-nums\">{t.count}</span>\n                  </button>\n                );\n              })}\n              <button\n                className=\"flex h-8 cursor-pointer items-center gap-2.5 rounded-md px-2 text-left text-muted-foreground outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                type=\"button\"\n              >\n                <Trash2Icon className=\"size-4 shrink-0 opacity-80\" />\n                Trash\n              </button>\n            </nav>\n          </LayoutGroup>\n\n          {starred.length > 0 && (\n            <div className=\"mt-6\">\n              <p className=\"px-2 pb-1.5 font-medium text-muted-foreground text-xs\">Quick access</p>\n              <ul className=\"flex flex-col gap-px\">\n                <AnimatePresence initial={false}>\n                  {starred.map((f) => (\n                    <motion.li\n                      animate={{ opacity: 1, height: \"auto\" }}\n                      exit={{ opacity: 0, height: 0 }}\n                      initial={{ opacity: 0, height: 0 }}\n                      key={f.id}\n                      transition={{ duration: 0.18, ease: [0.23, 1, 0.32, 1] }}\n                    >\n                      <button\n                        className=\"flex h-8 w-full cursor-pointer items-center gap-2.5 rounded-md px-2 text-left text-muted-foreground outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                        onClick={() => onOpenFolder?.(f)}\n                        type=\"button\"\n                      >\n                        <FolderGlyph className=\"h-3 w-3.5\" folderTone={f.tone} />\n                        <span className=\"truncate\">{f.name}</span>\n                      </button>\n                    </motion.li>\n                  ))}\n                </AnimatePresence>\n              </ul>\n            </div>\n          )}\n\n          <div className=\"mt-auto rounded-lg px-2 pt-4 pb-1\">\n            <div className=\"flex items-baseline justify-between text-xs\">\n              <span className=\"font-medium\">Storage</span>\n              <span className=\"text-muted-foreground tabular-nums\">{Math.round(usedPct)}%</span>\n            </div>\n            <span className=\"relative mt-2 block h-1 overflow-hidden rounded-full bg-foreground/8\">\n              <motion.span\n                animate={{ scaleX: usedPct / 100 }}\n                className=\"absolute inset-0 origin-left rounded-full bg-primary/72\"\n                initial={{ scaleX: 0 }}\n                transition={{ duration: 0.6, ease: [0.23, 1, 0.32, 1], delay: 0.1 }}\n              />\n            </span>\n            <p className=\"mt-2 text-muted-foreground text-xs tabular-nums\">\n              {usedGb} GB of {totalGb} GB used\n            </p>\n            <button className=\"mt-1 cursor-pointer rounded-sm font-medium text-xs outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring\" type=\"button\">\n              Get more space\n            </button>\n          </div>\n        </aside>\n\n        <div className=\"flex min-w-0 flex-1 flex-col\">\n          <header className=\"flex h-14 shrink-0 items-center gap-2 border-b px-4 @3xl:px-6\">\n            <InputGroup className=\"max-w-md flex-1\">\n              <InputGroupAddon>\n                <SearchIcon />\n              </InputGroupAddon>\n              <InputGroupInput aria-label=\"Search folders\" onChange={(e) => setQuery(e.target.value)} placeholder=\"Search folders\" value={query} />\n              <InputGroupAddon align=\"inline-end\">\n                {query ? (\n                  <Button aria-label=\"Clear search\" onClick={() => setQuery(\"\")} size=\"icon-xs\" variant=\"ghost\">\n                    <XIcon />\n                  </Button>\n                ) : (\n                  <Kbd className=\"hidden @md:inline-flex\">/</Kbd>\n                )}\n              </InputGroupAddon>\n            </InputGroup>\n            <div className=\"ms-auto flex items-center gap-2\">\n              <Button aria-label=\"Upload\" onClick={() => setCreated(\"Upload started\")} variant=\"outline\">\n                <CloudUploadIcon />\n                <span className=\"hidden @lg:inline\">Upload</span>\n              </Button>\n              <Button aria-label=\"New folder\" onClick={newFolder}>\n                <PlusIcon />\n                <span className=\"hidden @lg:inline\">New folder</span>\n              </Button>\n            </div>\n          </header>\n\n          <div className=\"min-h-0 flex-1 overflow-y-auto\">\n            <div className=\"mx-auto flex max-w-6xl flex-col px-4 pt-6 pb-12 @3xl:px-8 @3xl:pt-8\">\n              <h1 className=\"font-heading font-semibold text-2xl tracking-tight\">{heading}</h1>\n\n              <LayoutGroup id={`${group}-pills`}>\n                <div className=\"-mx-4 mt-4 flex gap-1.5 overflow-x-auto px-4 [scrollbar-width:none] @3xl:hidden\" role=\"tablist\">\n                  {tabs.map((t) => (\n                    <button\n                      aria-selected={tab === t.id}\n                      className={cn(\n                        \"relative flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-full border px-3 font-medium text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n                        tab === t.id ? \"border-transparent text-background\" : \"text-muted-foreground\",\n                      )}\n                      key={t.id}\n                      onClick={() => setTab(t.id)}\n                      role=\"tab\"\n                      type=\"button\"\n                    >\n                      {tab === t.id && <motion.span className=\"absolute inset-0 rounded-full bg-foreground\" layoutId={`${group}-pill`} transition={spring} />}\n                      <span className=\"relative\">{t.label}</span>\n                      <span className=\"relative tabular-nums opacity-64\">{t.count}</span>\n                    </button>\n                  ))}\n                </div>\n              </LayoutGroup>\n\n              {tab === \"all\" && !query && templates.length > 0 && (\n                <section aria-labelledby={`${group}-tpl`} className=\"mt-6\">\n                  <div className=\"flex h-8 items-center justify-between\">\n                    <h2 className=\"font-medium\" id={`${group}-tpl`}>\n                      Start something new\n                    </h2>\n                    <Button className=\"-me-2 text-muted-foreground\" size=\"xs\" variant=\"ghost\">\n                      All templates\n                    </Button>\n                  </div>\n                  <div className=\"-mx-4 mt-2 flex snap-x scroll-px-4 gap-2 overflow-x-auto px-4 pb-1 [scrollbar-width:none] @6xl:mx-0 @6xl:grid @6xl:grid-cols-[auto_repeat(5,minmax(0,1fr))] @6xl:px-0 @6xl:[&>*:nth-child(n+7)]:hidden\">\n                    <button\n                      className=\"group/tpl flex h-14 w-28 shrink-0 snap-start cursor-pointer items-center gap-3 rounded-xl border border-dashed px-3 text-left text-muted-foreground outline-none transition-[background-color,color,scale] duration-150 ease-out hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.97] @6xl:w-auto @6xl:pe-5\"\n                      onClick={() => setCreated(\"Untitled doc\")}\n                      type=\"button\"\n                    >\n                      <span className=\"flex h-9 w-8 shrink-0 items-center justify-center\">\n                        <PlusIcon className=\"size-4\" />\n                      </span>\n                      <span className=\"truncate font-medium\">Blank</span>\n                    </button>\n                    {templates.map((t) => (\n                      <button\n                        className=\"flex h-14 w-44 shrink-0 snap-start cursor-pointer items-center gap-3 rounded-xl border bg-card px-3 text-left outline-none transition-[border-color,box-shadow,scale] duration-150 ease-out hover:border-foreground/16 hover:shadow-xs/5 focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.97] @6xl:w-auto\"\n                        key={t.id}\n                        onClick={() => setCreated(t.name)}\n                        type=\"button\"\n                      >\n                        <span className=\"flex h-9 w-8 shrink-0 flex-col justify-center overflow-hidden rounded-[calc(var(--radius)*0.5)] border bg-background p-1\">\n                          <TemplatePreview kind={t.kind} />\n                        </span>\n                        <span className=\"truncate font-medium\">{t.name}</span>\n                      </button>\n                    ))}\n                  </div>\n                </section>\n              )}\n\n              <section aria-labelledby={`${group}-folders-h`} className=\"mt-8\">\n                <div className=\"flex h-8 items-center gap-2\">\n                  <h2 className=\"font-medium\" id={`${group}-folders-h`}>\n                    Folders\n                  </h2>\n                  <span className=\"text-muted-foreground text-xs tabular-nums\">{visible.length}</span>\n                  <div className=\"ms-auto flex items-center gap-1\">\n                    <Menu>\n                      <MenuTrigger render={<Button aria-label={`Sort by ${sortLabel}`} className=\"text-muted-foreground\" size=\"sm\" variant=\"ghost\" />}>\n                        <ArrowDownUpIcon />\n                        <span className=\"hidden @md:inline\">{sortLabel}</span>\n                      </MenuTrigger>\n                      <MenuPopup align=\"end\" className=\"w-48\">\n                        <MenuGroup>\n                          <MenuGroupLabel>Sort by</MenuGroupLabel>\n                          <MenuRadioGroup onValueChange={(v) => setSort(v as SortKey)} value={sort}>\n                            <MenuRadioItem value=\"name\">Name</MenuRadioItem>\n                            <MenuRadioItem value=\"edited\">Last edited</MenuRadioItem>\n                            <MenuRadioItem value=\"size\">Size</MenuRadioItem>\n                            <MenuRadioItem value=\"files\">File count</MenuRadioItem>\n                          </MenuRadioGroup>\n                        </MenuGroup>\n                        <MenuSeparator />\n                        <MenuGroup>\n                          <MenuGroupLabel>Order</MenuGroupLabel>\n                          <MenuRadioGroup onValueChange={(v) => setDir(v as \"asc\" | \"desc\")} value={dir}>\n                            <MenuRadioItem value=\"asc\">{sort === \"name\" ? \"A to Z\" : sort === \"edited\" ? \"Oldest first\" : \"Smallest first\"}</MenuRadioItem>\n                            <MenuRadioItem value=\"desc\">{sort === \"name\" ? \"Z to A\" : sort === \"edited\" ? \"Newest first\" : \"Largest first\"}</MenuRadioItem>\n                          </MenuRadioGroup>\n                        </MenuGroup>\n                      </MenuPopup>\n                    </Menu>\n                    <LayoutGroup id={`${group}-view`}>\n                      <div aria-label=\"Layout\" className=\"flex rounded-lg bg-muted p-0.5\" role=\"radiogroup\">\n                        {(\n                          [\n                            [\"grid\", LayoutGridIcon, \"Grid\"],\n                            [\"list\", ListIcon, \"List\"],\n                          ] as const\n                        ).map(([v, Icon, label]) => (\n                          <button\n                            aria-checked={view === v}\n                            aria-label={`${label} view`}\n                            className={cn(\n                              \"relative flex size-7 cursor-pointer items-center justify-center rounded-md 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-md bg-background shadow-xs/5 dark:bg-input\" layoutId={`${group}-view-on`} transition={spring} />\n                            )}\n                            <Icon className=\"relative size-3.5\" />\n                          </button>\n                        ))}\n                      </div>\n                    </LayoutGroup>\n                  </div>\n                </div>\n\n                <LayoutGroup id={`${group}-folders`}>\n                  <motion.div\n                    className={cn(\"mt-3\", !grid && \"overflow-hidden rounded-xl border bg-card\")}\n                    layout\n                    style={{ borderRadius: radius }}\n                    transition={spring}\n                  >\n                    {radiusProbe}\n                    {!grid && visible.length > 0 && (\n                      <div className=\"hidden h-9 grid-cols-[minmax(0,1fr)_7rem_6rem_6rem_2.5rem] items-center gap-4 border-b bg-muted/40 ps-4 pe-2 font-medium text-muted-foreground text-xs @2xl:grid\">\n                        <span>Name</span>\n                        <span>Shared with</span>\n                        <span>Edited</span>\n                        <span className=\"text-end\">Size</span>\n                        <span />\n                      </div>\n                    )}\n                    <ul className={cn(grid ? \"grid grid-cols-2 gap-3 @2xl:grid-cols-3 @5xl:grid-cols-4\" : \"flex flex-col\")}>\n                      <AnimatePresence mode=\"popLayout\">\n                        {visible.map((f, i) => (\n                          <motion.li\n                            animate={{ opacity: 1, scale: 1 }}\n                            className={cn(\n                              \"group/folder relative transition-[background-color,border-color,scale] duration-150 ease-out has-[>[data-hit]:active]:scale-[0.985]\",\n                              grid ? \"rounded-xl border bg-card hover:border-foreground/16\" : cn(\"hover:bg-accent/40\", i > 0 && \"border-t\"),\n                            )}\n                            exit={{ opacity: 0, scale: 0.96 }}\n                            initial={{ opacity: 0, scale: 0.96 }}\n                            key={f.id}\n                            layout\n                            style={{ borderRadius: grid ? radius : 0 }}\n                            transition={spring}\n                          >\n                            <button\n                              aria-label={`Open ${f.name}`}\n                              className=\"absolute inset-0 z-0 cursor-pointer rounded-[inherit] outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\"\n                              data-hit=\"\"\n                              onClick={() => onOpenFolder?.(f)}\n                              type=\"button\"\n                            />\n                            {grid ? (\n                              <motion.div\n                                animate={{ opacity: 1 }}\n                                className=\"pointer-events-none relative flex flex-col p-3.5\"\n                                initial={{ opacity: 0 }}\n                                key=\"grid\"\n                                layout=\"position\"\n                                transition={{ opacity: { duration: 0.2, delay: 0.06 }, layout: spring }}\n                              >\n                                <FolderGlyph className=\"h-6 w-7.5\" folderTone={f.tone} layoutId={`${group}-glyph-${f.id}`} />\n                                <span className=\"mt-5 truncate pe-6 font-medium\">{f.name}</span>\n                                <span className=\"mt-0.5 text-muted-foreground text-xs tabular-nums\">\n                                  {f.files === 0 ? \"No files yet\" : `${f.files} files · ${formatSize(f.sizeMb)}`}\n                                </span>\n                                <div className=\"mt-4 flex h-5 items-center justify-between\">\n                                  <Members ids={f.members} />\n                                  <span className=\"text-muted-foreground text-xs tabular-nums\">{formatAgo(f.editedMinutesAgo)}</span>\n                                </div>\n                              </motion.div>\n                            ) : (\n                              <motion.div\n                                animate={{ opacity: 1 }}\n                                className=\"pointer-events-none relative grid h-13 grid-cols-[minmax(0,1fr)_2.5rem] items-center gap-4 ps-4 pe-2 @2xl:grid-cols-[minmax(0,1fr)_7rem_6rem_6rem_2.5rem]\"\n                                initial={{ opacity: 0 }}\n                                key=\"list\"\n                                layout=\"position\"\n                                transition={{ opacity: { duration: 0.2, delay: 0.06 }, layout: spring }}\n                              >\n                                <span className=\"flex min-w-0 items-center gap-3\">\n                                  <FolderGlyph className=\"h-4 w-5\" folderTone={f.tone} layoutId={`${group}-glyph-${f.id}`} />\n                                  <span className=\"flex min-w-0 flex-col\">\n                                    <span className=\"truncate font-medium\">{f.name}</span>\n                                    <span className=\"text-muted-foreground text-xs tabular-nums @2xl:hidden\">\n                                      {f.files === 0 ? \"No files yet\" : `${f.files} files · ${formatSize(f.sizeMb)}`}\n                                    </span>\n                                  </span>\n                                </span>\n                                <span className=\"hidden @2xl:block\">\n                                  <Members ids={f.members} />\n                                </span>\n                                <span className=\"hidden text-muted-foreground tabular-nums @2xl:block\">{formatAgo(f.editedMinutesAgo)}</span>\n                                <span className=\"hidden text-end text-muted-foreground tabular-nums @2xl:block\">{f.sizeMb ? formatSize(f.sizeMb) : \"—\"}</span>\n                              </motion.div>\n                            )}\n                            <motion.button\n                              aria-label={f.starred ? `Unstar ${f.name}` : `Star ${f.name}`}\n                              aria-pressed={Boolean(f.starred)}\n                              className={cn(\n                                \"absolute z-10 flex size-8 cursor-pointer items-center justify-center rounded-md outline-none transition-opacity hover:bg-accent focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring\",\n                                grid ? \"top-2 right-2\" : \"top-2.5 right-2\",\n                                f.starred ? \"text-amber-500 opacity-100 dark:text-amber-400\" : \"text-muted-foreground opacity-0 group-hover/folder:opacity-100 pointer-coarse:opacity-100\",\n                              )}\n                              layout=\"position\"\n                              onClick={() => toggleStar(f.id)}\n                              transition={spring}\n                              type=\"button\"\n                            >\n                              <motion.span animate={{ scale: f.starred ? [1, 1.25, 1] : 1 }} transition={{ duration: 0.28 }}>\n                                <StarIcon className={cn(\"size-4\", f.starred && \"fill-current\")} />\n                              </motion.span>\n                            </motion.button>\n                          </motion.li>\n                        ))}\n                      </AnimatePresence>\n                    </ul>\n                  </motion.div>\n                  {visible.length === 0 && (\n                    <div className=\"mt-3 flex flex-col items-center gap-1 rounded-xl border border-dashed py-14 text-center\">\n                      <SearchIcon className=\"mb-2 size-5 text-muted-foreground\" />\n                      <span className=\"font-medium\">No folders match</span>\n                      <span className=\"text-muted-foreground text-xs\">\n                        {query ? `Nothing called “${query.trim()}”` : \"Nothing here yet\"}\n                        {tab !== \"all\" && ` in ${tabs.find((t) => t.id === tab)?.label}`}.\n                      </span>\n                      <Button\n                        className=\"mt-3\"\n                        onClick={() => {\n                          setQuery(\"\");\n                          setTab(\"all\");\n                        }}\n                        size=\"sm\"\n                        variant=\"outline\"\n                      >\n                        Show all files\n                      </Button>\n                    </div>\n                  )}\n                </LayoutGroup>\n              </section>\n            </div>\n          </div>\n        </div>\n\n        <AnimatePresence>\n          {created && (\n            <motion.div\n              animate={{ opacity: 1, y: 0 }}\n              className=\"absolute inset-x-4 bottom-4 z-20 mx-auto flex max-w-xs items-center gap-3 rounded-xl border bg-popover py-1.5 ps-3.5 pe-1.5 shadow-lg/10\"\n              exit={{ opacity: 0, y: 12 }}\n              initial={{ opacity: 0, y: 12 }}\n              role=\"status\"\n              transition={spring}\n            >\n              <span className=\"min-w-0 flex-1 truncate\">\n                <span className=\"font-medium\">{created}</span>\n                {created !== \"Upload started\" && \" created\"}\n              </span>\n              <Button onClick={() => setCreated(null)} size=\"xs\" variant=\"ghost\">\n                {created === \"Upload started\" ? \"Dismiss\" : \"Open\"}\n              </Button>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    </MotionConfig>\n  );\n}\n"
    }
  ]
}