(\r\n ThemeUtils.GetThemeFromSettingsOrDefaults(\r\n themeSettings,\r\n ),\r\n );\r\n const [\r\n themeCookie,\r\n setThemeCookie,\r\n removeThemeCookie,\r\n ] = useCookies([ 'cookie-theme' ]);\r\n\r\n useEffect(() =>\r\n {\r\n const newSettings =\r\n ThemeUtils.GetSettingsOrDefaults(\r\n themeState.settings,\r\n );\r\n const newThemeState =\r\n ThemeUtils.GetThemeFromSettingsOrDefaults(\r\n newSettings,\r\n );\r\n\r\n setCurrentTheme(newThemeState);\r\n\r\n }, [ themeState ]);\r\n\r\n useEffect(() =>\r\n {\r\n // monitor cookie\r\n }, [ themeCookie ]);\r\n\r\n return (\r\n \r\n \r\n { props.children }\r\n \r\n );\r\n};\r\nexport default ThemeManager;\r\n","import\r\n{\r\n PaletteColor,\r\n PaletteMode,\r\n ThemeOptions,\r\n Theme,\r\n} from '@mui/material';\r\nimport {createTheme} from '@mui/material/styles';\r\n\r\nimport {blue, green, grey, purple, red, yellow} from '@mui/material/colors';\r\n\r\nimport {isNullOrUndefined} from '../utilities/Utils';\r\nimport\r\n{\r\n DEFAULT_MODE,\r\n DEFAULT_PRIMARY_COLOR,\r\n DEFAULT_SECONDARY_COLOR,\r\n DEFAULT_TERTIARY_COLOR,\r\n DefaultThemeSettings,\r\n} from './ThemeDefaults';\r\nimport\r\n{\r\n IPaletteColorGraduationHues,\r\n IThemeSettings,\r\n ThemeMode,\r\n} from './ThemeTypes';\r\nimport {Margin, Padding} from '@mui/icons-material';\r\n\r\nconst emptyTheme: Theme = createTheme();\r\n\r\nexport const GetThemeFromSettingsOrDefaults = (\r\n settings: IThemeSettings | null,\r\n): Theme =>\r\n{\r\n const retVal =\r\n settings == null\r\n ? DefaultThemeSettings\r\n : settings;\r\n\r\n const paletteMode: PaletteMode =\r\n getThemeModeOrDefault(\r\n retVal.mode,\r\n DEFAULT_MODE,\r\n ) as PaletteMode;\r\n\r\n const primaryColor = augmentColor(\r\n 'primary',\r\n DEFAULT_PRIMARY_COLOR,\r\n );\r\n const secondaryColor = augmentColor(\r\n 'secondary',\r\n DEFAULT_SECONDARY_COLOR,\r\n );\r\n const tertiaryColor = augmentColor(\r\n 'tertiary',\r\n DEFAULT_TERTIARY_COLOR,\r\n false,\r\n );\r\n\r\n const defaultTheme: Theme = createTheme({\r\n palette: {\r\n mode: paletteMode,\r\n primary: primaryColor,\r\n secondary: secondaryColor,\r\n tertiary: tertiaryColor,\r\n primaryLightVariant: augmentColor(\r\n 'primaryLightVariant',\r\n primaryColor.light,\r\n ),\r\n primaryDarkVariant: augmentColor(\r\n 'primaryDarkVariant',\r\n primaryColor.dark,\r\n ),\r\n secondaryLightVariant: augmentColor(\r\n 'secondaryLightVariant',\r\n secondaryColor.light,\r\n ),\r\n secondaryDarkVariant: augmentColor(\r\n 'secondaryDarkVariant',\r\n secondaryColor.dark,\r\n ),\r\n tertiaryLightVariant: augmentColor(\r\n 'tertiaryLightVariant',\r\n tertiaryColor.light,\r\n ),\r\n tertiaryDarkVariant: augmentColor(\r\n 'tertiaryDarkVariant',\r\n tertiaryColor.dark,\r\n ),\r\n background: {\r\n default: paletteMode === 'light' ? grey[200] : grey[800],\r\n },\r\n commonColors: {\r\n Gray: generateColorGraduations(grey, paletteMode),\r\n Blue: generateColorGraduations(blue, paletteMode),\r\n Red: generateColorGraduations(red, paletteMode),\r\n Green: generateColorGraduations(green, paletteMode),\r\n Purple: generateColorGraduations(purple, paletteMode),\r\n Yellow: generateColorGraduations(yellow, paletteMode),\r\n // Add more color groups as needed \r\n },\r\n },\r\n typography: {\r\n fontFamily: `VAGRoundedStd,'Helvetica Neue', Helvetica, Arial, sans-serif`,\r\n },\r\n components: {\r\n MuiButton: {\r\n styleOverrides: {\r\n root: {\r\n Padding: 0,\r\n Margin: 0,\r\n borderRadius: 0,\r\n textTransform: 'none',\r\n },\r\n },\r\n },\r\n MuiPaper: {\r\n styleOverrides: {\r\n root: {\r\n backgroundColor:\r\n paletteMode === 'light' ? grey[100] : grey[900],\r\n padding: '16px',\r\n borderRadius: '1px',\r\n },\r\n },\r\n },\r\n MuiLink: {\r\n styleOverrides: {\r\n root: {\r\n color: paletteMode === 'light' ? blue[500] : blue[200],\r\n textDecoration: 'none', // Remove underline by default\r\n '&:hover': {\r\n textDecoration:\r\n 'underline', // Underline on hover\r\n color: secondaryColor.light, // Change color on hover\r\n },\r\n },\r\n },\r\n },\r\n },\r\n });\r\n\r\n return defaultTheme;\r\n};\r\n\r\nexport const GetSettingsOrDefaults = (\r\n settings: IThemeSettings | null | undefined,\r\n): IThemeSettings =>\r\n{\r\n return settings == null\r\n ? DefaultThemeSettings\r\n : settings;\r\n};\r\n\r\nexport const getThemeModeOrDefault = (\r\n mode: ThemeMode | undefined,\r\n defaultValue: ThemeMode,\r\n): PaletteMode =>\r\n{\r\n if (isNullOrUndefined(mode))\r\n {\r\n return GetPaletteModeFromThemeMode(\r\n defaultValue,\r\n );\r\n }\r\n\r\n if (mode === 'Dark')\r\n {\r\n return 'dark';\r\n }\r\n\r\n return 'light';\r\n};\r\n\r\nexport const getThemeColorOrDefault = (\r\n color: string | undefined,\r\n defaultValue: string,\r\n): string =>\r\n{\r\n if (isNullOrUndefined(color))\r\n {\r\n return defaultValue;\r\n }\r\n\r\n return color as string;\r\n};\r\n\r\nexport const UpdateThemeMode = (\r\n settings: IThemeSettings,\r\n mode: ThemeMode,\r\n): IThemeSettings =>\r\n{\r\n const retVal =\r\n settings == null\r\n ? DefaultThemeSettings\r\n : settings;\r\n\r\n retVal.mode = mode;\r\n\r\n return retVal;\r\n};\r\n\r\nexport const GetPaletteModeFromThemeMode = (\r\n mode: ThemeMode,\r\n): PaletteMode =>\r\n{\r\n return mode === 'Light' ? 'light' : 'dark';\r\n};\r\n\r\nexport const GetThemeModeFromPaletteMode = (\r\n mode: PaletteMode,\r\n): ThemeMode =>\r\n{\r\n return mode === 'light' ? 'Light' : 'Dark';\r\n};\r\n\r\nconst HUE_MAPPING: Record<\r\n keyof IPaletteColorGraduationHues,\r\n string\r\n> = {\r\n H100: '100',\r\n H200: '200',\r\n H300: '300',\r\n H400: '400',\r\n H500: '500',\r\n H600: '600',\r\n H700: '700',\r\n H800: '800',\r\n H900: '900',\r\n};\r\n\r\nconst REVERSE_HUE_MAPPING: Record<\r\n keyof IPaletteColorGraduationHues,\r\n string\r\n> = {\r\n H100: '900',\r\n H200: '800',\r\n H300: '700',\r\n H400: '600',\r\n H500: '500',\r\n H600: '400',\r\n H700: '300',\r\n H800: '200',\r\n H900: '100',\r\n};\r\n\r\nconst generateColorGraduations = (\r\n colorSet: {[key: string]: string;},\r\n paletteMode: PaletteMode = 'light'): IPaletteColorGraduationHues =>\r\n{\r\n const hueMapping: Record<\r\n keyof IPaletteColorGraduationHues,\r\n string\r\n > = paletteMode === 'light' ? HUE_MAPPING : REVERSE_HUE_MAPPING;\r\n\r\n return (\r\n Object.keys(\r\n hueMapping,\r\n ) as (keyof IPaletteColorGraduationHues)[]\r\n ).reduce((acc, key) =>\r\n {\r\n const colorKey = hueMapping[key];\r\n const mainColor = colorSet[colorKey];\r\n const contrastText =\r\n emptyTheme.palette.getContrastText(\r\n mainColor,\r\n );\r\n\r\n acc[key] = augmentColor(\r\n key,\r\n mainColor,\r\n );\r\n\r\n return acc;\r\n }, {} as IPaletteColorGraduationHues);\r\n};\r\n\r\nexport const getContrastText = (\r\n background: string,\r\n): string | undefined =>\r\n{\r\n return emptyTheme.palette.getContrastText(background);\r\n};\r\n\r\nexport const augmentColor = (\r\n name: string,\r\n color: string,\r\n augmentName: boolean = true,\r\n): PaletteColor =>\r\n{\r\n return emptyTheme.palette.augmentColor({\r\n color: {main: color},\r\n name: augmentName\r\n ? `augmented_${name}`\r\n : `${name}`,\r\n });\r\n};\r\n\r\n\r\nexport const isHexColor = (color: string): boolean => /^#([0-9A-F]{3}){1,2}$/i.test(color);\r\nexport const isRgbColor = (color: string): boolean => /^rgb(a)?\\(\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*\\d+(\\s*,\\s*(0|1|0?\\.\\d+))?\\s*\\)$/i.test(color);\r\n\r\nexport const parseHexColor = (hex: string): {r: number, g: number, b: number;} =>\r\n{\r\n hex = hex.replace(/^#/, '');\r\n\r\n let r: number, g: number, b: number;\r\n\r\n if (hex.length === 3)\r\n {\r\n r = parseInt(hex[0] + hex[0], 16);\r\n g = parseInt(hex[1] + hex[1], 16);\r\n b = parseInt(hex[2] + hex[2], 16);\r\n\r\n return {r, g, b};\r\n }\r\n\r\n if (hex.length === 6)\r\n {\r\n r = parseInt(hex.substring(0, 2), 16);\r\n g = parseInt(hex.substring(2, 4), 16);\r\n b = parseInt(hex.substring(4, 6), 16);\r\n\r\n return {r, g, b};\r\n }\r\n\r\n throw new Error('Invalid hex color format');\r\n};\r\n\r\nexport const parseRgbColor = (rgb: string): {r: number, g: number, b: number, a?: number;} =>\r\n{\r\n const match = rgb.match(/^rgb(a)?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(,\\s*(0|1|0?\\.\\d+))?\\)$/i);\r\n\r\n if (!match) throw new Error('Invalid RGB(A) color format');\r\n\r\n const r = parseInt(match[2], 10);\r\n const g = parseInt(match[3], 10);\r\n const b = parseInt(match[4], 10);\r\n\r\n const a = match[6] !== undefined\r\n ? parseFloat(match[6])\r\n : undefined;\r\n\r\n return {r, g, b, a};\r\n};\r\n\r\nexport const colorToRgba = (color: string, alpha: number): string =>\r\n{\r\n // Ensure the alpha value is between 0 and 1\r\n if (alpha < 0) alpha = 0;\r\n if (alpha > 1) alpha = 1;\r\n\r\n let r: number, g: number, b: number;\r\n let finalAlpha = alpha;\r\n\r\n if (isHexColor(color))\r\n {\r\n ({r, g, b} = parseHexColor(color));\r\n\r\n return `rgba(${r}, ${g}, ${b}, ${finalAlpha})`;\r\n }\r\n\r\n if (isRgbColor(color))\r\n {\r\n const parsedColor = parseRgbColor(color);\r\n r = parsedColor.r;\r\n g = parsedColor.g;\r\n b = parsedColor.b;\r\n\r\n if (parsedColor.a !== undefined)\r\n {\r\n finalAlpha = (alpha + parsedColor.a) / 2;\r\n }\r\n\r\n return `rgba(${r}, ${g}, ${b}, ${finalAlpha})`;\r\n }\r\n\r\n throw new Error('Invalid color format');\r\n};\r\n\r\nexport const createBoxShadow = (\r\n angle: number,\r\n distance: number,\r\n blurRadius: number,\r\n color: string,\r\n alpha: number\r\n): string => createBoxShadowWithAngle(angle, distance, blurRadius, color, alpha);\r\n\r\nexport const createBoxShadowWithOffsets = (\r\n hOffset: number,\r\n vOffset: number,\r\n blurRadius: number,\r\n color: string,\r\n alpha: number\r\n): string =>\r\n{\r\n // Convert the hex color to rgba\r\n const rgbaColor = colorToRgba(color, alpha);\r\n\r\n // Construct and return the box shadow string\r\n const result = `${hOffset}px ${vOffset}px ${blurRadius}px ${rgbaColor}`;\r\n\r\n return result;\r\n};\r\n\r\nexport const createBoxShadowWithAngle = (\r\n angle: number,\r\n distance: number,\r\n blurRadius: number,\r\n color: string,\r\n alpha: number\r\n): string =>\r\n{\r\n // Calculate the offsets\r\n const {hOffset, vOffset} = calculateOffsets(angle, distance);\r\n\r\n // Convert the hex color to rgba\r\n const rgbaColor = colorToRgba(color, alpha);\r\n\r\n // Construct and return the box shadow string\r\n const result = `${hOffset}px ${vOffset}px ${blurRadius}px ${rgbaColor}`;\r\n\r\n return result;\r\n};\r\n\r\nconst calculateOffsets = (angle: number, distance: number): {hOffset: number, vOffset: number;} => \r\n{\r\n const radians = (normalizeAngle(angle) * Math.PI) / 180;\r\n\r\n const hOffset = Math.round(Math.cos(radians) * distance);\r\n const vOffset = Math.round(Math.sin(radians) * distance);\r\n\r\n return {hOffset, vOffset};\r\n};\r\n\r\nexport const normalizeAngle = (angle: number): number =>\r\n{\r\n // Normalize the angle to be within 0 to 359 degrees\r\n return ((angle % 360) + 360) % 360;\r\n};","import React, { useState, useEffect } from 'react';\r\nimport\r\n{\r\n JwtHeader,\r\n JwtPayload,\r\n jwtDecode,\r\n} from 'jwt-decode';\r\nimport dayjs from 'dayjs';\r\n\r\nimport { useAuth } from '../providers/AuthProvider';\r\nimport\r\n{\r\n isNullOrUndefined,\r\n notNullOrUndefined,\r\n} from '../utilities/Utils';\r\nimport { LocalStorage } from './storage/LocalStorage';\r\nimport ErrorCard from '../components/notifications/ErrorCard';\r\nimport { Typography } from '@mui/material';\r\n\r\nexport function withSecurity(\r\n Component: React.ComponentType
,\r\n requiredRole: UserRole,\r\n): React.FC
\r\n{\r\n return function SecuredComponent(props: P)\r\n {\r\n const { loggedIn, user } = useAuth();\r\n\r\n const [ isLoggedIn, setIsLoggedIn ] =\r\n useState(false);\r\n const [ currentUser, setCurrentUser ] =\r\n useState(null);\r\n\r\n useEffect(() =>\r\n {\r\n setIsLoggedIn(loggedIn);\r\n setCurrentUser(user);\r\n }, [ user, loggedIn ]);\r\n\r\n // Check if the user's role matches the required role\r\n // userRole >= requiredRole\r\n if (\r\n isLoggedIn &&\r\n currentUser &&\r\n notNullOrUndefined(currentUser.email) &&\r\n notNullOrUndefined(currentUser.role) &&\r\n currentUser.role <= requiredRole\r\n )\r\n {\r\n return ;\r\n }\r\n else\r\n {\r\n return (\r\n \r\n \r\n You don't have the\r\n necessary privileges to\r\n access this content or\r\n resource.\r\n \r\n \r\n );\r\n }\r\n };\r\n}\r\n\r\nexport type JwtTokenType = 'AccessToken' | 'RefreshToken';\r\n\r\nexport enum UserRole\r\n{\r\n Root = -2147483648,\r\n Admin = 1000,\r\n SuperUser = 2000,\r\n PowerUser = 3000,\r\n Manager = 4000,\r\n User = 5000,\r\n Guest = 6000,\r\n Anonymous = 2147483647, // Using the maximum 32-bit integer value for TypeScript\r\n}\r\n\r\nexport type LoginResultType =\r\n | 'succeeded'\r\n | 'isLockedOut'\r\n | 'isNotAllowed'\r\n | 'requiresTwoFactor'\r\n | 'failed';\r\n\r\nexport interface ILoginRequest\r\n{\r\n email: string;\r\n password: string;\r\n twoFactorCode?: string;\r\n twoFactorRecoveryCode?: string;\r\n}\r\n\r\nexport interface ILoginInformation\r\n{\r\n user: IAuthUser | null;\r\n tokens: IUserTokens | null;\r\n}\r\n\r\nexport interface ILoginResponse extends ILoginInformation\r\n{\r\n result: LoginResultType;\r\n}\r\n\r\nexport interface IUserLoginFormData\r\n{\r\n userEmail: string;\r\n rememberMe: string;\r\n}\r\n\r\nexport interface IAuthUser\r\n{\r\n id: string,\r\n email: string;\r\n firstName: string | null;\r\n lastName: string | null;\r\n role: UserRole;\r\n roleName: string | null;\r\n lastLogin: Date | null;\r\n}\r\n\r\nexport interface IUserTokens\r\n{\r\n accessToken: IJwtToken | null;\r\n refreshToken: IJwtToken | null;\r\n}\r\n\r\nexport interface IJwtToken\r\n{\r\n type: JwtTokenType;\r\n expiration: Date;\r\n value: string;\r\n header: JwtHeader | null;\r\n payload: JwtPayload | null;\r\n}\r\n\r\nexport function getRoleByValue(\r\n roleNumber: number,\r\n): UserRole\r\n{\r\n if (Object.values(UserRole).includes(roleNumber))\r\n {\r\n return roleNumber as UserRole;\r\n }\r\n\r\n return UserRole.Anonymous;\r\n}\r\n\r\nexport function getRoleByName(roleName: string): UserRole\r\n{\r\n roleName =\r\n roleName.charAt(0).toUpperCase() +\r\n roleName.slice(1).toLowerCase();\r\n\r\n if (roleName in UserRole)\r\n {\r\n return UserRole[\r\n roleName as keyof typeof UserRole\r\n ];\r\n }\r\n\r\n return UserRole.Anonymous;\r\n}\r\n\r\nexport function getRoleName(role: UserRole): string\r\n{\r\n return `${UserRole[ role ]}`;\r\n}\r\n\r\nexport const parseLoginResponse = (\r\n data: any,\r\n): ILoginResponse | null =>\r\n{\r\n if (\r\n isNullOrUndefined(data?.email) ||\r\n isNullOrUndefined(data.result)\r\n )\r\n {\r\n return null;\r\n }\r\n\r\n const loginRes = parseLoginResult(data.result);\r\n\r\n if (loginRes !== 'succeeded')\r\n {\r\n return {\r\n result: loginRes,\r\n tokens: null,\r\n user: null,\r\n };\r\n }\r\n\r\n const userInfo = parseUserInformation(data);\r\n const loginTokens = parseTokens(data);\r\n\r\n if (\r\n isNullOrUndefined(userInfo) ||\r\n isNullOrUndefined(loginTokens)\r\n )\r\n {\r\n return null;\r\n }\r\n\r\n return {\r\n user: userInfo,\r\n tokens: loginTokens,\r\n result: loginRes,\r\n };\r\n};\r\n\r\nexport const parseLoginResult = (\r\n data: any,\r\n): LoginResultType =>\r\n{\r\n if (\r\n notNullOrUndefined(data?.isLockedOut) &&\r\n data?.isLockedOut === true\r\n )\r\n {\r\n return 'isLockedOut';\r\n }\r\n\r\n if (\r\n notNullOrUndefined(data?.requiresTwoFactor) &&\r\n data?.requiresTwoFactor === true\r\n )\r\n {\r\n return 'requiresTwoFactor';\r\n }\r\n\r\n if (\r\n notNullOrUndefined(data?.NotAllowed) &&\r\n data?.NotAllowed === true\r\n )\r\n {\r\n return 'isNotAllowed';\r\n }\r\n\r\n if (\r\n notNullOrUndefined(data?.succeeded) &&\r\n data?.succeeded === true\r\n )\r\n {\r\n return 'succeeded';\r\n }\r\n\r\n return 'failed';\r\n};\r\n\r\nexport const parseUserInformation = (\r\n data: any,\r\n): IAuthUser | null =>\r\n{\r\n if (\r\n notNullOrUndefined(data?.email) &&\r\n notNullOrUndefined(data.firstName) &&\r\n notNullOrUndefined(data.lastName) &&\r\n notNullOrUndefined(data.role)\r\n )\r\n {\r\n const currRole = parseUserRole(data.role);\r\n\r\n if (notNullOrUndefined(currRole))\r\n {\r\n return {\r\n id: data.userId,\r\n email: data.email,\r\n firstName: data.firstName,\r\n lastName: data.lastName,\r\n role: currRole as UserRole,\r\n roleName: getRoleName(currRole!),\r\n lastLogin: notNullOrUndefined(\r\n data.lastLogin,\r\n )\r\n ? dayjs(\r\n data.lastLogin,\r\n ).toDate()\r\n : null,\r\n };\r\n }\r\n }\r\n\r\n return null;\r\n};\r\n\r\nexport const parseUserRole = (\r\n value: number,\r\n): UserRole | null =>\r\n{\r\n return Object.values(UserRole).includes(value)\r\n ? (value as UserRole)\r\n : null;\r\n};\r\n\r\nexport const parseTokens = (\r\n data: any,\r\n): IUserTokens | null =>\r\n{\r\n if (\r\n notNullOrUndefined(data?.tokens) &&\r\n notNullOrUndefined(data?.tokens.accessToken) &&\r\n notNullOrUndefined(data?.tokens.refreshToken)\r\n )\r\n {\r\n return {\r\n accessToken: parseToken(\r\n data.tokens.accessToken,\r\n ),\r\n refreshToken: parseToken(\r\n data.tokens.refreshToken,\r\n ),\r\n };\r\n }\r\n\r\n return null;\r\n};\r\n\r\nexport const parseToken = (data: any): IJwtToken | null =>\r\n{\r\n if (\r\n notNullOrUndefined(data?.type) &&\r\n notNullOrUndefined(data?.expiration) &&\r\n notNullOrUndefined(data?.value)\r\n )\r\n {\r\n const tokenType: JwtTokenType =\r\n data.type === 0\r\n ? 'AccessToken'\r\n : 'RefreshToken';\r\n const expiration: Date = dayjs(\r\n data.expiration,\r\n ).toDate();\r\n const value: string = data.value;\r\n\r\n return {\r\n type: tokenType,\r\n expiration: expiration,\r\n // isExpired: () => dayjs().isAfter(dayjs(expiration)),\r\n value: value,\r\n header: jwtDecode(data.value, {\r\n header: true,\r\n }),\r\n payload: jwtDecode(data.value),\r\n };\r\n }\r\n\r\n return null;\r\n};\r\n\r\nexport const parseTokenFromStorage = (): string | null =>\r\n{\r\n const loginLocalStorage =\r\n new LocalStorage('UserLogin');\r\n\r\n const accessToken: string | undefined =\r\n loginLocalStorage.contains()\r\n ? loginLocalStorage.retrieve()?.tokens\r\n ?.accessToken?.value\r\n : undefined;\r\n\r\n if (notNullOrUndefined(accessToken))\r\n {\r\n const tokenPayload: JwtPayload = jwtDecode(\r\n accessToken!,\r\n );\r\n\r\n if (checkJwtTokenExpiry(tokenPayload.exp))\r\n {\r\n return null;\r\n }\r\n }\r\n\r\n return null;\r\n};\r\n\r\nexport const isJwtTokenExpired = (\r\n tokenValue: string | null | undefined,\r\n): boolean =>\r\n{\r\n if (isNullOrUndefined(tokenValue))\r\n {\r\n return true; // Consider null or undefined token as expired.\r\n }\r\n\r\n try\r\n {\r\n const tokenPayload: JwtPayload = jwtDecode(\r\n tokenValue!,\r\n );\r\n\r\n if (isNullOrUndefined(tokenPayload))\r\n {\r\n return true; // No payload could mean an issue with decoding, treat as expired.\r\n }\r\n\r\n return checkJwtTokenExpiry(tokenPayload.exp);\r\n }\r\n catch (error)\r\n {\r\n console.error('Failed to decode token:', error);\r\n\r\n return true; // Any error in decoding should be treated as expired/invalid token.\r\n }\r\n};\r\n\r\nconst checkJwtTokenExpiry = (\r\n tokenExp: number | undefined,\r\n): boolean =>\r\n{\r\n if (\r\n isNullOrUndefined(tokenExp) ||\r\n typeof tokenExp !== 'number'\r\n )\r\n {\r\n return true; // If exp is not a number or undefined, consider the token as expired.\r\n }\r\n\r\n return new Date().getTime() > tokenExp * 1000; // Convert exp to milliseconds and compare\r\n};\r\n"],"names":["onPerfEntry","Function","then","getCLS","getFID","getFCP","getLCP","getTTFB","GetLinkFromKey","key","RouteLinks","find","itm","order","icon","elementTo","component","display","included","showInSideMenu","showInToolbar","A","requiredRole","SuperUser","User","showInBottomMenu","PowerUser","initialState","mode","settings","ThemingSlice","name","reducers","setThemeMode","state","action","payload","setThemePrimaryColor","primaryColor","setThemeSecondaryColor","secondaryColor","setThemeSettings","actions","SimpleSlice","boolValue","intValue","add","subtract","setSimpleState","setSimpleStateBool","setSimpleStateInt","ServiceStore","reducer","config","loading","theming","simple","cart","CartSlice","reducerPath","middleware","getDefaultMiddleware","serializableCheck","concat","options","dispatch","injectedRestApiCart","injectEndpoints","endpoints","build","RestApiOperationsPostCartCreateOrder","mutation","query","queryArg","url","method","body","extraOptions","controller","notificationType","transformResponse","response","invalidatesTags","overrideExisting","useRestApiOperationsPostCartCreateOrderMutation","restApiCart","createOrder","hooks","mutations","injectedRestApiImages","RestApiOperationsGetImagesGetImage","imageId","params","width","height","resizeType","providesTags","keepUnusedDataFor","useRestApiOperationsGetImagesGetImageQuery","useLazyRestApiOperationsGetImagesGetImageQuery","restApiImages","getImage","queries","lazyQueries","injectedRestApiOrders","RestApiOperationsGetOrdersGetAll","userRole","tokenType","RestApiOperationsGetOrdersGetById","id","RestApiOperationsGetOrdersGetForUser","userId","RestApiOperationsGetOrdersGetInvoiceForOrder","orderId","useRestApiOperationsGetOrdersGetAllQuery","useLazyRestApiOperationsGetOrdersGetAllQuery","useRestApiOperationsGetOrdersGetByIdQuery","useLazyRestApiOperationsGetOrdersGetByIdQuery","useRestApiOperationsGetOrdersGetForUserQuery","useLazyRestApiOperationsGetOrdersGetForUserQuery","useRestApiOperationsGetOrdersGetInvoiceForOrderQuery","useLazyRestApiOperationsGetOrdersGetInvoiceForOrderQuery","localEndpoints","restApiOrders","getAll","getById","getForUser","getInvoiceForOrder","injectedRestApiProductCategories","RestApiOperationsGetProductCategoriesGetAll","RestApiOperationsGetProductCategoriesGetAllMinimalTop","RestApiOperationsGetProductCategoriesGetAllMinimal","RestApiOperationsGetProductCategoriesGetAllNames","RestApiOperationsGetProductCategoriesGetById","RestApiOperationsGetProductCategoriesGetWithImagesById","RestApiOperationsPostProductCategoriesCreate","RestApiOperationsPatchProductCategoriesUpdate","RestApiOperationsDeleteProductCategoriesDeleteById","RestApiOperationsDeleteProductCategoriesDeleteMultipleById","useRestApiOperationsGetProductCategoriesGetAllQuery","useLazyRestApiOperationsGetProductCategoriesGetAllQuery","useRestApiOperationsGetProductCategoriesGetAllMinimalTopQuery","useLazyRestApiOperationsGetProductCategoriesGetAllMinimalTopQuery","useRestApiOperationsGetProductCategoriesGetAllMinimalQuery","useLazyRestApiOperationsGetProductCategoriesGetAllMinimalQuery","useRestApiOperationsGetProductCategoriesGetAllNamesQuery","useLazyRestApiOperationsGetProductCategoriesGetAllNamesQuery","useRestApiOperationsGetProductCategoriesGetByIdQuery","useLazyRestApiOperationsGetProductCategoriesGetByIdQuery","useRestApiOperationsGetProductCategoriesGetWithImagesByIdQuery","useLazyRestApiOperationsGetProductCategoriesGetWithImagesByIdQuery","useRestApiOperationsPostProductCategoriesCreateMutation","useRestApiOperationsPatchProductCategoriesUpdateMutation","useRestApiOperationsDeleteProductCategoriesDeleteByIdMutation","useRestApiOperationsDeleteProductCategoriesDeleteMultipleByIdMutation","restApiProductCategories","getAllMinimalTop","getAllMinimal","getAllNames","getWithImagesById","create","update","deleteById","deleteMultipleById","injectedRestApiProducts","RestApiOperationsGetProductsGetAll","RestApiOperationsGetProductsGetFeaturedOrRandom","RestApiOperationsGetProductsGetById","RestApiOperationsGetProductsGetByIdWithImages","RestApiOperationsGetProductsGetIdFromName","RestApiOperationsPostProductsCreate","RestApiOperationsPatchProductsUpdate","RestApiOperationsDeleteProductsDeleteById","RestApiOperationsDeleteProductsDeleteMultipleById","RestApiOperationsGetProductsGetExistingProductColors","RestApiOperationsGetProductsGetExistingProductSizes","useRestApiOperationsGetProductsGetAllQuery","useLazyRestApiOperationsGetProductsGetAllQuery","useRestApiOperationsGetProductsGetFeaturedOrRandomQuery","useLazyRestApiOperationsGetProductsGetFeaturedOrRandomQuery","useRestApiOperationsGetProductsGetByIdQuery","useLazyRestApiOperationsGetProductsGetByIdQuery","useRestApiOperationsGetProductsGetByIdWithImagesQuery","useLazyRestApiOperationsGetProductsGetByIdWithImagesQuery","useRestApiOperationsGetProductsGetIdFromNameQuery","useLazyRestApiOperationsGetProductsGetIdFromNameQuery","useRestApiOperationsPostProductsCreateMutation","useRestApiOperationsPatchProductsUpdateMutation","useRestApiOperationsDeleteProductsDeleteByIdMutation","useRestApiOperationsDeleteProductsDeleteMultipleByIdMutation","useRestApiOperationsGetProductsGetExistingProductColorsQuery","useLazyRestApiOperationsGetProductsGetExistingProductColorsQuery","useRestApiOperationsGetProductsGetExistingProductSizesQuery","useLazyRestApiOperationsGetProductsGetExistingProductSizesQuery","restApiProducts","getFeaturedOrRandom","getByIdWithImages","getIdFromName","getExistingProductColors","getExistingProductSizes","injectedRestApiUSStates","RestApiOperationsGetUSStatesGetAllStatesWithRates","RestApiOperationsGetUSStatesGetAllStates","RestApiOperationsGetUSStatesGetStateFromCode","stateCode","RestApiOperationsGetUSStatesGetStatesFromCodes","stateCodes","RestApiOperationsGetUSStatesGetShippingRateForState","stateAbbreviation","RestApiOperationsPostUSStatesCalculateShippingRateForState","useRestApiOperationsGetUSStatesGetAllStatesWithRatesQuery","useLazyRestApiOperationsGetUSStatesGetAllStatesWithRatesQuery","useRestApiOperationsGetUSStatesGetAllStatesQuery","useLazyRestApiOperationsGetUSStatesGetAllStatesQuery","useRestApiOperationsGetUSStatesGetStateFromCodeQuery","useLazyRestApiOperationsGetUSStatesGetStateFromCodeQuery","useRestApiOperationsGetUSStatesGetStatesFromCodesQuery","useLazyRestApiOperationsGetUSStatesGetStatesFromCodesQuery","useRestApiOperationsGetUSStatesGetShippingRateForStateQuery","useLazyRestApiOperationsGetUSStatesGetShippingRateForStateQuery","useRestApiOperationsPostUSStatesCalculateShippingRateForStateMutation","restApiUSStates","getAllStatesWithRates","getAllStates","getStateFromCode","getStatesFromCodes","getShippingRateForState","calculateShippingRateForState","injectedRestApiUserAccount","RestApiOperationsPatchUserAccountUpdatePassword","RestApiOperationsPostUserAccountRequestPasswordReset","RestApiOperationsPostUserAccountResetPassword","RestApiOperationsPatchUserAccountUpdateUserProfile","RestApiOperationsPostUserAccountRegisterUser","RestApiOperationsPostUserAccountConfirmEmail","useRestApiOperationsPatchUserAccountUpdatePasswordMutation","useRestApiOperationsPostUserAccountRequestPasswordResetMutation","useRestApiOperationsPostUserAccountResetPasswordMutation","useRestApiOperationsPatchUserAccountUpdateUserProfileMutation","useRestApiOperationsPostUserAccountRegisterUserMutation","useRestApiOperationsPostUserAccountConfirmEmailMutation","restApiUserAccount","updatePassword","requestPasswordReset","resetPassword","updateUserProfile","registerUser","confirmEmail","injectedRestApiUserOperations","RestApiOperationsGetUserOperationsGetAllUsers","RestApiOperationsGetUserOperationsGetUser","userEmail","RestApiOperationsGetUserOperationsGetUserInformation","RestApiOperationsGetUserOperationsGetNewRefreshToken","RestApiOperationsGetUserOperationsIsUserLocked","RestApiOperationsGetUserOperationsLockUser","RestApiOperationsGetUserOperationsUnlockUser","RestApiOperationsGetUserOperationsTestAccessToken","RestApiOperationsGetUserOperationsTestRefreshToken","useRestApiOperationsGetUserOperationsGetAllUsersQuery","useLazyRestApiOperationsGetUserOperationsGetAllUsersQuery","useRestApiOperationsGetUserOperationsGetUserQuery","useLazyRestApiOperationsGetUserOperationsGetUserQuery","useRestApiOperationsGetUserOperationsGetUserInformationQuery","useLazyRestApiOperationsGetUserOperationsGetUserInformationQuery","useRestApiOperationsGetUserOperationsGetNewRefreshTokenQuery","useLazyRestApiOperationsGetUserOperationsGetNewRefreshTokenQuery","useRestApiOperationsGetUserOperationsIsUserLockedQuery","useLazyRestApiOperationsGetUserOperationsIsUserLockedQuery","useRestApiOperationsGetUserOperationsLockUserQuery","useLazyRestApiOperationsGetUserOperationsLockUserQuery","useRestApiOperationsGetUserOperationsUnlockUserQuery","useLazyRestApiOperationsGetUserOperationsUnlockUserQuery","useRestApiOperationsGetUserOperationsTestAccessTokenQuery","useLazyRestApiOperationsGetUserOperationsTestAccessTokenQuery","useRestApiOperationsGetUserOperationsTestRefreshTokenQuery","useLazyRestApiOperationsGetUserOperationsTestRefreshTokenQuery","restApiUserOperations","getAllUsers","getUser","getUserInformation","getNewRefreshToken","isUserLocked","lockUser","unlockUser","testAccessToken","testRefreshToken","RestApiMultipleIdsDTO","ids","constructor","data","property","hasOwnProperty","this","init","_data","fromJS","result","toJSON","RestApiProductCategoryMinimalDTO","sortOrder","parentCategoryId","title","subtitle","description","bannerImageId","thumbnailImageId","childCategories","RestApiUserAddressDTO","type","addressLine1","addressLine2","addressLine3","city","postalCode","country","enhancedRestApi","enhanceEndpoints","addTagTypes","getTagTypeFromString","tagName","includes","InvalidateTags","tagKeys","Array","isArray","length","forEach","tagKeyItm","InvalidateTag","Error","tagKey","util","invalidateTags","RestApiCacheInvalidator","GetTagFromString","InvalidateTagFromString","tagType","InvalidateRestApiTags","InvalidateRestApiTag","ClearRestApiCache","InvalidateRestApiCartCache","InvalidateRestApiExampleEntitiesCache","InvalidateRestApiSuperComplexCache","InvalidateRestApiComplexTagCache","InvalidateRestApiAnOptionalTagCache","InvalidateRestApiTheFirstTagCache","InvalidateRestApiTheSecondTagCache","InvalidateRestApiYetAnotherTagCache","InvalidateRestApiYetAnotherDifferentTagCache","InvalidateRestApiImagesCache","InvalidateRestApiOrdersCache","InvalidateRestApiProductCategoriesCache","InvalidateRestApiProductsCache","InvalidateRestApiUserAccountCache","InvalidateRestApiUserOperationsCache","InvalidateRestApiUSStatesCache","useCallback","getInvalidateTagPayload","fetchData","async","jwtToken","headers","fetchOptions","JSON","stringify","fetch","error","getAPIMethodEndpoint","window","AppConfiguration","methods","endpointUrl","attemptToRefreshToken","user","email","tokens","accessToken","value","isAfter","expiration","refreshTokenUrl","status","newTokenJson","json","newToken","toDate","header","parseTokenLocal","storage","SessionStorage","refreshToken","baseRestApi","baseQuery","arg","api","meta","timestamp","Date","now","token","tokensStorage","storedData","retrieve","storedTokens","assertQueryToken","inner","reason","fetchMethod","toUpperCase","bodyRequest","undefined","ok","fetchError","sessionStorage","items","getItemsFromStorage","saveStateToSessionStorage","addItemToCart","item","i","productId","colorId","quantity","push","removeItemFromCart","filter","increaseItemQuantity","decreaseItemQuantity","markItem","checked","unmarkItem","setItemQuantity","newQuantity","Math","max","min","selectedProduct","stockQuantity","clearCart","selectCartItems","selectCartQuantity","reduce","total","ConfigurationData","valid","ConfigurationSlice","loadConfiguration","newState","LoadingControlSlice","isVisible","message","showDialog","hideDialog","setMessage","clearMessage","getAvatar","source","bgColour","md5Hash","padEnd","r","parseInt","substring","g","b","toString","padStart","convertMD5ToColor","getStringFromParts","sx","color","bgcolor","children","getAvatarStyleParts","handleArray","stringResult","handleString","pushIfNotNull","slice","str","extractedChars","parts","firstChar","trim","match","sourceArray","target","element","DEFAULT_MODE","DEFAULT_PRIMARY_COLOR","DEFAULT_SECONDARY_COLOR","DEFAULT_TERTIARY_COLOR","DefaultThemeSettings","tertiaryColor","props","themeState","themeSettings","useState","currentTheme","setCurrentTheme","themeCookie","setThemeCookie","removeThemeCookie","useEffect","newSettings","newThemeState","theme","emptyTheme","GetThemeFromSettingsOrDefaults","retVal","paletteMode","getThemeModeOrDefault","augmentColor","palette","primary","secondary","tertiary","primaryLightVariant","light","primaryDarkVariant","dark","secondaryLightVariant","secondaryDarkVariant","tertiaryLightVariant","tertiaryDarkVariant","background","default","commonColors","Gray","generateColorGraduations","Blue","Red","Green","Purple","Yellow","typography","fontFamily","components","MuiButton","styleOverrides","root","Padding","Margin","borderRadius","textTransform","MuiPaper","backgroundColor","padding","MuiLink","textDecoration","GetSettingsOrDefaults","defaultValue","GetPaletteModeFromThemeMode","HUE_MAPPING","H100","H200","H300","H400","H500","H600","H700","H800","H900","REVERSE_HUE_MAPPING","colorSet","hueMapping","Object","keys","acc","mainColor","getContrastText","augmentName","main","colorToRgba","alpha","finalAlpha","test","isHexColor","hex","replace","parseHexColor","isRgbColor","parsedColor","rgb","a","parseFloat","parseRgbColor","createBoxShadow","angle","distance","blurRadius","createBoxShadowWithAngle","hOffset","vOffset","calculateOffsets","radians","normalizeAngle","PI","round","cos","sin","UserRole","withSecurity","Component","loggedIn","isLoggedIn","setIsLoggedIn","currentUser","setCurrentUser","role","errorCode","showContactAdminButton","variant","parseLoginResponse","loginRes","parseLoginResult","userInfo","parseUserInformation","loginTokens","parseTokens","isLockedOut","requiresTwoFactor","NotAllowed","succeeded","firstName","lastName","currRole","parseUserRole","roleName","lastLogin","values","parseToken"],"sourceRoot":""}