{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-file-explorer",
  "type": "registry:component",
  "title": "App File Explorer",
  "description": "A column file browser where each folder opens in a new column to the right, with breadcrumbs, full arrow key navigation and a preview pane. The preview renders highlighted source, image art, a playable waveform, a spreadsheet grid or a document page depending on the file.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "app-ui",
    "files",
    "column view",
    "breadcrumbs",
    "preview",
    "explorer",
    "keyboard"
  ],
  "docs": "https://hyperblur.dev/effects/app-file-explorer",
  "files": [
    {
      "path": "registry/hyperblur/app-file-explorer.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/app-file-explorer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type ExplorerKind = \"folder\" | \"code\" | \"image\" | \"doc\" | \"sheet\" | \"pdf\" | \"audio\";\n\nexport interface ExplorerNode {\n  id: string;\n  name: string;\n  kind: ExplorerKind;\n  size?: string;\n  modified?: string;\n  children?: ExplorerNode[];\n  lines?: string[];\n  tint?: string;\n  dimensions?: string;\n  duration?: string;\n}\n\nexport interface AppFileExplorerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n  tree?: ExplorerNode[];\n  rootLabel?: string;\n  path?: string[];\n  defaultPath?: string[];\n  onPathChange?: (path: string[]) => void;\n  onOpen?: (node: ExplorerNode) => void;\n  onShare?: (node: ExplorerNode) => void;\n  accent?: string;\n}\n\nconst sampleTree: ExplorerNode[] = [\n  {\n    id: \"src\",\n    name: \"src\",\n    kind: \"folder\",\n    modified: \"Today, 10:42\",\n    children: [\n      {\n        id: \"components\",\n        name: \"components\",\n        kind: \"folder\",\n        modified: \"Today, 10:42\",\n        children: [\n          {\n            id: \"button\",\n            name: \"Button.tsx\",\n            kind: \"code\",\n            size: \"2.1 KB\",\n            modified: \"Today, 10:42\",\n            lines: [\n              'import { forwardRef } from \"react\";',\n              'import { cx } from \"../lib/cx\";',\n              \"\",\n              \"export const Button = forwardRef(\",\n              \"  function Button({ tone = \\\"primary\\\", ...props }, ref) {\",\n              \"    return (\",\n              \"      <button\",\n              \"        ref={ref}\",\n              \"        className={cx(\\\"btn\\\", `btn-${tone}`)}\",\n              \"        {...props}\",\n              \"      />\",\n              \"    );\",\n              \"  },\",\n              \");\",\n            ],\n          },\n          { id: \"sheet\", name: \"Sheet.tsx\", kind: \"code\", size: \"4.8 KB\", modified: \"Yesterday\", lines: ['import { useEffect } from \"react\";', \"\", \"export function Sheet({ open, onClose }) {\", \"  useEffect(() => {\", \"    if (!open) return;\", '    document.body.style.overflow = \"hidden\";', \"  }, [open]);\", \"  return null;\", \"}\"] },\n          { id: \"avatar\", name: \"Avatar.tsx\", kind: \"code\", size: \"1.3 KB\", modified: \"Oct 28\", lines: [\"export function Avatar({ name }) {\", \"  const initials = name.slice(0, 2);\", \"  return <span className=\\\"avatar\\\">{initials}</span>;\", \"}\"] },\n          { id: \"tabbar\", name: \"TabBar.tsx\", kind: \"code\", size: \"3.6 KB\", modified: \"Oct 24\", lines: ['import { usePathname } from \"../router\";', \"\", \"export function TabBar() {\", \"  const path = usePathname();\", \"  return <nav aria-label=\\\"Main\\\" />;\", \"}\"] },\n        ],\n      },\n      { id: \"hooks\", name: \"hooks\", kind: \"folder\", modified: \"Oct 30\", children: [{ id: \"session\", name: \"useSession.ts\", kind: \"code\", size: \"1.9 KB\", modified: \"Oct 30\", lines: ['import { useSyncExternalStore } from \"react\";', 'import { store } from \"./store\";', \"\", \"export function useSession() {\", \"  return useSyncExternalStore(store.subscribe, store.get);\", \"}\"] }] },\n      { id: \"app\", name: \"App.tsx\", kind: \"code\", size: \"5.2 KB\", modified: \"Today, 09:15\", lines: ['import { Router } from \"./router\";', 'import { TabBar } from \"./components/TabBar\";', \"\", \"export default function App() {\", \"  return (\", \"    <Router>\", \"      <TabBar />\", \"    </Router>\", \"  );\", \"}\"] },\n      { id: \"theme\", name: \"theme.ts\", kind: \"code\", size: \"860 B\", modified: \"Oct 12\", lines: [\"export const theme = {\", '  accent: \"#5b8cff\",', \"  radius: 12,\", \"};\"] },\n    ],\n  },\n  {\n    id: \"design\",\n    name: \"design\",\n    kind: \"folder\",\n    modified: \"Nov 2\",\n    children: [\n      { id: \"hero\", name: \"onboarding-hero.png\", kind: \"image\", size: \"1.8 MB\", modified: \"Nov 2\", tint: \"#ff8a5b\", dimensions: \"2400 × 1600\" },\n      { id: \"icons\", name: \"tab-icons@3x.png\", kind: \"image\", size: \"420 KB\", modified: \"Oct 29\", tint: \"#5b8cff\", dimensions: \"1080 × 360\" },\n      { id: \"splash\", name: \"splash-dark.png\", kind: \"image\", size: \"960 KB\", modified: \"Oct 20\", tint: \"#9a7bff\", dimensions: \"1290 × 2796\" },\n    ],\n  },\n  {\n    id: \"docs\",\n    name: \"docs\",\n    kind: \"folder\",\n    modified: \"Nov 4\",\n    children: [\n      { id: \"brief\", name: \"Launch brief.docx\", kind: \"doc\", size: \"86 KB\", modified: \"Nov 4\" },\n      { id: \"metrics\", name: \"Beta metrics.xlsx\", kind: \"sheet\", size: \"212 KB\", modified: \"Nov 3\" },\n      { id: \"msa\", name: \"Vendor MSA.pdf\", kind: \"pdf\", size: \"1.1 MB\", modified: \"Oct 18\" },\n    ],\n  },\n  {\n    id: \"audio\",\n    name: \"audio\",\n    kind: \"folder\",\n    modified: \"Oct 26\",\n    children: [\n      { id: \"vo\", name: \"welcome-voiceover.wav\", kind: \"audio\", size: \"6.4 MB\", modified: \"Oct 26\", duration: \"0:38\" },\n      { id: \"chime\", name: \"success-chime.wav\", kind: \"audio\", size: \"210 KB\", modified: \"Oct 26\", duration: \"0:02\" },\n    ],\n  },\n  { id: \"readme\", name: \"README.md\", kind: \"doc\", size: \"3.4 KB\", modified: \"Oct 30\" },\n  { id: \"pkg\", name: \"package.json\", kind: \"code\", size: \"1.2 KB\", modified: \"Nov 1\", lines: [\"{\", '  \"name\": \"harbor-mobile\",', '  \"version\": \"2.4.0\",', '  \"private\": true', \"}\"] },\n];\n\nconst kindLabel: Record<ExplorerKind, string> = { folder: \"Folder\", code: \"Source file\", image: \"PNG image\", doc: \"Document\", sheet: \"Spreadsheet\", pdf: \"PDF document\", audio: \"WAV audio\" };\nconst kindColor: Record<ExplorerKind, string> = { folder: \"#6aa2ff\", code: \"#c4b5fd\", image: \"#ff9f7a\", doc: \"#8fb8ff\", sheet: \"#5ed39b\", pdf: \"#ff7a7a\", audio: \"#f5c25b\" };\n\nconst hash = (s: string, i: number) => {\n  let h = 2166136261 ^ i;\n  for (let k = 0; k < s.length; k++) h = Math.imul(h ^ s.charCodeAt(k), 16777619);\n  return (h >>> 0) / 4294967295;\n};\n\nfunction Icon({ kind }: { kind: ExplorerKind }) {\n  const c = kindColor[kind];\n  if (kind === \"folder\")\n    return (\n      <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\">\n        <path d=\"M2.5 5.5A1.5 1.5 0 0 1 4 4h3.6l1.6 1.8H16a1.5 1.5 0 0 1 1.5 1.5v7.2A1.5 1.5 0 0 1 16 16H4a1.5 1.5 0 0 1-1.5-1.5Z\" fill={c} opacity=\"0.9\" />\n        <path d=\"M2.5 8h15v6.5A1.5 1.5 0 0 1 16 16H4a1.5 1.5 0 0 1-1.5-1.5Z\" fill={c} />\n      </svg>\n    );\n  return (\n    <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\">\n      <path d=\"M5 2.5h6.5L15.5 6.5v10A1 1 0 0 1 14.5 17.5h-9.5A1 1 0 0 1 4 16.5v-13A1 1 0 0 1 5 2.5Z\" fill=\"#1f1f1f\" stroke={c} strokeWidth=\"1.2\" />\n      <path d=\"M11.5 2.5v4h4\" fill=\"none\" stroke={c} strokeWidth=\"1.2\" />\n      {kind === \"code\" && <path d=\"M8.2 10 6.6 11.6l1.6 1.6M11.8 10l1.6 1.6-1.6 1.6\" fill=\"none\" stroke={c} strokeWidth=\"1.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />}\n      {kind === \"image\" && <path d=\"m6.5 14.5 2.4-3 1.7 2 1.4-1.5 1.5 2.5Z\" fill={c} />}\n      {(kind === \"doc\" || kind === \"pdf\") && <path d=\"M7 10h6M7 12.2h6M7 14.4h4\" stroke={c} strokeWidth=\"1.1\" strokeLinecap=\"round\" />}\n      {kind === \"sheet\" && <path d=\"M6.8 9.8h6.4v4.8H6.8ZM6.8 12.2h6.4M10 9.8v4.8\" fill=\"none\" stroke={c} strokeWidth=\"1.1\" />}\n      {kind === \"audio\" && <path d=\"M7 12.5v1M8.6 11v4M10.2 10v6M11.8 11.5v3M13.2 12.3v1.4\" stroke={c} strokeWidth=\"1.1\" strokeLinecap=\"round\" />}\n    </svg>\n  );\n}\n\nconst keywords = new Set([\"import\", \"from\", \"export\", \"const\", \"function\", \"return\", \"default\", \"if\", \"type\", \"interface\", \"async\", \"await\"]);\n\nfunction Code({ lines }: { lines: string[] }) {\n  return (\n    <div className=\"hb-wj2-code\" role=\"presentation\">\n      {lines.slice(0, 14).map((line, i) => (\n        <div key={i} className=\"hb-wj2-ln\">\n          <span className=\"hb-wj2-no\">{i + 1}</span>\n          <span>\n            {line.split(/(\"[^\"]*\"|`[^`]*`|\\b[A-Za-z_]+\\b|<\\/?[A-Z][A-Za-z]*)/).map((part, k) => {\n              if (!part) return null;\n              if (/^[\"`]/.test(part)) return <span key={k} className=\"hb-wj2-s\">{part}</span>;\n              if (keywords.has(part)) return <span key={k} className=\"hb-wj2-k\">{part}</span>;\n              if (/^<\\/?[A-Z]/.test(part)) return <span key={k} className=\"hb-wj2-t\">{part}</span>;\n              if (/^[A-Z][a-z]/.test(part)) return <span key={k} className=\"hb-wj2-f\">{part}</span>;\n              return <React.Fragment key={k}>{part}</React.Fragment>;\n            })}\n          </span>\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction Preview({ node }: { node: ExplorerNode }) {\n  const [playing, setPlaying] = React.useState(false);\n  if (node.kind === \"code\") return <Code lines={node.lines ?? []} />;\n  if (node.kind === \"image\") {\n    const t = node.tint ?? \"#5b8cff\";\n    return (\n      <div className=\"hb-wj2-img\" style={{ \"--t\": t } as React.CSSProperties}>\n        <span className=\"hb-wj2-sun\" />\n        <span className=\"hb-wj2-hill\" data-n=\"1\" />\n        <span className=\"hb-wj2-hill\" data-n=\"2\" />\n        <span className=\"hb-wj2-dim\">{node.dimensions}</span>\n      </div>\n    );\n  }\n  if (node.kind === \"audio\")\n    return (\n      <div className=\"hb-wj2-audio\" data-playing={playing}>\n        <button type=\"button\" className=\"hb-wj2-play\" aria-label={playing ? \"Pause\" : \"Play\"} onClick={() => setPlaying((p) => !p)}>\n          {playing ? (\n            <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M5 3.5h2v9H5zM9 3.5h2v9H9z\" fill=\"currentColor\" /></svg>\n          ) : (\n            <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M5 3.2v9.6L12.5 8Z\" fill=\"currentColor\" /></svg>\n          )}\n        </button>\n        <div className=\"hb-wj2-wave\">\n          {Array.from({ length: 42 }, (_, i) => {\n            const v = 0.18 + 0.82 * Math.abs(Math.sin(i * 0.45 + hash(node.id, i) * 2.4)) * (0.55 + 0.45 * hash(node.id, i + 99));\n            return <span key={i} style={{ height: `${(v * 100).toFixed(1)}%`, \"--i\": i } as React.CSSProperties} />;\n          })}\n        </div>\n        <span className=\"hb-wj2-dur\">{node.duration}</span>\n      </div>\n    );\n  if (node.kind === \"sheet\")\n    return (\n      <div className=\"hb-wj2-sheet\" role=\"presentation\">\n        {[[\"Week\", \"Signups\", \"D7 ret.\"], [\"W40\", \"1,284\", \"41%\"], [\"W41\", \"1,612\", \"44%\"], [\"W42\", \"2,038\", \"47%\"], [\"W43\", \"2,415\", \"52%\"]].map((row, r) => (\n          <div key={r} className=\"hb-wj2-row\" data-head={r === 0}>\n            {row.map((c, k) => (\n              <span key={k}>{c}</span>\n            ))}\n          </div>\n        ))}\n      </div>\n    );\n  if (node.kind === \"folder\") {\n    const kids = node.children ?? [];\n    return (\n      <div className=\"hb-wj2-folder\">\n        <div className=\"hb-wj2-big\"><Icon kind=\"folder\" /></div>\n        <div className=\"hb-wj2-chips\">\n          {kids.slice(0, 4).map((k) => (\n            <span key={k.id}><Icon kind={k.kind} />{k.name}</span>\n          ))}\n          {kids.length > 4 && <span>+{kids.length - 4} more</span>}\n        </div>\n      </div>\n    );\n  }\n  return (\n    <div className=\"hb-wj2-page\" data-kind={node.kind}>\n      <b>{node.name.replace(/\\.[a-z]+$/, \"\")}</b>\n      {Array.from({ length: 7 }, (_, i) => (\n        <span key={i} style={{ width: `${(58 + hash(node.id, i) * 40).toFixed(0)}%` }} />\n      ))}\n    </div>\n  );\n}\n\nconst css = `\n.hb-wj2 {\n  --hb-wj2-a: #2f7bff;\n  box-sizing: border-box;\n  container-type: inline-size;\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  height: 440px;\n  font-family: inherit;\n  font-size: 12.5px;\n  color: #ededed;\n  background: #0f0f0f;\n  border: 1px solid #262626;\n  border-radius: 16px;\n  overflow: hidden;\n  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 30px 70px -40px rgba(0,0,0,0.9);\n}\n.hb-wj2 *, .hb-wj2 *::before, .hb-wj2 *::after { box-sizing: border-box; font-family: inherit; }\n.hb-wj2-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: linear-gradient(180deg, #151515, #121212); border-bottom: 1px solid #222; }\n.hb-wj2-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; color: #a1a1a1; background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer; transition: background-color .15s ease, color .15s ease; }\n.hb-wj2-icon svg { width: 15px; height: 15px; }\n.hb-wj2-icon:hover:not(:disabled) { color: #fff; background: #1d1d1d; border-color: #2a2a2a; }\n.hb-wj2-icon:disabled { opacity: 0.35; cursor: default; }\n.hb-wj2-crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; margin: 0; padding: 0; list-style: none; overflow: hidden; }\n.hb-wj2-crumbs li { display: flex; align-items: center; min-width: 0; gap: 2px; }\n.hb-wj2-crumbs li + li::before { content: \"\"; width: 5px; height: 5px; margin: 0 4px; border-top: 1.4px solid #555; border-right: 1.4px solid #555; transform: rotate(45deg); flex: none; }\n.hb-wj2-crumb { min-width: 0; padding: 4px 7px; font: inherit; font-size: 12.5px; color: #a1a1a1; background: none; border: 0; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background-color .15s ease, color .15s ease; }\n.hb-wj2-crumb:hover { color: #fff; background: #1d1d1d; }\n.hb-wj2-crumb[aria-current=\"page\"] { color: #fff; font-weight: 600; }\n.hb-wj2-main { display: flex; flex: 1; min-height: 0; }\n.hb-wj2-cols { display: flex; flex: 1; min-width: 0; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }\n.hb-wj2-col { flex: none; width: 188px; margin: 0; padding: 6px; list-style: none; border-right: 1px solid #1d1d1d; overflow-y: auto; scrollbar-width: none; animation: hb-wj2-in .26s cubic-bezier(.2,.8,.2,1) both; }\n.hb-wj2-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 28px; padding: 0 8px; font: inherit; font-size: 12.5px; text-align: left; color: #d4d4d4; background: transparent; border: 0; border-radius: 7px; cursor: pointer; transition: background-color .12s ease, color .12s ease; }\n.hb-wj2-item svg { flex: none; width: 16px; height: 16px; }\n.hb-wj2-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-wj2-item i { flex: none; width: 5px; height: 5px; border-top: 1.4px solid #6a6a6a; border-right: 1.4px solid #6a6a6a; transform: rotate(45deg); font-style: normal; }\n.hb-wj2-item:hover { background: #181818; }\n.hb-wj2-item[aria-selected=\"true\"] { color: #fff; background: #222; }\n.hb-wj2-item[aria-selected=\"true\"][data-active=\"true\"] { background: linear-gradient(180deg, color-mix(in srgb, var(--hb-wj2-a) 92%, #fff 8%), var(--hb-wj2-a)); box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 6px 16px -10px var(--hb-wj2-a); }\n.hb-wj2-item[aria-selected=\"true\"][data-active=\"true\"] i { border-color: #fff; }\n.hb-wj2-item:focus-visible { outline: 2px solid var(--hb-wj2-a); outline-offset: -2px; }\n.hb-wj2-pv { display: flex; flex-direction: column; flex: none; width: 262px; padding: 14px; gap: 12px; background: linear-gradient(180deg, #121212, #0e0e0e); border-left: 1px solid #1d1d1d; overflow: hidden; animation: hb-wj2-fade .3s ease both; }\n.hb-wj2-stage { display: grid; place-items: center; height: 150px; border-radius: 12px; background: #0a0a0a; border: 1px solid #1f1f1f; overflow: hidden; }\n.hb-wj2-name { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }\n.hb-wj2-name svg { width: 18px; height: 18px; flex: none; }\n.hb-wj2-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-wj2-meta { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 11.5px; }\n.hb-wj2-meta dt { color: #7a7a7a; }\n.hb-wj2-meta dd { margin: 0; color: #d4d4d4; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }\n.hb-wj2-acts { display: flex; gap: 6px; margin-top: auto; }\n.hb-wj2-act { flex: 1; height: 30px; font: inherit; font-size: 12px; font-weight: 500; color: #ededed; background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, transform .1s ease; }\n.hb-wj2-act:hover { background: #222; border-color: #363636; }\n.hb-wj2-act:active { transform: translateY(1px); }\n.hb-wj2-act[data-primary=\"true\"] { color: #fff; background: var(--hb-wj2-a); border-color: transparent; box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset; }\n.hb-wj2-act[data-primary=\"true\"]:hover { background: color-mix(in srgb, var(--hb-wj2-a) 88%, #fff); }\n.hb-wj2-act:focus-visible, .hb-wj2-crumb:focus-visible, .hb-wj2-icon:focus-visible, .hb-wj2-play:focus-visible { outline: 2px solid var(--hb-wj2-a); outline-offset: 1px; }\n.hb-wj2-code { align-self: stretch; justify-self: stretch; padding: 10px 0; font-family: var(--font-mono), ui-monospace, monospace; font-size: 9.5px; line-height: 1.55; color: #cfcfcf; overflow: hidden; white-space: pre; }\n.hb-wj2-ln { display: flex; gap: 10px; padding-right: 8px; }\n.hb-wj2-no { flex: none; width: 22px; text-align: right; color: #4a4a4a; }\n.hb-wj2-k { color: #c792ea; }\n.hb-wj2-s { color: #a5d6a7; }\n.hb-wj2-t { color: #7fb3ff; }\n.hb-wj2-f { color: #ffcb6b; }\n.hb-wj2-img { position: relative; align-self: stretch; justify-self: stretch; overflow: hidden; background: radial-gradient(120% 90% at 20% 10%, color-mix(in srgb, var(--t) 55%, #fff) 0%, var(--t) 38%, color-mix(in srgb, var(--t) 40%, #0a0a0a) 100%); }\n.hb-wj2-sun { position: absolute; right: 22%; top: 18%; width: 34px; height: 34px; border-radius: 50%; background: #fff6e8; box-shadow: 0 0 30px rgba(255,246,232,0.8); }\n.hb-wj2-hill { position: absolute; left: -20%; right: -20%; bottom: -40%; height: 80%; border-radius: 50%; background: color-mix(in srgb, var(--t) 45%, #0a0a0a); }\n.hb-wj2-hill[data-n=\"2\"] { left: 30%; right: -50%; bottom: -50%; background: color-mix(in srgb, var(--t) 25%, #0a0a0a); }\n.hb-wj2-dim { position: absolute; left: 8px; bottom: 8px; padding: 2px 6px; font-size: 10px; color: #fff; background: rgba(0,0,0,0.45); border-radius: 5px; backdrop-filter: blur(6px); font-variant-numeric: tabular-nums; }\n.hb-wj2-audio { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0 14px; }\n.hb-wj2-play { display: grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; color: #0a0a0a; background: #f5c25b; border: 0; border-radius: 50%; cursor: pointer; box-shadow: 0 6px 18px -8px #f5c25b; transition: transform .15s ease; }\n.hb-wj2-play:active { transform: scale(.94); }\n.hb-wj2-play svg { width: 14px; height: 14px; }\n.hb-wj2-wave { display: flex; align-items: center; gap: 2px; flex: 1; height: 54px; }\n.hb-wj2-wave span { flex: 1; min-height: 3px; border-radius: 2px; background: #4a4030; transform-origin: center; }\n.hb-wj2-audio[data-playing=\"true\"] .hb-wj2-wave span { animation: hb-wj2-fill 4.2s linear infinite; animation-delay: calc(var(--i) * 0.1s - 4.2s); }\n.hb-wj2-dur { flex: none; font-size: 10.5px; color: #8f8f8f; font-variant-numeric: tabular-nums; }\n.hb-wj2-sheet { display: grid; width: 86%; font-size: 10px; border: 1px solid #263a30; border-radius: 6px; overflow: hidden; font-variant-numeric: tabular-nums; }\n.hb-wj2-row { display: grid; grid-template-columns: 1fr 1.2fr 1fr; }\n.hb-wj2-row span { padding: 4px 6px; border-top: 1px solid #1d2a23; color: #cfe9db; }\n.hb-wj2-row span + span { border-left: 1px solid #1d2a23; text-align: right; }\n.hb-wj2-row[data-head=\"true\"] span { color: #5ed39b; font-weight: 600; background: #10201a; border-top: 0; }\n.hb-wj2-folder { display: flex; flex-direction: column; align-items: center; gap: 10px; }\n.hb-wj2-big svg { width: 54px; height: 54px; filter: drop-shadow(0 8px 16px rgba(80,140,255,0.35)); }\n.hb-wj2-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 0 10px; }\n.hb-wj2-chips span { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px 2px 4px; font-size: 10px; color: #bdbdbd; background: #171717; border: 1px solid #262626; border-radius: 999px; }\n.hb-wj2-chips svg { width: 12px; height: 12px; }\n.hb-wj2-page { display: flex; flex-direction: column; gap: 6px; width: 104px; height: 132px; padding: 12px 10px; background: #f4f1ea; border-radius: 4px; box-shadow: 0 12px 26px -10px rgba(0,0,0,0.8); transform: rotate(-2deg); }\n.hb-wj2-page b { margin-bottom: 4px; font-size: 8.5px; line-height: 1.2; color: #1d1d1d; }\n.hb-wj2-page span { height: 3px; border-radius: 2px; background: #cfcac0; }\n.hb-wj2-page[data-kind=\"pdf\"] b { color: #c33a3a; }\n@keyframes hb-wj2-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }\n@keyframes hb-wj2-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-wj2-fill { 0%, 49.9% { background: #f5c25b; } 50%, 100% { background: #4a4030; } }\n@container (max-width: 620px) {\n  .hb-wj2-pv { display: none; }\n  .hb-wj2-col { width: 160px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wj2-col, .hb-wj2-pv, .hb-wj2-audio[data-playing=\"true\"] .hb-wj2-wave span { animation: none; }\n  .hb-wj2-cols { scroll-behavior: auto; }\n}\n`;\n\nexport function AppFileExplorer({\n  tree = sampleTree,\n  rootLabel = \"harbor-mobile\",\n  path,\n  defaultPath = [\"src\", \"components\", \"button\"],\n  onPathChange,\n  onOpen,\n  onShare,\n  accent = \"#2f7bff\",\n  className,\n  style,\n  ...rest\n}: AppFileExplorerProps) {\n  const [inner, setInner] = React.useState(defaultPath);\n  const current = path ?? inner;\n  const [activeCol, setActiveCol] = React.useState(Math.max(0, current.length - 1));\n  const [copied, setCopied] = React.useState(false);\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const colsRef = React.useRef<HTMLDivElement>(null);\n\n  const columns: ExplorerNode[][] = [tree];\n  const chain: ExplorerNode[] = [];\n  for (let i = 0; i < current.length; i++) {\n    const node = columns[i]?.find((n) => n.id === current[i]);\n    if (!node) break;\n    chain.push(node);\n    if (node.kind === \"folder\" && node.children) columns.push(node.children);\n  }\n  const selected = chain[chain.length - 1];\n\n  const setPath = (next: string[]) => {\n    if (path === undefined) setInner(next);\n    onPathChange?.(next);\n  };\n\n  React.useEffect(() => {\n    const el = colsRef.current;\n    if (el) el.scrollLeft = el.scrollWidth;\n  }, [current.length]);\n\n  React.useEffect(() => {\n    if (!copied) return;\n    const t = window.setTimeout(() => setCopied(false), 1400);\n    return () => window.clearTimeout(t);\n  }, [copied]);\n\n  const focusItem = (col: number, idx: number) => {\n    requestAnimationFrame(() => {\n      const el = rootRef.current?.querySelector<HTMLButtonElement>(`[data-col=\"${col}\"][data-idx=\"${idx}\"]`);\n      el?.focus();\n    });\n  };\n\n  const choose = (col: number, node: ExplorerNode) => {\n    setActiveCol(col);\n    setPath([...current.slice(0, col), node.id]);\n  };\n\n  const onKey = (e: React.KeyboardEvent<HTMLButtonElement>, col: number, idx: number) => {\n    const items = columns[col];\n    const node = items[idx];\n    if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n      e.preventDefault();\n      const next = Math.min(items.length - 1, Math.max(0, idx + (e.key === \"ArrowDown\" ? 1 : -1)));\n      choose(col, items[next]);\n      focusItem(col, next);\n    } else if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      if (node.kind === \"folder\" && node.children?.length) {\n        setActiveCol(col + 1);\n        setPath([...current.slice(0, col), node.id, node.children[0].id]);\n        focusItem(col + 1, 0);\n      }\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      if (col > 0) {\n        const parentIdx = columns[col - 1].findIndex((n) => n.id === current[col - 1]);\n        setActiveCol(col - 1);\n        setPath(current.slice(0, col));\n        focusItem(col - 1, Math.max(0, parentIdx));\n      }\n    } else if (e.key === \"Enter\") {\n      e.preventDefault();\n      onOpen?.(node);\n    }\n  };\n\n  const crumbPath = chain.filter((n) => n.kind === \"folder\");\n  const where = [rootLabel, ...crumbPath.map((n) => n.name)].join(\"/\");\n  const goUp = () => {\n    const folderDepth = crumbPath.length;\n    if (folderDepth === 0) return;\n    setPath(current.slice(0, folderDepth - 1));\n    setActiveCol(Math.max(0, folderDepth - 1));\n  };\n\n  return (\n    <div ref={rootRef} className={[\"hb-wj2\", className].filter(Boolean).join(\" \")} style={{ \"--hb-wj2-a\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-app-file-explorer\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wj2-bar\">\n        <button type=\"button\" className=\"hb-wj2-icon\" aria-label=\"Enclosing folder\" disabled={crumbPath.length === 0} onClick={goUp}>\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M8 12.5v-9M4 7.5 8 3.5l4 4\" /></svg>\n        </button>\n        <ol className=\"hb-wj2-crumbs\" aria-label=\"Path\">\n          <li>\n            <button type=\"button\" className=\"hb-wj2-crumb\" aria-current={crumbPath.length === 0 ? \"page\" : undefined} onClick={() => { setPath([]); setActiveCol(0); }}>\n              {rootLabel}\n            </button>\n          </li>\n          {crumbPath.map((n, i) => (\n            <li key={n.id}>\n              <button type=\"button\" className=\"hb-wj2-crumb\" aria-current={i === crumbPath.length - 1 ? \"page\" : undefined} onClick={() => { setPath(current.slice(0, i + 1)); setActiveCol(i); }}>\n                {n.name}\n              </button>\n            </li>\n          ))}\n        </ol>\n      </div>\n      <div className=\"hb-wj2-main\">\n        <div ref={colsRef} className=\"hb-wj2-cols\">\n          {columns.map((items, col) => (\n            <ul key={`${col}-${current[col - 1] ?? \"root\"}`} className=\"hb-wj2-col\" role=\"listbox\" aria-label={col === 0 ? rootLabel : chain[col - 1]?.name}>\n              {items.map((node, idx) => {\n                const isSel = current[col] === node.id;\n                const tab = isSel || (current[col] === undefined && idx === 0) ? 0 : -1;\n                return (\n                  <li key={node.id} role=\"presentation\">\n                    <button\n                      type=\"button\"\n                      role=\"option\"\n                      className=\"hb-wj2-item\"\n                      aria-selected={isSel}\n                      data-active={col === activeCol || (isSel && col === chain.length - 1)}\n                      data-col={col}\n                      data-idx={idx}\n                      tabIndex={tab}\n                      onClick={() => choose(col, node)}\n                      onDoubleClick={() => onOpen?.(node)}\n                      onKeyDown={(e) => onKey(e, col, idx)}\n                    >\n                      <Icon kind={node.kind} />\n                      <span>{node.name}</span>\n                      {node.kind === \"folder\" && <i aria-hidden=\"true\" />}\n                    </button>\n                  </li>\n                );\n              })}\n            </ul>\n          ))}\n        </div>\n        {selected && (\n          <aside key={selected.id} className=\"hb-wj2-pv\" aria-label={`Preview of ${selected.name}`}>\n            <div className=\"hb-wj2-stage\">\n              <Preview node={selected} />\n            </div>\n            <p className=\"hb-wj2-name\">\n              <Icon kind={selected.kind} />\n              <span>{selected.name}</span>\n            </p>\n            <dl className=\"hb-wj2-meta\">\n              <dt>Kind</dt>\n              <dd>{kindLabel[selected.kind]}</dd>\n              <dt>{selected.kind === \"folder\" ? \"Items\" : \"Size\"}</dt>\n              <dd>{selected.kind === \"folder\" ? `${selected.children?.length ?? 0} items` : selected.size ?? \"–\"}</dd>\n              <dt>Modified</dt>\n              <dd>{selected.modified ?? \"–\"}</dd>\n              <dt>Where</dt>\n              <dd title={where}>{where}</dd>\n            </dl>\n            <div className=\"hb-wj2-acts\">\n              <button type=\"button\" className=\"hb-wj2-act\" onClick={() => {\n                const full = selected.kind === \"folder\" ? where : `${where}/${selected.name}`;\n                navigator.clipboard?.writeText(full).catch(() => undefined);\n                setCopied(true);\n              }}>\n                {copied ? \"Copied\" : \"Copy path\"}\n              </button>\n              <button type=\"button\" className=\"hb-wj2-act\" onClick={() => onShare?.(selected)}>\n                Share\n              </button>\n              <button type=\"button\" className=\"hb-wj2-act\" data-primary=\"true\" onClick={() => onOpen?.(selected)}>\n                Open\n              </button>\n            </div>\n          </aside>\n        )}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}