{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "icon-picker",
  "title": "Icon Picker",
  "description": "Searchable Lucide icon grid with arrow-key navigation, roving tabindex, recent icons, and tags search.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "input",
    "utils",
    "@drift-ui/use-controllable-state",
    "@drift-ui/shape"
  ],
  "files": [
    {
      "path": "registry/default/ui/icon-picker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { SearchIcon, SearchXIcon } from \"lucide-react\"\nimport { DynamicIcon, type IconName } from \"lucide-react/dynamic\"\n\nimport { useControllableState } from \"@/registry/default/hooks/use-controllable-state\"\nimport {\n  addRecent,\n  buildSections,\n  isValidIconName,\n  layoutSections,\n  moveCell,\n  normalizeColumns,\n  normalizeIcons,\n  readPreferences,\n  searchIcons,\n  STORAGE_KEY,\n  writePreferences,\n  type IconCell,\n  type IconItem,\n} from \"@/registry/default/lib/icon-picker-utils\"\nimport { cn } from \"@/registry/default/lib/utils\"\nimport { Button } from \"@/registry/default/ui/button\"\nimport { Input } from \"@/registry/default/ui/input\"\n\nconst DEFAULT_COLUMNS = 6\nconst ROW_BATCH = 12\n\nfunction subscribeToNothing() {\n  return () => {}\n}\n\nfunction IconPlaceholder({ className }: { className?: string }) {\n  return (\n    <span\n      aria-hidden\n      className={cn(\"rounded-sm bg-muted motion-safe:animate-pulse\", className)}\n    />\n  )\n}\n\nfunction IconGlyph({ name, className }: { name: string; className?: string }) {\n  if (!isValidIconName(name)) {\n    return <span aria-hidden className={cn(\"shrink-0\", className)} />\n  }\n  return (\n    <DynamicIcon\n      name={name as IconName}\n      aria-hidden\n      className={cn(\"shrink-0\", className)}\n      fallback={() => <IconPlaceholder className={className} />}\n    />\n  )\n}\n\nconst IconRow = React.memo(function IconRow({\n  icons,\n  row,\n  tabColumn,\n  selectedValue,\n  columns,\n}: {\n  icons: IconItem[]\n  row: number\n  tabColumn: number | null\n  selectedValue?: string\n  columns: number\n}) {\n  return (\n    <div\n      role=\"row\"\n      aria-rowindex={row + 1}\n      className=\"grid gap-0.5 pb-0.5 [contain-intrinsic-size:auto_2.5rem] [content-visibility:auto]\"\n      style={{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }}\n    >\n      {icons.map((item, column) => {\n        const isSelected = selectedValue === item.name\n        return (\n          <div\n            key={`${item.name}-${column}`}\n            role=\"gridcell\"\n            aria-selected={isSelected}\n          >\n            <button\n              type=\"button\"\n              data-row={row}\n              data-column={column}\n              data-selected={isSelected || undefined}\n              tabIndex={column === tabColumn ? 0 : -1}\n              aria-label={item.name}\n              aria-pressed={isSelected}\n              title={item.name}\n              className={cn(\n                \"flex aspect-square w-full items-center justify-center rounded-md text-muted-foreground outline-none\",\n                \"transition-[color,background-color,scale] duration-150 ease-out motion-safe:active:scale-90\",\n                \"hover:bg-accent hover:text-accent-foreground\",\n                \"focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50\",\n                \"data-selected:bg-primary data-selected:text-primary-foreground data-selected:hover:bg-primary/90 data-selected:focus-visible:bg-primary data-selected:focus-visible:text-primary-foreground\"\n              )}\n            >\n              <IconGlyph name={item.name} className=\"size-5\" />\n            </button>\n          </div>\n        )\n      })}\n    </div>\n  )\n})\n\nexport interface IconPickerProps extends Omit<\n  React.ComponentProps<\"div\">,\n  \"onSelect\" | \"defaultValue\"\n> {\n  value?: string\n  defaultValue?: string\n  onValueChange?: (value: string) => void\n  onSelect?: (value: string) => void\n  icons?: (string | IconItem)[]\n  tags?: Record<string, string[]>\n  columns?: number\n  maxRecent?: number\n  storageKey?: string\n}\n\nfunction IconPicker({\n  value: controlledValue,\n  defaultValue = \"\",\n  onValueChange,\n  onSelect,\n  icons: userIcons,\n  tags,\n  columns: requestedColumns = DEFAULT_COLUMNS,\n  maxRecent,\n  storageKey = STORAGE_KEY,\n  className,\n  \"aria-label\": ariaLabel = \"Icon picker\",\n  ...props\n}: IconPickerProps) {\n  const id = React.useId()\n  const gridRef = React.useRef<HTMLDivElement>(null)\n  const searchRef = React.useRef<HTMLInputElement>(null)\n  const pendingFocusRef = React.useRef<IconCell | null>(null)\n  const columns = normalizeColumns(requestedColumns, DEFAULT_COLUMNS)\n\n  const [query, setQuery] = React.useState(\"\")\n  const [rowLimit, setRowLimit] = React.useState(ROW_BATCH)\n  const [activeCell, setActiveCell] = React.useState<IconCell>({\n    row: 0,\n    column: 0,\n  })\n  const [previewName, setPreviewName] = React.useState<string | null>(null)\n  const isHydrated = React.useSyncExternalStore(\n    subscribeToNothing,\n    () => true,\n    () => false\n  )\n  const recentIcons = React.useMemo(\n    () => (isHydrated ? readPreferences(storageKey).recent : []),\n    [isHydrated, storageKey]\n  )\n\n  const { value, setValue } = useControllableState({\n    value: controlledValue,\n    defaultValue,\n    onChange: onValueChange,\n  })\n\n  const allIcons = React.useMemo(() => normalizeIcons(userIcons), [userIcons])\n\n  const needle = query.trim()\n  const layout = React.useMemo(() => {\n    const sections = needle\n      ? [\n          {\n            id: \"results\",\n            label: \"Search results\",\n            icons: searchIcons(allIcons, needle, tags),\n          },\n        ]\n      : buildSections(allIcons, recentIcons)\n\n    return layoutSections(sections, columns)\n  }, [allIcons, needle, tags, recentIcons, columns])\n\n  const resultCount = needle ? (layout.sections[0]?.icons.length ?? 0) : null\n  const visibleRowCount = Math.min(rowLimit, layout.rows.length)\n  const tabCell = layout.rows[activeCell.row]?.[activeCell.column]\n    ? activeCell\n    : { row: 0, column: 0 }\n\n  const footerName = previewName ?? (value || null)\n\n  React.useEffect(() => {\n    const cell = pendingFocusRef.current\n    if (!cell) return\n    pendingFocusRef.current = null\n    gridRef.current\n      ?.querySelector<HTMLElement>(\n        `[data-row=\"${cell.row}\"][data-column=\"${cell.column}\"]`\n      )\n      ?.focus()\n  }, [rowLimit])\n\n  React.useEffect(() => {\n    if (visibleRowCount >= layout.rows.length) return\n    const el = gridRef.current\n    if (el && el.clientHeight > 0 && el.scrollHeight <= el.clientHeight) {\n      setRowLimit((current) =>\n        Math.min(layout.rows.length, current + ROW_BATCH)\n      )\n    }\n  }, [visibleRowCount, layout.rows.length])\n\n  function focusCell(cell: IconCell) {\n    setActiveCell(cell)\n    if (cell.row >= rowLimit) {\n      pendingFocusRef.current = cell\n      setRowLimit(cell.row + ROW_BATCH)\n      return\n    }\n    gridRef.current\n      ?.querySelector<HTMLElement>(\n        `[data-row=\"${cell.row}\"][data-column=\"${cell.column}\"]`\n      )\n      ?.focus()\n  }\n\n  function pick(name: string) {\n    const preferences = readPreferences(storageKey)\n    writePreferences(\n      {\n        ...preferences,\n        recent: addRecent(preferences.recent, name, maxRecent),\n      },\n      storageKey\n    )\n    setValue(name)\n    onSelect?.(name)\n  }\n\n  function updateQuery(next: string) {\n    setQuery(next)\n    setActiveCell({ row: 0, column: 0 })\n    setRowLimit(ROW_BATCH)\n    setPreviewName(null)\n    if (gridRef.current) gridRef.current.scrollTop = 0\n  }\n\n  function cellOf(target: EventTarget) {\n    const button = (target as HTMLElement).closest<HTMLElement>(\"[data-row]\")\n    return button\n      ? {\n          row: Number(button.dataset.row),\n          column: Number(button.dataset.column),\n        }\n      : null\n  }\n\n  function itemAt(cell: IconCell | null) {\n    return cell ? layout.rows[cell.row]?.[cell.column] : undefined\n  }\n\n  function resetPointerPreview() {\n    const focused =\n      document.activeElement &&\n      gridRef.current?.contains(document.activeElement)\n        ? cellOf(document.activeElement)\n        : null\n    setPreviewName(itemAt(focused)?.name ?? null)\n  }\n\n  function handleGridKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n    const cell = cellOf(event.target)\n    if (!cell) return\n\n    if (event.key === \"Enter\" || event.key === \" \") {\n      event.preventDefault()\n      const item = itemAt(cell)\n      if (item) pick(item.name)\n      return\n    }\n\n    const next = moveCell(\n      layout.rows.map((row) => row.length),\n      layout.sections.map((section) => section.firstRow),\n      cell,\n      event.key,\n      event.ctrlKey || event.metaKey\n    )\n    if (!next) return\n    event.preventDefault()\n\n    if (event.key === \"ArrowUp\" && cell.row === 0) {\n      searchRef.current?.focus()\n    } else {\n      focusCell(next)\n    }\n  }\n\n  function handleSearchKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n    if (event.key === \"ArrowDown\") {\n      event.preventDefault()\n      focusCell(tabCell)\n    }\n    if (event.key === \"Enter\" && needle && layout.rows[0]?.[0]) {\n      event.preventDefault()\n      pick(layout.rows[0][0].name)\n    }\n  }\n\n  return (\n    <div\n      role=\"group\"\n      aria-label={ariaLabel}\n      data-slot=\"icon-picker\"\n      className={cn(\n        \"flex h-96 w-80 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground\",\n        className\n      )}\n      {...props}\n    >\n      <div className=\"relative m-2 mb-1\">\n        <SearchIcon\n          aria-hidden\n          className=\"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground\"\n        />\n        <Input\n          ref={searchRef}\n          type=\"search\"\n          aria-label=\"Search icons\"\n          placeholder=\"Search icons\"\n          value={query}\n          onChange={(event) => updateQuery(event.target.value)}\n          onKeyDown={handleSearchKeyDown}\n          className=\"h-control-sm py-0 pl-8\"\n        />\n      </div>\n      {layout.rows.length === 0 ? (\n        <div className=\"flex min-h-0 flex-1 flex-col items-center justify-center gap-1 px-6 text-center\">\n          <SearchXIcon\n            aria-hidden\n            className=\"mb-2 size-6 text-muted-foreground\"\n          />\n          <p className=\"text-sm font-medium\">No icons found</p>\n          <p className=\"max-w-full truncate text-xs text-muted-foreground\">\n            Nothing matches &ldquo;{needle}&rdquo;\n          </p>\n          <Button\n            type=\"button\"\n            variant=\"ghost\"\n            size=\"sm\"\n            className=\"mt-2\"\n            onClick={() => {\n              updateQuery(\"\")\n              searchRef.current?.focus()\n            }}\n          >\n            Clear search\n          </Button>\n        </div>\n      ) : (\n        <div\n          ref={gridRef}\n          role=\"grid\"\n          aria-label=\"Icons\"\n          aria-rowcount={layout.rows.length}\n          aria-colcount={columns}\n          onKeyDown={handleGridKeyDown}\n          onFocus={(event) => {\n            const cell = cellOf(event.target)\n            if (!cell) return\n            setActiveCell(cell)\n            setPreviewName(itemAt(cell)?.name ?? null)\n          }}\n          onBlur={(event) => {\n            if (!event.currentTarget.contains(event.relatedTarget)) {\n              setPreviewName(null)\n            }\n          }}\n          onPointerOver={(event) => {\n            const cell = cellOf(event.target)\n            if (cell) {\n              setPreviewName(itemAt(cell)?.name ?? null)\n            } else {\n              resetPointerPreview()\n            }\n          }}\n          onPointerLeave={resetPointerPreview}\n          onClick={(event) => {\n            const item = itemAt(cellOf(event.target))\n            if (item) pick(item.name)\n          }}\n          onScroll={(event) => {\n            if (rowLimit >= layout.rows.length) return\n            const el = event.currentTarget\n            if (el.scrollTop + el.clientHeight >= el.scrollHeight - 200) {\n              setRowLimit((current) =>\n                Math.min(layout.rows.length, current + ROW_BATCH)\n              )\n            }\n          }}\n          className=\"relative min-h-0 flex-1 scroll-pt-7 overflow-y-auto px-2\"\n        >\n          {layout.sections\n            .filter((section) => section.firstRow < visibleRowCount)\n            .map((section) => (\n              <div\n                key={section.id}\n                id={`${id}-${section.id}`}\n                role=\"rowgroup\"\n                aria-labelledby={`${id}-${section.id}-label`}\n              >\n                <div\n                  role=\"presentation\"\n                  className=\"sticky top-0 z-10 flex items-baseline justify-between bg-popover pt-2 pb-1.5 text-xs text-muted-foreground\"\n                >\n                  <span\n                    id={`${id}-${section.id}-label`}\n                    className=\"font-medium\"\n                  >\n                    {section.label}\n                  </span>\n                  <span aria-hidden className=\"tabular-nums\">\n                    {section.icons.length}\n                  </span>\n                </div>\n                {layout.rows\n                  .slice(\n                    section.firstRow,\n                    Math.min(\n                      section.firstRow + section.rowCount,\n                      visibleRowCount\n                    )\n                  )\n                  .map((rowIcons, offset) => {\n                    const row = section.firstRow + offset\n                    return (\n                      <IconRow\n                        key={row}\n                        icons={rowIcons}\n                        row={row}\n                        tabColumn={row === tabCell.row ? tabCell.column : null}\n                        selectedValue={value}\n                        columns={columns}\n                      />\n                    )\n                  })}\n              </div>\n            ))}\n        </div>\n      )}\n      <div\n        data-slot=\"icon-picker-footer\"\n        className=\"flex h-11 shrink-0 items-center gap-2.5 border-t bg-muted/40 px-3 text-xs\"\n      >\n        {footerName ? (\n          <>\n            <span className=\"flex size-7 shrink-0 items-center justify-center rounded-md border bg-background text-foreground\">\n              <IconGlyph name={footerName} className=\"size-4\" />\n            </span>\n            <span className=\"min-w-0 flex-1 truncate font-mono text-foreground\">\n              {footerName}\n            </span>\n            {footerName === value && (\n              <span className=\"shrink-0 text-muted-foreground\">Selected</span>\n            )}\n          </>\n        ) : (\n          <span className=\"text-muted-foreground\">No icon selected</span>\n        )}\n      </div>\n      <span role=\"status\" className=\"sr-only\">\n        {resultCount === null\n          ? \"\"\n          : `${resultCount} ${resultCount === 1 ? \"result\" : \"results\"}`}\n      </span>\n    </div>\n  )\n}\n\nexport { IconPicker }\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/default/lib/icon-picker-utils.ts",
      "content": "import { iconNames, type IconName } from \"lucide-react/dynamic\"\n\nexport type IconItem = {\n  name: string\n  tags?: string[]\n}\n\nexport type IconSection = {\n  id: string\n  label: string\n  icons: IconItem[]\n}\n\nexport type IconCell = {\n  row: number\n  column: number\n}\n\nexport type IconPreferences = {\n  recent: string[]\n}\n\nexport const RECENT_SECTION_ID = \"recent\"\nexport const ALL_SECTION_ID = \"all\"\nexport const MAX_RECENT = 16\nexport const STORAGE_KEY = \"drift-ui:icon-picker\"\n\nconst VALID_NAMES = new Set<string>(iconNames)\n\nexport function isValidIconName(name: string): name is IconName {\n  return VALID_NAMES.has(name)\n}\n\nexport const LUCIDE_TAGS: Record<string, string[]> = {\n  activity: [\"heartbeat\", \"pulse\", \"health\", \"monitor\", \"status\", \"fitness\"],\n  \"alert-circle\": [\"warning\", \"danger\", \"error\", \"info\", \"notice\"],\n  \"alert-triangle\": [\"warning\", \"danger\", \"caution\", \"alert\", \"error\"],\n  archive: [\"box\", \"storage\", \"save\", \"package\"],\n  award: [\"trophy\", \"medal\", \"prize\", \"badge\", \"achievement\"],\n  \"bar-chart\": [\"graph\", \"analytics\", \"statistics\", \"metrics\", \"chart\"],\n  \"bar-chart-2\": [\"graph\", \"analytics\", \"statistics\", \"metrics\"],\n  \"bar-chart-3\": [\"graph\", \"analytics\", \"statistics\", \"metrics\"],\n  battery: [\"power\", \"charge\", \"energy\"],\n  \"battery-charging\": [\"power\", \"charge\", \"plug\", \"energy\"],\n  bell: [\"notification\", \"alert\", \"reminder\", \"alarm\"],\n  \"bell-off\": [\"silent\", \"mute\", \"quiet\", \"disable notifications\"],\n  bluetooth: [\"wireless\", \"connectivity\", \"device\"],\n  bookmark: [\"save\", \"favorite\", \"marker\", \"read later\"],\n  bot: [\"robot\", \"ai\", \"assistant\", \"agent\", \"automation\"],\n  box: [\"package\", \"cube\", \"container\", \"storage\"],\n  briefcase: [\"work\", \"job\", \"business\", \"portfolio\"],\n  bug: [\"issue\", \"error\", \"defect\", \"problem\", \"inspect\", \"debug\"],\n  calendar: [\"date\", \"schedule\", \"event\", \"month\", \"time\", \"planner\"],\n  \"calendar-check\": [\"scheduled\", \"todo\", \"appointment\", \"done\"],\n  \"calendar-days\": [\"week\", \"month\", \"schedule\"],\n  camera: [\"photo\", \"picture\", \"snapshot\", \"image\", \"lens\"],\n  check: [\"tick\", \"done\", \"confirm\", \"ok\", \"verify\", \"success\", \"accept\"],\n  \"check-check\": [\"read\", \"delivered\", \"double check\"],\n  \"check-circle\": [\"done\", \"completed\", \"resolved\", \"success\"],\n  \"check-square\": [\"todo\", \"task\", \"done\", \"checkbox\"],\n  clock: [\"time\", \"watch\", \"timer\", \"schedule\", \"hour\", \"minute\"],\n  cloud: [\"storage\", \"weather\", \"upload\", \"sync\", \"backup\"],\n  \"cloud-rain\": [\"weather\", \"shower\", \"storm\", \"rainy\"],\n  code: [\"developer\", \"syntax\", \"source\", \"programming\", \"html\", \"tag\"],\n  \"code-2\": [\"developer\", \"syntax\", \"brackets\", \"programming\"],\n  compass: [\"navigation\", \"direction\", \"explore\", \"safari\"],\n  copy: [\"duplicate\", \"clone\", \"clipboard\"],\n  cpu: [\"processor\", \"chip\", \"hardware\", \"computer\", \"ai\"],\n  \"credit-card\": [\"payment\", \"money\", \"billing\", \"card\", \"purchase\"],\n  database: [\"sql\", \"storage\", \"server\", \"data\", \"records\"],\n  delete: [\"backspace\", \"remove\", \"erase\"],\n  \"dollar-sign\": [\"money\", \"currency\", \"price\", \"cash\", \"finance\", \"usd\"],\n  download: [\"save\", \"export\", \"fetch\", \"get\"],\n  edit: [\"pencil\", \"pen\", \"write\", \"modify\", \"change\"],\n  \"edit-2\": [\"pencil\", \"pen\", \"write\"],\n  \"edit-3\": [\"pencil\", \"pen\", \"write\"],\n  \"external-link\": [\"open\", \"new tab\", \"new window\", \"hyperlink\", \"url\"],\n  eye: [\"view\", \"show\", \"visible\", \"see\", \"watch\"],\n  \"eye-off\": [\"hide\", \"hidden\", \"invisible\", \"conceal\", \"private\"],\n  file: [\"document\", \"sheet\", \"page\", \"paper\"],\n  \"file-text\": [\"document\", \"sheet\", \"notes\", \"article\"],\n  filter: [\"sort\", \"refine\", \"funnel\", \"query\"],\n  flag: [\"report\", \"country\", \"marker\", \"milestone\", \"priority\"],\n  folder: [\"directory\", \"group\", \"category\", \"collection\"],\n  \"folder-open\": [\"directory\", \"browse\", \"collection\"],\n  frown: [\"sad\", \"face\", \"negative\", \"unhappy\"],\n  gauge: [\"meter\", \"speed\", \"dashboard\", \"metric\", \"performance\"],\n  gift: [\"present\", \"reward\", \"surprise\", \"bonus\"],\n  \"git-branch\": [\"vcs\", \"code\", \"fork\", \"version\"],\n  \"git-commit\": [\"vcs\", \"code\", \"log\", \"history\"],\n  \"git-pull-request\": [\"pr\", \"merge\", \"vcs\", \"code\"],\n  globe: [\"world\", \"earth\", \"web\", \"international\", \"planet\", \"internet\"],\n  grid: [\"table\", \"cards\", \"layout\", \"matrix\"],\n  \"hard-drive\": [\"storage\", \"disk\", \"memory\", \"drive\"],\n  heart: [\"like\", \"love\", \"favorite\", \"health\"],\n  \"help-circle\": [\"question\", \"faq\", \"support\", \"help\", \"info\"],\n  history: [\"recent\", \"time\", \"clock\", \"past\", \"log\", \"audit\"],\n  home: [\"house\", \"main\", \"dashboard\", \"index\"],\n  image: [\"picture\", \"photo\", \"graphic\", \"gallery\"],\n  inbox: [\"tray\", \"mail\", \"messages\", \"received\"],\n  info: [\"information\", \"help\", \"about\", \"details\", \"notice\"],\n  key: [\"password\", \"auth\", \"access\", \"token\", \"unlock\"],\n  laptop: [\"macbook\", \"computer\", \"notebook\"],\n  layers: [\"stack\", \"pile\", \"sheets\", \"levels\"],\n  layout: [\"grid\", \"template\", \"dashboard\", \"wireframe\"],\n  \"life-buoy\": [\"help\", \"support\", \"rescue\", \"faq\"],\n  link: [\"url\", \"chain\", \"hyperlink\", \"anchor\"],\n  list: [\"tasks\", \"bullet\", \"todo\", \"menu\", \"checklist\"],\n  lock: [\"security\", \"password\", \"private\", \"protect\", \"closed\"],\n  \"log-in\": [\"signin\", \"enter\", \"access\"],\n  \"log-out\": [\"signout\", \"exit\", \"leave\"],\n  mail: [\"email\", \"envelope\", \"message\", \"inbox\"],\n  map: [\"navigation\", \"travel\", \"gps\", \"directions\", \"location\"],\n  \"map-pin\": [\"location\", \"place\", \"spot\", \"marker\", \"address\", \"gps\"],\n  maximize: [\"fullscreen\", \"expand\", \"scale\"],\n  meh: [\"neutral\", \"face\", \"indifferent\"],\n  \"message-circle\": [\"chat\", \"comment\", \"conversation\"],\n  \"message-square\": [\"chat\", \"comment\", \"bubble\", \"talk\", \"feedback\"],\n  mic: [\"microphone\", \"audio\", \"record\", \"voice\", \"podcast\"],\n  minimize: [\"shrink\", \"collapse\", \"exit fullscreen\"],\n  minus: [\"remove\", \"subtract\", \"decrease\", \"hyphen\"],\n  monitor: [\"screen\", \"display\", \"desktop\", \"computer\"],\n  moon: [\"dark\", \"night\", \"lunar\", \"evening\", \"weather\"],\n  music: [\"audio\", \"sound\", \"tune\", \"song\", \"note\"],\n  paperclip: [\"attachment\", \"attach\", \"file\"],\n  pen: [\"edit\", \"write\", \"sign\"],\n  pencil: [\"edit\", \"write\", \"draw\", \"compose\"],\n  phone: [\"call\", \"telephone\", \"contact\", \"support\"],\n  \"pie-chart\": [\"diagram\", \"analytics\", \"breakdown\"],\n  plus: [\"add\", \"create\", \"new\", \"more\"],\n  power: [\"on\", \"off\", \"shutdown\", \"turn off\", \"switch\"],\n  printer: [\"print\", \"paper\", \"document\"],\n  redo: [\"forward\", \"repeat\", \"next\"],\n  \"refresh-cw\": [\"reload\", \"sync\", \"repeat\", \"rotate\", \"cycle\"],\n  repeat: [\"loop\", \"sync\", \"again\"],\n  scissors: [\"cut\", \"snip\", \"trim\"],\n  search: [\"find\", \"magnifying glass\", \"zoom\", \"query\", \"explore\"],\n  send: [\"paper plane\", \"message\", \"mail\", \"fly\", \"submit\"],\n  server: [\"network\", \"hardware\", \"host\", \"cloud\", \"data\"],\n  settings: [\"gear\", \"cog\", \"preferences\", \"options\", \"config\"],\n  share: [\"forward\", \"export\", \"social\"],\n  \"share-2\": [\"forward\", \"export\", \"social\"],\n  shield: [\"security\", \"safety\", \"protect\", \"defense\", \"secure\"],\n  \"shield-alert\": [\"warning\", \"danger\", \"vulnerability\"],\n  \"shield-check\": [\"verified\", \"safe\", \"secure\"],\n  \"shopping-bag\": [\"bag\", \"store\", \"buy\", \"shop\", \"ecommerce\"],\n  \"shopping-cart\": [\"cart\", \"basket\", \"store\", \"buy\", \"ecommerce\", \"purchase\"],\n  shuffle: [\"random\", \"sort\", \"mix\"],\n  sliders: [\"controls\", \"settings\", \"filter\", \"adjust\"],\n  smartphone: [\"mobile\", \"phone\", \"iphone\", \"android\", \"device\"],\n  smile: [\"happy\", \"emoji\", \"face\", \"positive\"],\n  sparkles: [\"magic\", \"ai\", \"stars\", \"clean\", \"fresh\", \"shine\"],\n  star: [\"favorite\", \"bookmark\", \"rating\", \"like\"],\n  sun: [\"light\", \"day\", \"bright\", \"sunny\", \"weather\"],\n  tag: [\"label\", \"badge\", \"category\", \"price\", \"ticket\"],\n  tags: [\"labels\", \"badges\", \"categories\"],\n  terminal: [\"console\", \"code\", \"cli\", \"command\", \"shell\", \"bash\"],\n  \"thumbs-down\": [\"dislike\", \"reject\", \"vote\", \"no\", \"disagree\"],\n  \"thumbs-up\": [\"like\", \"approve\", \"vote\", \"yes\", \"agree\"],\n  trash: [\"delete\", \"remove\", \"bin\", \"garbage\", \"rubbish\"],\n  \"trash-2\": [\"delete\", \"remove\", \"bin\", \"garbage\"],\n  \"trending-down\": [\"decrease\", \"decline\", \"metrics\", \"graph\", \"stats\"],\n  \"trending-up\": [\n    \"growth\",\n    \"increase\",\n    \"metrics\",\n    \"graph\",\n    \"stats\",\n    \"analytics\",\n  ],\n  trophy: [\"winner\", \"cup\", \"award\", \"prize\", \"achievement\"],\n  undo: [\"revert\", \"back\", \"previous\"],\n  unlock: [\"open\", \"public\", \"unprotect\", \"access\"],\n  upload: [\"import\", \"send\", \"cloud\", \"publish\"],\n  user: [\"person\", \"account\", \"profile\", \"member\", \"avatar\"],\n  users: [\"group\", \"team\", \"people\", \"members\", \"collaborators\"],\n  video: [\"camera\", \"movie\", \"film\", \"record\", \"clip\"],\n  \"volume-2\": [\"sound\", \"speaker\", \"audio\", \"loud\"],\n  \"volume-x\": [\"mute\", \"silent\", \"quiet\", \"no sound\"],\n  wallet: [\"money\", \"finance\", \"cash\", \"payment\"],\n  \"wand-2\": [\"magic\", \"ai\", \"auto\", \"generate\", \"wizard\"],\n  wifi: [\"internet\", \"network\", \"wireless\", \"connection\"],\n  x: [\"close\", \"cross\", \"cancel\", \"dismiss\", \"delete\", \"clear\"],\n  zap: [\"lightning\", \"bolt\", \"electric\", \"fast\", \"power\", \"energy\"],\n}\n\nexport function normalizeIcons(icons?: (string | IconItem)[]): IconItem[] {\n  if (!icons) {\n    return iconNames.map((name) => ({ name }))\n  }\n  return icons.map((item) => (typeof item === \"string\" ? { name: item } : item))\n}\n\nexport function normalizeColumns(columns: number, fallback: number) {\n  return Number.isFinite(columns) && columns >= 1\n    ? Math.floor(columns)\n    : fallback\n}\n\nexport function searchIcons(\n  icons: IconItem[],\n  query: string,\n  customTags?: Record<string, string[]>\n): IconItem[] {\n  const needle = query.trim().toLowerCase()\n  if (!needle) return icons\n\n  return icons.filter((icon) => {\n    const name = icon.name.toLowerCase()\n    if (name.includes(needle)) return true\n\n    if (icon.tags?.some((tag) => tag.toLowerCase().includes(needle))) {\n      return true\n    }\n\n    if (\n      customTags?.[icon.name]?.some((tag) => tag.toLowerCase().includes(needle))\n    ) {\n      return true\n    }\n\n    if (\n      LUCIDE_TAGS[icon.name]?.some((tag) => tag.toLowerCase().includes(needle))\n    ) {\n      return true\n    }\n\n    return false\n  })\n}\n\nexport function buildSections(\n  icons: IconItem[],\n  recent: string[],\n  allLabel = \"All icons\"\n): IconSection[] {\n  const recentIcons = recent.flatMap(\n    (name) => icons.find((icon) => icon.name === name) ?? []\n  )\n\n  const allSection: IconSection = {\n    id: ALL_SECTION_ID,\n    label: allLabel,\n    icons,\n  }\n\n  return recentIcons.length > 0\n    ? [\n        {\n          id: RECENT_SECTION_ID,\n          label: \"Recently used\",\n          icons: recentIcons,\n        },\n        allSection,\n      ]\n    : [allSection]\n}\n\nexport function layoutSections(\n  sections: IconSection[],\n  requestedColumns: number\n) {\n  const columns = normalizeColumns(requestedColumns, 1)\n  const rows: IconItem[][] = []\n  const laidOut = sections\n    .filter((section) => section.icons.length > 0)\n    .map((section) => {\n      const firstRow = rows.length\n      for (let index = 0; index < section.icons.length; index += columns) {\n        rows.push(section.icons.slice(index, index + columns))\n      }\n      return { ...section, firstRow, rowCount: rows.length - firstRow }\n    })\n\n  return { rows, sections: laidOut }\n}\n\nexport function moveCell(\n  rowLengths: number[],\n  sectionStarts: number[],\n  { row, column }: IconCell,\n  key: string,\n  toGridEdge: boolean\n): IconCell | null {\n  const lastRow = rowLengths.length - 1\n  const lastColumn = (target: number) => rowLengths[target] - 1\n  const sameColumnIn = (target: number) => ({\n    row: target,\n    column: Math.min(column, lastColumn(target)),\n  })\n\n  switch (key) {\n    case \"ArrowRight\":\n      if (column < lastColumn(row)) return { row, column: column + 1 }\n      return row < lastRow ? { row: row + 1, column: 0 } : { row, column }\n    case \"ArrowLeft\":\n      if (column > 0) return { row, column: column - 1 }\n      return row > 0\n        ? { row: row - 1, column: lastColumn(row - 1) }\n        : { row, column }\n    case \"ArrowDown\":\n      return sameColumnIn(Math.min(row + 1, lastRow))\n    case \"ArrowUp\":\n      return sameColumnIn(Math.max(row - 1, 0))\n    case \"Home\":\n      return toGridEdge ? { row: 0, column: 0 } : { row, column: 0 }\n    case \"End\":\n      return toGridEdge\n        ? { row: lastRow, column: lastColumn(lastRow) }\n        : { row, column: lastColumn(row) }\n    case \"PageDown\": {\n      const next = sectionStarts.find((start) => start > row)\n      return next === undefined\n        ? { row: lastRow, column: lastColumn(lastRow) }\n        : { row: next, column: 0 }\n    }\n    case \"PageUp\":\n      return {\n        row: sectionStarts.findLast((start) => start < row) ?? 0,\n        column: 0,\n      }\n    default:\n      return null\n  }\n}\n\nexport function addRecent(\n  recent: string[],\n  name: string,\n  maxRecent = MAX_RECENT\n): string[] {\n  return [name, ...recent.filter((item) => item !== name)].slice(0, maxRecent)\n}\n\nexport function readPreferences(storageKey = STORAGE_KEY): IconPreferences {\n  try {\n    const stored = JSON.parse(localStorage.getItem(storageKey) ?? \"{}\")\n    return {\n      recent: Array.isArray(stored.recent)\n        ? stored.recent.filter((item: unknown) => typeof item === \"string\")\n        : [],\n    }\n  } catch {\n    return { recent: [] }\n  }\n}\n\nexport function writePreferences(\n  preferences: IconPreferences,\n  storageKey = STORAGE_KEY\n) {\n  try {\n    localStorage.setItem(storageKey, JSON.stringify(preferences))\n  } catch {\n    return\n  }\n}\n",
      "type": "registry:lib"
    }
  ],
  "type": "registry:ui"
}