// BB's built-in icon names, vendored from BB's shared-ui (`CORE_ICON_MAP` keys // in components/ui/icon.tsx and `EXTENDED_ICON_NAMES` in icon-registry.ts). // BB draws any other name as its Zap fallback, so names a spec writes are // resolved here first: models write lucide/heroicons names in any case. const BB_ICON_NAMES = [ // CORE_ICON_MAP "AlertCircle", "AlertTriangle", "Archive", "Bot", "Bug", "Check", "ChevronDown", "ChevronLeft", "ChevronRight", "Circle", "CircleCheck", "CircleQuestion", "CircleX", "ClosePluginPane", "CloseThreadPane", "Code", "ComputerTerminal01", "Copy", "Download", "Edit", "Filter", "FilterHorizontal", "Folder", "FolderExport", "FolderGit", "FolderPlus", "FolderSync", "FolderUnknown", "Folder02", "Home", "Info", "ListTodo", "Loading", "MessageQuestion", "MessageCirclePlus", "MessageSquarePlus", "MessageSquare", "MoreHorizontal", "PanelLeft", "Search", "SectionAdd", "SectionMove", "Settings", "SlidersHorizontal", "Spinner", "Target", "Terminal", "Toolbox", "ToolCase", "Trash2", "Unavailable", "UserRoundPlus", "Workflow", "X", "Zap", // EXTENDED_ICON_NAMES "AiBrain01", "AiBrowser", "AiContentGenerator01", "AlignLeft", "AppWindow", "ArchiveRestore", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowReloadHorizontal", "ArrowUp", "ArrowUpDown", "ArrowTurnBackward", "ArrowTurnForward", "ArrowUpRight", "Beaker", "BellDot", "Browser", "Brain", "Calendar", "CalendarCheckOut02", "ChartColumn", "ChevronUp", "ChevronsDown", "ChevronsUp", "CircleArrowShrink", "Clean", "Clock", "ClockArrowUp", "ClockArrowDown", "Cloud", "CloudOff", "ComputerCloud", "Coffee", "Columns2", "CornerDownLeft", "CornerDownRight", "DiffAdded", "DiffConflict", "DiffModified", "DiffRemoved", "DiffRenamed", "Discord", "DiscordLogo", "DateTime", "Github", "GithubLogo", "DragDropHorizontal", "DragDropVertical", "EditFile", "ElectricPlugs", "Eye", "EyeOff", "Explore", "ExternalLink", "FileDiff", "File", "FileAttachment", "FileQuestion", "FileText", "FolderOpen", "FolderEdit", "FolderMinus", "Fork", "GitBranch", "GitMerge", "GitPullRequest", "GitPullRequestArrow", "GitPullRequestClosed", "GitPullRequestDraft", "Globe", "GridView", "Keyboard", "Laptop", "Layers", "Limitation", "Link", "ListEnd", "ListView", "Lock", "Mail", "MailOpen", "Maximize2", "Mic", "Minus", "Minimize2", "MoveTo", "NewTab", "News01", "PackageReceive", "Palette", "PanelBottom", "PanelRight", "Paperclip", "Pause", "Pin", "PinOff", "Play", "Plug02", "Plus", "Puzzle", "Repeat", "RotateCcw", "Rows2", "SecurityCheck", "Sent", "SideChat", "Smartphone", "Sort", "SortingAZ02", "SortingZA01", "SortingOneNine", "SortingNineOne", "Square", "SquareUnlock02", "Star", "TextWrap", "TimeSchedule", "UserRound", "ZoomIn", "ZoomOut", ] as const; export type BbIconName = (typeof BB_ICON_NAMES)[number]; /** Every BB name keyed with case and separators dropped: "git-branch", "git_branch" and "gitBranch" all key as "gitbranch". */ const BY_KEY: ReadonlyMap = new Map( BB_ICON_NAMES.map((name) => [name.toLowerCase(), name]), ); /** * Common lucide and heroicons names that BB spells differently, keyed the * same way. Real BB names win over these (`x` is BB's X). */ const ALIASES: Record = { trash: "Trash2", trashcan: "Trash2", delete: "Trash2", bin: "Trash2", close: "CircleX", cancel: "CircleX", xcircle: "CircleX", xmark: "X", xmarkcircle: "CircleX", checkmark: "Check", tick: "Check", checkcircle: "CircleCheck", checkcircle2: "CircleCheck", circlecheckbig: "CircleCheck", warning: "AlertTriangle", alert: "AlertTriangle", trianglealert: "AlertTriangle", exclamationtriangle: "AlertTriangle", circlealert: "AlertCircle", exclamationcircle: "AlertCircle", information: "Info", informationcircle: "Info", circleinfo: "Info", help: "CircleQuestion", helpcircle: "CircleQuestion", circlehelp: "CircleQuestion", question: "CircleQuestion", questionmarkcircle: "CircleQuestion", external: "ExternalLink", squarearrowoutupright: "ExternalLink", arrowtoprightonsquare: "ExternalLink", refresh: "ArrowReloadHorizontal", reload: "ArrowReloadHorizontal", refreshcw: "ArrowReloadHorizontal", refreshccw: "ArrowReloadHorizontal", rotatecw: "ArrowReloadHorizontal", arrowpath: "ArrowReloadHorizontal", undo: "ArrowTurnBackward", undo2: "ArrowTurnBackward", redo: "ArrowTurnForward", redo2: "ArrowTurnForward", pencil: "Edit", pen: "Edit", pencilline: "Edit", squarepen: "Edit", pencilsquare: "Edit", cog: "Settings", gear: "Settings", cog6tooth: "Settings", clipboard: "Copy", documentduplicate: "Copy", arrowdowntray: "Download", send: "Sent", sendhorizontal: "Sent", paperairplane: "Sent", add: "Plus", pluscircle: "Plus", circleplus: "Plus", magnifyingglass: "Search", branch: "GitBranch", merge: "GitMerge", pullrequest: "GitPullRequest", console: "Terminal", commandline: "Terminal", squareterminal: "Terminal", stop: "Square", view: "Eye", unlock: "SquareUnlock02", lockopen: "SquareUnlock02", chain: "Link", date: "Calendar", time: "Clock", email: "Mail", envelope: "Mail", document: "FileText", house: "Home", favorite: "Star", world: "Globe", restore: "ArchiveRestore", more: "MoreHorizontal", ellipsis: "MoreHorizontal", chat: "MessageSquare", message: "MessageSquare", comment: "MessageSquare", user: "UserRound", person: "UserRound", robot: "Bot", loader: "Loading", loader2: "Loading", phone: "Smartphone", mobile: "Smartphone", microphone: "Mic", grid: "GridView", list: "ListView", columns: "Columns2", rows: "Rows2", plug: "Plug02", flask: "Beaker", bell: "BellDot", chart: "ChartColumn", barchart: "ChartColumn", chartbar: "ChartColumn", maximize: "Maximize2", expand: "Maximize2", minimize: "Minimize2", collapse: "Minimize2", attachment: "Paperclip", bolt: "Zap", lightning: "Zap", }; /** * The BB icon a spec's icon name means, or null when BB has no such icon * (callers then draw nothing rather than BB's Zap fallback). Accepts any * case and separator, lucide/heroicons spellings, and a trailing "Icon". */ export function resolveIconName(name: string): string | null { const key = name.replace(/[-_\s.]+/g, "").toLowerCase(); if (key === "") return null; const found = BY_KEY.get(key) ?? (Object.hasOwn(ALIASES, key) ? ALIASES[key] : undefined); if (found !== undefined) return found; // `TrashIcon`, `trash-icon`: the component name some icon libraries export. return key.endsWith("icon") && key.length > 4 ? resolveIconName(key.slice(0, -4)) : null; }