import React, { createContext, useContext, type ReactNode } from 'react';

import type { SuperagentEditorTab } from './types';

type OpenConversationFeature = (tab: SuperagentEditorTab) => void;

const ConversationFeatureNavigationContext = createContext<OpenConversationFeature | null>(null);

export function ConversationFeatureNavigationProvider({
  children,
  onOpenFeature,
}: {
  children: ReactNode;
  onOpenFeature: OpenConversationFeature;
}) {
  return (
    <ConversationFeatureNavigationContext.Provider value={onOpenFeature}>
      {children}
    </ConversationFeatureNavigationContext.Provider>
  );
}

export function useConversationFeatureNavigation() {
  return useContext(ConversationFeatureNavigationContext);
}
