export class AppConstants {

  public static SNACKBAR_MSG_DURATION = 5000;
  public static SNACKBAR_ERR_DURATION = 10000;

  public static RETRY_ATTEMPTS = 3;
  public static RETRY_DELAY = 500;
  public static RETRY_HTTP_CODES = [408, 500];

  public static AUTOCOMPLETE_DEBOUNCE = 1000;
  public static AUTOCOMPLETE_LIMIT = 20;

  public static SEARCH_DEBOUNCE = 1000;
  
  public static API = getAPI();
}

function getAPI(): string {
  const baseHref = new URL(document.baseURI);
 
  let path = baseHref.pathname.slice(0, baseHref.pathname.indexOf('/ui'))
  let api = `${baseHref.protocol}//${baseHref.host}`+path;
  
  console.log(`API ${api}`);
  return api;
}

/*

export const OAuthConfig: AuthConfig = {

  // Url of the Identity Provider
  issuer: AppConstants.API,

  // URL of the SPA to redirect the user to after login
  redirectUri: AppConstants.API + '/ui/index.html',

  // The SPA's id. The SPA is registerd with this id at the auth-server
  clientId: 'authn',

  dummyClientSecret: 'secret',

  // set the scope for the permissions the client should request
  // The first four are defined by OIDC.
  // Important: Request offline_access to get a refresh token
  // The api scope is a usecase specific one
  scope: 'openid profile email offline_access api',

  responseType: 'code',

  // turn on validation that discovery document endpoints start with the issuer url defined above
  strictDiscoveryDocumentValidation: true,

  // show debug
  showDebugInformation: true,

  // Activate Session Checks:
  sessionChecksEnabled: true,

  // Disable requirement of https for tests
  requireHttps: false,

  // oidc: true, // ID_Token
  //this.oauthService.setStorage(sessionStorage);

  preserveRequestedRoute: true,
};
*/