{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-manager",
  "title": "File Manager Block",
  "description": "A file manager with breadcrumb folders, a grid and list view, a storage bar split by file type, drag and drop uploads with progress, inline rename and delete with undo.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/file-manager/file-manager.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface FileItem {\n  id: string;\n  name: string;\n  /** null for the root folder. */\n  parentId: string | null;\n  folder?: boolean;\n  /** Bytes. Ignored for folders. */\n  size?: number;\n  /** YYYY-MM-DD */\n  modified: string;\n}\n\nexport interface FileManagerProps {\n  title?: string;\n  items?: FileItem[];\n  /** Storage quota in bytes. Defaults to 15 GB. */\n  quota?: number;\n  /** Today as YYYY-MM-DD, used as the modified date of uploads. */\n  today?: string;\n  view?: \"grid\" | \"list\";\n  /** Upload a file. Call progress(0–100) as it goes; resolve when done. Without it, uploads are simulated. */\n  onUpload?: (file: File, folderId: string | null, progress: (pct: number) => void) => Promise<void>;\n  onRename?: (id: string, name: string) => void;\n  /** Called once the undo window has passed. */\n  onDelete?: (ids: string[]) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\ntype Item = FileItem & { progress?: number };\ntype Kind = \"folder\" | \"image\" | \"pdf\" | \"doc\" | \"sheet\" | \"video\" | \"audio\" | \"zip\" | \"code\" | \"other\";\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.6)\", faint: \"rgba(245,244,241,0.36)\", card: \"#111111\", border: \"rgba(255,255,255,0.09)\", row: \"rgba(255,255,255,0.03)\", hover: \"rgba(255,255,255,0.05)\", chip: \"rgba(255,255,255,0.06)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", folder: \"#E8C468\", ring: \"rgba(245,244,241,0.6)\", track: \"rgba(255,255,255,0.07)\", danger: \"#F87171\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.6)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", border: \"rgba(10,10,10,0.09)\", row: \"rgba(10,10,10,0.025)\", hover: \"rgba(10,10,10,0.04)\", chip: \"rgba(10,10,10,0.05)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", folder: \"#D4A72C\", ring: \"rgba(10,10,10,0.5)\", track: \"rgba(10,10,10,0.07)\", danger: \"#DC2626\" },\n};\n\nconst KIND_COLOR: Record<Exclude<Kind, \"folder\">, string> = { image: \"#A78BFA\", pdf: \"#F87171\", doc: \"#60A5FA\", sheet: \"#4ADE80\", video: \"#F472B6\", audio: \"#FB923C\", zip: \"#FBBF24\", code: \"#2DD4BF\", other: \"#9CA3AF\" };\nconst EXT: Record<string, Kind> = { png: \"image\", jpg: \"image\", jpeg: \"image\", gif: \"image\", webp: \"image\", svg: \"image\", heic: \"image\", pdf: \"pdf\", doc: \"doc\", docx: \"doc\", txt: \"doc\", md: \"doc\", pages: \"doc\", key: \"doc\", pptx: \"doc\", xls: \"sheet\", xlsx: \"sheet\", csv: \"sheet\", numbers: \"sheet\", mp4: \"video\", mov: \"video\", webm: \"video\", mp3: \"audio\", m4a: \"audio\", wav: \"audio\", zip: \"zip\", rar: \"zip\", \"7z\": \"zip\", gz: \"zip\", js: \"code\", ts: \"code\", tsx: \"code\", json: \"code\", html: \"code\", css: \"code\", py: \"code\" };\nconst ext = (name: string) => (name.includes(\".\") ? name.split(\".\").pop()!.toLowerCase() : \"\");\nconst kindOf = (i: Item): Kind => (i.folder ? \"folder\" : (EXT[ext(i.name)] ?? \"other\"));\n\nconst GB = 1024 ** 3;\nconst MB = 1024 ** 2;\nconst DEFAULT_ITEMS: FileItem[] = [\n  { id: \"projects\", name: \"Projects\", parentId: null, folder: true, modified: \"2026-10-30\" },\n  { id: \"contracts\", name: \"Contracts\", parentId: null, folder: true, modified: \"2026-10-21\" },\n  { id: \"recordings\", name: \"Recordings\", parentId: null, folder: true, modified: \"2026-10-28\" },\n  { id: \"f1\", name: \"Q4 planning.pdf\", parentId: null, size: 4.2 * MB, modified: \"2026-10-29\" },\n  { id: \"f2\", name: \"Budget 2027.xlsx\", parentId: null, size: 860 * 1024, modified: \"2026-10-27\" },\n  { id: \"f3\", name: \"team-offsite.jpg\", parentId: null, size: 6.8 * MB, modified: \"2026-10-12\" },\n  { id: \"f4\", name: \"archive-2025.zip\", parentId: null, size: 1.8 * GB, modified: \"2026-09-30\" },\n  { id: \"f5\", name: \"readme.md\", parentId: null, size: 3.1 * 1024, modified: \"2026-08-14\" },\n  { id: \"halcyon\", name: \"Halcyon rebrand\", parentId: \"projects\", folder: true, modified: \"2026-10-30\" },\n  { id: \"p1\", name: \"Website v3\", parentId: \"projects\", folder: true, modified: \"2026-10-18\" },\n  { id: \"p2\", name: \"roadmap.xlsx\", parentId: \"projects\", size: 1.2 * MB, modified: \"2026-10-25\" },\n  { id: \"p3\", name: \"kickoff-notes.docx\", parentId: \"projects\", size: 420 * 1024, modified: \"2026-10-02\" },\n  { id: \"h1\", name: \"brand-guidelines.pdf\", parentId: \"halcyon\", size: 24.6 * MB, modified: \"2026-10-30\" },\n  { id: \"h2\", name: \"moodboard.png\", parentId: \"halcyon\", size: 11.3 * MB, modified: \"2026-10-26\" },\n  { id: \"h3\", name: \"launch-film.mp4\", parentId: \"halcyon\", size: 1.4 * GB, modified: \"2026-10-29\" },\n  { id: \"h4\", name: \"logo-mark.svg\", parentId: \"halcyon\", size: 18 * 1024, modified: \"2026-10-22\" },\n  { id: \"w1\", name: \"tokens.json\", parentId: \"p1\", size: 42 * 1024, modified: \"2026-10-18\" },\n  { id: \"w2\", name: \"hero.webp\", parentId: \"p1\", size: 380 * 1024, modified: \"2026-10-16\" },\n  { id: \"c1\", name: \"msa-northwind.pdf\", parentId: \"contracts\", size: 2.4 * MB, modified: \"2026-10-21\" },\n  { id: \"c2\", name: \"nda-template.docx\", parentId: \"contracts\", size: 96 * 1024, modified: \"2026-07-03\" },\n  { id: \"r1\", name: \"all-hands-october.mp4\", parentId: \"recordings\", size: 2.1 * GB, modified: \"2026-10-28\" },\n  { id: \"r2\", name: \"customer-call-kestrel.m4a\", parentId: \"recordings\", size: 48 * MB, modified: \"2026-10-24\" },\n  { id: \"r3\", name: \"design-review.mov\", parentId: \"recordings\", size: 3.6 * GB, modified: \"2026-10-15\" },\n];\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\nconst day = (d: string) => `${Number(d.slice(8, 10))} ${MONTHS[Number(d.slice(5, 7)) - 1]} ${d.slice(0, 4)}`;\nfunction bytes(n: number) {\n  if (n >= GB) return `${(n / GB).toFixed(n >= 10 * GB ? 0 : 1)} GB`;\n  if (n >= MB) return `${(n / MB).toFixed(n >= 100 * MB ? 0 : 1)} MB`;\n  if (n >= 1024) return `${Math.round(n / 1024)} KB`;\n  return `${n} B`;\n}\n\nfunction icon(kind: Kind, folderColor: string, big: boolean, label: string) {\n  const s = big ? 44 : 20;\n  if (kind === \"folder\")\n    return (\n      <svg width={s} height={s} viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n        <path d=\"M2.5 6.5A2 2 0 0 1 4.5 4.5h4.2l2 2h8.8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-15a2 2 0 0 1-2-2v-11Z\" fill={folderColor} />\n        <path d=\"M2.5 9h19v8.5a2 2 0 0 1-2 2h-15a2 2 0 0 1-2-2V9Z\" fill={folderColor} style={{ filter: \"brightness(1.12)\" }} />\n      </svg>\n    );\n  const c = KIND_COLOR[kind];\n  return (\n    <svg width={s} height={s} viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n      <path d=\"M6 2.5h8.5L19.5 7.5v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-15a2 2 0 0 1 2-2Z\" fill={c} fillOpacity=\"0.16\" stroke={c} strokeWidth=\"1.3\" />\n      <path d=\"M14.5 2.5v5h5\" fill=\"none\" stroke={c} strokeWidth=\"1.3\" strokeLinejoin=\"round\" />\n      {big && label ? (\n        <text x=\"11.75\" y=\"17.2\" textAnchor=\"middle\" fontSize=\"4.6\" fontWeight=\"700\" fill={c} fontFamily=\"ui-sans-serif, system-ui, sans-serif\">\n          {label.slice(0, 4).toUpperCase()}\n        </text>\n      ) : null}\n    </svg>\n  );\n}\n\ntype SortKey = \"name\" | \"modified\" | \"size\";\n\nexport function FileManager({ title = \"Files\", items, quota = 15 * GB, today = \"2026-11-01\", view: initialView = \"grid\", onUpload, onRename, onDelete, theme = \"dark\", className }: FileManagerProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const [list, setList] = React.useState<Item[]>(() => items ?? DEFAULT_ITEMS);\n  const [cwd, setCwd] = React.useState<string | null>(null);\n  const [view, setView] = React.useState<\"grid\" | \"list\">(initialView);\n  const [sort, setSort] = React.useState<{ key: SortKey; dir: 1 | -1 }>({ key: \"name\", dir: 1 });\n  const [renaming, setRenaming] = React.useState<string | null>(null);\n  const [undo, setUndo] = React.useState<{ label: string; removed: Item[] } | null>(null);\n  const [dragging, setDragging] = React.useState(false);\n  const fileInput = React.useRef<HTMLInputElement>(null);\n  const seq = React.useRef(0);\n  const dragDepth = React.useRef(0);\n  const timers = React.useRef<ReturnType<typeof setInterval>[]>([]);\n  const undoTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const pending = React.useRef<{ ids: string[] } | null>(null);\n  const returnFocus = React.useRef<string | null>(null);\n\n  React.useEffect(\n    () => () => {\n      timers.current.forEach(clearInterval);\n      if (undoTimer.current) clearTimeout(undoTimer.current);\n    },\n    [],\n  );\n\n  const children = (id: string | null) => list.filter((i) => i.parentId === id);\n  const descendants = (id: string): Item[] => children(id).flatMap((c) => [c, ...(c.folder ? descendants(c.id) : [])]);\n  const folderSize = (id: string) => descendants(id).reduce((s, i) => s + (i.size ?? 0), 0);\n  const crumbs: Item[] = [];\n  for (let at = cwd; at; ) {\n    const f = list.find((i) => i.id === at);\n    if (!f) break;\n    crumbs.unshift(f);\n    at = f.parentId;\n  }\n  const here = children(cwd).sort((a, b) => {\n    if (!!a.folder !== !!b.folder) return a.folder ? -1 : 1;\n    const v = sort.key === \"name\" ? a.name.localeCompare(b.name, undefined, { numeric: true }) : sort.key === \"size\" ? (a.folder ? folderSize(a.id) : (a.size ?? 0)) - (b.folder ? folderSize(b.id) : (b.size ?? 0)) : a.modified.localeCompare(b.modified);\n    return v * sort.dir;\n  });\n\n  // Storage split by type\n  const files = list.filter((i) => !i.folder && i.progress === undefined);\n  const used = files.reduce((s, i) => s + (i.size ?? 0), 0);\n  const groups = [\n    { label: \"Video\", kinds: [\"video\", \"audio\"], color: KIND_COLOR.video },\n    { label: \"Images\", kinds: [\"image\"], color: KIND_COLOR.image },\n    { label: \"Documents\", kinds: [\"pdf\", \"doc\", \"sheet\", \"code\"], color: KIND_COLOR.doc },\n    { label: \"Other\", kinds: [\"zip\", \"other\"], color: KIND_COLOR.zip },\n  ].map((g) => ({ ...g, total: files.filter((f) => g.kinds.includes(kindOf(f))).reduce((s, f) => s + (f.size ?? 0), 0) }));\n\n  const setProgress = (id: string, pct: number) => setList((v) => v.map((i) => (i.id === id ? { ...i, progress: pct >= 100 ? undefined : pct } : i)));\n  const upload = (incoming: File[]) => {\n    if (!incoming.length) return;\n    const folderId = cwd;\n    const added: Item[] = incoming.map((f) => {\n      seq.current += 1;\n      return { id: `upload-${seq.current}`, name: f.name, parentId: folderId, size: f.size, modified: today, progress: 0 };\n    });\n    setList((v) => {\n      const taken = new Set(v.filter((i) => i.parentId === folderId).map((i) => i.name));\n      return [\n        ...v,\n        ...added.map((a) => {\n          let name = a.name;\n          for (let n = 1; taken.has(name); n++) name = a.name.replace(/(\\.[^.]*)?$/, ` (${n})$1`);\n          taken.add(name);\n          return { ...a, name };\n        }),\n      ];\n    });\n    added.forEach((a, k) => {\n      if (onUpload) {\n        onUpload(incoming[k], folderId, (pct) => setProgress(a.id, Math.min(99, pct))).then(\n          () => setProgress(a.id, 100),\n          () => setList((v) => v.filter((i) => i.id !== a.id)),\n        );\n        return;\n      }\n      let pct = 0;\n      const speed = 6 + Math.random() * 10;\n      const t = setInterval(() => {\n        pct = Math.min(100, pct + speed + Math.random() * 8);\n        setProgress(a.id, pct);\n        if (pct >= 100) clearInterval(t);\n      }, 160);\n      timers.current.push(t);\n    });\n  };\n\n  const commitPending = () => {\n    if (undoTimer.current) clearTimeout(undoTimer.current);\n    if (pending.current) onDelete?.(pending.current.ids);\n    pending.current = null;\n  };\n  const remove = (item: Item) => {\n    commitPending();\n    const removed = [item, ...(item.folder ? descendants(item.id) : [])];\n    const ids = removed.map((r) => r.id);\n    setList((v) => v.filter((i) => !ids.includes(i.id)));\n    pending.current = { ids };\n    setUndo({ label: item.name, removed });\n    undoTimer.current = setTimeout(() => {\n      commitPending();\n      setUndo(null);\n    }, 6000);\n  };\n  const restore = () => {\n    if (!undo) return;\n    if (undoTimer.current) clearTimeout(undoTimer.current);\n    pending.current = null;\n    const back = undo.removed;\n    returnFocus.current = back[0].id;\n    setList((v) => [...v, ...back]);\n    setUndo(null);\n  };\n  const rename = (item: Item, raw: string) => {\n    const name = raw.trim();\n    setRenaming(null);\n    returnFocus.current = item.id;\n    if (!name || name === item.name) return;\n    if (list.some((i) => i.parentId === item.parentId && i.id !== item.id && i.name.toLowerCase() === name.toLowerCase())) return;\n    setList((v) => v.map((i) => (i.id === item.id ? { ...i, name, modified: today } : i)));\n    onRename?.(item.id, name);\n  };\n  const go = (id: string | null) => {\n    setCwd(id);\n    setRenaming(null);\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const selectName = React.useCallback((el: HTMLInputElement | null) => {\n    if (!el) return;\n    el.focus();\n    const dot = el.value.lastIndexOf(\".\");\n    el.setSelectionRange(0, dot > 0 ? dot : el.value.length);\n  }, []);\n  const refocus = (id: string) => (el: HTMLElement | null) => {\n    if (el && returnFocus.current === id) {\n      returnFocus.current = null;\n      el.focus();\n    }\n  };\n\n  const nameField = (item: Item, big: boolean) =>\n    renaming === item.id ? (\n      <form\n        className=\"min-w-0 flex-1\"\n        onSubmit={(e) => {\n          e.preventDefault();\n          rename(item, (e.currentTarget.elements.namedItem(\"name\") as HTMLInputElement).value);\n        }}\n      >\n        <input\n          ref={selectName}\n          name=\"name\"\n          defaultValue={item.name}\n          aria-label={`Rename ${item.name}`}\n          onBlur={(e) => rename(item, e.currentTarget.value)}\n          onKeyDown={(e) => {\n            if (e.key === \"Escape\") {\n              e.preventDefault();\n              e.stopPropagation();\n              returnFocus.current = item.id;\n              setRenaming(null);\n            }\n          }}\n          className={cn(\"w-full rounded-md border px-1.5 py-0.5 text-[13.5px] outline-none\", big && \"text-center\")}\n          style={{ background: p.bg, borderColor: p.ring, color: p.text }}\n        />\n      </form>\n    ) : item.folder ? (\n      <button type=\"button\" ref={refocus(item.id)} onClick={() => go(item.id)} onKeyDown={(e) => e.key === \"F2\" && setRenaming(item.id)} className={cn(\"min-w-0 cursor-pointer truncate rounded-md border-0 bg-transparent p-0 text-left text-[13.5px] font-medium after:absolute after:inset-0 after:content-['']\", focus, big && \"w-full text-center\")} style={{ color: p.text, ...ring }} title={item.name}>\n        {item.name}\n      </button>\n    ) : (\n      <span ref={refocus(item.id)} tabIndex={-1} className={cn(\"block min-w-0 truncate text-[13.5px] font-medium outline-none\", big && \"w-full text-center\")} title={item.name}>\n        {item.name}\n      </span>\n    );\n\n  const actions = (item: Item, big: boolean) =>\n    item.progress === undefined && renaming !== item.id ? (\n      <span className={cn(\"relative z-10 flex shrink-0 gap-0.5\", big && \"absolute top-1.5 right-1.5 rounded-lg p-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100\")} style={big ? { background: p.card } : undefined}>\n        <button type=\"button\" onClick={() => setRenaming(item.id)} aria-label={`Rename ${item.name}`} title=\"Rename (F2)\" className={cn(\"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent\", focus)} style={{ color: p.muted, ...ring }}>\n          <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d=\"M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16v4Z\" />\n          </svg>\n        </button>\n        <button type=\"button\" onClick={() => remove(item)} aria-label={`Delete ${item.name}`} title=\"Delete\" className={cn(\"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent\", focus)} style={{ color: p.muted, ...ring }}>\n          <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d=\"M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3\" />\n          </svg>\n        </button>\n      </span>\n    ) : null;\n\n  const meta = (item: Item) => (item.folder ? `${children(item.id).length} ${children(item.id).length === 1 ? \"item\" : \"items\"}` : bytes(item.size ?? 0));\n  const bar = (item: Item) => (\n    <span className=\"mt-1.5 block h-1 w-full overflow-hidden rounded-full\" style={{ background: p.track }} role=\"progressbar\" aria-label={`Uploading ${item.name}`} aria-valuenow={Math.round(item.progress ?? 0)} aria-valuemin={0} aria-valuemax={100}>\n      <motion.span className=\"block h-full rounded-full\" style={{ background: p.on }} initial={false} animate={{ width: `${item.progress ?? 0}%` }} transition={{ duration: reduce ? 0 : 0.18 }} />\n    </span>\n  );\n  const sortBtn = (key: SortKey, label: string, cls?: string) => (\n    <button type=\"button\" onClick={() => setSort((s) => ({ key, dir: s.key === key ? (s.dir === 1 ? -1 : 1) : key === \"name\" ? 1 : -1 }))} aria-label={`Sort by ${label}${sort.key === key ? (sort.dir === 1 ? \", ascending\" : \", descending\") : \"\"}`} className={cn(\"inline-flex cursor-pointer items-center gap-1 rounded border-0 bg-transparent p-0 text-[12px] font-medium\", focus, cls)} style={{ color: sort.key === key ? p.text : p.faint, ...ring }}>\n      {label}\n      {sort.key === key && (\n        <svg width=\"10\" height=\"10\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\" style={{ transform: sort.dir === 1 ? undefined : \"rotate(180deg)\" }}>\n          <path d=\"M8 13V3m0 0L4 7m4-4 4 4\" />\n        </svg>\n      )}\n    </button>\n  );\n  const folderName = crumbs.length ? crumbs[crumbs.length - 1].name : title;\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"relative mx-auto max-w-6xl px-4 py-10 @[640px]:px-6 @[640px]:py-14\">\n        <div\n          className=\"relative overflow-hidden rounded-2xl border\"\n          style={{ background: p.card, borderColor: p.border }}\n          onDragEnter={(e) => {\n            if (!e.dataTransfer.types.includes(\"Files\")) return;\n            e.preventDefault();\n            dragDepth.current += 1;\n            setDragging(true);\n          }}\n          onDragOver={(e) => {\n            if (!e.dataTransfer.types.includes(\"Files\")) return;\n            e.preventDefault();\n            e.dataTransfer.dropEffect = \"copy\";\n          }}\n          onDragLeave={() => {\n            dragDepth.current = Math.max(0, dragDepth.current - 1);\n            if (!dragDepth.current) setDragging(false);\n          }}\n          onDrop={(e) => {\n            if (!e.dataTransfer.types.includes(\"Files\")) return;\n            e.preventDefault();\n            dragDepth.current = 0;\n            setDragging(false);\n            upload(Array.from(e.dataTransfer.files));\n          }}\n        >\n          {/* Header */}\n          <div className=\"flex flex-wrap items-center justify-between gap-3 border-b px-4 py-3 @[640px]:px-5\" style={{ borderColor: p.border }}>\n            <nav aria-label=\"Breadcrumb\" className=\"min-w-0 flex-1\">\n              <ol className=\"m-0 flex min-w-0 list-none items-center gap-1 p-0 text-[15px]\">\n                {[{ id: null as string | null, name: title }, ...crumbs.map((c) => ({ id: c.id as string | null, name: c.name }))].map((c, i, arr) => {\n                  const last = i === arr.length - 1;\n                  const hiddenMid = arr.length > 3 && i > 0 && i < arr.length - 2;\n                  return (\n                    <li key={c.id ?? \"root\"} className={cn(\"flex min-w-0 items-center gap-1\", hiddenMid && \"hidden @[560px]:flex\", last ? \"shrink\" : \"shrink-0\")}>\n                      {i > 0 && (\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\" style={{ color: p.faint }} className=\"shrink-0\">\n                          <path d=\"m6 3 5 5-5 5\" />\n                        </svg>\n                      )}\n                      {i === 1 && arr.length > 3 && (\n                        <span className=\"@[560px]:hidden\" style={{ color: p.faint }} aria-hidden=\"true\">\n                          …\n                        </span>\n                      )}\n                      {last ? (\n                        <span aria-current=\"page\" className=\"truncate font-semibold tracking-[-0.01em]\">\n                          {c.name}\n                        </span>\n                      ) : (\n                        <button type=\"button\" onClick={() => go(c.id)} className={cn(\"cursor-pointer truncate rounded-md border-0 bg-transparent px-1 py-0.5\", focus)} style={{ color: p.muted, ...ring }}>\n                          {c.name}\n                        </button>\n                      )}\n                    </li>\n                  );\n                })}\n              </ol>\n            </nav>\n            <div className=\"flex items-center gap-2\">\n              <div role=\"radiogroup\" aria-label=\"View\" className=\"flex rounded-lg border p-0.5\" style={{ borderColor: p.border }}>\n                {([\"grid\", \"list\"] as const).map((v) => (\n                  <button key={v} type=\"button\" role=\"radio\" aria-checked={view === v} aria-label={v === \"grid\" ? \"Grid view\" : \"List view\"} onClick={() => setView(v)} className={cn(\"relative flex h-7 w-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent\", focus)} style={{ color: view === v ? p.text : p.faint, ...ring }}>\n                    {view === v && <motion.span layoutId=\"file-manager-view\" className=\"absolute inset-0 rounded-md\" style={{ background: p.chip }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 36 }} />}\n                    <svg className=\"relative\" width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                      {v === \"grid\" ? <path d=\"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z\" /> : <path d=\"M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01\" />}\n                    </svg>\n                  </button>\n                ))}\n              </div>\n              <button type=\"button\" onClick={() => fileInput.current?.click()} className={cn(\"flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border-0 px-3 text-[13px] font-medium\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"M12 19V5m0 0-6 6m6-6 6 6\" />\n                </svg>\n                Upload\n              </button>\n              <input\n                ref={fileInput}\n                type=\"file\"\n                multiple\n                className=\"sr-only\"\n                tabIndex={-1}\n                aria-hidden=\"true\"\n                onChange={(e) => {\n                  upload(Array.from(e.currentTarget.files ?? []));\n                  e.currentTarget.value = \"\";\n                }}\n              />\n            </div>\n          </div>\n\n          {/* Storage */}\n          <div className=\"border-b px-4 py-3.5 @[640px]:px-5\" style={{ borderColor: p.border }}>\n            <div className=\"mb-2 flex items-baseline justify-between gap-3 text-[12.5px]\">\n              <span style={{ color: p.muted }}>\n                <span className=\"font-medium tabular-nums\" style={{ color: p.text }}>\n                  {bytes(used)}\n                </span>{\" \"}\n                of {bytes(quota)} used\n              </span>\n              <span className=\"tabular-nums\" style={{ color: p.faint }}>\n                {Math.round((used / quota) * 100)}%\n              </span>\n            </div>\n            <div className=\"flex h-2 gap-px overflow-hidden rounded-full\" style={{ background: p.track }} role=\"img\" aria-label={`${bytes(used)} of ${bytes(quota)} used: ${groups.map((g) => `${g.label} ${bytes(g.total)}`).join(\", \")}`}>\n              {groups.map((g) => (g.total ? <motion.span key={g.label} className=\"h-full\" style={{ background: g.color }} initial={false} animate={{ width: `${(g.total / quota) * 100}%` }} transition={{ duration: reduce ? 0 : 0.4 }} /> : null))}\n            </div>\n            <ul className=\"m-0 mt-2.5 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-[12px]\" style={{ color: p.muted }}>\n              {groups.map((g) => (\n                <li key={g.label} className=\"flex items-center gap-1.5\">\n                  <span className=\"h-2 w-2 rounded-full\" style={{ background: g.color }} aria-hidden=\"true\" />\n                  {g.label} <span className=\"tabular-nums\" style={{ color: p.faint }}>{bytes(g.total)}</span>\n                </li>\n              ))}\n            </ul>\n          </div>\n\n          {/* Content */}\n          <div className=\"relative min-h-[300px] p-3 @[640px]:p-4\">\n            {view === \"list\" && here.length > 0 && (\n              <div className=\"grid grid-cols-[1fr_auto_64px] items-center gap-3 px-2 pb-2 @[560px]:grid-cols-[1fr_120px_84px_64px]\">\n                {sortBtn(\"name\", \"Name\")}\n                {sortBtn(\"modified\", \"Modified\", \"hidden @[560px]:inline-flex\")}\n                {sortBtn(\"size\", \"Size\", \"justify-self-end\")}\n                <span />\n              </div>\n            )}\n            <motion.ul key={`${cwd}-${view}`} initial={reduce ? false : { opacity: 0, y: 4 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.2 }} className={cn(\"m-0 list-none p-0\", view === \"grid\" ? \"grid grid-cols-2 gap-2 @[480px]:grid-cols-3 @[720px]:grid-cols-4 @[900px]:grid-cols-5\" : \"flex flex-col\")} aria-label={`Contents of ${folderName}`}>\n              <AnimatePresence initial={false} mode=\"popLayout\">\n                {here.map((item) => {\n                  const k = kindOf(item);\n                  const uploading = item.progress !== undefined;\n                  return view === \"grid\" ? (\n                    <motion.li key={item.id} layout={!reduce} initial={reduce ? false : { opacity: 0, scale: 0.96 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0, scale: 0.96 }} transition={{ duration: 0.2 }} className=\"group relative flex flex-col items-center gap-2 rounded-xl border px-3 pt-5 pb-3 transition-colors hover:bg-[var(--fm-hover)]\" style={{ borderColor: p.border, [\"--fm-hover\" as string]: p.hover }}>\n                      <span className=\"flex h-14 items-center justify-center\" style={{ opacity: uploading ? 0.5 : 1 }}>\n                        {icon(k, p.folder, true, ext(item.name))}\n                      </span>\n                      {nameField(item, true)}\n                      {uploading ? bar(item) : (\n                        <span className=\"text-[12px] tabular-nums\" style={{ color: p.faint }}>\n                          {meta(item)}\n                        </span>\n                      )}\n                      {actions(item, true)}\n                    </motion.li>\n                  ) : (\n                    <motion.li key={item.id} layout={!reduce} initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} exit={reduce ? undefined : { opacity: 0 }} transition={{ duration: 0.18 }} className=\"relative grid grid-cols-[1fr_auto_64px] items-center gap-3 rounded-lg px-2 py-2 transition-colors hover:bg-[var(--fm-hover)] @[560px]:grid-cols-[1fr_120px_84px_64px]\" style={{ [\"--fm-hover\" as string]: p.hover }}>\n                      <span className=\"flex min-w-0 items-center gap-2.5\">\n                        <span className=\"shrink-0\" style={{ opacity: uploading ? 0.5 : 1 }}>\n                          {icon(k, p.folder, false, \"\")}\n                        </span>\n                        <span className=\"min-w-0 flex-1\">\n                          {nameField(item, false)}\n                          {uploading && bar(item)}\n                        </span>\n                      </span>\n                      <span className=\"hidden text-[12.5px] tabular-nums @[560px]:block\" style={{ color: p.faint }}>\n                        {day(item.modified)}\n                      </span>\n                      <span className=\"justify-self-end text-[12.5px] tabular-nums\" style={{ color: p.faint }}>\n                        {uploading ? `${Math.round(item.progress ?? 0)}%` : item.folder ? bytes(folderSize(item.id)) : bytes(item.size ?? 0)}\n                      </span>\n                      <span className=\"flex justify-end\">{actions(item, false)}</span>\n                    </motion.li>\n                  );\n                })}\n              </AnimatePresence>\n            </motion.ul>\n            {here.length === 0 && (\n              <div className=\"flex min-h-[260px] flex-col items-center justify-center gap-2 text-center\">\n                {icon(\"folder\", p.folder, true, \"\")}\n                <p className=\"m-0 text-[14px] font-medium\">This folder is empty</p>\n                <p className=\"m-0 text-[13px]\" style={{ color: p.muted }}>\n                  Drop files here or use Upload.\n                </p>\n              </div>\n            )}\n          </div>\n\n          <AnimatePresence>\n            {dragging && (\n              <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.15 }} className=\"pointer-events-none absolute inset-2 z-20 flex flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed\" style={{ borderColor: p.on, background: theme === \"dark\" ? \"rgba(10,10,10,0.82)\" : \"rgba(250,250,248,0.86)\" }}>\n                <motion.span animate={reduce ? undefined : { y: [0, -6, 0] }} transition={{ duration: 1.2, repeat: Infinity, ease: \"easeInOut\" }}>\n                  <svg width=\"30\" height=\"30\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"M12 16V4m0 0-5 5m5-5 5 5M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\" />\n                  </svg>\n                </motion.span>\n                <span className=\"text-[15px] font-semibold\">Drop to upload</span>\n                <span className=\"text-[13px]\" style={{ color: p.muted }}>\n                  into {folderName}\n                </span>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </div>\n\n        <div className=\"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center px-4\" aria-live=\"polite\">\n          <AnimatePresence>\n            {undo && (\n              <motion.div key={undo.label} initial={reduce ? false : { opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: 6 }} className=\"pointer-events-auto flex max-w-full items-center gap-3 rounded-full py-1.5 pr-1.5 pl-4 text-[13px] shadow-lg\" style={{ background: p.on, color: p.onText }}>\n                <span className=\"min-w-0 truncate\">\n                  Deleted <span className=\"font-medium\">{undo.label}</span>\n                </span>\n                <button type=\"button\" onClick={restore} className=\"h-7 shrink-0 cursor-pointer rounded-full border-0 px-3 text-[13px] font-semibold outline-none focus-visible:ring-2\" style={{ background: p.onText, color: p.on, [\"--tw-ring-color\" as string]: p.onText }}>\n                  Undo\n                </button>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default FileManager;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}