import { UrlMatchResult, UrlSegment } from '@angular/router';

export function urlMatcher(url: UrlSegment[]): UrlMatchResult {
  if (url.length) {
    const firstSegment = url[0];
    const activeClientId = parseInt(firstSegment.path, 10);
    if (activeClientId && activeClientId > 0) {
      return {
        consumed: [firstSegment],
        posParams: {
          activeClientId: firstSegment,
        }
      };
    }
  }

  return {consumed: []};
}

export function hideLoader() {
  const loadingElement = document.querySelector('.app-loading');
  if (loadingElement) {
    loadingElement.classList.remove('app-loading');
  }
}
