const topBarForwardedSlots = new Set([ 'icon', 'logo', 'page-selector-icon', 'page-selector-item-icon', 'nav', 'center', 'actions', 'account-menu-items', 'account-menu-item-icon', 'settings-appearance', ]) const sidebarForwardedSlots = new Set([ 'header', 'collapsed', 'collapsed-footer', 'footer', ]) type SlotKeyMap = Readonly> export interface PluginWorkspaceSidebarSurfaceOptions { showSidebar: boolean panels: Record forms: Record model: unknown controls: unknown showSidebarWhenEmpty: boolean sidebarContentId?: string sidebarTitle?: string sidebarSubtitle?: string sidebarBadge?: string | number hasSidebarSlot: boolean sidebarSlotCount: number } export function getPluginWorkspaceTopBarSlotNames(slots: SlotKeyMap): string[] { return Object.keys(slots).filter(name => topBarForwardedSlots.has(name) || name.startsWith('settings-tab-'), ) } export function getPluginWorkspaceSidebarSlotNames(slots: SlotKeyMap): string[] { return Object.keys(slots).filter(name => sidebarForwardedSlots.has(name) || name.startsWith('section-'), ) } export function hasPluginWorkspaceSidebarSurface( options: PluginWorkspaceSidebarSurfaceOptions, ): boolean { if (!options.showSidebar) return false return ( Object.keys(options.panels).length > 0 || Object.keys(options.forms).length > 0 || options.model !== undefined || options.controls !== undefined || options.showSidebarWhenEmpty || options.sidebarContentId !== undefined || options.sidebarTitle !== undefined || options.sidebarSubtitle !== undefined || options.sidebarBadge !== undefined || options.hasSidebarSlot || options.sidebarSlotCount > 0 ) }