{"version":3,"file":"slotBinding.mjs","names":[],"sources":["../../../../src/plugins/SlotLayout/slotBinding.ts"],"sourcesContent":["// Entity-binding primitives shared by ChatView, `<Slot>` and the slot renderer registry. It has no\n// value imports from ChatView.tsx, so `Slot` and `slotRegistry` can use it without an import cycle.\n\nimport type { Channel as StreamChannel, Thread } from 'stream-chat';\nimport type { ReactNode } from 'react';\nimport type { ChatView } from './ChatView';\nimport type {\n  LayoutSlotBinding,\n  SlotName,\n} from './layoutController/layoutControllerTypes';\n\nexport type UserListEntitySource = {\n  query: string;\n};\n\n// List kinds carry no source: the layout that seeds them picks `channelList` or `threadList`.\nexport type ChannelListEntitySource = Record<string, never>;\nexport type ThreadListEntitySource = Record<string, never>;\n\nexport type SearchResultsEntitySource = {\n  query: string;\n};\n\nexport type UserProfileEntitySource = {\n  userId: string;\n};\n\nexport type ChatViewEntityBinding =\n  | { key?: string; kind: 'channelList'; source: ChannelListEntitySource }\n  | { key?: string; kind: 'threadList'; source: ThreadListEntitySource }\n  | { key?: string; kind: 'channel'; source: StreamChannel }\n  | { key?: string; kind: 'thread'; source: Thread }\n  | { key?: string; kind: 'memberList'; source: StreamChannel }\n  | { key?: string; kind: 'userList'; source: UserListEntitySource }\n  | { key?: string; kind: 'searchResults'; source: SearchResultsEntitySource }\n  | { key?: string; kind: 'pinnedMessagesList'; source: StreamChannel }\n  | { key?: string; kind: 'userProfile'; source: UserProfileEntitySource };\n\nexport type ChatViewEntityKind = ChatViewEntityBinding['kind'];\n\nexport type LayoutEntityByKind<TKind extends ChatViewEntityKind> = Extract<\n  ChatViewEntityBinding,\n  { kind: TKind }\n>;\n\nexport type ChatViewSlotRendererProps<TKind extends ChatViewEntityKind> = {\n  entity: LayoutEntityByKind<TKind>;\n  slot: string;\n  source: LayoutEntityByKind<TKind>['source'];\n};\n\nexport type ChatViewSlotFallbackProps = {\n  slot: string;\n};\n\n/**\n * Per-kind render overrides: `slotRenderers[kind]` replaces only that kind's `Component` and keeps\n * its built-in `persistent` and `view` policy.\n */\nexport type ChatViewSlotRenderers = Partial<{\n  [TKind in ChatViewEntityKind]: (props: ChatViewSlotRendererProps<TKind>) => ReactNode;\n}>;\n\nconst isChatViewEntityBinding = (value: unknown): value is ChatViewEntityBinding => {\n  if (!value || typeof value !== 'object') return false;\n  const candidate = value as Partial<ChatViewEntityBinding>;\n  return typeof candidate.kind === 'string' && 'source' in candidate;\n};\n\nexport const getChatViewEntityBinding = (\n  binding?: LayoutSlotBinding,\n): ChatViewEntityBinding | undefined =>\n  isChatViewEntityBinding(binding?.payload) ? binding.payload : undefined;\n\nexport const createChatViewSlotBinding = (\n  entity: ChatViewEntityBinding,\n): LayoutSlotBinding => ({\n  key: entity.key ? `${entity.kind}:${entity.key}` : undefined,\n  payload: entity,\n});\n\n/**\n * Declarative layout of a view: its slot names plus optional bindings seeded into them. Each layout\n * keeps its own slot state across view switches.\n */\nexport type LayoutDescriptor = {\n  id: ChatView;\n  slots: SlotName[];\n  initialBindings?: Partial<Record<SlotName, ChatViewEntityBinding>>;\n};\n"],"mappings":";AA+DA,IAAM,2BAA2B,UAAmD;CAClF,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,YAAY;CAClB,OAAO,OAAO,UAAU,SAAS,YAAY,YAAY;AAC3D;AAEA,IAAa,4BACX,YAEA,wBAAwB,SAAS,OAAO,IAAI,QAAQ,UAAU,KAAA;AAEhE,IAAa,6BACX,YACuB;CACvB,KAAK,OAAO,MAAM,GAAG,OAAO,KAAK,GAAG,OAAO,QAAQ,KAAA;CACnD,SAAS;AACX"}