import { useMemo } from 'react';
import { HeaderAction } from "./types.js";
export function useHeader(props) {
    const { icon, title, preview, baseActions = [], handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState = 'opened', additionalActions = [], titlePosition = 'left', withIcon = true, showTitle = true, className, historyButtonRef, qa, actionQa, actionTooltipTexts, } = props;
    // Build base actions
    const baseActionsList = useMemo(() => {
        const actions = [];
        baseActions.forEach((action) => {
            if (action === HeaderAction.Folding) {
                if (handleFolding) {
                    actions.push({
                        id: action,
                        type: 'base',
                        onClick: () => {
                            const newState = foldingState === 'opened' ? 'collapsed' : 'opened';
                            handleFolding(newState);
                        },
                        foldingState,
                    });
                }
                return;
            }
            const actionMap = {
                [HeaderAction.NewChat]: handleNewChat,
                [HeaderAction.History]: handleHistoryToggle,
                [HeaderAction.Close]: handleClose,
            };
            const handler = actionMap[action];
            if (handler) {
                actions.push({
                    id: action,
                    type: 'base',
                    onClick: handler,
                });
            }
        });
        return actions;
    }, [baseActions, handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState]);
    return {
        title,
        preview,
        icon,
        baseActions: baseActionsList,
        additionalActions,
        titlePosition,
        withIcon,
        showTitle,
        className,
        historyButtonRef,
        qa,
        actionQa,
        actionTooltipTexts,
    };
}
//# sourceMappingURL=useHeader.js.map
