{"version":3,"file":"static/chunks/4331-a0f8ce66b4dcf24a.js","mappings":"ybAMe,SAASA,EAAT,GAAyD,IAAjCC,EAAiC,EAAjCA,cAAeC,EAAkB,EAAlBA,eAC5CC,EAAYC,EAAAA,EAAeH,GACjC,OAAKE,GAGE,SAACA,E,qWAAD,IAAeD,KAFX,uCAAeD,EAAf","sources":["webpack://_N_E/./pages/[...path].js"],"sourcesContent":["import querystring from 'querystring';\nimport { getPage, getRedirect, getViewData } from '../api/wagtail';\nimport LazyContainers from '../containers/LazyContainers';\n\nconst isProd = process.env.NODE_ENV === 'production';\n\nexport default function CatchAllPage({ componentName, componentProps }) {\n const Component = LazyContainers[componentName];\n if (!Component) {\n return

Component {componentName} not found

;\n }\n return ;\n}\n\n// For SSR\nexport async function getServerSideProps({ req, params, res }) {\n let path = params?.path || [];\n path = path.join('/');\n\n const { host } = req.headers;\n let queryParams = new URL(req.url, `https://${host}`).search;\n if (queryParams.indexOf('?') === 0) {\n queryParams = queryParams.substr(1);\n }\n queryParams = querystring.parse(queryParams);\n\n // Try to serve page\n try {\n const {\n componentName,\n componentProps,\n redirect,\n customResponse,\n statusCode,\n } = await getPage(\n path,\n queryParams, {\n headers: {\n cookie: req.headers.cookie,\n host,\n },\n }\n );\n\n if (customResponse) {\n const { body, body64, contentType } = customResponse;\n res.setHeader('Content-Type', contentType);\n res.statusCode = 200;\n res.write(\n body64 ? Buffer.from(body64, 'base64') : body\n );\n res.end();\n\n return { props: {} };\n }\n\n if (redirect) {\n const { destination, isPermanent } = redirect;\n return {\n redirect: {\n destination: destination,\n permanent: isPermanent,\n }\n }\n }\n\n if (statusCode) {\n res.statusCode = statusCode;\n }\n\n return { props: { componentName, componentProps } };\n } catch (err) {\n // When in development, show django error page on error\n if (!isProd && err.response.status >= 500) {\n const html = await err.response.text();\n return {\n props: {\n componentName: 'PureHtmlPage',\n componentProps: { html },\n },\n };\n }\n\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Try to serve redirect\n try {\n const redirect = await getRedirect(path, queryParams, {\n headers: {\n cookie: req.headers.cookie,\n host,\n },\n });\n const { destination, isPermanent } = redirect;\n return {\n redirect: {\n destination: destination,\n permanent: isPermanent,\n }\n }\n } catch (err) {\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Try to locate moved pages and redirect\n try {\n const { redirect } = await getViewData(\"moved_page\", { htmlPath: path, ...queryParams }, {\n headers: {\n cookie: req.headers.cookie,\n host,\n },\n });\n const { destination, isPermanent } = redirect;\n return {\n redirect: {\n destination: destination,\n permanent: isPermanent,\n }\n }\n } catch (err) {\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Load 404 page\n try {\n const { componentName, componentProps } = await getViewData(\n '404',\n {\n path,\n },\n {\n headers: {\n cookie: req.headers.cookie,\n host,\n },\n }\n );\n\n res.statusCode = 404\n\n return { props: { componentName, componentProps } };\n } catch (err) {\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Serve 404 page\n return { notFound: true };\n}\n"],"names":["CatchAllPage","componentName","componentProps","Component","LazyContainers"],"sourceRoot":""}