{"version":3,"file":"ThreadSlot.mjs","names":[],"sources":["../../../../src/plugins/SlotLayout/ThreadSlot.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport { useChatViewContext } from './ChatView';\nimport { useSlotThread } from './hooks';\nimport { Thread, type ThreadProps } from '../../components/Thread';\nimport { WorkspacePanelProvider } from '../../context/WorkspaceNavigationContext';\n\nimport type { PropsWithChildren, ReactNode } from 'react';\nimport type { SlotName } from './layoutController/layoutControllerTypes';\n\nexport type ThreadSlotProps = PropsWithChildren<\n  Omit<ThreadProps, 'thread'> & {\n    fallback?: ReactNode;\n    hideIfEmpty?: boolean;\n    slot?: SlotName;\n  }\n>;\n\nexport const ThreadSlot = ({\n  children,\n  fallback = null,\n  hideIfEmpty = true,\n  slot,\n  ...threadProps\n}: ThreadSlotProps) => {\n  const { layoutController } = useChatViewContext();\n  const thread = useSlotThread({ slot });\n\n  useEffect(() => {\n    if (!slot || !hideIfEmpty) return;\n    if (thread) layoutController.unhide(slot);\n    else layoutController.hide(slot);\n  }, [hideIfEmpty, layoutController, slot, thread]);\n\n  if (!thread) return <>{fallback}</>;\n\n  return (\n    <WorkspacePanelProvider panel={slot}>\n      <Thread {...threadProps} thread={thread}>\n        {children}\n      </Thread>\n    </WorkspacePanelProvider>\n  );\n};\n"],"mappings":";;;;;;;AAkBA,IAAa,cAAc,EACzB,UACA,WAAW,MACX,cAAc,MACd,MACA,GAAG,kBACkB;CACrB,MAAM,EAAE,qBAAqB,mBAAmB;CAChD,MAAM,SAAS,cAAc,EAAE,KAAK,CAAC;CAErC,gBAAgB;EACd,IAAI,CAAC,QAAQ,CAAC,aAAa;EAC3B,IAAI,QAAQ,iBAAiB,OAAO,IAAI;OACnC,iBAAiB,KAAK,IAAI;CACjC,GAAG;EAAC;EAAa;EAAkB;EAAM;CAAM,CAAC;CAEhD,IAAI,CAAC,QAAQ,OAAO,oBAAA,YAAA,EAAA,UAAG,SAAW,CAAA;CAElC,OACE,oBAAC,wBAAD;EAAwB,OAAO;YAC7B,oBAAC,QAAD;GAAQ,GAAI;GAAqB;GAC9B;EACK,CAAA;CACc,CAAA;AAE5B"}