import { M as Membership } from './membership-61c4a2f7.js';
import { M as MembershipConfig } from './membership-config-a51a5232.js';
import { U as User } from './User-d2ee8b71.js';
import { U as UserSettings } from './UserSettings-7b80b841.js';
import { C as CookieStorage } from './cookie-93ea205f.js';
import { r as routeParser } from './index-d3bd30bd.js';

const mentornityApiEndpoint = 'https://api.mentornity.com';
// export const mentornityApiEndpoint = 'http://localhost:1707';

const appRoute = '/:domain(/:page)(/:id)';
function getRouteParams(pathname) {
  // console.log(pathname, new Route(appRoute).match(pathname));
  return new routeParser(appRoute).match(pathname);
}

function getSessionDetails(groupId) {
  const { domain } = getRouteParams(location.pathname);
  const jwt = new CookieStorage().get('mt_at');
  const sessionToken = new CookieStorage().get('mt_st');
  const context = {
    organisationDomain: domain,
    organisationId: new CookieStorage().get('mt_oid'),
    userId: new CookieStorage().get('mt_uid'),
    role: new CookieStorage().get('mt_role'),
  };
  const headers = {
    Client: 'd2ViLWNsaWVu',
  };
  if (jwt) {
    headers['Authorization'] = `Bearer ${jwt}`;
    headers['Session-Token'] = sessionToken;
  }
  else {
    headers['Session-Token'] = `NTdiMzY3NjBlNjNiY2UxZWViMDAwMDA0`;
  }
  context.groupId = groupId;
  return { context, headers };
}
function getUserSettings(timeFormat, timeZone, language, isZoomAuthenticated) {
  const authPlatforms = [];
  if (isZoomAuthenticated) {
    authPlatforms.push({
      id: 'zoom',
      name: 'Zoom',
      scope: []
    });
  }
  return UserSettings.decode({ timeFormat, timeZone, language, authPlatforms });
}
function generateMembershipForRole(role) {
  return Membership.decode({
    config: generateMembershipConfigForRole(role),
  });
}
function generateMembershipConfigForRole(role) {
  return MembershipConfig.decode({
    _id: role === 'mentor' ? 'mentors' : 'mentees',
    roleName: role
  });
}
function getUser(id) {
  return User.decode({ _id: id });
}

export { generateMembershipConfigForRole as a, getRouteParams as b, getUser as c, getUserSettings as d, generateMembershipForRole as e, getSessionDetails as g, mentornityApiEndpoint as m };
