import React from 'react';
import { useEntityPageContext } from '../../providers';
import { EntityPageActionsBar } from '../../components/EntityPage';
import { useFormPageHeader } from '../FormPage';
import { useWixPatternsRouter } from '../../providers/WixPatternsRouterProvider';
import { useIsMobile } from '../../hooks/useIsMobile';
import { Breadcrumbs } from '@wix/design-system';
export function useEntityPageHeader(child) {
    const state = useEntityPageContext();
    const router = useWixPatternsRouter();
    const actionsBar = (React.createElement(EntityPageActionsBar, { moreActions: child.props.moreActions }));
    const routerEntityData = router?.currentState?._chosenEntity?.entity;
    const { title = null, subtitle = null, breadcrumbs = null, } = routerEntityData || !state.isFetching ? child.props : {};
    const isMobile = useIsMobile();
    const header = useFormPageHeader(child, {
        headerProps: {
            dataHook: 'entity-page-header',
            actionsBar,
            showBackButton: !isMobile,
            onBackClicked: () => state.navigateToParent(),
        },
        overrides: {
            title,
            subtitle: isMobile ? undefined : subtitle,
            breadcrumbs: isMobile ? React.createElement(Breadcrumbs, { items: [] }) : breadcrumbs,
        },
    });
    return header;
}
//# sourceMappingURL=useEntityPageHeader.js.map