{"version":3,"file":"js/client_components_loaders_MainLoader_jsx-client_lib_Api_jsx.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAEA;AAGA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;AClFA;AACA;AAAA;AAEA;AAAA;AAAA;AAIA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAjDA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDA;;;;;;;;;;;;;;;;;ACvDA;AACA;AACA;AAEA;AAEA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjBA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AAEA;AAEA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AAEA;AAAA;AAAA;AACA;AAAA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAEA;;;;;;;;;;;AC/JA;AACA","sources":["webpack://@fortressiq/trinity/./client/components/flash/Flash.js","webpack://@fortressiq/trinity/./client/components/flash/flashStore.js","webpack://@fortressiq/trinity/./client/components/loaders/MainLoader.jsx","webpack://@fortressiq/trinity/./client/lib/Api.jsx","webpack://@fortressiq/trinity/./client/components/loaders/mainLoader.scss"],"sourcesContent":["/*\n * Avoid using this as much as possible. Just directly use the hook.\n * Only using it for other js files that aren't react components\n */\nimport { useEffect } from 'react'\nimport { observer } from 'mobx-react'\nimport { autorun } from 'mobx'\nimport { useNotification } from '@fortressiq/fiq-ds'\n\nimport store from './flashStore.js'\n\nexport const FLASH_LEVELS = {\n ERROR: 'error',\n INFO: 'info',\n SUCCESS: 'success',\n WARNING: 'warning',\n}\n\nexport const sidebarWidthPlusSpacer = 60\n\nconst onCloseHandler = (key, onClose) => {\n if (onClose) {\n onClose()\n }\n\n store.remove(key)\n}\n\nconst Flash = () => {\n const { addNotification, removeNotification, updateNotification } = useNotification()\n\n useEffect(\n () =>\n autorun(() => {\n store.messages.forEach(\n ({ message, description, displayed, remove, cta, key, level, onClose, ...notificationProps }) => {\n if (!displayed) {\n const nProps = {\n align: { left: sidebarWidthPlusSpacer },\n cta,\n description,\n id: key,\n key: key,\n message,\n onClose: () => onCloseHandler(key, onClose),\n type: level,\n ...notificationProps,\n position: 'bottom-left',\n }\n\n if (store.messages.filter(m => m.id === key).length > 1) {\n updateNotification(key, nProps)\n } else {\n addNotification(nProps)\n }\n\n store.messageDisplayed(key)\n } else if (remove) {\n removeNotification(key)\n store.remove(key)\n }\n }\n )\n }),\n [addNotification, removeNotification, updateNotification]\n )\n\n return null\n}\n\nconst send = ({ message, description, cta }, level, options = {}) =>\n store.add({ message, description, cta }, level, options)\nFlash.error = ({ message, description, cta }) => send({ message, description, cta }, FLASH_LEVELS.ERROR)\nFlash.info = ({ message, description, cta }, options) => send({ message, description, cta }, FLASH_LEVELS.INFO, options)\nFlash.success = ({ message, description, cta }, options) =>\n send({ message, description, cta }, FLASH_LEVELS.SUCCESS, options)\nFlash.warning = ({ message, description, cta }, options) =>\n send({ message, description, cta }, FLASH_LEVELS.WARNING, options)\nFlash.remove = key => {\n store.close(key)\n}\n\nexport default observer(Flash)\n","import { observable, action } from 'mobx'\nimport shortid from 'shortid'\n\nclass FlashStore {\n @observable messages = []\n\n @action\n add({ message, description, cta }, level, options = {}) {\n const newMessage = {\n key: options.key || shortid.generate(),\n message,\n description,\n cta,\n level,\n ...options,\n }\n this.messages.push(newMessage)\n return newMessage\n }\n\n @action\n remove(key) {\n this.messages = this.messages.filter(msg => msg.key !== key)\n }\n\n @action\n messageDisplayed(key) {\n this.messages = this.messages.map(msg => {\n if (msg.key === key) {\n return { ...msg, displayed: true }\n }\n return msg\n })\n }\n\n @action\n close(key) {\n let changed = false\n\n const messages = this.messages.map(msg => {\n if (msg.key === key) {\n if (!msg.remove) {\n changed = true\n return { ...msg, remove: true }\n }\n }\n return msg\n })\n\n if (changed) {\n this.messages = messages\n }\n }\n}\n\nexport default new FlashStore()\n","import React from 'react'\nimport classNames from 'classnames'\nimport { Element } from '@fortressiq/fiq-ds'\n\nimport css from './mainLoader.scss'\n\nconst MainLoader = ({ className, style }) => (\n \n
\n
\n
\n
\n
\n
\n \n)\n\nexport default MainLoader\n","/* eslint-disable no-console */\nimport React from 'react'\nimport ReactGA from 'react-ga'\n\nimport DOMPurify from 'dompurify'\n\nimport axios from 'axios'\nimport snakeCase from 'lodash/snakeCase'\n\nimport Flash from 'components/flash/Flash'\n\naxios.interceptors.request.use(\n config => {\n config.metadata = { startTime: new Date() }\n return config\n },\n error => {\n return Promise.reject(error)\n }\n)\n\naxios.interceptors.response.use(\n response => {\n response.config.metadata.endTime = new Date()\n response.duration = response.config.metadata.endTime - response.config.metadata.startTime\n return response\n },\n error => {\n error.config.metadata.endTime = new Date()\n error.duration = error.config.metadata.endTime - error.config.metadata.startTime\n return Promise.reject(error)\n }\n)\n\nexport const toRailsHash = params =>\n Object.entries(params).reduce((acc, [key, val]) => ({ ...acc, [snakeCase(key)]: val }), {})\n\nclass Api {\n constructor() {\n const csrfToken = document.querySelector('meta[name=csrf-token]')\n this.token = csrfToken && csrfToken.content\n }\n\n delete(url, params) {\n return this.send('DELETE', url, params, {})\n }\n\n get(url, params, appendExt = true) {\n return this.send('GET', url, params, {}, appendExt)\n }\n\n patch(url, data) {\n return this.send('PATCH', url, {}, data)\n }\n\n post(url, data) {\n return this.send('POST', url, {}, data)\n }\n\n put(url, data, appendExt = true) {\n return this.send('PUT', url, {}, data, appendExt)\n }\n\n upload(url, data, method = 'POST') {\n const form = new FormData()\n\n Object.keys(data).forEach(key => {\n form.append(key, data[key])\n })\n\n return this.send(method, url, {}, form)\n }\n\n cleanURL(appendExt, url) {\n const newUrl = appendExt ? `${url}.json` : url\n return DOMPurify.sanitize(newUrl)\n }\n\n send(method, url, params, data, appendExt = true) {\n const cancelable = axios.CancelToken.source()\n\n const promise = axios\n .request({\n url: this.cleanURL(appendExt, url),\n method: method,\n params: params,\n data: data,\n cancelToken: cancelable.token,\n headers: {\n Accept: 'application/json',\n 'X-CSRF-Token': this.token,\n 'X-Requested-With': 'XMLHttpRequest',\n },\n })\n .catch(error => {\n this.onFail(error)\n throw error\n })\n\n promise.cancel = (reason = 'Request canceled') => {\n cancelable.cancel(reason)\n }\n\n promise.then(response =>\n ReactGA.timing({\n category: 'API Performance',\n variable: response.config.url,\n label: response.config.method,\n value: response.duration,\n })\n )\n\n return promise\n }\n\n onFail(error) {\n if (axios.isCancel(error)) return\n\n const { response } = error\n const { data } = response\n\n if (response.status === 304) return\n\n if (response.status === 401) {\n location = '/users/sign_in'\n return\n }\n\n if (response.status === 503) {\n location = '/'\n return\n }\n\n let message = error.toString()\n\n if (typeof data === 'object') {\n if (response.status === 422) {\n if (data.error) {\n message = data.error\n } else if (data.errors) {\n message = Array.isArray(data.errors) ? data.errors.join('\\n') : data.errors\n }\n } else {\n message = (\n

\n {data.type}: {data.error}\n

\n )\n }\n } else {\n message = 'Unknown Error'\n console.warn(data)\n }\n if (response.status !== 502) {\n Flash.error({ message: 'Server Error', description: message })\n }\n }\n}\n\nexport default new Api()\n","// extracted by mini-css-extract-plugin\nexport default {\"loaderLayout\":\"mainLoader-loaderLayout__B0COf\",\"loaderContainer\":\"mainLoader-loaderContainer__nTA1F\",\"blockLoader\":\"mainLoader-blockLoader__uW5v9\",\"aniCube\":\"mainLoader-aniCube__fFewa\",\"lowerLeft\":\"mainLoader-lowerLeft__FpJol mainLoader-aniCube__fFewa\",\"colorLL\":\"mainLoader-colorLL__YgBaB\",\"lowerRight\":\"mainLoader-lowerRight__LEGiS mainLoader-aniCube__fFewa\",\"colorLR\":\"mainLoader-colorLR__gFDhQ\",\"topRight\":\"mainLoader-topRight__EY4to mainLoader-aniCube__fFewa\",\"colorTR\":\"mainLoader-colorTR__vdKjp\",\"topLeft\":\"mainLoader-topLeft__M44Zy mainLoader-aniCube__fFewa\",\"colorTL\":\"mainLoader-colorTL__GuYO8\",\"opacity\":\"mainLoader-opacity__u0NgR\"};"],"names":[],"sourceRoot":""}