{\n private _hasHeadManager: boolean\n\n emitChange = (): void => {\n if (this._hasHeadManager) {\n this.props.headManager.updateHead(\n this.props.reduceComponentsToState(\n [...this.props.headManager.mountedInstances],\n this.props\n )\n )\n }\n }\n\n constructor(props: any) {\n super(props)\n this._hasHeadManager =\n this.props.headManager && this.props.headManager.mountedInstances\n\n if (isServer && this._hasHeadManager) {\n this.props.headManager.mountedInstances.add(this)\n this.emitChange()\n }\n }\n componentDidMount() {\n if (this._hasHeadManager) {\n this.props.headManager.mountedInstances.add(this)\n }\n this.emitChange()\n }\n componentDidUpdate() {\n this.emitChange()\n }\n componentWillUnmount() {\n if (this._hasHeadManager) {\n this.props.headManager.mountedInstances.delete(this)\n }\n this.emitChange()\n }\n\n render() {\n return null\n }\n}\n","import React, { ReactElement, ReactNode } from 'react';\nimport { AppProps } from 'next/app';\nimport Head from 'next/head';\n\nimport { GraphQLClient, GraphQLProvider } from 'graphql-clientgen';\nimport { API_URL } from '../../config/apiURL';\nimport { AppMethods, AppMethodsInfo } from '../../client/client';\nimport { graphqlAuthMiddleware } from '../utils/graphqlAuthMiddleware';\nimport { graphqlLogsMiddleware } from '../utils/graphqlLogsMiddleware';\nimport '../theme/index.less';\nimport { UserProvider } from '../hooks/useUser';\nimport { PositivatorContext } from '../components/Positivator/usePositivatorState';\nimport type { NextPage } from 'next';\n\nexport type NextPageWithLayout = NextPage
& {\n getLayout?: (page: ReactElement) => ReactNode;\n};\n\ntype AppPropsWithLayout = AppProps & {\n Component: NextPageWithLayout;\n};\n\nconst MyApp: React.FC = function MyApp({\n Component,\n pageProps\n}: AppPropsWithLayout) {\n const client = React.useMemo(() => {\n return new GraphQLClient({\n url: API_URL,\n methods: AppMethods,\n methodsInfo: AppMethodsInfo,\n middleware: [graphqlAuthMiddleware, graphqlLogsMiddleware]\n });\n }, []);\n\n const getLayout = Component.getLayout ?? ((page) => page);\n\n return (\n <>\n \n \n \n \n \n \n \n \n {favIcons()}\n {splash()}\n \n\n \n \n {() => (\n \n {getLayout()}\n \n )}\n \n \n >\n );\n};\n\nexport default MyApp;\n\nfunction favIcons(color = '#004691') {\n return (\n <>\n \n\n \n \n \n \n \n \n >\n );\n}\nfunction splash() {\n return (\n <>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n >\n );\n}\n","import React from 'react'\n\nexport const AmpStateContext: React.Context = React.createContext({})\n\nif (process.env.NODE_ENV !== 'production') {\n AmpStateContext.displayName = 'AmpStateContext'\n}\n","import { Context, Middleware } from 'graphql-clientgen';\nimport { UserSession } from './UserSession';\nimport { message } from 'antd';\n\nexport const graphqlAuthMiddleware: Middleware = async (ctx) => {\n handleApiErrors(ctx);\n\n const token = UserSession.getToken();\n\n if (token) {\n ctx.requestConfig.headers = {\n ...ctx.requestConfig.headers,\n Authorization: `bearer ${token}`\n };\n }\n\n // quando usamos um token temporario, a api pode retornar\n // um novo token permanente no response header authorization\n // quando isso ocorre, salvamos o novo token permanente\n if (ctx.fetchResponse) {\n const newToken = ctx.fetchResponse.headers.get('authorization');\n if (newToken) {\n UserSession.setItem('temp_token', newToken);\n }\n }\n\n return ctx;\n};\n\nconst handleApiErrors = (ctx: Context) => {\n if (!ctx.errors) return;\n if (ctx.action !== 'complete') return;\n if (ctx.methodConfig.entityName === 'User') return; // nao notificar 401 quando fetch de user\n\n const error = ctx.errors.join();\n\n ctx.errors.forEach(function (err: string | Record) {\n const msg = typeof err === 'string' ? err : err.message;\n if (msg === '401' || msg.match(/Unauthorized/i)) {\n localStorage.clear();\n if (!window.location.pathname.match(/login/)) {\n window.location.href = '/';\n }\n }\n });\n\n if (typeof window !== 'undefined') {\n if (error.match(/CLIENT_INFO::/)) {\n return message.info(error.replace('CLIENT_INFO::', ''));\n }\n\n if (error.match(/CLIENT_WARNING::/)) {\n return message.warn(error.replace('CLIENT_WARNING::', ''));\n }\n\n message.error(`${ctx.methodConfig.entityName}: ${error}`);\n }\n\n return ctx;\n};\n","import { createLessContext, UseLessAPI } from '../../hooks/useLess';\nimport { PositivatorItem } from '../../../client/types';\n\nfunction initialState() {\n return {\n positivatorModalData: null as null | PositivatorItem\n };\n}\n\ntype State = ReturnType;\n\nexport const PositivatorContext = createLessContext({\n factory() {\n return initialState();\n },\n\n actions(api: UseLessAPI) {\n return {\n closePositivatorModal() {\n api.setState({\n positivatorModalData: null\n });\n },\n\n openPositivatorModal(positivator: PositivatorItem) {\n api.setState({\n positivatorModalData: positivator\n });\n }\n };\n }\n});\n"],"sourceRoot":""}