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tBC,CAAAA,EAAAA,EAAAA,UAAAA,EAAWzB,6FC3EpB,IAAMnD,QAAU,GACPD,MAAMC,OAAO,CAACY,GAGjBiE,SAAW,GACRC,IAAMC,OAAOD,IAAM,CAAC9E,QAAQ8E,IAAM,mBAAOA,EAGrChG,YAAc,IACzB,GAAI+F,SAASC,GAAI,CACf,IAAME,EAAI,CAAC,EAMX,OAJAD,OAAOE,IAAI,CAACH,GAAGxC,OAAO,CAAC,IACrB0C,CAAC,CAACE,IAAUC,GAAG,CAAGrG,YAAYgG,CAAC,CAACK,EAAE,CACpC,GAEOH,CACT,QAAO,QAAYF,GACVA,EAAEb,GAAG,CAAC,GACJnF,YAAYsG,IAIhBN,CACT","sources":["webpack://_N_E/../../packages/api/api-service.ts","webpack://_N_E/../../packages/lib/segment.ts","webpack://_N_E/../../packages/api/site-service.ts","webpack://_N_E/../../packages/utils/context/TeamsContext.tsx","webpack://_N_E/../../packages/utils/helpers/objectUtils.ts","webpack://_N_E/"],"sourcesContent":["import axios, { CreateAxiosDefaults, type AxiosInstance } from \"axios\";\nimport jwt from \"jwt-decode\";\nimport router from \"next/router\";\nimport { getSession, signOut } from \"next-auth/react\";\n\nimport { resetAnalytics } from \"lib/segment\";\nimport { keysToCamel } from \"utils/helpers/objectUtils\";\n\nimport type { DecodedJWT } from \"next-auth\";\n\n/**\n * The function sets the default access token for axios.\n * @param {string} token - The value parameter is a string that represents the access token.\n */\nexport const setAccessToken = (token: string): void => {\n axios.defaults.headers.common.Authorization = token\n ? `Bearer ${token}`\n : undefined;\n};\n\n/**\n * The CustomError class extends the Error class and creates a custom error object with an error\n * description.\n * @extends Error\n * @property {string} errorDescription - The errorDescription property is a string that represents the\n * description of the error.\n * @constructor\n * @param {string} message - The message parameter is a string that represents the error message.\n * @param {string} errorDescription - The errorDescription parameter is an optional string that\n * represents the description of the error.\n */\nexport class CustomError extends Error {\n errorDescription: string;\n constructor(message: string, errorDescription?: string) {\n super(message);\n this.errorDescription = errorDescription;\n }\n}\n\n/**\n * The APIServiceClient class creates an Axios instance for making HTTP requests to the\n * relevant backend service.\n * @property {AxiosInstance} instance - The instance property is an Axios instance that is used to make\n * HTTP requests to the backend service.\n * @returns an instance of the APIServiceClient class.\n */\nexport class APIServiceClient {\n protected instance: AxiosInstance;\n\n /**\n * The constructor method creates an instance of the APIServiceClient class.\n * @constructor\n * @param {Object} params - The params parameter is an object that contains the following properties:\n * @param {string} params.baseURL - The baseURL property is a string that represents the base URL of the\n * backend service.\n * @param {string} params.accessToken - The accessToken property is an optional string that represents\n * the access token.\n * @param {CancelToken} params.cancelToken - The cancelToken property is an optional CancelToken that\n * represents the token to cancel the request.\n * @param {boolean} params.disabledKeysToCamel - The disabledKeysToCamel property is an optional boolean\n * value that indicates whether or not the keysToCamel call is disabled.\n */\n constructor({\n baseURL,\n accessToken,\n config,\n disabledKeysToCamel,\n }: {\n baseURL: string;\n accessToken?: string;\n config?: CreateAxiosDefaults;\n disabledKeysToCamel?: boolean;\n }) {\n accessToken && setAccessToken(accessToken);\n\n this.instance = axios.create({\n baseURL: baseURL,\n cancelToken: config?.cancelToken || axios.CancelToken.source().token,\n ...config,\n });\n\n this.instance.interceptors.request.use(async (request) => {\n if (\n \"Authorization\" in request.headers &&\n request.headers.Authorization === undefined\n ) {\n request.headers.clear(\"Authorization\");\n }\n\n if (\"withCredentials\" in request) {\n if (request.withCredentials) {\n if (!axios.defaults.headers.common.Authorization) {\n await this.getAccessToken();\n }\n\n if (!request.headers.Authorization) {\n request.headers.Authorization =\n axios.defaults.headers.common.Authorization;\n }\n\n delete request.withCredentials;\n\n const accessToken = request.headers.Authorization?.toString()\n ?.split(\" \")\n ?.at(-1);\n\n if (accessToken) {\n const decodedToken: DecodedJWT = jwt(accessToken);\n\n if (Date.now() > decodedToken.exp * 1000) {\n const newAccessToken = await this.getAccessToken();\n request.headers.setAuthorization(`Bearer ${newAccessToken}`);\n }\n }\n\n return request;\n } else {\n request.headers.clear(\"Authorization\");\n delete request.withCredentials;\n }\n }\n\n return request;\n });\n\n this.instance.interceptors.response.use(\n (response) => {\n return disabledKeysToCamel ? response.data : keysToCamel(response.data);\n },\n async (error) => {\n const originalRequest = error.config;\n\n if (error.response) {\n const { response } = error;\n\n const { data } = response || {};\n\n // If the access token is invalid, get a new one and retry the request\n if (response?.status === 403 && data.code === \"token_not_valid\") {\n /**\n * Get a new access token and retry the request\n */\n const newAccessToken = await this.getAccessToken();\n\n if (newAccessToken) {\n originalRequest._retry = true;\n originalRequest.headers.Authorization = `Bearer ${newAccessToken}`;\n\n return this.instance(originalRequest);\n } else {\n /**\n * If the new access token is not available, logout and redirect the user to the login page\n * with an error message\n */\n const data = await signOut({\n redirect: false,\n callbackUrl: `/home/login?error=${encodeURIComponent(\n \"Session expired. Log back in to continue.\"\n )}`,\n });\n\n if (typeof window !== \"undefined\") {\n router.push(data.url);\n resetAnalytics();\n }\n }\n }\n\n const errorFromBackend =\n (data && data.detail) ||\n (data && data.email && data.email[0]) ||\n (data && data.password && data.password[0]) ||\n (Array.isArray(data) && data[0]) ||\n (data && Array.isArray(data.error) && data.error[0]) ||\n response?.statusText;\n\n if (\n Array.isArray(errorFromBackend?.error) &&\n errorFromBackend?.error[0]\n ) {\n throw new CustomError(errorFromBackend, errorFromBackend?.error[0]);\n } else if (data?.error?.E301) {\n throw new CustomError(data?.error?.E301);\n }\n\n throw new CustomError(errorFromBackend);\n }\n\n throw error;\n }\n );\n }\n\n /**\n * The function is an asynchronous method that makes a GET request to an endpoint and returns a promise\n * of type T.\n * @param {string} endpoint - The `endpoint` parameter is a string that represents the URL or path of\n * the API endpoint that you want to make a GET request to. It specifies the location where the server\n * should handle the request and return the response data.\n * @param {boolean} [withCredentials] - The `withCredentials` parameter is a boolean value that\n * indicates whether or not cross-site Access-Control requests should be made using credentials such as\n * cookies, authorization headers, or TLS client certificates. If `withCredentials` is set to `true`,\n * the request will include any cookies or authorization headers associated with the\n * @returns a Promise of type T.\n */\n async get(endpoint: string, withCredentials = false): Promise {\n return await this.instance.get(endpoint, { withCredentials });\n }\n\n async getWithApiKey(endpoint: string, key): Promise {\n return await this.instance.get(endpoint, {\n headers: {\n \"x-api-key\": key,\n },\n });\n }\n\n async getWithToken(endpoint: string, accessToken: string): Promise {\n return await this.instance.get(endpoint, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n }\n\n /**\n * The function is an asynchronous method that sends a POST request to an endpoint with optional data\n * and credentials.\n * @param {string} endpoint - The endpoint parameter is a string that represents the URL or path where\n * the HTTP POST request will be sent to. It typically specifies the server-side endpoint or API route\n * that will handle the request.\n * @param {unknown} [data] - The `data` parameter is an optional parameter of type `unknown`. It\n * represents the data that will be sent in the request body when making a POST request to the\n * specified `endpoint`. The type `unknown` means that the data can be of any type.\n * @param {boolean} [withCredentials] - The `withCredentials` parameter is a boolean value that\n * determines whether or not cross-site Access-Control requests should be made using credentials such\n * as cookies, authorization headers, or TLS client certificates. If `withCredentials` is set to\n * `true`, the request will include credentials; if set to `false`,\n * @returns a Promise of type T.\n */\n async post(\n endpoint: string,\n data?: unknown,\n withCredentials = false\n ): Promise {\n return await this.instance.post(endpoint, data, { withCredentials });\n }\n\n /**\n * The function is an asynchronous method that sends a PUT request to an endpoint with optional data\n * and credentials.\n * @param {string} endpoint - The endpoint parameter is a string that represents the URL or path where\n * the data will be sent to or retrieved from. It typically specifies the location of a specific\n * resource on a server.\n * @param {unknown} [data] - The `data` parameter is an optional parameter that represents the data\n * that you want to send in the PUT request. It can be of any type (`unknown`) as specified in the\n * function signature.\n * @param {boolean} [withCredentials] - The `withCredentials` parameter is a boolean value that\n * indicates whether or not cross-site Access-Control requests should be made using credentials such as\n * cookies, authorization headers, or TLS client certificates. When set to `true`, the request will\n * include credentials; when set to `false`, the request will not include\n * @returns a Promise of type T.\n */\n async put(\n endpoint: string,\n data?: unknown,\n withCredentials = false\n ): Promise {\n return await this.instance.put(endpoint, data, { withCredentials });\n }\n\n /**\n * The function is an asynchronous method that sends a DELETE request to a specified endpoint and\n * returns a promise with the response data.\n * @param {string} endpoint - The endpoint parameter is a string that represents the URL or path of the\n * resource that you want to delete. It specifies the location of the resource on the server.\n * @param {boolean} [withCredentials] - The `withCredentials` parameter is a boolean value that\n * indicates whether or not cross-site Access-Control requests should be made using credentials such as\n * cookies, authorization headers, or TLS client certificates. If `withCredentials` is set to `true`,\n * the request will include credentials; if set to `false`,\n * @returns The delete method is returning a Promise of type T.\n */\n async delete(endpoint: string, withCredentials = false): Promise {\n return await this.instance.delete(endpoint, { withCredentials });\n }\n\n /**\n * The function `getAccessToken` retrieves and returns an access token, either from the current session\n * or by setting a new one.\n * @returns {Promise} a Promise that resolves to a string.\n */\n async getAccessToken(): Promise {\n const token = (await getSession())?.accessToken;\n\n setAccessToken(token);\n\n return token;\n }\n}\n","import { AnalyticsBrowser, type UserTraits } from \"@segment/analytics-next\";\nimport pick from \"lodash/pick\";\n\nimport type { UserModelInterface } from \"utils/types/account\";\n\nexport function analytics(): AnalyticsBrowser | undefined {\n if (\n process.env.BUILD_ENV === \"development\" ||\n process.env.BUILD_ENV === \"production\"\n ) {\n const analyticsBrowser = AnalyticsBrowser.load({\n writeKey: process.env.NEXT_PUBLIC_SEGMENT_WRITE_KEY,\n });\n\n return analyticsBrowser;\n }\n\n return undefined;\n}\n\n/**\n * Tracks an event with properties to the analytics service.\n * @param event - The name of the event to track.\n * @param properties - The properties to send with the event.\n */\nexport function trackEvent(\n event: string,\n properties?: Record\n) {\n const a = analytics();\n if (!a) return;\n\n a.track(event, properties);\n}\n\n/**\n * These are the base user traits to identify the user\n */\nconst BASE_USER_TRAITS_TO_IDENTIFY = [\n \"email\",\n \"firstName\",\n \"lastName\",\n \"username\",\n \"authProvider\",\n \"subscription\",\n \"createdAt\",\n];\n\n/**\n * Identifies a user and sends user traits to the analytics service.\n * @param userId - The ID of the user.\n * @param data - The user data including traits and subscription information.\n */\nexport async function identifyUser(\n userId: string,\n data?: Partial\n) {\n const a = analytics();\n if (!a) return;\n\n const traits: UserTraits = {\n ...pick(data, BASE_USER_TRAITS_TO_IDENTIFY),\n };\n\n if (data.customerTeams?.[0]) {\n traits.team = data.customerTeams[0].teamName;\n }\n\n a.identify(userId, traits);\n}\n\nexport async function softIdentifyUser(\n data?: Partial<{ email: string; firstName: string; lastName: string }>\n) {\n const a = analytics();\n if (!a) return;\n\n a.identify(data);\n}\n\nexport function resetAnalytics() {\n const a = analytics();\n if (!a) return;\n\n a.reset();\n}\n\nexport function pageViewed(path: string) {\n const a = analytics();\n if (!a) return;\n\n a.page({ path });\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useMemo } from \"react\";\n\nimport axios from \"axios\";\n\nimport { APIServiceClient } from \"./api-service\";\n\nimport type {\n Team,\n ContactFormRequestBody,\n ContactFormType,\n DefaultColor,\n BrandColor,\n TeamColor,\n} from \"./types/site-service\";\n\nexport const cancelTokenSource = axios.CancelToken.source();\n\nlet siteServiceClient: SiteServiceClient | undefined;\n\n/**\n * The SiteServiceClient class creates an Axios instance for making HTTP requests to the\n * User microservice API, with methods for authentication, profile management, and miscellaneous tasks.\n *\n * TODO: Add types for all data models used in this service.\n * TODO: Replace all uses of \"any\" type.\n */\nclass SiteServiceClient extends APIServiceClient {\n constructor() {\n super({\n baseURL: process.env.TPL_USERS_SERVICE,\n config: {\n cancelToken: cancelTokenSource.token,\n transformRequest: [\n (data, headers) => {\n headers.clear(\"Authorization\");\n return data;\n },\n ],\n },\n });\n }\n\n theme() {\n return {\n getSiteDefaultColors: async (): Promise =>\n await this.instance.get(\"tpl-legacy/site-default-colors/\", {\n withCredentials: false,\n }),\n getSiteBrandColors: async (): Promise =>\n await this.instance.get(\"tpl-legacy/site-brand-colors/\", {\n withCredentials: false,\n }),\n getTeamColors: async (teamIds: string[]): Promise => {\n const params = new URLSearchParams();\n teamIds.forEach((id: string) => params.append(\"team_id\", id));\n return await this.instance.get(\"tpl-legacy/site-organization-colors/\", {\n params,\n withCredentials: false,\n });\n },\n };\n }\n\n teams() {\n return {\n fetchAll: async (): Promise =>\n await this.instance.get(\"auth/teams/\", { withCredentials: false }),\n };\n }\n\n misc() {\n return {\n submitContactForm: async (\n data: ContactFormRequestBody,\n form: ContactFormType\n ) =>\n await this.instance.post(\n `${form === \"contactUs\" ? \"contact_us/\" : \"work_with_us/\"}`,\n { ...data, company: data.company ?? null }\n ),\n };\n }\n}\n\nconst createSiteServiceClient = () => {\n return new SiteServiceClient();\n};\n\nexport const getSiteService = () => {\n const _siteServiceClient = siteServiceClient ?? createSiteServiceClient();\n\n if (!siteServiceClient) siteServiceClient = _siteServiceClient;\n\n return _siteServiceClient;\n};\n\n/**\n * It creates a SiteService Client instance and returns it\n */\nexport const useSiteService = () => {\n const store = useMemo(() => getSiteService(), []);\n return store;\n};\n\nexport type { TeamColor, BrandColor, DefaultColor };\n","import {\n createContext,\n useContext,\n useState,\n PropsWithChildren,\n useMemo,\n} from \"react\";\n\nimport useSWRImmutable from \"swr/immutable\";\n\nimport { getSiteService } from \"api/site-service\";\n\nimport type { Fetcher } from \"swr\";\nimport type { Team } from \"utils/types/teams\";\n\ninterface Props extends PropsWithChildren {\n fallback?: Team[];\n}\n\ninterface TeamsContextProps {\n teams: Team[];\n currentTeam: Team;\n setCurrentTeam: (data: Team) => void;\n setCurrentTeamBySlug: (slug: string) => void;\n getTeamByKey: (value: string, key: keyof Team) => Team;\n}\n\n// Creating the teams context\nexport const TeamsContext = createContext({\n teams: [],\n currentTeam: null,\n setCurrentTeam: null,\n setCurrentTeamBySlug: null,\n getTeamByKey: null,\n});\n\nconst fetcher: Fetcher = (url: string) =>\n getSiteService().get(url);\n\nexport const TeamsContextProvider = ({ children, fallback }: Props) => {\n const [currentTeam, setCurrentTeam] = useState(null);\n\n const { data } = useSWRImmutable(\"auth/teams/\", fetcher);\n\n const teams = useMemo(\n () =>\n data?.map((t) => ({ ...t, slug: t.shortName.toLowerCase() })) || fallback,\n [data, fallback]\n );\n\n const setCurrentTeamBySlug = (slug: string) => {\n const team = teams.find((t) => t.shortName.toLowerCase() === slug);\n\n setCurrentTeam(team);\n };\n\n const getTeamByKey = (value: string, key: keyof Team) => {\n return teams?.find((t) => t[key] === value);\n };\n\n return (\n \n {children}\n \n );\n};\n\n// Make useTeamsContext Hook to easily use our context throughout the application\nexport const useTeamsContext = () => {\n return useContext(TeamsContext);\n};\n","import camelCase from \"lodash/camelCase\";\n\nconst isArray = (a) => {\n return Array.isArray(a);\n};\n\nconst isObject = (o) => {\n return o === Object(o) && !isArray(o) && typeof o !== \"function\";\n};\n\nexport const keysToCamel = (o) => {\n if (isObject(o)) {\n const n = {};\n\n Object.keys(o).forEach((k) => {\n n[camelCase(k)] = keysToCamel(o[k]);\n });\n\n return n;\n } else if (isArray(o)) {\n return o.map((i) => {\n return keysToCamel(i);\n });\n }\n\n return o;\n};\n\nexport const getObjectSubset = (\n obj: Record,\n keys: string[]\n) => {\n return keys.reduce((subset, key) => {\n if (key in obj) {\n subset[key] = obj[key];\n }\n\n return subset;\n }, {});\n};\n\nexport const hasMatchingKey = (\n obj: Record,\n keys: string[]\n) => {\n return Object.keys(obj).some((key) => keys.includes(key));\n};\n"],"names":["setAccessToken","axios","defaults","headers","common","Authorization","token","concat","undefined","CustomError","Error","constructor","message","errorDescription","APIServiceClient","get","endpoint","withCredentials","instance","getWithApiKey","key","getWithToken","accessToken","post","data","put","delete","getAccessToken","_this","getSession","baseURL","config","disabledKeysToCamel","create","cancelToken","CancelToken","source","interceptors","request","use","clear","toString","split","at","decodedToken","jwt","Date","now","exp","newAccessToken","setAuthorization","response","keysToCamel","error","originalRequest","status","code","_retry","signOut","redirect","callbackUrl","encodeURIComponent","router","url","resetAnalytics","errorFromBackend","detail","email","password","Array","isArray","statusText","E301","analytics","analyticsBrowser","AnalyticsBrowser","load","writeKey","process","trackEvent","event","properties","a","track","BASE_USER_TRAITS_TO_IDENTIFY","identifyUser","userId","traits","pick","customerTeams","team","teamName","identify","softIdentifyUser","reset","pageViewed","path","page","siteServiceClient","cancelTokenSource","SiteServiceClient","theme","getSiteDefaultColors","getSiteBrandColors","getTeamColors","teamIds","params","URLSearchParams","forEach","append","id","teams","fetchAll","misc","submitContactForm","form","company","transformRequest","createSiteServiceClient","getSiteService","_siteServiceClient","TeamsContext","createContext","currentTeam","setCurrentTeam","setCurrentTeamBySlug","getTeamByKey","fetcher","TeamsContextProvider","children","fallback","param","useState","useSWRImmutable","useMemo","map","t","slug","shortName","toLowerCase","jsx_runtime","jsx","Provider","value","find","useTeamsContext","useContext","isObject","o","Object","n","keys","camelCase","k","i"],"sourceRoot":""}