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AK9C,CAEA,IAAMT,ECjGS,WAEiB,2BAD3BU,EAAS,yBAATA,EAAS,gBAEZ,OAAO,SAAmB,GAA6B,IAA3BlE,EAAQ,EAARA,SAC1B,OACE,gCACGkE,EAAUC,aACT,SAACC,EAAK3C,GAAQ,OACZ,gBAACA,EAAQ,KAAE2C,EAAe,GAE5BpE,GAIR,CACF,CDkFkBqE,CAChBC,EAAAA,IAUF,SAA4C,GAIxC,IAHFtE,EAAQ,EAARA,SAIMuE,GAAS/D,EAAAA,EAAAA,MAEf,OACE,gBAAC,EAAsC,CACrCS,mBAAoBsD,EAAOC,gBAE1BxE,EAGP,GAtBEyE,EAAAA,GACAC,EAAAA,IAuBF,SAA6B,GAAyC,IAAvC1E,EAAQ,EAARA,SAC7B,OACE,gBAAC,KAAuB,CAAC2E,OAAQhD,GAC9B3B,EAGP,GA3BEM,EACAsE,EAAAA,GACAC,EAAAA,E","sources":["pages/errors/ResourceNotFoundPage.tsx","pages/errors/ServiceProblemsPage.tsx","components/PageErrorBoundary.tsx","contexts/ConfiguredMsalProvider.tsx","../../explore-education-statistics-common/src/contexts/ApplicationInsightsContext.tsx","pages/errors/PageNotFoundPage.tsx","App.tsx","../../explore-education-statistics-common/src/hocs/composeProviders.tsx"],"sourcesContent":["import Page from '@admin/components/Page';\nimport React from 'react';\n\nconst ResourceNotFoundPage = () => {\n return (\n \n

There was a problem accessing a resource.

\n

Try again later.

\n
\n );\n};\n\nexport default ResourceNotFoundPage;\n","import Page from '@admin/components/Page';\nimport React from 'react';\n\nconst ServiceProblemsPage = () => {\n return (\n \n

Try again later.

\n
\n );\n};\n\nexport default ServiceProblemsPage;\n","import ForbiddenPage from '@admin/pages/errors/ForbiddenPage';\nimport ResourceNotFoundPage from '@admin/pages/errors/ResourceNotFoundPage';\nimport ServiceProblemsPage from '@admin/pages/errors/ServiceProblemsPage';\nimport { ErrorControlContextProvider } from '@common/contexts/ErrorControlContext';\nimport logger from '@common/services/logger';\nimport { isAxiosError } from 'axios';\nimport React, { Component, ReactNode } from 'react';\nimport { RouteComponentProps, withRouter } from 'react-router';\n\ninterface State {\n errorCode?: number;\n}\n\ninterface Props extends RouteComponentProps {\n children: ReactNode;\n}\n\n/**\n * This component is responsible for rendering error pages of\n * specific types, or a fallback \"Service problems\" page\n * dependant on the type of error encountered.\n */\nclass PageErrorBoundary extends Component {\n public state: State = {};\n\n private unregisterCallback?: () => void;\n\n private errorPages = {\n forbidden: () => {\n this.setState({\n errorCode: 403,\n });\n },\n };\n\n public componentDidMount() {\n const { history } = this.props;\n\n this.unregisterCallback = history.listen(() => {\n this.setState({\n errorCode: undefined,\n });\n });\n\n window.addEventListener('unhandledrejection', this.handlePromiseRejections);\n }\n\n public componentDidCatch(error: Error) {\n logger.error(error);\n\n this.setState({\n errorCode: 500,\n });\n }\n\n public componentWillUnmount() {\n if (this.unregisterCallback) {\n this.unregisterCallback();\n }\n\n window.removeEventListener(\n 'unhandledrejection',\n this.handlePromiseRejections,\n );\n }\n\n private handlePromiseRejections = (event: PromiseRejectionEvent) => {\n this.handleError(event.reason);\n };\n\n private handleError = (error: unknown) => {\n logger.error(error);\n\n this.setState({\n errorCode: isAxiosError(error) ? error.response?.status : 500,\n });\n };\n\n public render() {\n const { handleError, errorPages } = this;\n const { children } = this.props;\n const { errorCode } = this.state;\n\n if (!errorCode) {\n return (\n \n {children}\n \n );\n }\n\n if (errorCode === 401 || errorCode === 403) {\n return ;\n }\n\n if (errorCode === 404) {\n return ;\n }\n\n return ;\n }\n}\n\nexport default withRouter(PageErrorBoundary);\n","import React, { ReactNode } from 'react';\nimport { useConfig } from '@admin/contexts/ConfigContext';\nimport useAsyncHandledRetry from '@common/hooks/useAsyncHandledRetry';\nimport { createMsalInstance } from '@admin/auth/msal';\nimport { MsalProvider } from '@azure/msal-react';\n\ninterface Props {\n children?: ReactNode;\n}\n\n/**\n * This component is responsible for providing child components with a\n * configured MSAL instance, accessed via the \"useMsal()\" hook.\n *\n * The configuration for the MSAL instance is acquired from the\n * ConfigurationController in the Admin API, and has the ability to redirect\n * the user to the Identity Provider's login page, handle post-login redirects,\n * and acquire new access tokens for the current user.\n */\nexport const ConfiguredMsalProvider = ({ children }: Props) => {\n const { oidc } = useConfig();\n const { value: msalInstance, isLoading } = useAsyncHandledRetry(() =>\n createMsalInstance(oidc),\n );\n return !isLoading && msalInstance ? (\n {children}\n ) : null;\n};\n\nexport default ConfiguredMsalProvider;\n","import { ApplicationInsights } from '@microsoft/applicationinsights-web';\nimport React, {\n createContext,\n ReactNode,\n useContext,\n useEffect,\n useState,\n} from 'react';\n\nconst ApplicationInsightsContext = createContext<\n ApplicationInsights | undefined\n>(undefined);\n\ninterface ApplicationInsightsContextProviderProps {\n children: ReactNode;\n instrumentationKey: string | Promise;\n}\n\nexport const ApplicationInsightsContextProvider = ({\n children,\n instrumentationKey,\n}: ApplicationInsightsContextProviderProps) => {\n const [appInsights, setAppInsights] = useState();\n\n useEffect(() => {\n import('@common/services/applicationInsightsService').then(\n async ({ initApplicationInsights }) => {\n const applicationInsights = initApplicationInsights(\n await instrumentationKey,\n );\n\n setAppInsights(applicationInsights);\n },\n );\n }, [instrumentationKey]);\n\n return (\n \n {children}\n \n );\n};\n\nexport function useApplicationInsights(): ApplicationInsights | undefined {\n return useContext(ApplicationInsightsContext);\n}\n","import Page from '@admin/components/Page';\nimport React from 'react';\n\nconst PageNotFoundPage = () => {\n return (\n \n

\n If you typed the web address, check it is correct.\n

\n

\n If you pasted the web address, check you copied the entire address.\n

\n

\n If the web address is correct or you clicked a link or button and ended\n up on this page,{' '}\n \n contact our Explore education statistics team\n {' '}\n if you need any help or support.\n

\n
\n );\n};\n\nexport default PageNotFoundPage;\n","import PageErrorBoundary from '@admin/components/PageErrorBoundary';\nimport ProtectedRoute from '@admin/components/ProtectedRoute';\nimport { AuthContextProvider } from '@admin/contexts/AuthContext';\nimport {\n ConfigContextProvider,\n useConfig,\n} from '@admin/contexts/ConfigContext';\nimport ServiceProblemsPage from '@admin/pages/errors/ServiceProblemsPage';\nimport routes, { publicRoutes } from '@admin/routes/routes';\nimport { ConfiguredMsalProvider } from '@admin/contexts/ConfiguredMsalProvider';\nimport {\n ApplicationInsightsContextProvider as BaseApplicationInsightsContextProvider,\n useApplicationInsights,\n} from '@common/contexts/ApplicationInsightsContext';\nimport { NetworkActivityContextProvider } from '@common/contexts/NetworkActivityContext';\nimport composeProviders from '@common/hocs/composeProviders';\nimport useAsyncRetry from '@common/hooks/useAsyncRetry';\nimport {\n QueryClient,\n QueryClientProvider as BaseQueryClientProvider,\n} from '@tanstack/react-query';\nimport React, { lazy, ReactNode, Suspense, useEffect } from 'react';\nimport { Route, Switch, useHistory } from 'react-router';\nimport { BrowserRouter } from 'react-router-dom';\nimport PageNotFoundPage from './pages/errors/PageNotFoundPage';\nimport { LastLocationContextProvider } from './contexts/LastLocationContext';\n\nconst queryClient = new QueryClient();\n\nconst PrototypeIndexPage = lazy(\n () => import('@admin/prototypes/PrototypeIndexPage'),\n);\n\nfunction ApplicationInsightsTracking() {\n const appInsights = useApplicationInsights();\n const history = useHistory();\n\n useEffect(() => {\n if (appInsights) {\n appInsights.trackPageView({\n uri: history.location.pathname,\n });\n\n history.listen(location => {\n appInsights.trackPageView({\n uri: location.pathname,\n });\n });\n }\n\n document.body.classList.add('js-enabled', 'govuk-frontend-supported');\n }, [appInsights, history]);\n\n return null;\n}\n\nfunction PrototypesEntry() {\n const { value: prototypeRoutes = [] } = useAsyncRetry(() =>\n import('./prototypes/prototypeRoutes').then(module => module.default),\n );\n\n return (\n }>\n \n \n {prototypeRoutes?.map(route => (\n \n ))}\n \n \n );\n}\n\nexport default function App() {\n return (\n \n \n \n\n \n {Object.entries(publicRoutes).map(([key, route]) => (\n \n ))}\n\n {Object.entries(routes).map(([key, route]) => (\n \n ))}\n\n {/* Prototype pages are protected by default. To open them up change the ProtectedRoute to: */}\n {/* */}\n permissions.isBauUser}\n component={PrototypesEntry}\n />\n\n \n \n \n \n );\n}\n\nconst Providers = composeProviders(\n ConfigContextProvider,\n ApplicationInsightsContextProvider,\n BrowserRouter,\n NetworkActivityContextProvider,\n QueryClientProvider,\n ConfiguredMsalProvider,\n AuthContextProvider,\n LastLocationContextProvider,\n);\n\nfunction ApplicationInsightsContextProvider({\n children,\n}: {\n children?: ReactNode;\n}) {\n const config = useConfig();\n\n return (\n \n {children}\n \n );\n}\n\nfunction QueryClientProvider({ children }: { children?: ReactNode }) {\n return (\n \n {children}\n \n );\n}\n","import React, { ComponentType, ReactNode } from 'react';\n\ninterface ProviderProps {\n children?: ReactNode;\n}\n\nexport default function composeProviders(\n ...providers: ComponentType[]\n): ComponentType {\n return function Providers({ children }: ProviderProps) {\n return (\n <>\n {providers.reduceRight(\n (acc, Provider) => (\n {acc}\n ),\n children,\n )}\n \n );\n };\n}\n"],"names":["Page","title","className","PageErrorBoundary","state","unregisterCallback","errorPages","forbidden","setState","errorCode","handlePromiseRejections","event","handleError","reason","error","logger","isAxiosError","response","status","history","this","props","listen","undefined","window","addEventListener","removeEventListener","children","ForbiddenPage","ErrorControlContext","value","Component","withRouter","ConfiguredMsalProvider","oidc","useConfig","useAsyncHandledRetry","createMsalInstance","msalInstance","isLoading","instance","ApplicationInsightsContext","createContext","ApplicationInsightsContextProvider","instrumentationKey","useState","appInsights","setAppInsights","useEffect","then","initApplicationInsights","applicationInsights","Provider","href","queryClient","QueryClient","PrototypeIndexPage","lazy","ApplicationInsightsTracking","useContext","useHistory","trackPageView","uri","location","pathname","document","body","classList","add","PrototypesEntry","useAsyncRetry","module","default","prototypeRoutes","Suspense","fallback","exact","path","component","map","route","key","App","Providers","Object","entries","publicRoutes","routes","ProtectedRoute","protectionAction","permissions","isBauUser","PageNotFoundPage","providers","reduceRight","acc","composeProviders","ConfigContextProvider","config","appInsightsKey","BrowserRouter","NetworkActivityContextProvider","client","AuthContextProvider","LastLocationContextProvider"],"sourceRoot":""}