// ─── Entra External ID (CIAM for third-party logins) ───
const TENANT_ID = '891f98f1-ed34-42a1-9b6c-28b0554d92c2';
const CLIENT_ID = '154c9111-14a0-4c0f-8132-7bc68254a74e';
const AUTHORITY  = `https://PositiveSpendClients.ciamlogin.com/${TENANT_ID}`;

// ─── Gateway API ───
export const GATEWAY_URL = 'https://portal.positivespend.com';

// ─── Management API (used by HelpIcon for contextual help content) ───
export const MANAGEMENT_URL = 'https://mgmt.positivespend.com';

// ─── Session endpoint ───
export const SESSION_ENDPOINT = `${GATEWAY_URL}/api/auth/session`;

// ─── Registration portal ───
export const REGISTRATION_URL = 'https://regapi.positivespend.com';

// ─── MSAL configuration ───
export const msalConfig = {
  auth: {
    clientId: CLIENT_ID,
    authority: AUTHORITY,
    redirectUri: window.location.origin,
    postLogoutRedirectUri: window.location.origin,
    knownAuthorities: ['PositiveSpendClients.ciamlogin.com'],
    navigateToLoginRequestUrl: true
  },
  cache: {
    cacheLocation: 'localStorage',
    storeAuthStateInCookie: false
  },
  system: {
    loggerOptions: {
      loggerCallback: (level, message, containsPii) => {
        if (containsPii) return;
        switch (level) {
          case 0: console.error(message); break;
          case 1: console.warn(message); break;
          case 2: console.info(message); break;
          case 3: console.debug(message); break;
        }
      },
      logLevel: 3
    }
  }
};

export const loginRequest = {
  scopes: ['openid', 'profile', 'email']
};


// ─── Aliases for current Client components ───
export const API_BASE_URL    = GATEWAY_URL;
export const GATEWAY_API_URL = GATEWAY_URL;
export const API_BASE        = GATEWAY_URL;
export const MGMT_BASE       = MANAGEMENT_URL;
