export default class NavigationUtil {
    static setNavigationRef(ref) {
        this.heapNavRef = ref;
    }
    static getScreenPropsForCurrentRoute() {
        if (!(this.heapNavRef && this.heapNavRef.state && this.heapNavRef.state.nav)) {
            return null;
        }
        const routeProps = this.getActiveRouteProps(this.heapNavRef.state.nav);
        if (routeProps) {
            return routeProps;
        }
        return null;
    }
    // :TODO: (jmtaber129): Add type for navigationState.
    static getActiveRouteProps(navigationState) {
        const paths = this.getActiveRouteNames(navigationState);
        return {
            screen_path: paths.join('::'),
            screen_name: paths[paths.length - 1],
        };
    }
    // Returns an array of route names, with the root name first, and the most nested name last.
    static getActiveRouteNames(navigationState) {
        const route = navigationState.routes[navigationState.index];
        // Dive into nested navigators.
        if (route.routes) {
            const paths = this.getActiveRouteNames(route);
            return [route.routeName].concat(paths);
        }
        return [route.routeName];
    }
}
