import { isValidElement, Children } from 'react';
import { EntityPageHeader, } from '../../components/EntityPageHeader';
import { EntityPageContent, } from '../../components/EntityPageContent';
export function useEntityPageChild(children, scrollableRef) {
    // Mapping to raw WDS components since original Page filtering none expected components: https://github.com/wix-private/wix-design-systems/blob/master/packages/wix-style-react/src/Page/Page.js#L626
    return Children.toArray(children)
        .map((child) => {
        if (isValidElement(child)) {
            switch (child.type) {
                case EntityPageHeader:
                    const header = child;
                    return header.type.useEntityPageHeader(header);
                case EntityPageContent:
                    const content = child;
                    return content.type.useEntityPageContent(content, scrollableRef);
                default:
                    // TODO: Check whenever we should filter out or not other Page components
                    return null;
            }
        }
        return null;
    })
        .filter((c) => c);
}
//# sourceMappingURL=useEntityPageChild.js.map