@dr.pogodin/react-utils 1.21.2 → 1.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,3 +13,5 @@ rapid development and prototyping.
13
13
  implements required setup, and provides usage examples.
14
14
 
15
15
  [**Documentation**](https://dr.pogodin.studio/docs/react-utils/index.html)
16
+
17
+ [![Sponsor](.README/sponsor.png)](https://github.com/sponsors/birdofpreyru)
@@ -11,7 +11,7 @@ var _url = require("url");
11
11
  var _lodash = require("lodash");
12
12
  var _compression = _interopRequireDefault(require("compression"));
13
13
  var _cookieParser = _interopRequireDefault(require("cookie-parser"));
14
- var _csurf = _interopRequireDefault(require("csurf"));
14
+ var _csurf = _interopRequireDefault(require("@dr.pogodin/csurf"));
15
15
  var _express = _interopRequireDefault(require("express"));
16
16
  var _serveFavicon = _interopRequireDefault(require("serve-favicon"));
17
17
  var _helmet = _interopRequireDefault(require("helmet"));
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["defaultCspSettings","directives","mapValues","helmet","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","cloneDeep","factory","webpackConfig","options","rendererOps","pick","renderer","rendererFactory","publicPath","output","server","express","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","compression","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","nonce","uuid","cspNonce","cspSettings","cspSettingsHook","favicon","send","json","limit","urlencoded","extended","cookieParser","requestIp","mw","csrf","cookie","loggerMiddleware","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","pathToFileURL","process","cwd","sep","webpack","require","webpackDevMiddleware","webpackHotMiddleware","compiler","serverSideRender","onExpressJsSetup","newError","ERRORS","NOT_FOUND","CODES","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","message","getErrorForCode","env","NODE_ENV","undefined"],"sources":["../../../src/server/server.js"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'path';\nimport { pathToFileURL } from 'url';\n\nimport {\n cloneDeep,\n mapValues,\n pick,\n} from 'lodash';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from 'csurf';\nimport express from 'express';\nimport favicon from 'serve-favicon';\nimport helmet from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\n\nimport rendererFactory from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => array.filter((item) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\ndefaultCspSettings.directives['script-src'].push(\"'unsafe-eval'\");\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings() {\n return cloneDeep(defaultCspSettings);\n}\n\nexport default async function factory(webpackConfig, options) {\n const rendererOps = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output;\n\n const server = express();\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n return res.redirect(url);\n }\n return next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use((req, res, next) => {\n req.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req.cspNonce = req.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings = cloneDeep(defaultCspSettings);\n cspSettings.directives['script-src'].push(`'nonce-${req.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n });\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => res.send('User-agent: *\\nDisallow:'));\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser());\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token('ip', (req) => req.clientIp);\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n write: options.logger.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output.path,\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable global-require */\n /* eslint-disable import/no-extraneous-dependencies */\n /* eslint-disable import/no-unresolved */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n };\n }\n\n const webpack = require('webpack');\n const webpackDevMiddleware = require('webpack-dev-middleware');\n const webpackHotMiddleware = require('webpack-hot-middleware');\n const compiler = webpack(webpackConfig);\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable global-require */\n /* eslint-enable import/no-extraneous-dependencies */\n /* eslint-enable import/no-unresolved */\n\n server.use(publicPath, express.static(webpackConfig.output.path));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((error, req, res, next) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) return next(error);\n\n const status = error.status || CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= CODES.INTERNAL_SERVER_ERROR;\n\n // Log server-side errors always, client-side at debug level only.\n options.logger.log(serverSide ? 'error' : 'debug', error);\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n return undefined;\n });\n }\n\n return server;\n}\n"],"mappings":";;;;;;;;AAIA;AACA;AAEA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAzBA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG;EACzBC,UAAU,EAAE,IAAAC,iBAAS,EACnBC,eAAM,CAACC,qBAAqB,CAACC,oBAAoB,EAAE;EAEnD;EACA;EACA;EACA;EACCC,KAAK,IAAKA,KAAK,CAACC,MAAM,CAAEC,IAAI,IAAKA,IAAI,KAAK,QAAQ,CAAC;AAExD,CAAC;AACDR,kBAAkB,CAACC,UAAU,CAAC,WAAW,CAAC,GAAG,CAC3C,QAAQ;AAER;AACA;AACA,uBAAuB,CACxB;AACDD,kBAAkB,CAACC,UAAU,CAAC,YAAY,CAAC,CAACQ,IAAI,CAAC,eAAe,CAAC;;AAEjE;AACA;AACA;AACA,OAAOT,kBAAkB,CAACC,UAAU,CAAC,2BAA2B,CAAC;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,qBAAqB,GAAG;EACtC,OAAO,IAAAC,iBAAS,EAACX,kBAAkB,CAAC;AACtC;AAEe,eAAeY,OAAO,CAACC,aAAa,EAAEC,OAAO,EAAE;EAC5D,MAAMC,WAAW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AAIM,OAAO,GAAGN,KAAK,CAACM,OAAO,IAAI,IAAAC,uBAAe,EAACL,MAAM,CAAC;MACtD,IAAIE,UAAU,IAAIpB,OAAO,CAACwB,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACvDH,OAAO,GAAGX,cAAM,CAACQ,qBAAqB;MACxC;MAEAlE,GAAG,CAACiE,MAAM,CAACA,MAAM,CAAC,CAAC9C,IAAI,CAACkD,OAAO,CAAC;MAChC,OAAOI,SAAS;IAClB,CAAC,CAAC;EACJ;EAEA,OAAOhF,MAAM;AACf"}
1
+ {"version":3,"file":"server.js","names":["defaultCspSettings","directives","mapValues","helmet","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","cloneDeep","factory","webpackConfig","options","rendererOps","pick","renderer","rendererFactory","publicPath","output","server","express","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","compression","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","nonce","uuid","cspNonce","cspSettings","cspSettingsHook","favicon","send","json","limit","urlencoded","extended","cookieParser","requestIp","mw","csrf","cookie","loggerMiddleware","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","pathToFileURL","process","cwd","sep","webpack","require","webpackDevMiddleware","webpackHotMiddleware","compiler","serverSideRender","onExpressJsSetup","newError","ERRORS","NOT_FOUND","CODES","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","message","getErrorForCode","env","NODE_ENV","undefined"],"sources":["../../../src/server/server.js"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'path';\nimport { pathToFileURL } from 'url';\n\nimport {\n cloneDeep,\n mapValues,\n pick,\n} from 'lodash';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from '@dr.pogodin/csurf';\nimport express from 'express';\nimport favicon from 'serve-favicon';\nimport helmet from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\n\nimport rendererFactory from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => array.filter((item) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\ndefaultCspSettings.directives['script-src'].push(\"'unsafe-eval'\");\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings() {\n return cloneDeep(defaultCspSettings);\n}\n\nexport default async function factory(webpackConfig, options) {\n const rendererOps = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output;\n\n const server = express();\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n return res.redirect(url);\n }\n return next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use((req, res, next) => {\n req.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req.cspNonce = req.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings = cloneDeep(defaultCspSettings);\n cspSettings.directives['script-src'].push(`'nonce-${req.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n });\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => res.send('User-agent: *\\nDisallow:'));\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser());\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token('ip', (req) => req.clientIp);\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n write: options.logger.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output.path,\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable global-require */\n /* eslint-disable import/no-extraneous-dependencies */\n /* eslint-disable import/no-unresolved */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n };\n }\n\n const webpack = require('webpack');\n const webpackDevMiddleware = require('webpack-dev-middleware');\n const webpackHotMiddleware = require('webpack-hot-middleware');\n const compiler = webpack(webpackConfig);\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable global-require */\n /* eslint-enable import/no-extraneous-dependencies */\n /* eslint-enable import/no-unresolved */\n\n server.use(publicPath, express.static(webpackConfig.output.path));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((error, req, res, next) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) return next(error);\n\n const status = error.status || CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= CODES.INTERNAL_SERVER_ERROR;\n\n // Log server-side errors always, client-side at debug level only.\n options.logger.log(serverSide ? 'error' : 'debug', error);\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n return undefined;\n });\n }\n\n return server;\n}\n"],"mappings":";;;;;;;;AAIA;AACA;AAEA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAzBA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG;EACzBC,UAAU,EAAE,IAAAC,iBAAS,EACnBC,eAAM,CAACC,qBAAqB,CAACC,oBAAoB,EAAE;EAEnD;EACA;EACA;EACA;EACCC,KAAK,IAAKA,KAAK,CAACC,MAAM,CAAEC,IAAI,IAAKA,IAAI,KAAK,QAAQ,CAAC;AAExD,CAAC;AACDR,kBAAkB,CAACC,UAAU,CAAC,WAAW,CAAC,GAAG,CAC3C,QAAQ;AAER;AACA;AACA,uBAAuB,CACxB;AACDD,kBAAkB,CAACC,UAAU,CAAC,YAAY,CAAC,CAACQ,IAAI,CAAC,eAAe,CAAC;;AAEjE;AACA;AACA;AACA,OAAOT,kBAAkB,CAACC,UAAU,CAAC,2BAA2B,CAAC;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,qBAAqB,GAAG;EACtC,OAAO,IAAAC,iBAAS,EAACX,kBAAkB,CAAC;AACtC;AAEe,eAAeY,OAAO,CAACC,aAAa,EAAEC,OAAO,EAAE;EAC5D,MAAMC,WAAW,GAAG,IAAAC,YAAI,EAACF,OAAO,EAAE,CAChC,aAAa,EACb,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACd,OAAO,EACP,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,CAClB,CAAC;EACF,MAAMG,QAAQ,GAAG,IAAAC,iBAAe,EAACL,aAAa,EAAEE,WAAW,CAAC;EAC5D,MAAM;IAAEI;EAAW,CA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AAI,CAACkD,OAAO,CAAC;MAChC,OAAOI,SAAS;IAClB,CAAC,CAAC;EACJ;EAEA,OAAOhF,MAAM;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","webpack","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time, { timer } from './time';\nimport * as webpack from './webpack';\n\nexport * from './Barrier';\nexport { default as Emitter } from './Emitter';\nexport { default as Semaphore } from './Semaphore';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAMA;AACA;AAAyC;AACzC;AACA;AAAqC;AAErC;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AACA;AAA6D;AAAA;AAE7DA,oBAAM,CAACC,OAAO,GAAGA,oBAAO;AACxBD,oBAAM,CAACE,QAAQ,GAAGA,qBAAQ;;AAE1B;AACA;AACA;AACA,IAAIC,eAAe;AACnB,IAAI;EACFA,eAAe,GAAGC,OAAO,CAACC,GAAG,CAACF,eAAe;AAC/C,CAAC,CAAC,MAAM,CAAE,UAAW;AAErB,MAAME,GAAG,GAAGF,eAAe,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ;AACnD,MAAMC,EAAE,GAAGF,GAAG,KAAK,YAAY,IAAIG,OAAO,CAACC,WAAW,WAAWC,SAAS,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlCA;AAmCO,eAAeC,WAAW,CAACC,MAAM,EAAEC,UAAU,GAAG,CAAC,EAAEC,QAAQ,GAAG,IAAI,EAAE;EACzE;EACA,KAAK,IAAIC,CAAC,GAAG,CAAC,GAAI,EAAEA,CAAC,EAAE;IACrB,IAAI;MACF,OAAO,MAAMH,MAAM,EAAE;IACvB,CAAC,CAAC,OAAOI,KAAK,EAAE;MACd,IAAID,CAAC,GAAGF,UAAU,EAAE,MAAM,IAAAI,WAAK,EAACH,QAAQ,CAAC,CAAC,KACrC,MAAME,KAAK;IAClB;EACF;EACA;AACF"}
1
+ {"version":3,"file":"index.js","names":["themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","webpack","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time, { timer } from './time';\nimport * as webpack from './webpack';\n\nexport * from './Barrier';\nexport { default as Emitter } from './Emitter';\nexport { default as Semaphore } from './Semaphore';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAMA;AACA;AAAyC;AACzC;AACA;AAAqC;AAErC;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AACA;AAA6D;AAAA;AAE7DA,oBAAM,CAACC,OAAO,GAAGA,oBAAO;AACxBD,oBAAM,CAACE,QAAQ,GAAGA,qBAAQ;;AAE1B;AACA;AACA;AACA,IAAIC,eAAe;AACnB,IAAI;EACFA,eAAe,GAAGC,OAAO,CAACC,GAAG,CAACF,eAAe;AAC/C,CAAC,CAAC,MAAM,CAAE;AAEV,MAAME,GAAG,GAAGF,eAAe,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ;AACnD,MAAMC,EAAE,GAAGF,GAAG,KAAK,YAAY,IAAIG,OAAO,CAACC,WAAW,WAAWC,SAAS,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlCA;AAmCO,eAAeC,WAAW,CAACC,MAAM,EAAEC,UAAU,GAAG,CAAC,EAAEC,QAAQ,GAAG,IAAI,EAAE;EACzE;EACA,KAAK,IAAIC,CAAC,GAAG,CAAC,GAAI,EAAEA,CAAC,EAAE;IACrB,IAAI;MACF,OAAO,MAAMH,MAAM,EAAE;IACvB,CAAC,CAAC,OAAOI,KAAK,EAAE;MACd,IAAID,CAAC,GAAGF,UAAU,EAAE,MAAM,IAAAI,WAAK,EAACH,QAAQ,CAAC,CAAC,KACrC,MAAME,KAAK;IAClB;EACF;EACA;AACF"}
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  exports.timer = timer;
9
+ exports.useCurrent = useCurrent;
9
10
  var _dayjs = _interopRequireDefault(require("dayjs"));
10
11
  var _lodash = require("lodash");
12
+ var _react = require("react");
13
+ var _reactGlobalState = require("@dr.pogodin/react-global-state");
11
14
  var _Barrier = require("./Barrier");
12
15
  /**
13
16
  * @static
@@ -89,7 +92,51 @@ async function timer(timeout) {
89
92
  }
90
93
  return res;
91
94
  }
95
+
96
+ /**
97
+ * This react hook wraps Date.now() function in a SSR friendly way,
98
+ * ensuring that all calls to useCurrent() within the same render return
99
+ * exactly the same time (which is retrieved from Date.now() first, and
100
+ * then stored in the global state to be reused in all other calls), which
101
+ * is also passed and used in the first client side render, and then updated
102
+ * with a finite precision to avoid infinite re-rendering loops.
103
+ * @param {object} [options] Optional settings.
104
+ * @param {string} [options.globalStatePath="currentTime"] Global state path
105
+ * to keep the current time value.
106
+ * @param {number} [options.precision= 5 * time.SEC_MS] Current time precision.
107
+ * The hook won't update the current time stored in the global state unless it
108
+ * is different from Date.now() result by this number (in milliseconds).
109
+ * Default to 5 seconds.
110
+ * @param {boolean} [options.autorefresh=false] Set `true` to automatically
111
+ * refresh time stored in the global state with the given `precision` (and
112
+ * thus automatically re-rendering components dependent on this hook, or
113
+ * the global state with the period equal to the `precision`.
114
+ * @return {number} Unix timestamp in milliseconds.
115
+ */
116
+ function useCurrent({
117
+ autorefresh = false,
118
+ globalStatePath = 'currentTime',
119
+ precision = 5 * _dayjs.default.SEC_MS
120
+ } = {}) {
121
+ const [now, setter] = (0, _reactGlobalState.useGlobalState)(globalStatePath, Date.now);
122
+ (0, _react.useEffect)(() => {
123
+ let timerId;
124
+ const update = () => {
125
+ setter(old => {
126
+ const neu = Date.now();
127
+ return Math.abs(neu - old) > precision ? neu : old;
128
+ });
129
+ if (autorefresh) timerId = setTimeout(update, precision);
130
+ };
131
+ update();
132
+ return () => {
133
+ if (timerId) clearTimeout(timerId);
134
+ };
135
+ }, [autorefresh, precision, setter]);
136
+ return now;
137
+ }
92
138
  _dayjs.default.timer = timer;
139
+ _dayjs.default.useCurrent = useCurrent;
93
140
  var _default = _dayjs.default;
94
141
  exports.default = _default;
95
142
  //# sourceMappingURL=time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","names":["dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","res","Barrier","id","setTimeout","resolve","bind","abort","clearTimeout","noop"],"sources":["../../../../src/shared/utils/time.js"],"sourcesContent":["import dayjs from 'dayjs';\nimport { noop } from 'lodash';\n\nimport { Barrier } from './Barrier';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nexport async function timer(timeout) {\n const res = new Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = noop;\n res.resolve();\n }\n return res;\n}\n\ndayjs.timer = timer;\n\nexport default dayjs;\n"],"mappings":";;;;;;;;AAAA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAA,cAAK,CAACC,MAAM,GAAG,IAAI;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAD,cAAK,CAACE,MAAM,GAAG,EAAE,GAAGF,cAAK,CAACC,MAAM;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAD,cAAK,CAACG,OAAO,GAAG,EAAE,GAAGH,cAAK,CAACE,MAAM;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAF,cAAK,CAACI,MAAM,GAAG,EAAE,GAAGJ,cAAK,CAACG,OAAO;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAH,cAAK,CAACK,OAAO,GAAG,GAAG,GAAGL,cAAK,CAACI,MAAM;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAJ,cAAK,CAACM,GAAG,GAAGC,IAAI,CAACD,GAAG;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,KAAK,CAACC,OAAO,EAAE;EACnC,MAAMC,GAAG,GAAG,IAAIC,gBAAO,EAAE;EACzB,IAAIF,OAAO,GAAG,CAAC,EAAE;IACf,MAAMG,EAAE,GAAGC,UAAU,CAACH,GAAG,CAACI,OAAO,CAACC,IAAI,CAACL,GAAG,CAAC,EAAED,OAAO,CAAC;IACrDC,GAAG,CAACM,KAAK,GAAG,MAAMC,YAAY,CAACL,EAAE,CAAC;EACpC,CAAC,MAAM;IACLF,GAAG,CAACM,KAAK,GAAGE,YAAI;IAChBR,GAAG,CAACI,OAAO,EAAE;EACf;EACA,OAAOJ,GAAG;AACZ;AAEAV,cAAK,CAACQ,KAAK,GAAGA,KAAK;AAAC,eAELR,cAAK;AAAA"}
1
+ {"version":3,"file":"time.js","names":["dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","res","Barrier","id","setTimeout","resolve","bind","abort","clearTimeout","noop","useCurrent","autorefresh","globalStatePath","precision","setter","useGlobalState","useEffect","timerId","update","old","neu","Math","abs"],"sources":["../../../../src/shared/utils/time.js"],"sourcesContent":["import dayjs from 'dayjs';\nimport { noop } from 'lodash';\nimport { useEffect } from 'react';\n\nimport { useGlobalState } from '@dr.pogodin/react-global-state';\n\nimport { Barrier } from './Barrier';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nexport async function timer(timeout) {\n const res = new Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = noop;\n res.resolve();\n }\n return res;\n}\n\n/**\n * This react hook wraps Date.now() function in a SSR friendly way,\n * ensuring that all calls to useCurrent() within the same render return\n * exactly the same time (which is retrieved from Date.now() first, and\n * then stored in the global state to be reused in all other calls), which\n * is also passed and used in the first client side render, and then updated\n * with a finite precision to avoid infinite re-rendering loops.\n * @param {object} [options] Optional settings.\n * @param {string} [options.globalStatePath=\"currentTime\"] Global state path\n * to keep the current time value.\n * @param {number} [options.precision= 5 * time.SEC_MS] Current time precision.\n * The hook won't update the current time stored in the global state unless it\n * is different from Date.now() result by this number (in milliseconds).\n * Default to 5 seconds.\n * @param {boolean} [options.autorefresh=false] Set `true` to automatically\n * refresh time stored in the global state with the given `precision` (and\n * thus automatically re-rendering components dependent on this hook, or\n * the global state with the period equal to the `precision`.\n * @return {number} Unix timestamp in milliseconds.\n */\nexport function useCurrent({\n autorefresh = false,\n globalStatePath = 'currentTime',\n precision = 5 * dayjs.SEC_MS,\n} = {}) {\n const [now, setter] = useGlobalState(globalStatePath, Date.now);\n useEffect(() => {\n let timerId;\n const update = () => {\n setter((old) => {\n const neu = Date.now();\n return Math.abs(neu - old) > precision ? neu : old;\n });\n if (autorefresh) timerId = setTimeout(update, precision);\n };\n update();\n return () => {\n if (timerId) clearTimeout(timerId);\n };\n }, [autorefresh, precision, setter]);\n return now;\n}\n\ndayjs.timer = timer;\ndayjs.useCurrent = useCurrent;\n\nexport default dayjs;\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAA,cAAK,CAACC,MAAM,GAAG,IAAI;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAD,cAAK,CAACE,MAAM,GAAG,EAAE,GAAGF,cAAK,CAACC,MAAM;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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MC,MAAM,GAAG,MAAM;MACnBJ,MAAM,CAAEK,GAAG,IAAK;QACd,MAAMC,GAAG,GAAGtB,IAAI,CAACD,GAAG,EAAE;QACtB,OAAOwB,IAAI,CAACC,GAAG,CAACF,GAAG,GAAGD,GAAG,CAAC,GAAGN,SAAS,GAAGO,GAAG,GAAGD,GAAG;MACpD,CAAC,CAAC;MACF,IAAIR,WAAW,EAAEM,OAAO,GAAGb,UAAU,CAACc,MAAM,EAAEL,SAAS,CAAC;IAC1D,CAAC;IACDK,MAAM,EAAE;IACR,OAAO,MAAM;MACX,IAAID,OAAO,EAAET,YAAY,CAACS,OAAO,CAAC;IACpC,CAAC;EACH,CAAC,EAAE,CAACN,WAAW,EAAEE,SAAS,EAAEC,MAAM,CAAC,CAAC;EACpC,OAAOjB,GAAG;AACZ;AAEAN,cAAK,CAACQ,KAAK,GAAGA,KAAK;AACnBR,cAAK,CAACmB,UAAU,GAAGA,UAAU;AAAC,eAEfnB,cAAK;AAAA"}
@@ -464,8 +464,8 @@ body {
464
464
  }
465
465
  @media (max-width: 1280px) {
466
466
  *.-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___container___gyZ4rc,
467
- .-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___context___Szmbbz.-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___container___gyZ4rc,
468
- .-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___ad___Ah-Nsc.-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___hoc___Wki41G.-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___container___gyZ4rc {
467
+ .-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___context___Szmbbz.-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___container___gyZ4rc,
468
+ .-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___ad___Ah-Nsc.-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___hoc___Wki41G.-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___container___gyZ4rc {
469
469
  max-width: 95vw;
470
470
  }
471
471
  }
@@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
286
286
  \**********************************/
287
287
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
288
288
 
289
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"timer\": function() { return /* binding */ timer; }\n/* harmony export */ });\n/* harmony import */ var dayjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! dayjs */ \"dayjs\");\n/* harmony import */ var dayjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(dayjs__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ \"lodash\");\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _Barrier__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Barrier */ \"./src/shared/utils/Barrier.js\");\n\n\n\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().SEC_MS) = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().MIN_MS) = 60 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().SEC_MS);\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().HOUR_MS) = 60 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().MIN_MS);\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().DAY_MS) = 24 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().HOUR_MS);\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().YEAR_MS) = 365 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().DAY_MS);\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().now) = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nasync function timer(timeout) {\n const res = new _Barrier__WEBPACK_IMPORTED_MODULE_2__.Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = lodash__WEBPACK_IMPORTED_MODULE_1__.noop;\n res.resolve();\n }\n return res;\n}\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().timer) = timer;\n/* harmony default export */ __webpack_exports__[\"default\"] = ((dayjs__WEBPACK_IMPORTED_MODULE_0___default()));\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/time.js?");
289
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"timer\": function() { return /* binding */ timer; },\n/* harmony export */ \"useCurrent\": function() { return /* binding */ useCurrent; }\n/* harmony export */ });\n/* harmony import */ var dayjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! dayjs */ \"dayjs\");\n/* harmony import */ var dayjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(dayjs__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ \"lodash\");\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _Barrier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Barrier */ \"./src/shared/utils/Barrier.js\");\n\n\n\n\n\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().SEC_MS) = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().MIN_MS) = 60 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().SEC_MS);\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().HOUR_MS) = 60 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().MIN_MS);\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().DAY_MS) = 24 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().HOUR_MS);\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().YEAR_MS) = 365 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().DAY_MS);\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().now) = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nasync function timer(timeout) {\n const res = new _Barrier__WEBPACK_IMPORTED_MODULE_4__.Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = lodash__WEBPACK_IMPORTED_MODULE_1__.noop;\n res.resolve();\n }\n return res;\n}\n\n/**\n * This react hook wraps Date.now() function in a SSR friendly way,\n * ensuring that all calls to useCurrent() within the same render return\n * exactly the same time (which is retrieved from Date.now() first, and\n * then stored in the global state to be reused in all other calls), which\n * is also passed and used in the first client side render, and then updated\n * with a finite precision to avoid infinite re-rendering loops.\n * @param {object} [options] Optional settings.\n * @param {string} [options.globalStatePath=\"currentTime\"] Global state path\n * to keep the current time value.\n * @param {number} [options.precision= 5 * time.SEC_MS] Current time precision.\n * The hook won't update the current time stored in the global state unless it\n * is different from Date.now() result by this number (in milliseconds).\n * Default to 5 seconds.\n * @param {boolean} [options.autorefresh=false] Set `true` to automatically\n * refresh time stored in the global state with the given `precision` (and\n * thus automatically re-rendering components dependent on this hook, or\n * the global state with the period equal to the `precision`.\n * @return {number} Unix timestamp in milliseconds.\n */\nfunction useCurrent() {\n let {\n autorefresh = false,\n globalStatePath = 'currentTime',\n precision = 5 * (dayjs__WEBPACK_IMPORTED_MODULE_0___default().SEC_MS)\n } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const [now, setter] = (0,_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3__.useGlobalState)(globalStatePath, Date.now);\n (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {\n let timerId;\n const update = () => {\n setter(old => {\n const neu = Date.now();\n return Math.abs(neu - old) > precision ? neu : old;\n });\n if (autorefresh) timerId = setTimeout(update, precision);\n };\n update();\n return () => {\n if (timerId) clearTimeout(timerId);\n };\n }, [autorefresh, precision, setter]);\n return now;\n}\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().timer) = timer;\n(dayjs__WEBPACK_IMPORTED_MODULE_0___default().useCurrent) = useCurrent;\n/* harmony default export */ __webpack_exports__[\"default\"] = ((dayjs__WEBPACK_IMPORTED_MODULE_0___default()));\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/time.js?");
290
290
 
291
291
  /***/ }),
292
292
 
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=factory;exports.getDefaultCspSettings=getDefaultCspSettings;var _path=require("path");var _url=require("url");var _lodash=require("lodash");var _compression=_interopRequireDefault(require("compression"));var _cookieParser=_interopRequireDefault(require("cookie-parser"));var _csurf=_interopRequireDefault(require("csurf"));var _express=_interopRequireDefault(require("express"));var _serveFavicon=_interopRequireDefault(require("serve-favicon"));var _helmet=_interopRequireDefault(require("helmet"));var _morgan=_interopRequireDefault(require("morgan"));var _requestIp=_interopRequireDefault(require("request-ip"));var _uuid=require("uuid");var _renderer=_interopRequireDefault(require("./renderer"));var _errors=require("./utils/errors");/**
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=factory;exports.getDefaultCspSettings=getDefaultCspSettings;var _path=require("path");var _url=require("url");var _lodash=require("lodash");var _compression=_interopRequireDefault(require("compression"));var _cookieParser=_interopRequireDefault(require("cookie-parser"));var _csurf=_interopRequireDefault(require("@dr.pogodin/csurf"));var _express=_interopRequireDefault(require("express"));var _serveFavicon=_interopRequireDefault(require("serve-favicon"));var _helmet=_interopRequireDefault(require("helmet"));var _morgan=_interopRequireDefault(require("morgan"));var _requestIp=_interopRequireDefault(require("request-ip"));var _uuid=require("uuid");var _renderer=_interopRequireDefault(require("./renderer"));var _errors=require("./utils/errors");/**
2
2
  * Creation of standard ExpressJS server for ReactJS apps.
3
3
  */ /**
4
4
  * Default Content Security Policy settings.
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["defaultCspSettings","directives","mapValues","helmet","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","cloneDeep","factory","webpackConfig","options","rendererOps","pick","renderer","rendererFactory","publicPath","output","server","express","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","compression","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","nonce","uuid","cspNonce","cspSettings","cspSettingsHook","favicon","send","json","limit","urlencoded","extended","cookieParser","requestIp","mw","csrf","cookie","loggerMiddleware","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","pathToFileURL","process","cwd","sep","webpack","require","webpackDevMiddleware","webpackHotMiddleware","compiler","serverSideRender","onExpressJsSetup","newError","ERRORS","NOT_FOUND","CODES","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","message","getErrorForCode","env","NODE_ENV","undefined"],"sources":["../../../src/server/server.js"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'path';\nimport { pathToFileURL } from 'url';\n\nimport {\n cloneDeep,\n mapValues,\n pick,\n} from 'lodash';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from 'csurf';\nimport express from 'express';\nimport favicon from 'serve-favicon';\nimport helmet from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\n\nimport rendererFactory from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => array.filter((item) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\ndefaultCspSettings.directives['script-src'].push(\"'unsafe-eval'\");\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings() {\n return cloneDeep(defaultCspSettings);\n}\n\nexport default async function factory(webpackConfig, options) {\n const rendererOps = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output;\n\n const server = express();\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n return res.redirect(url);\n }\n return next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use((req, res, next) => {\n req.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req.cspNonce = req.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings = cloneDeep(defaultCspSettings);\n cspSettings.directives['script-src'].push(`'nonce-${req.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n });\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => res.send('User-agent: *\\nDisallow:'));\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser());\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token('ip', (req) => req.clientIp);\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n write: options.logger.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output.path,\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable global-require */\n /* eslint-disable import/no-extraneous-dependencies */\n /* eslint-disable import/no-unresolved */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n };\n }\n\n const webpack = require('webpack');\n const webpackDevMiddleware = require('webpack-dev-middleware');\n const webpackHotMiddleware = require('webpack-hot-middleware');\n const compiler = webpack(webpackConfig);\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable global-require */\n /* eslint-enable import/no-extraneous-dependencies */\n /* eslint-enable import/no-unresolved */\n\n server.use(publicPath, express.static(webpackConfig.output.path));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((error, req, res, next) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) return next(error);\n\n const status = error.status || CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= CODES.INTERNAL_SERVER_ERROR;\n\n // Log server-side errors always, client-side at debug level only.\n options.logger.log(serverSide ? 'error' : 'debug', error);\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n return undefined;\n });\n }\n\n return server;\n}\n"],"mappings":"qOAIA,0BACA,wBAEA,8BAMA,gEACA,mEACA,oDACA,wDACA,mEACA,sDACA,sDACA,6DACA,0BAEA,4DAE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AAC,CAClD,CAAC,CAAC,CAEF,GAAIE,8BAA6B,CACjC,GAAI3E,OAAO,CAAC4E,oBAAoB,CAAE,CAChCD,6BAA6B,CAAG,KAAM3E,QAAO,CAAC4E,oBAAoB,CAACrE,MAAM,CAC3E,CAEA,oBACA,GAAI,CAACoE,6BAA6B,CAAE,CAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACApE,MAAM,CAACK,GAAG,CAAC,CAACiE,KAAK,CAAEhE,GAAG,CAAEC,GAAG,CAAEC,IAAI,GAAK,CACpC;AACA;AACA,GAAID,GAAG,CAACgE,WAAW,CAAE,MAAO/D,KAAI,CAAC8D,KAAK,CAAC,CAEvC,KAAME,OAAM,CAAGF,KAAK,CAACE,MAAM,EAAIL,aAAK,CAACM,qBAAqB,CAC1D,KAAMC,WAAU,CAAGF,MAAM,EAAIL,aAAK,CAACM,qBAAqB,CAExD;AACAhF,OAAO,CAACU,MAAM,CAACwE,GAAG,CAACD,UAAU,CAAG,OAAO,CAAG,OAAO,CAAEJ,KAAK,CAAC,CAEzD,GAAIM,QAAO,CAAGN,KAAK,CAACM,OAAO,EAAI,GAAAC,uBAAe,EAACL,MAAM,CAAC,CACtD,GAAIE,UAAU,EAAIpB,OAAO,CAACwB,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAE,CACvDH,OAAO,CAAGX,cAAM,CAACQ,qBACnB,CAEAlE,GAAG,CAACiE,MAAM,CAACA,MAAM,CAAC,CAAC9C,IAAI,CAACkD,OAAO,CAAC,CAChC,MAAOI,UACT,CAAC,CACH,CAEA,MAAOhF,OACT"}
1
+ {"version":3,"file":"server.js","names":["defaultCspSettings","directives","mapValues","helmet","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","cloneDeep","factory","webpackConfig","options","rendererOps","pick","renderer","rendererFactory","publicPath","output","server","express","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","compression","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","nonce","uuid","cspNonce","cspSettings","cspSettingsHook","favicon","send","json","limit","urlencoded","extended","cookieParser","requestIp","mw","csrf","cookie","loggerMiddleware","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","pathToFileURL","process","cwd","sep","webpack","require","webpackDevMiddleware","webpackHotMiddleware","compiler","serverSideRender","onExpressJsSetup","newError","ERRORS","NOT_FOUND","CODES","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","message","getErrorForCode","env","NODE_ENV","undefined"],"sources":["../../../src/server/server.js"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'path';\nimport { pathToFileURL } from 'url';\n\nimport {\n cloneDeep,\n mapValues,\n pick,\n} from 'lodash';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from '@dr.pogodin/csurf';\nimport express from 'express';\nimport favicon from 'serve-favicon';\nimport helmet from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\n\nimport rendererFactory from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => array.filter((item) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\ndefaultCspSettings.directives['script-src'].push(\"'unsafe-eval'\");\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings() {\n return cloneDeep(defaultCspSettings);\n}\n\nexport default async function factory(webpackConfig, options) {\n const rendererOps = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output;\n\n const server = express();\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n return res.redirect(url);\n }\n return next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use((req, res, next) => {\n req.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req.cspNonce = req.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings = cloneDeep(defaultCspSettings);\n cspSettings.directives['script-src'].push(`'nonce-${req.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n });\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => res.send('User-agent: *\\nDisallow:'));\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser());\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token('ip', (req) => req.clientIp);\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n write: options.logger.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output.path,\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable global-require */\n /* eslint-disable import/no-extraneous-dependencies */\n /* eslint-disable import/no-unresolved */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n };\n }\n\n const webpack = require('webpack');\n const webpackDevMiddleware = require('webpack-dev-middleware');\n const webpackHotMiddleware = require('webpack-hot-middleware');\n const compiler = webpack(webpackConfig);\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable global-require */\n /* eslint-enable import/no-extraneous-dependencies */\n /* eslint-enable import/no-unresolved */\n\n server.use(publicPath, express.static(webpackConfig.output.path));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((error, req, res, next) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) return next(error);\n\n const status = error.status || CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= CODES.INTERNAL_SERVER_ERROR;\n\n // Log server-side errors always, client-side at debug level only.\n options.logger.log(serverSide ? 'error' : 'debug', error);\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n return undefined;\n });\n }\n\n return server;\n}\n"],"mappings":"qOAIA,0BACA,wBAEA,8BAMA,gEACA,mEACA,gEACA,wDACA,mEACA,sDACA,sDACA,6DACA,0BAEA,4DAEA,sCAzBA;AACA;AACA,GAFA,CAgCA;AACA;AACA;AACA,GACA,KAAMA,mBAAkB,CAAG,CACzBC,UAAU,CAAE,GAAAC,iBAAS,EACnBC,eAAM,CAACC,qBAAqB,CAACC,oBAAoB,EAAE,CAEnD;AACA;AACA;AACA;AACCC,KAAK,EAAKA,KAAK,CAACC,MAAM,CAAEC,IAAI,EAAKA,IAAI,GAAK,QAAQ,CAAC,CAExD,CAAC,CACDR,kBAAkB,CAACC,UAAU,CAAC,WAAW,CAAC,CAAG,CAC3C,QAAQ,CAER;AACA;AACA,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GAAG,CAACgE,WAAW,CAAE,MAAO/D,KAAI,CAAC8D,KAAK,CAAC,CAEvC,KAAME,OAAM,CAAGF,KAAK,CAACE,MAAM,EAAIL,aAAK,CAACM,qBAAqB,CAC1D,KAAMC,WAAU,CAAGF,MAAM,EAAIL,aAAK,CAACM,qBAAqB,CAExD;AACAhF,OAAO,CAACU,MAAM,CAACwE,GAAG,CAACD,UAAU,CAAG,OAAO,CAAG,OAAO,CAAEJ,KAAK,CAAC,CAEzD,GAAIM,QAAO,CAAGN,KAAK,CAACM,OAAO,EAAI,GAAAC,uBAAe,EAACL,MAAM,CAAC,CACtD,GAAIE,UAAU,EAAIpB,OAAO,CAACwB,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAE,CACvDH,OAAO,CAAGX,cAAM,CAACQ,qBACnB,CAEAlE,GAAG,CAACiE,MAAM,CAACA,MAAM,CAAC,CAAC9C,IAAI,CAACkD,OAAO,CAAC,CAChC,MAAOI,UACT,CAAC,CACH,CAEA,MAAOhF,OACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","webpack","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time, { timer } from './time';\nimport * as webpack from './webpack';\n\nexport * from './Barrier';\nexport { default as Emitter } from './Emitter';\nexport { default as Semaphore } from './Semaphore';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":"0nCAAA,8EAMA,wDACA,8DAAyC,4BACzC,qDACA,0DAAqC,wBAErC,gVACA,0DACA,8DACA,wEAA6D,o9BAE7DA,oBAAM,CAACC,OAAO,CAAGA,oBAAO,CACxBD,oBAAM,CAACE,QAAQ,CAAGA,qBAAQ,CAE1B;AACA;AACA;AACA,GAAIC,gBAAe,CACnB,GAAI,CACFA,eAAe,CAAGC,OAAO,CAACC,GAAG,CAACF,eAChC,CAAE,KAAM,CAAE,UAAW,CAErB,KAAME,IAAG,CAAGF,eAAe,EAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,CACnD,KAAMC,GAAE,CAAGF,GAAG,GAAK,YAAY,EAAIG,OAAO,CAACC,WAAW,UAAWC,SAAS,CAAC,CAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlCA,cAmCO,cAAeC,YAAW,CAACC,MAAM,CAAEC,UAAU,CAAG,CAAC,CAAEC,QAAQ,CAAG,IAAI,CAAE,CACzE,qCACA,IAAK,GAAIC,EAAC,CAAG,CAAC,EAAI,EAAEA,CAAC,CAAE,CACrB,GAAI,CACF,MAAO,MAAMH,OAAM,EACrB,CAAE,MAAOI,KAAK,CAAE,CACd,GAAID,CAAC,CAAGF,UAAU,CAAE,KAAM,GAAAI,WAAK,EAACH,QAAQ,CAAC,CAAC,IACrC,MAAME,MACb,CACF,CACA,oCACF"}
1
+ {"version":3,"file":"index.js","names":["themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","webpack","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time, { timer } from './time';\nimport * as webpack from './webpack';\n\nexport * from './Barrier';\nexport { default as Emitter } from './Emitter';\nexport { default as Semaphore } from './Semaphore';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":"0nCAAA,8EAMA,wDACA,8DAAyC,4BACzC,qDACA,0DAAqC,wBAErC,gVACA,0DACA,8DACA,wEAA6D,o9BAE7DA,oBAAM,CAACC,OAAO,CAAGA,oBAAO,CACxBD,oBAAM,CAACE,QAAQ,CAAGA,qBAAQ,CAE1B;AACA;AACA;AACA,GAAIC,gBAAe,CACnB,GAAI,CACFA,eAAe,CAAGC,OAAO,CAACC,GAAG,CAACF,eAChC,CAAE,KAAM,CAAE,WAEV,KAAME,IAAG,CAAGF,eAAe,EAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,CACnD,KAAMC,GAAE,CAAGF,GAAG,GAAK,YAAY,EAAIG,OAAO,CAACC,WAAW,UAAWC,SAAS,CAAC,CAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlCA,cAmCO,cAAeC,YAAW,CAACC,MAAM,CAAEC,UAAU,CAAG,CAAC,CAAEC,QAAQ,CAAG,IAAI,CAAE,CACzE,qCACA,IAAK,GAAIC,EAAC,CAAG,CAAC,EAAI,EAAEA,CAAC,CAAE,CACrB,GAAI,CACF,MAAO,MAAMH,OAAM,EACrB,CAAE,MAAOI,KAAK,CAAE,CACd,GAAID,CAAC,CAAGF,UAAU,CAAE,KAAM,GAAAI,WAAK,EAACH,QAAQ,CAAC,CAAC,IACrC,MAAME,MACb,CACF,CACA,oCACF"}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;exports.timer=timer;var _dayjs=_interopRequireDefault(require("dayjs"));var _lodash=require("lodash");var _Barrier=require("./Barrier");/**
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;exports.timer=timer;exports.useCurrent=useCurrent;var _dayjs=_interopRequireDefault(require("dayjs"));var _lodash=require("lodash");var _react=require("react");var _reactGlobalState=require("@dr.pogodin/react-global-state");var _Barrier=require("./Barrier");/**
2
2
  * @static
3
3
  * @const SEC_MS
4
4
  * @desc One second, expressed in milliseconds (equals 1000 ms).
@@ -48,5 +48,24 @@
48
48
  * @return {Barrier} Resolves after the timeout. It has additional
49
49
  * .abort() method attached, which cancels the pending timer resolution
50
50
  * (without resolving or rejecting the barrier).
51
- */async function timer(timeout){const res=new _Barrier.Barrier;if(timeout>0){const id=setTimeout(res.resolve.bind(res),timeout);res.abort=()=>clearTimeout(id)}else{res.abort=_lodash.noop;res.resolve()}return res}_dayjs.default.timer=timer;var _default=_dayjs.default;exports.default=_default;
51
+ */async function timer(timeout){const res=new _Barrier.Barrier;if(timeout>0){const id=setTimeout(res.resolve.bind(res),timeout);res.abort=()=>clearTimeout(id)}else{res.abort=_lodash.noop;res.resolve()}return res}/**
52
+ * This react hook wraps Date.now() function in a SSR friendly way,
53
+ * ensuring that all calls to useCurrent() within the same render return
54
+ * exactly the same time (which is retrieved from Date.now() first, and
55
+ * then stored in the global state to be reused in all other calls), which
56
+ * is also passed and used in the first client side render, and then updated
57
+ * with a finite precision to avoid infinite re-rendering loops.
58
+ * @param {object} [options] Optional settings.
59
+ * @param {string} [options.globalStatePath="currentTime"] Global state path
60
+ * to keep the current time value.
61
+ * @param {number} [options.precision= 5 * time.SEC_MS] Current time precision.
62
+ * The hook won't update the current time stored in the global state unless it
63
+ * is different from Date.now() result by this number (in milliseconds).
64
+ * Default to 5 seconds.
65
+ * @param {boolean} [options.autorefresh=false] Set `true` to automatically
66
+ * refresh time stored in the global state with the given `precision` (and
67
+ * thus automatically re-rendering components dependent on this hook, or
68
+ * the global state with the period equal to the `precision`.
69
+ * @return {number} Unix timestamp in milliseconds.
70
+ */function useCurrent({autorefresh=false,globalStatePath="currentTime",precision=5*_dayjs.default.SEC_MS}={}){const[now,setter]=(0,_reactGlobalState.useGlobalState)(globalStatePath,Date.now);(0,_react.useEffect)(()=>{let timerId;const update=()=>{setter(old=>{const neu=Date.now();return Math.abs(neu-old)>precision?neu:old});if(autorefresh)timerId=setTimeout(update,precision)};update();return()=>{if(timerId)clearTimeout(timerId)}},[autorefresh,precision,setter]);return now}_dayjs.default.timer=timer;_dayjs.default.useCurrent=useCurrent;var _default=_dayjs.default;exports.default=_default;
52
71
  //# sourceMappingURL=time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","names":["dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","res","Barrier","id","setTimeout","resolve","bind","abort","clearTimeout","noop"],"sources":["../../../../src/shared/utils/time.js"],"sourcesContent":["import dayjs from 'dayjs';\nimport { noop } from 'lodash';\n\nimport { Barrier } from './Barrier';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nexport async function timer(timeout) {\n const res = new Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = noop;\n res.resolve();\n }\n return res;\n}\n\ndayjs.timer = timer;\n\nexport default dayjs;\n"],"mappings":"oMAAA,oDACA,8BAEA,kCAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAA,cAAK,CAACC,MAAM,CAAG,IAAI,CAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACE,MAAM,CAAG,EAAE,CAAGF,cAAK,CAACC,MAAM,CAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACG,OAAO,CAAG,EAAE,CAAGH,cAAK,CAACE,MAAM,CAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAF,cAAK,CAACI,MAAM,CAAG,EAAE,CAAGJ,cAAK,CAACG,OAAO,CAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAH,cAAK,CAACK,OAAO,CAAG,GAAG,CAAGL,cAAK,CAACI,MAAM,CAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAJ,cAAK,CAACM,GAAG,CAAGC,IAAI,CAACD,GAAG,CAEpB;AACA;AACA;AACA;AACA;AACA;AACA,GACO,cAAeE,MAAK,CAACC,OAAO,CAAE,CACnC,KAAMC,IAAG,CAAG,GAAIC,iBAAS,CACzB,GAAIF,OAAO,CAAG,CAAC,CAAE,CACf,KAAMG,GAAE,CAAGC,UAAU,CAACH,GAAG,CAACI,OAAO,CAACC,IAAI,CAACL,GAAG,CAAC,CAAED,OAAO,CAAC,CACrDC,GAAG,CAACM,KAAK,CAAG,IAAMC,YAAY,CAACL,EAAE,CACnC,CAAC,IAAM,CACLF,GAAG,CAACM,KAAK,CAAGE,YAAI,CAChBR,GAAG,CAACI,OAAO,EACb,CACA,MAAOJ,IACT,CAEAV,cAAK,CAACQ,KAAK,CAAGA,KAAK,CAAC,aAELR,cAAK"}
1
+ {"version":3,"file":"time.js","names":["dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","res","Barrier","id","setTimeout","resolve","bind","abort","clearTimeout","noop","useCurrent","autorefresh","globalStatePath","precision","setter","useGlobalState","useEffect","timerId","update","old","neu","Math","abs"],"sources":["../../../../src/shared/utils/time.js"],"sourcesContent":["import dayjs from 'dayjs';\nimport { noop } from 'lodash';\nimport { useEffect } from 'react';\n\nimport { useGlobalState } from '@dr.pogodin/react-global-state';\n\nimport { Barrier } from './Barrier';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nexport async function timer(timeout) {\n const res = new Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = noop;\n res.resolve();\n }\n return res;\n}\n\n/**\n * This react hook wraps Date.now() function in a SSR friendly way,\n * ensuring that all calls to useCurrent() within the same render return\n * exactly the same time (which is retrieved from Date.now() first, and\n * then stored in the global state to be reused in all other calls), which\n * is also passed and used in the first client side render, and then updated\n * with a finite precision to avoid infinite re-rendering loops.\n * @param {object} [options] Optional settings.\n * @param {string} [options.globalStatePath=\"currentTime\"] Global state path\n * to keep the current time value.\n * @param {number} [options.precision= 5 * time.SEC_MS] Current time precision.\n * The hook won't update the current time stored in the global state unless it\n * is different from Date.now() result by this number (in milliseconds).\n * Default to 5 seconds.\n * @param {boolean} [options.autorefresh=false] Set `true` to automatically\n * refresh time stored in the global state with the given `precision` (and\n * thus automatically re-rendering components dependent on this hook, or\n * the global state with the period equal to the `precision`.\n * @return {number} Unix timestamp in milliseconds.\n */\nexport function useCurrent({\n autorefresh = false,\n globalStatePath = 'currentTime',\n precision = 5 * dayjs.SEC_MS,\n} = {}) {\n const [now, setter] = useGlobalState(globalStatePath, Date.now);\n useEffect(() => {\n let timerId;\n const update = () => {\n setter((old) => {\n const neu = Date.now();\n return Math.abs(neu - old) > precision ? neu : old;\n });\n if (autorefresh) timerId = setTimeout(update, precision);\n };\n update();\n return () => {\n if (timerId) clearTimeout(timerId);\n };\n }, [autorefresh, precision, setter]);\n return now;\n}\n\ndayjs.timer = timer;\ndayjs.useCurrent = useCurrent;\n\nexport default dayjs;\n"],"mappings":"kOAAA,oDACA,8BACA,4BAEA,gEAEA,kCAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAA,cAAK,CAACC,MAAM,CAAG,IAAI,CAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACE,MAAM,CAAG,EAAE,CAAGF,cAAK,CAACC,MAAM,CAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACG,OAAO,CAAG,EAAE,CAAGH,cAAK,CAACE,MAAM,CAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAF,cAAK,CAACI,MAAM,CAAG,EAAE,CAAGJ,cAAK,CAACG,OAAO,CAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAH,cAAK,CAACK,OAAO,CAAG,GAAG,CAAGL,cAAK,CAACI,MAAM,CAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAJ,cAAK,CAACM,GAAG,CAAGC,IAAI,CAACD,GAAG,CAEpB;AACA;AACA;AACA;AACA;AACA;AACA,GACO,cAAeE,MAAK,CAACC,OAAO,CAAE,CACnC,KAAMC,IAAG,CAAG,GAAIC,iBAAS,CACzB,GAAIF,OAAO,CAAG,CAAC,CAAE,CACf,KAAMG,GAAE,CAAGC,UAAU,CAACH,GAAG,CAACI,OAAO,CAACC,IAAI,CAACL,GAAG,CAAC,CAAED,OAAO,CAAC,CACrDC,GAAG,CAACM,KAAK,CAAG,IAAMC,YAAY,CAACL,EAAE,CACnC,CAAC,IAAM,CACLF,GAAG,CAACM,KAAK,CAAGE,YAAI,CAChBR,GAAG,CAACI,OAAO,EACb,CACA,MAAOJ,IACT,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAASS,WAAU,CAAC,CACzBC,WAAW,CAAG,KAAK,CACnBC,eAAe,CAAG,aAAa,CAC/BC,SAAS,CAAG,CAAC,CAAGtB,cAAK,CAACC,MACxB,CAAC,CAAG,CAAC,CAAC,CAAE,CACN,KAAM,CAACK,GAAG,CAAEiB,MAAM,CAAC,CAAG,GAAAC,gCAAc,EAACH,eAAe,CAAEd,IAAI,CAACD,GAAG,CAAC,CAC/D,GAAAmB,gBAAS,EAAC,IAAM,CACd,GAAIC,QAAO,CACX,KAAMC,OAAM,CAAG,IAAM,CACnBJ,MAAM,CAAEK,GAAG,EAAK,CACd,KAAMC,IAAG,CAAGtB,IAAI,CAACD,GAAG,EAAE,CACtB,MAAOwB,KAAI,CAACC,GAAG,CAACF,GAAG,CAAGD,GAAG,CAAC,CAAGN,SAAS,CAAGO,GAAG,CAAGD,GACjD,CAAC,CAAC,CACF,GAAIR,WAAW,CAAEM,OAAO,CAAGb,UAAU,CAACc,MAAM,CAAEL,SAAS,CACzD,CAAC,CACDK,MAAM,EAAE,CACR,MAAO,IAAM,CACX,GAAID,OAAO,CAAET,YAAY,CAACS,OAAO,CACnC,CACF,CAAC,CAAE,CAACN,WAAW,CAAEE,SAAS,CAAEC,MAAM,CAAC,CAAC,CACpC,MAAOjB,IACT,CAEAN,cAAK,CAACQ,KAAK,CAAGA,KAAK,CACnBR,cAAK,CAACmB,UAAU,CAAGA,UAAU,CAAC,aAEfnB,cAAK"}
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see web.bundle.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@babel/runtime/helpers/classPrivateFieldGet"),require("@babel/runtime/helpers/classPrivateFieldSet"),require("@dr.pogodin/react-global-state"),require("@dr.pogodin/react-themes"),require("axios"),require("dayjs"),require("lodash"),require("prop-types"),require("qs"),require("react"),require("react-dom"),require("react-dom/client"),require("react-helmet"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["@babel/runtime/helpers/classPrivateFieldGet","@babel/runtime/helpers/classPrivateFieldSet","@dr.pogodin/react-global-state","@dr.pogodin/react-themes","axios","dayjs","lodash","prop-types","qs","react","react-dom","react-dom/client","react-helmet","react-router-dom"],t):"object"==typeof exports?exports["@dr.pogodin/react-utils"]=t(require("@babel/runtime/helpers/classPrivateFieldGet"),require("@babel/runtime/helpers/classPrivateFieldSet"),require("@dr.pogodin/react-global-state"),require("@dr.pogodin/react-themes"),require("axios"),require("dayjs"),require("lodash"),require("prop-types"),require("qs"),require("react"),require("react-dom"),require("react-dom/client"),require("react-helmet"),require("react-router-dom")):e["@dr.pogodin/react-utils"]=t(e["@babel/runtime/helpers/classPrivateFieldGet"],e["@babel/runtime/helpers/classPrivateFieldSet"],e["@dr.pogodin/react-global-state"],e["@dr.pogodin/react-themes"],e.axios,e.dayjs,e.lodash,e["prop-types"],e.qs,e.react,e["react-dom"],e["react-dom/client"],e["react-helmet"],e["react-router-dom"])}("undefined"!=typeof self?self:this,(function(__WEBPACK_EXTERNAL_MODULE__226__,__WEBPACK_EXTERNAL_MODULE__556__,__WEBPACK_EXTERNAL_MODULE__899__,__WEBPACK_EXTERNAL_MODULE__198__,__WEBPACK_EXTERNAL_MODULE__300__,__WEBPACK_EXTERNAL_MODULE__760__,__WEBPACK_EXTERNAL_MODULE__467__,__WEBPACK_EXTERNAL_MODULE__99__,__WEBPACK_EXTERNAL_MODULE__656__,__WEBPACK_EXTERNAL_MODULE__156__,__WEBPACK_EXTERNAL_MODULE__111__,__WEBPACK_EXTERNAL_MODULE__715__,__WEBPACK_EXTERNAL_MODULE__383__,__WEBPACK_EXTERNAL_MODULE__128__){return function(){"use strict";var __webpack_modules__={450:function(e,t,n){n.r(t),n.d(t,{IS_CLIENT_SIDE:function(){return r},IS_SERVER_SIDE:function(){return o},buildTimestamp:function(){return l},getBuildInfo:function(){return c},isDevBuild:function(){return i},isProdBuild:function(){return a}});const r="object"!=typeof process||!process.versions||!process.versions.node||!!n.g.REACT_UTILS_FORCE_CLIENT_SIDE,o=!r;function i(){return!1}function a(){return!0}function c(){return(r?window:n.g).TRU_BUILD_INFO}function l(){return c().timestamp}},869:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{requireWeak:function(){return requireWeak},resolveWeak:function(){return resolveWeak}});var _isomorphy__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(450);function requireWeak(modulePath,basePath){if(_isomorphy__WEBPACK_IMPORTED_MODULE_0__.IS_CLIENT_SIDE)return null;try{const{resolve:resolve}=eval("require")("path"),path=basePath?resolve(basePath,modulePath):modulePath,{default:def,...named}=eval("require")(path);return def?(Object.entries(named).forEach((e=>{let[t,n]=e;if(def[t])throw Error("Conflict between default and named exports");def[t]=n})),def):named}catch{return null}}function resolveWeak(e){return e}},251:function(e,t,n){var r=n(156),o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,c=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,n){var r,i={},s=null,u=null;for(r in void 0!==n&&(s=""+n),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,r)&&!l.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:o,type:e,key:s,ref:u,props:i,_owner:c.current}}t.Fragment=i,t.jsx=s,t.jsxs=s},893:function(e,t,n){e.exports=n(251)},226:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__226__},556:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__556__},899:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__899__},198:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__198__},300:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__300__},760:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__760__},467:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__467__},99:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__99__},656:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__656__},156:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__156__},111:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__111__},715:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__715__},383:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__383__},128:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__128__}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=function(e,t){for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};return function(){__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Barrier:function(){return b},BaseModal:function(){return he},Button:function(){return $},Checkbox:function(){return Q},Dropdown:function(){return ne},Emitter:function(){return g},GlobalStateProvider:function(){return O.GlobalStateProvider},Input:function(){return ie},JU:function(){return W},Link:function(){return G},MetaTags:function(){return _e},Modal:function(){return me},NavLink:function(){return be},PT:function(){return A},PageLayout:function(){return le},ScalableRect:function(){return Ee},Semaphore:function(){return S},ThemeProvider:function(){return e.ThemeProvider},Throbber:function(){return ve},WithTooltip:function(){return Ne},YouTubeVideo:function(){return Oe},api:function(){return I()},client:function(){return Z},config:function(){return r},getGlobalState:function(){return O.getGlobalState},getSsrContext:function(){return O.getSsrContext},isomorphy:function(){return o},newBarrier:function(){return E},server:function(){return je},splitComponent:function(){return B},themed:function(){return t()},time:function(){return v},useAsyncCollection:function(){return O.useAsyncCollection},useAsyncData:function(){return O.useAsyncData},useGlobalState:function(){return O.useGlobalState},webpack:function(){return n},withRetries:function(){return U}});var e=__webpack_require__(198),t=__webpack_require__.n(e),n=__webpack_require__(869),r=(0,n.requireWeak)("config")||window.CONFIG||{},o=__webpack_require__(450),i=__webpack_require__(760),a=__webpack_require__.n(i),c=__webpack_require__(467),l=__webpack_require__(226),s=__webpack_require__.n(l),u=__webpack_require__(556),_=__webpack_require__.n(u);function d(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}var p=new WeakMap,h=new WeakMap,f=new WeakMap,m=new WeakMap;class b extends Promise{constructor(e){let t,n;super(((r,o)=>{t=e=>{r(e),_()(this,h,!0)},n=e=>{o(e),_()(this,m,!0)},e&&e(t,n)})),d(this,p,{writable:!0,value:void 0}),d(this,h,{writable:!0,value:!1}),d(this,f,{writable:!0,value:void 0}),d(this,m,{writable:!0,value:!1}),_()(this,p,t),_()(this,f,n)}get resolve(){return s()(this,p)}get resolved(){return s()(this,h)}get reject(){return s()(this,f)}get rejected(){return s()(this,m)}then(e,t){const n=super.then(e,t);return _()(n,p,s()(this,p)),_()(n,f,s()(this,f)),n}}function E(e){return new b(e)}async function w(e){const t=new b;if(e>0){const n=setTimeout(t.resolve.bind(t),e);t.abort=()=>clearTimeout(n)}else t.abort=c.noop,t.resolve();return t}a().SEC_MS=1e3,a().MIN_MS=60*a().SEC_MS,a().HOUR_MS=60*a().MIN_MS,a().DAY_MS=24*a().HOUR_MS,a().YEAR_MS=365*a().DAY_MS,a().now=Date.now,a().timer=w;var v=a();class g{constructor(){this.listeners=[]}get hasListeners(){return!!this.listeners.length}addListener(e){return this.listeners.includes(e)||this.listeners.push(e),()=>this.removeListener(e)}emit(){const{listeners:e}=this;for(let t=0;t<e.length;++t)e[t](...arguments)}removeListener(e){const t=this.listeners.indexOf(e);t>=0&&this.listeners.splice(t,1)}}function y(e,t,n){x(e,t),t.set(e,n)}function x(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function T(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}var k=new WeakSet,C=new WeakMap,P=new WeakMap,N=new WeakMap;class S{constructor(e){var t;x(this,t=k),t.add(this),y(this,C,{writable:!0,value:!1}),y(this,P,{writable:!0,value:[]}),y(this,N,{writable:!0,value:void 0}),_()(this,N,!!e)}get ready(){return s()(this,N)}setReady(e){const t=!!e;s()(this,N)!==t&&(_()(this,N,t),t&&!s()(this,C)&&T(this,k,q).call(this))}async seize(){await this.waitReady(),this.setReady(!1)}async waitReady(){if(!s()(this,N)||s()(this,P).length){const e=E();s()(this,P).push(e),await e,s()(this,P).shift()}}}function q(){if(s()(this,N)&&s()(this,P).length&&(s()(this,P)[0].resolve(),s()(this,P).length))return setTimeout(T(this,k,q).bind(this)),void _()(this,C,!0);_()(this,C,!1)}var R=__webpack_require__(156),A=__webpack_require__(99),L=__webpack_require__.n(A),O=__webpack_require__(899),j=__webpack_require__(893);function M(e){let{children:t,chunkName:n,getComponent:r,placeholder:i,...a}=e;const{current:c}=(0,R.useRef)({mounted:!1,pendingStyles:[]}),{publicPath:l}=(0,o.getBuildInfo)(),s=(0,R.lazy)((async()=>{const e=await r();return c.pendingStyles.length&&await Promise.all(c.pendingStyles),e.default?e:{default:e}}));if(o.IS_SERVER_SIDE){const{chunks:e}=(0,O.getGlobalState)().ssrContext;if(e.includes(n))throw Error(`Chunk name clash for "${n}"`);e.push(n)}else c.mounted||(c.mounted=!0,window.CHUNK_GROUPS[n].forEach((e=>{if(!e.endsWith(".css"))return;const t=`${l}/${e}`;let n=document.querySelector(`link[href="${t}"]`);if(!n){n=document.createElement("link"),n.setAttribute("href",t),n.setAttribute("rel","stylesheet");const e=E();n.onload=e.resolve,n.onerror=e.resolve,c.pendingStyles.push(e),document.querySelector("head").appendChild(n)}window.STYLESHEET_USAGE_COUNTERS||={},window.STYLESHEET_USAGE_COUNTERS[t]||=0,++window.STYLESHEET_USAGE_COUNTERS[t]})));return(0,R.useEffect)((()=>()=>{c.mounted=!1,window.CHUNK_GROUPS[n].forEach((e=>{if(!e.endsWith(".css"))return;const t=`${l}/${e}`;if(--window.STYLESHEET_USAGE_COUNTERS[t]<=0){const e=document.querySelector(`link[href="${t}"]`);document.querySelector("head").removeChild(e)}}))}),[n,c,l]),(0,j.jsx)(R.Suspense,{fallback:i,children:(0,j.jsx)(s,{...a,children:t})})}function B(e){let{chunkName:t,getComponent:n,placeholder:r}=e;return function(){let{children:e,...o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,R.createElement)(M,{...o,chunkName:t,getComponent:n,placeholder:r},e)}}let D;M.propTypes={children:L().node,chunkName:L().string.isRequired,getComponent:L().func.isRequired,placeholder:L().node},M.defaultProps={children:void 0,placeholder:void 0},t().COMPOSE=e.COMPOSE,t().PRIORITY=e.PRIORITY;try{D=process.env.NODE_CONFIG_ENV}catch{}const W="production"!==(D||"production")&&n.requireWeak("./jest","/");async function U(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;for(let r=1;;++r)try{return await e()}catch(e){if(!(r<t))throw e;await w(n)}}var X=__webpack_require__(300),I=__webpack_require__.n(X),K=__webpack_require__(128);function Y(e){let{children:t,className:n,disabled:r,enforceA:o,keepScrollPosition:i,onClick:a,onMouseDown:c,openNewTab:l,replace:s,routerLinkType:u,to:_,...d}=e;return r||o||l||_.match(/^(#|(https?|mailto):)/)?(0,j.jsx)("a",{className:(n?n+" ":"")+"zH52sA",disabled:r,href:_,onClick:r?e=>e.preventDefault():a,onMouseDown:r?e=>e.preventDefault():c,rel:"noopener noreferrer",target:l?"_blank":"",children:t}):(0,R.createElement)(u,{className:n,disabled:r,onMouseDown:c,replace:s,to:_,onClick:e=>{a&&a(e),i||window.scroll(0,0)},...d},t)}function G(e){return(0,j.jsx)(Y,{...e,routerLinkType:K.Link})}function F(e){let{active:t,children:n,disabled:r,enforceA:o,onClick:i,onMouseDown:a,openNewTab:c,replace:l,theme:s,to:u}=e,_=s.button;return t&&s.active&&(_+=` ${s.active}`),r?(s.disabled&&(_+=` ${s.disabled}`),(0,j.jsx)("div",{className:_,children:n})):u?(0,j.jsx)(G,{className:_,enforceA:o,onClick:i,onMouseDown:a,openNewTab:c,replace:l,to:u,children:n}):(0,j.jsx)("div",{className:_,onClick:i,onKeyPress:i,onMouseDown:a,role:"button",tabIndex:0,children:n})}Y.defaultProps={children:null,className:null,disabled:!1,enforceA:!1,keepScrollPosition:!1,onClick:null,onMouseDown:null,openNewTab:!1,replace:!1,to:""},Y.propTypes={children:L().node,className:L().string,disabled:L().bool,enforceA:L().bool,keepScrollPosition:L().bool,onClick:L().func,onMouseDown:L().func,openNewTab:L().bool,replace:L().bool,routerLinkType:L().elementType.isRequired,to:L().oneOfType([L().object,L().string])};const H=t()("Button",["active","button","disabled"],{button:"E1FNQT",context:"KM0v4f",ad:"_3jm1-Q",hoc:"_0plpDL",active:"MAe9O6",disabled:"Br9IWV"})(F);F.defaultProps={active:!1,children:void 0,disabled:!1,enforceA:!1,onClick:void 0,onMouseDown:void 0,openNewTab:!1,replace:!1,to:void 0},F.propTypes={active:L().bool,children:L().node,disabled:L().bool,enforceA:L().bool,onClick:L().func,onMouseDown:L().func,openNewTab:L().bool,replace:L().bool,theme:H.themeType.isRequired,to:L().oneOfType([L().object,L().string])};var $=H;function z(e){let{checked:t,label:n,onChange:r,theme:o}=e;return(0,j.jsxs)("div",{className:o.container,children:[void 0===n?null:(0,j.jsx)("p",{className:o.label,children:n}),(0,j.jsx)("input",{checked:t,className:o.checkbox,onChange:r,type:"checkbox"})]})}const V=t()("Checkbox",["checkbox","container","label"],{checkbox:"A-f8qJ",context:"dNQcC6",ad:"earXxa",hoc:"qAPfQ6",container:"Kr0g3M",label:"_3dML-O"})(z);z.propTypes={checked:L().bool,label:L().string,onChange:L().func,theme:V.themeType.isRequired},z.defaultProps={checked:void 0,label:void 0,onChange:void 0};var Q=V,J=__webpack_require__(715);function Z(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=document.getElementById("react-view"),r=(0,j.jsx)(O.GlobalStateProvider,{initialState:window.ISTATE,children:(0,j.jsx)(K.BrowserRouter,{children:(0,j.jsx)(e,{})})});t.dontHydrate?(0,J.createRoot)(n).render(r):(0,J.hydrateRoot)(n,r)}function ee(e){let{filter:t,label:n,onChange:r,options:o,theme:i,value:a}=e;const l=[(0,j.jsx)("option",{className:i.hiddenOption,children:"‌"},"__reactUtilsHiddenOption")];for(let e=0;e<o.length;++e){let n=o[e];t&&!t(n)||((0,c.isString)(n)&&(n={value:n}),l.push((0,j.jsx)("option",{className:i.option,value:n.value,children:void 0===n.name?n.value:n.name},n.value)))}return(0,j.jsxs)("div",{className:i.container,children:[void 0===n?null:(0,j.jsx)("p",{className:i.label,children:n}),(0,j.jsx)("select",{className:i.select,onChange:r,value:a,children:l}),(0,j.jsx)("div",{className:i.arrow,children:"▼"})]})}const te=t()("Dropdown",["arrow","container","hiddenOption","label","option","select"],{arrow:"-zPK7Y",context:"haRIry",ad:"D4XHG2",hoc:"N3nd34",container:"_9CQpeA",label:"Gv0kyu",hiddenOption:"RdW3yR",select:"JXK1uw"})(ee);ee.propTypes={filter:L().func,label:L().string,onChange:L().func,options:L().arrayOf(L().oneOfType([L().shape({name:L().node,value:L().string.isRequired}),L().string]).isRequired),theme:te.themeType.isRequired,value:L().string},ee.defaultProps={filter:void 0,label:void 0,onChange:void 0,options:[],value:void 0};var ne=te;const re=(0,R.forwardRef)(((e,t)=>{let{label:n,theme:r,...o}=e;return(0,j.jsxs)("span",{className:r.container,children:[void 0===n?null:(0,j.jsx)("p",{className:r.label,children:n}),(0,j.jsx)("input",{className:r.input,ref:t,...o})]})})),oe=t()("Input",["container","input","label"],{container:"Cxx397",context:"X5WszA",ad:"_8s7GCr",hoc:"TVlBYc",input:"M07d4s",label:"gfbdq-"})(re);re.propTypes={label:L().string,theme:oe.themeType.isRequired},re.defaultProps={label:void 0};var ie=oe;function ae(e){let{children:t,leftSidePanelContent:n,rightSidePanelContent:r,theme:o}=e;return(0,j.jsxs)("div",{className:o.container,children:[(0,j.jsx)("div",{className:[o.sidePanel,o.leftSidePanel].join(" "),children:n}),(0,j.jsx)("div",{className:o.mainPanel,children:t}),(0,j.jsx)("div",{className:[o.sidePanel,o.rightSidePanel].join(" "),children:r})]})}const ce=t()("PageLayout",["container","leftSidePanel","mainPanel","rightSidePanel","sidePanel"],{container:"T3cuHB",context:"m4mL-M",ad:"m3-mdC",hoc:"J15Z4H",mainPanel:"pPlQO2",sidePanel:"lqNh4h"})(ae);ae.propTypes={children:L().node,leftSidePanelContent:L().node,rightSidePanelContent:L().node,theme:ce.themeType.isRequired},ae.defaultProps={children:null,leftSidePanelContent:null,rightSidePanelContent:null};var le=ce,se=__webpack_require__(383);const ue=(0,R.createContext)();function _e(e){let{children:t,description:n,image:r,siteName:o,socialDescription:i,socialTitle:a,title:c,url:l}=e;const s=a||c,u=i||n,_=(0,R.useMemo)((()=>({description:n,image:r,siteName:o,socialDescription:i,socialTitle:a,title:c,url:l})),[n,r,o,i,a,c,l]);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(se.Helmet,{children:[(0,j.jsx)("title",{children:c}),(0,j.jsx)("meta",{name:"description",content:n}),(0,j.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,j.jsx)("meta",{name:"twitter:title",content:s}),(0,j.jsx)("meta",{name:"twitter:description",content:u}),r?(0,j.jsx)("meta",{name:"twitter:image",content:r}):null,o?(0,j.jsx)("meta",{name:"twitter:site",content:`@${o}`}):null,(0,j.jsx)("meta",{name:"og:title",content:s}),r?(0,j.jsx)("meta",{name:"og:image",content:r}):null,r?(0,j.jsx)("meta",{name:"og:image:alt",content:s}):null,(0,j.jsx)("meta",{name:"og:description",content:u}),o?(0,j.jsx)("meta",{name:"og:sitename",content:o}):null,l?(0,j.jsx)("meta",{name:"og:url",content:l}):null]}),t?(0,j.jsx)(ue.Provider,{value:_,children:t}):null]})}_e.Context=ue,_e.defaultProps={children:null,image:null,siteName:null,socialDescription:null,socialTitle:null,url:null},_e.propTypes={children:L().node,description:L().string.isRequired,image:L().string,siteName:L().string,socialDescription:L().string,socialTitle:L().string,title:L().string.isRequired,url:L().string};var de=__webpack_require__(111),pe=__webpack_require__.n(de);function he(e){let{children:t,onCancel:n,theme:r}=e;const o=(0,R.useRef)(),i=(0,R.useRef)(),[a,c]=(0,R.useState)();(0,R.useEffect)((()=>{const e=document.createElement("div");return document.body.classList.add("scrolling-disabled-by-modal"),document.body.appendChild(e),c(e),()=>{document.body.classList.remove("scrolling-disabled-by-modal"),document.body.removeChild(e)}}),[]);const l=(0,R.useMemo)((()=>(0,j.jsx)("div",{onFocus:()=>{const e=o.current.querySelectorAll("*");for(let t=e.length-1;t>=0;--t)if(e[t].focus(),document.activeElement===e[t])return;i.current.focus()},tabIndex:"0"})),[]);return a?pe().createPortal((0,j.jsxs)(j.Fragment,{children:[l,(0,j.jsx)("div",{"aria-label":"Cancel",className:r.overlay,onClick:()=>n(),onKeyDown:e=>{"Escape"===e.key&&n()},ref:e=>{e&&e!==i.current&&(i.current=e,e.focus())},role:"button",tabIndex:"0"}),(0,j.jsx)("div",{"aria-modal":"true",className:r.container,onWheel:e=>e.stopPropagation(),ref:o,role:"dialog",children:t}),(0,j.jsx)("div",{onFocus:()=>{i.current.focus()},tabIndex:"0"}),l]}),a):null}const fe=t()("Modal",["container","overlay"],{overlay:"ye2BZo",context:"Szmbbz",ad:"Ah-Nsc",hoc:"Wki41G",container:"gyZ4rc"})(he);he.propTypes={onCancel:L().func,children:L().node,theme:fe.themeType.isRequired},he.defaultProps={onCancel:c.noop,children:null};var me=fe;function be(e){return(0,j.jsx)(Y,{...e,routerLinkType:K.NavLink})}function Ee(e){let{children:t,className:n,ratio:r}=e;const o=r.split(":"),i=100*o[1]/o[0]+"%",a=(0,j.jsx)("div",{style:{paddingBottom:i},className:"EznFz3",children:(0,j.jsx)("div",{className:"_0vb7tq",children:t})});return n?(0,j.jsx)("div",{className:n,children:a}):a}function we(e){let{theme:t}=e;return(0,j.jsxs)("span",{className:(t.container?t.container+" ":"")+"_7zdld4",children:[(0,j.jsx)("span",{className:(t.circle?t.circle+" ":"")+"dBrB4g"}),(0,j.jsx)("span",{className:(t.circle?t.circle+" ":"")+"dBrB4g"}),(0,j.jsx)("span",{className:(t.circle?t.circle+" ":"")+"dBrB4g"})]})}Ee.defaultProps={children:null,className:null,ratio:"1:1"},Ee.propTypes={children:L().node,className:L().string,ratio:L().string},we.defaultProps={theme:{}},we.propTypes={theme:L().shape({container:L().string,circle:L().string})};var ve=t()("Throbber",["circle","container"],{container:"_7zdld4",context:"uIObt7",ad:"XIxe9o",hoc:"YOyORH",circle:"dBrB4g",bouncing:"TJe-6j"})(we);const ge={ABOVE_CURSOR:"ABOVE_CURSOR",ABOVE_ELEMENT:"ABOVE_ELEMENT",BELOW_CURSOR:"BELOW_CURSOR",BELOW_ELEMENT:"BELOW_ELEMENT"},ye=["border-bottom-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";"),xe=["border-top-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");const Te=(0,R.forwardRef)(((e,t)=>{let{children:n,theme:r}=e;const[o,i]=(0,R.useState)(null),a=(e,t,n,r)=>o&&function(e,t,n,r,o){const i=function(e){return{arrow:e.arrow.getBoundingClientRect(),container:e.container.getBoundingClientRect()}}(o),a=function(){const{pageXOffset:e,pageYOffset:t}=window,{documentElement:{clientHeight:n,clientWidth:r}}=document;return{left:e,right:e+r,top:t,bottom:t+n}}(),c=function(e,t,n){const{arrow:r,container:o}=n;return{arrowX:.5*(o.width-r.width),arrowY:o.height,containerX:e-o.width/2,containerY:t-o.height-r.height/1.5,baseArrowStyle:ye}}(e,t,i);if(c.containerX<a.left+6)c.containerX=a.left+6,c.arrowX=Math.max(6,e-c.containerX-i.arrow.width/2);else{const t=a.right-6-i.container.width;c.containerX>t&&(c.containerX=t,c.arrowX=Math.min(i.container.width-6,e-c.containerX-i.arrow.width/2))}c.containerY<a.top+6&&(c.containerY+=i.container.height+2*i.arrow.height,c.arrowY-=i.container.height+i.arrow.height,c.baseArrowStyle=xe);const l=`left:${c.containerX}px;top:${c.containerY}px`;o.container.setAttribute("style",l);const s=`${c.baseArrowStyle};left:${c.arrowX}px;top:${c.arrowY}px`;o.arrow.setAttribute("style",s)}(e,t,0,0,o);return(0,R.useImperativeHandle)(t,(()=>({pointTo:a}))),(0,R.useEffect)((()=>{const e=function(e){const t=document.createElement("div");e.arrow&&t.setAttribute("class",e.arrow);const n=document.createElement("div");e.content&&n.setAttribute("class",e.content);const r=document.createElement("div");return e.container&&r.setAttribute("class",e.container),r.appendChild(t),r.appendChild(n),document.body.appendChild(r),{container:r,arrow:t,content:n}}(r);return i(e),()=>{document.body.removeChild(e.container),i(null)}}),[r]),o?(0,de.createPortal)(n,o.content):null}));Te.propTypes={children:L().node,theme:L().shape().isRequired},Te.defaultProps={children:null};var ke=Te;function Ce(e){let{children:t,placement:n,tip:r,theme:o}=e;const i=(0,R.useRef)(),a=(0,R.useRef)(),[c,l]=(0,R.useState)(!1);return(0,R.useEffect)((()=>{if(c&&null!==r){const e=()=>l(!1);return window.addEventListener("scroll",e),()=>window.removeEventListener("scroll",e)}}),[c,r]),(0,j.jsxs)("div",{className:o.wrapper,onMouseLeave:()=>l(!1),onMouseMove:e=>((e,t)=>{if(c){const r=a.current.getBoundingClientRect();e<r.left||e>r.right||t<r.top||t>r.bottom?l(!1):i.current&&i.current.pointTo(e+window.pageXOffset,t+window.pageYOffset,n,a.current)}else l(!0)})(e.clientX,e.clientY),ref:a,children:[c&&null!==r?(0,j.jsx)(ke,{ref:i,theme:o,children:r}):null,t]})}const Pe=t()("WithTooltip",["appearance","arrow","container","content","wrapper"],{arrow:"M9gywF",ad:"_4xT7zE",hoc:"zd-vnH",context:"GdZucr",container:"f9gY8K",appearance:"L4ubm-",wrapper:"_4qDBRM"})(Ce);Pe.PLACEMENTS=ge,Ce.propTypes={children:L().node,placement:L().oneOf(Object.values(ge)),theme:Pe.themeType.isRequired,tip:L().node},Ce.defaultProps={children:null,placement:ge.ABOVE_CURSOR,tip:null};var Ne=Pe,Se=__webpack_require__(656),qe=__webpack_require__.n(Se),Re={container:"jTxmOX",context:"dzIcLh",ad:"_5a9XX1",hoc:"_7sH52O"};function Ae(e){let{autoplay:t,src:n,theme:r,title:o}=e,[i,a]=n.split("?");a=a?qe().parse(a):{};const c=a.v||i.match(/\/([a-zA-Z0-9-_]*)$/)[1];return i=`https://www.youtube.com/embed/${c}`,delete a.v,a.autoplay=t?1:0,i+=`?${qe().stringify(a)}`,(0,j.jsxs)(Ee,{className:r.container,ratio:"16:9",children:[(0,j.jsx)(ve,{theme:Re}),(0,j.jsx)("iframe",{allow:"autoplay",allowFullScreen:!0,className:r.video,src:i,title:o})]})}const Le=t()("YouTubeVideo",["container","video"],{container:"sXHM81",context:"veKyYi",ad:"r3ABzd",hoc:"YKcPnR",video:"SlV2zw"})(Ae);Ae.propTypes={autoplay:L().bool,src:L().string.isRequired,theme:Le.themeType.isRequired,title:L().string},Ae.defaultProps={autoplay:!1,title:""};var Oe=Le;const je=n.requireWeak("./server","/")}(),__webpack_exports__}()}));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@babel/runtime/helpers/classPrivateFieldGet"),require("@babel/runtime/helpers/classPrivateFieldSet"),require("@dr.pogodin/react-global-state"),require("@dr.pogodin/react-themes"),require("axios"),require("dayjs"),require("lodash"),require("prop-types"),require("qs"),require("react"),require("react-dom"),require("react-dom/client"),require("react-helmet"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["@babel/runtime/helpers/classPrivateFieldGet","@babel/runtime/helpers/classPrivateFieldSet","@dr.pogodin/react-global-state","@dr.pogodin/react-themes","axios","dayjs","lodash","prop-types","qs","react","react-dom","react-dom/client","react-helmet","react-router-dom"],t):"object"==typeof exports?exports["@dr.pogodin/react-utils"]=t(require("@babel/runtime/helpers/classPrivateFieldGet"),require("@babel/runtime/helpers/classPrivateFieldSet"),require("@dr.pogodin/react-global-state"),require("@dr.pogodin/react-themes"),require("axios"),require("dayjs"),require("lodash"),require("prop-types"),require("qs"),require("react"),require("react-dom"),require("react-dom/client"),require("react-helmet"),require("react-router-dom")):e["@dr.pogodin/react-utils"]=t(e["@babel/runtime/helpers/classPrivateFieldGet"],e["@babel/runtime/helpers/classPrivateFieldSet"],e["@dr.pogodin/react-global-state"],e["@dr.pogodin/react-themes"],e.axios,e.dayjs,e.lodash,e["prop-types"],e.qs,e.react,e["react-dom"],e["react-dom/client"],e["react-helmet"],e["react-router-dom"])}("undefined"!=typeof self?self:this,(function(__WEBPACK_EXTERNAL_MODULE__226__,__WEBPACK_EXTERNAL_MODULE__556__,__WEBPACK_EXTERNAL_MODULE__899__,__WEBPACK_EXTERNAL_MODULE__198__,__WEBPACK_EXTERNAL_MODULE__300__,__WEBPACK_EXTERNAL_MODULE__760__,__WEBPACK_EXTERNAL_MODULE__467__,__WEBPACK_EXTERNAL_MODULE__99__,__WEBPACK_EXTERNAL_MODULE__656__,__WEBPACK_EXTERNAL_MODULE__156__,__WEBPACK_EXTERNAL_MODULE__111__,__WEBPACK_EXTERNAL_MODULE__715__,__WEBPACK_EXTERNAL_MODULE__383__,__WEBPACK_EXTERNAL_MODULE__128__){return function(){"use strict";var __webpack_modules__={450:function(e,t,n){n.r(t),n.d(t,{IS_CLIENT_SIDE:function(){return r},IS_SERVER_SIDE:function(){return o},buildTimestamp:function(){return l},getBuildInfo:function(){return c},isDevBuild:function(){return i},isProdBuild:function(){return a}});const r="object"!=typeof process||!process.versions||!process.versions.node||!!n.g.REACT_UTILS_FORCE_CLIENT_SIDE,o=!r;function i(){return!1}function a(){return!0}function c(){return(r?window:n.g).TRU_BUILD_INFO}function l(){return c().timestamp}},869:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{requireWeak:function(){return requireWeak},resolveWeak:function(){return resolveWeak}});var _isomorphy__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(450);function requireWeak(modulePath,basePath){if(_isomorphy__WEBPACK_IMPORTED_MODULE_0__.IS_CLIENT_SIDE)return null;try{const{resolve:resolve}=eval("require")("path"),path=basePath?resolve(basePath,modulePath):modulePath,{default:def,...named}=eval("require")(path);return def?(Object.entries(named).forEach((e=>{let[t,n]=e;if(def[t])throw Error("Conflict between default and named exports");def[t]=n})),def):named}catch{return null}}function resolveWeak(e){return e}},251:function(e,t,n){var r=n(156),o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,c=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,n){var r,i={},s=null,u=null;for(r in void 0!==n&&(s=""+n),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,r)&&!l.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:o,type:e,key:s,ref:u,props:i,_owner:c.current}}t.Fragment=i,t.jsx=s,t.jsxs=s},893:function(e,t,n){e.exports=n(251)},226:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__226__},556:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__556__},899:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__899__},198:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__198__},300:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__300__},760:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__760__},467:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__467__},99:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__99__},656:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__656__},156:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__156__},111:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__111__},715:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__715__},383:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__383__},128:function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__128__}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=function(e,t){for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};return function(){__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Barrier:function(){return w},BaseModal:function(){return he},Button:function(){return $},Checkbox:function(){return Q},Dropdown:function(){return ne},Emitter:function(){return x},GlobalStateProvider:function(){return s.GlobalStateProvider},Input:function(){return ie},JU:function(){return W},Link:function(){return G},MetaTags:function(){return _e},Modal:function(){return me},NavLink:function(){return be},PT:function(){return L},PageLayout:function(){return le},ScalableRect:function(){return Ee},Semaphore:function(){return R},ThemeProvider:function(){return e.ThemeProvider},Throbber:function(){return ve},WithTooltip:function(){return Se},YouTubeVideo:function(){return Oe},api:function(){return I()},client:function(){return Z},config:function(){return r},getGlobalState:function(){return s.getGlobalState},getSsrContext:function(){return s.getSsrContext},isomorphy:function(){return o},newBarrier:function(){return v},server:function(){return je},splitComponent:function(){return D},themed:function(){return t()},time:function(){return y},useAsyncCollection:function(){return s.useAsyncCollection},useAsyncData:function(){return s.useAsyncData},useGlobalState:function(){return s.useGlobalState},webpack:function(){return n},withRetries:function(){return U}});var e=__webpack_require__(198),t=__webpack_require__.n(e),n=__webpack_require__(869),r=(0,n.requireWeak)("config")||window.CONFIG||{},o=__webpack_require__(450),i=__webpack_require__(760),a=__webpack_require__.n(i),c=__webpack_require__(467),l=__webpack_require__(156),s=__webpack_require__(899),u=__webpack_require__(226),_=__webpack_require__.n(u),d=__webpack_require__(556),p=__webpack_require__.n(d);function h(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}var f=new WeakMap,m=new WeakMap,b=new WeakMap,E=new WeakMap;class w extends Promise{constructor(e){let t,n;super(((r,o)=>{t=e=>{r(e),p()(this,m,!0)},n=e=>{o(e),p()(this,E,!0)},e&&e(t,n)})),h(this,f,{writable:!0,value:void 0}),h(this,m,{writable:!0,value:!1}),h(this,b,{writable:!0,value:void 0}),h(this,E,{writable:!0,value:!1}),p()(this,f,t),p()(this,b,n)}get resolve(){return _()(this,f)}get resolved(){return _()(this,m)}get reject(){return _()(this,b)}get rejected(){return _()(this,E)}then(e,t){const n=super.then(e,t);return p()(n,f,_()(this,f)),p()(n,b,_()(this,b)),n}}function v(e){return new w(e)}async function g(e){const t=new w;if(e>0){const n=setTimeout(t.resolve.bind(t),e);t.abort=()=>clearTimeout(n)}else t.abort=c.noop,t.resolve();return t}a().SEC_MS=1e3,a().MIN_MS=60*a().SEC_MS,a().HOUR_MS=60*a().MIN_MS,a().DAY_MS=24*a().HOUR_MS,a().YEAR_MS=365*a().DAY_MS,a().now=Date.now,a().timer=g,a().useCurrent=function(){let{autorefresh:e=!1,globalStatePath:t="currentTime",precision:n=5*a().SEC_MS}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[r,o]=(0,s.useGlobalState)(t,Date.now);return(0,l.useEffect)((()=>{let t;const r=()=>{o((e=>{const t=Date.now();return Math.abs(t-e)>n?t:e})),e&&(t=setTimeout(r,n))};return r(),()=>{t&&clearTimeout(t)}}),[e,n,o]),r};var y=a();class x{constructor(){this.listeners=[]}get hasListeners(){return!!this.listeners.length}addListener(e){return this.listeners.includes(e)||this.listeners.push(e),()=>this.removeListener(e)}emit(){const{listeners:e}=this;for(let t=0;t<e.length;++t)e[t](...arguments)}removeListener(e){const t=this.listeners.indexOf(e);t>=0&&this.listeners.splice(t,1)}}function T(e,t,n){k(e,t),t.set(e,n)}function k(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function C(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}var P=new WeakSet,S=new WeakMap,N=new WeakMap,q=new WeakMap;class R{constructor(e){var t;k(this,t=P),t.add(this),T(this,S,{writable:!0,value:!1}),T(this,N,{writable:!0,value:[]}),T(this,q,{writable:!0,value:void 0}),p()(this,q,!!e)}get ready(){return _()(this,q)}setReady(e){const t=!!e;_()(this,q)!==t&&(p()(this,q,t),t&&!_()(this,S)&&C(this,P,A).call(this))}async seize(){await this.waitReady(),this.setReady(!1)}async waitReady(){if(!_()(this,q)||_()(this,N).length){const e=v();_()(this,N).push(e),await e,_()(this,N).shift()}}}function A(){if(_()(this,q)&&_()(this,N).length&&(_()(this,N)[0].resolve(),_()(this,N).length))return setTimeout(C(this,P,A).bind(this)),void p()(this,S,!0);p()(this,S,!1)}var L=__webpack_require__(99),O=__webpack_require__.n(L),j=__webpack_require__(893);function M(e){let{children:t,chunkName:n,getComponent:r,placeholder:i,...a}=e;const{current:c}=(0,l.useRef)({mounted:!1,pendingStyles:[]}),{publicPath:u}=(0,o.getBuildInfo)(),_=(0,l.lazy)((async()=>{const e=await r();return c.pendingStyles.length&&await Promise.all(c.pendingStyles),e.default?e:{default:e}}));if(o.IS_SERVER_SIDE){const{chunks:e}=(0,s.getGlobalState)().ssrContext;if(e.includes(n))throw Error(`Chunk name clash for "${n}"`);e.push(n)}else c.mounted||(c.mounted=!0,window.CHUNK_GROUPS[n].forEach((e=>{if(!e.endsWith(".css"))return;const t=`${u}/${e}`;let n=document.querySelector(`link[href="${t}"]`);if(!n){n=document.createElement("link"),n.setAttribute("href",t),n.setAttribute("rel","stylesheet");const e=v();n.onload=e.resolve,n.onerror=e.resolve,c.pendingStyles.push(e),document.querySelector("head").appendChild(n)}window.STYLESHEET_USAGE_COUNTERS||={},window.STYLESHEET_USAGE_COUNTERS[t]||=0,++window.STYLESHEET_USAGE_COUNTERS[t]})));return(0,l.useEffect)((()=>()=>{c.mounted=!1,window.CHUNK_GROUPS[n].forEach((e=>{if(!e.endsWith(".css"))return;const t=`${u}/${e}`;if(--window.STYLESHEET_USAGE_COUNTERS[t]<=0){const e=document.querySelector(`link[href="${t}"]`);document.querySelector("head").removeChild(e)}}))}),[n,c,u]),(0,j.jsx)(l.Suspense,{fallback:i,children:(0,j.jsx)(_,{...a,children:t})})}function D(e){let{chunkName:t,getComponent:n,placeholder:r}=e;return function(){let{children:e,...o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,l.createElement)(M,{...o,chunkName:t,getComponent:n,placeholder:r},e)}}let B;M.propTypes={children:O().node,chunkName:O().string.isRequired,getComponent:O().func.isRequired,placeholder:O().node},M.defaultProps={children:void 0,placeholder:void 0},t().COMPOSE=e.COMPOSE,t().PRIORITY=e.PRIORITY;try{B=process.env.NODE_CONFIG_ENV}catch{}const W="production"!==(B||"production")&&n.requireWeak("./jest","/");async function U(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;for(let r=1;;++r)try{return await e()}catch(e){if(!(r<t))throw e;await g(n)}}var X=__webpack_require__(300),I=__webpack_require__.n(X),K=__webpack_require__(128);function Y(e){let{children:t,className:n,disabled:r,enforceA:o,keepScrollPosition:i,onClick:a,onMouseDown:c,openNewTab:s,replace:u,routerLinkType:_,to:d,...p}=e;return r||o||s||d.match(/^(#|(https?|mailto):)/)?(0,j.jsx)("a",{className:(n?n+" ":"")+"zH52sA",disabled:r,href:d,onClick:r?e=>e.preventDefault():a,onMouseDown:r?e=>e.preventDefault():c,rel:"noopener noreferrer",target:s?"_blank":"",children:t}):(0,l.createElement)(_,{className:n,disabled:r,onMouseDown:c,replace:u,to:d,onClick:e=>{a&&a(e),i||window.scroll(0,0)},...p},t)}function G(e){return(0,j.jsx)(Y,{...e,routerLinkType:K.Link})}function F(e){let{active:t,children:n,disabled:r,enforceA:o,onClick:i,onMouseDown:a,openNewTab:c,replace:l,theme:s,to:u}=e,_=s.button;return t&&s.active&&(_+=` ${s.active}`),r?(s.disabled&&(_+=` ${s.disabled}`),(0,j.jsx)("div",{className:_,children:n})):u?(0,j.jsx)(G,{className:_,enforceA:o,onClick:i,onMouseDown:a,openNewTab:c,replace:l,to:u,children:n}):(0,j.jsx)("div",{className:_,onClick:i,onKeyPress:i,onMouseDown:a,role:"button",tabIndex:0,children:n})}Y.defaultProps={children:null,className:null,disabled:!1,enforceA:!1,keepScrollPosition:!1,onClick:null,onMouseDown:null,openNewTab:!1,replace:!1,to:""},Y.propTypes={children:O().node,className:O().string,disabled:O().bool,enforceA:O().bool,keepScrollPosition:O().bool,onClick:O().func,onMouseDown:O().func,openNewTab:O().bool,replace:O().bool,routerLinkType:O().elementType.isRequired,to:O().oneOfType([O().object,O().string])};const H=t()("Button",["active","button","disabled"],{button:"E1FNQT",context:"KM0v4f",ad:"_3jm1-Q",hoc:"_0plpDL",active:"MAe9O6",disabled:"Br9IWV"})(F);F.defaultProps={active:!1,children:void 0,disabled:!1,enforceA:!1,onClick:void 0,onMouseDown:void 0,openNewTab:!1,replace:!1,to:void 0},F.propTypes={active:O().bool,children:O().node,disabled:O().bool,enforceA:O().bool,onClick:O().func,onMouseDown:O().func,openNewTab:O().bool,replace:O().bool,theme:H.themeType.isRequired,to:O().oneOfType([O().object,O().string])};var $=H;function z(e){let{checked:t,label:n,onChange:r,theme:o}=e;return(0,j.jsxs)("div",{className:o.container,children:[void 0===n?null:(0,j.jsx)("p",{className:o.label,children:n}),(0,j.jsx)("input",{checked:t,className:o.checkbox,onChange:r,type:"checkbox"})]})}const V=t()("Checkbox",["checkbox","container","label"],{checkbox:"A-f8qJ",context:"dNQcC6",ad:"earXxa",hoc:"qAPfQ6",container:"Kr0g3M",label:"_3dML-O"})(z);z.propTypes={checked:O().bool,label:O().string,onChange:O().func,theme:V.themeType.isRequired},z.defaultProps={checked:void 0,label:void 0,onChange:void 0};var Q=V,J=__webpack_require__(715);function Z(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=document.getElementById("react-view"),r=(0,j.jsx)(s.GlobalStateProvider,{initialState:window.ISTATE,children:(0,j.jsx)(K.BrowserRouter,{children:(0,j.jsx)(e,{})})});t.dontHydrate?(0,J.createRoot)(n).render(r):(0,J.hydrateRoot)(n,r)}function ee(e){let{filter:t,label:n,onChange:r,options:o,theme:i,value:a}=e;const l=[(0,j.jsx)("option",{className:i.hiddenOption,children:"‌"},"__reactUtilsHiddenOption")];for(let e=0;e<o.length;++e){let n=o[e];t&&!t(n)||((0,c.isString)(n)&&(n={value:n}),l.push((0,j.jsx)("option",{className:i.option,value:n.value,children:void 0===n.name?n.value:n.name},n.value)))}return(0,j.jsxs)("div",{className:i.container,children:[void 0===n?null:(0,j.jsx)("p",{className:i.label,children:n}),(0,j.jsx)("select",{className:i.select,onChange:r,value:a,children:l}),(0,j.jsx)("div",{className:i.arrow,children:"▼"})]})}const te=t()("Dropdown",["arrow","container","hiddenOption","label","option","select"],{arrow:"-zPK7Y",context:"haRIry",ad:"D4XHG2",hoc:"N3nd34",container:"_9CQpeA",label:"Gv0kyu",hiddenOption:"RdW3yR",select:"JXK1uw"})(ee);ee.propTypes={filter:O().func,label:O().string,onChange:O().func,options:O().arrayOf(O().oneOfType([O().shape({name:O().node,value:O().string.isRequired}),O().string]).isRequired),theme:te.themeType.isRequired,value:O().string},ee.defaultProps={filter:void 0,label:void 0,onChange:void 0,options:[],value:void 0};var ne=te;const re=(0,l.forwardRef)(((e,t)=>{let{label:n,theme:r,...o}=e;return(0,j.jsxs)("span",{className:r.container,children:[void 0===n?null:(0,j.jsx)("p",{className:r.label,children:n}),(0,j.jsx)("input",{className:r.input,ref:t,...o})]})})),oe=t()("Input",["container","input","label"],{container:"Cxx397",context:"X5WszA",ad:"_8s7GCr",hoc:"TVlBYc",input:"M07d4s",label:"gfbdq-"})(re);re.propTypes={label:O().string,theme:oe.themeType.isRequired},re.defaultProps={label:void 0};var ie=oe;function ae(e){let{children:t,leftSidePanelContent:n,rightSidePanelContent:r,theme:o}=e;return(0,j.jsxs)("div",{className:o.container,children:[(0,j.jsx)("div",{className:[o.sidePanel,o.leftSidePanel].join(" "),children:n}),(0,j.jsx)("div",{className:o.mainPanel,children:t}),(0,j.jsx)("div",{className:[o.sidePanel,o.rightSidePanel].join(" "),children:r})]})}const ce=t()("PageLayout",["container","leftSidePanel","mainPanel","rightSidePanel","sidePanel"],{container:"T3cuHB",context:"m4mL-M",ad:"m3-mdC",hoc:"J15Z4H",mainPanel:"pPlQO2",sidePanel:"lqNh4h"})(ae);ae.propTypes={children:O().node,leftSidePanelContent:O().node,rightSidePanelContent:O().node,theme:ce.themeType.isRequired},ae.defaultProps={children:null,leftSidePanelContent:null,rightSidePanelContent:null};var le=ce,se=__webpack_require__(383);const ue=(0,l.createContext)();function _e(e){let{children:t,description:n,image:r,siteName:o,socialDescription:i,socialTitle:a,title:c,url:s}=e;const u=a||c,_=i||n,d=(0,l.useMemo)((()=>({description:n,image:r,siteName:o,socialDescription:i,socialTitle:a,title:c,url:s})),[n,r,o,i,a,c,s]);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(se.Helmet,{children:[(0,j.jsx)("title",{children:c}),(0,j.jsx)("meta",{name:"description",content:n}),(0,j.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,j.jsx)("meta",{name:"twitter:title",content:u}),(0,j.jsx)("meta",{name:"twitter:description",content:_}),r?(0,j.jsx)("meta",{name:"twitter:image",content:r}):null,o?(0,j.jsx)("meta",{name:"twitter:site",content:`@${o}`}):null,(0,j.jsx)("meta",{name:"og:title",content:u}),r?(0,j.jsx)("meta",{name:"og:image",content:r}):null,r?(0,j.jsx)("meta",{name:"og:image:alt",content:u}):null,(0,j.jsx)("meta",{name:"og:description",content:_}),o?(0,j.jsx)("meta",{name:"og:sitename",content:o}):null,s?(0,j.jsx)("meta",{name:"og:url",content:s}):null]}),t?(0,j.jsx)(ue.Provider,{value:d,children:t}):null]})}_e.Context=ue,_e.defaultProps={children:null,image:null,siteName:null,socialDescription:null,socialTitle:null,url:null},_e.propTypes={children:O().node,description:O().string.isRequired,image:O().string,siteName:O().string,socialDescription:O().string,socialTitle:O().string,title:O().string.isRequired,url:O().string};var de=__webpack_require__(111),pe=__webpack_require__.n(de);function he(e){let{children:t,onCancel:n,theme:r}=e;const o=(0,l.useRef)(),i=(0,l.useRef)(),[a,c]=(0,l.useState)();(0,l.useEffect)((()=>{const e=document.createElement("div");return document.body.classList.add("scrolling-disabled-by-modal"),document.body.appendChild(e),c(e),()=>{document.body.classList.remove("scrolling-disabled-by-modal"),document.body.removeChild(e)}}),[]);const s=(0,l.useMemo)((()=>(0,j.jsx)("div",{onFocus:()=>{const e=o.current.querySelectorAll("*");for(let t=e.length-1;t>=0;--t)if(e[t].focus(),document.activeElement===e[t])return;i.current.focus()},tabIndex:"0"})),[]);return a?pe().createPortal((0,j.jsxs)(j.Fragment,{children:[s,(0,j.jsx)("div",{"aria-label":"Cancel",className:r.overlay,onClick:()=>n(),onKeyDown:e=>{"Escape"===e.key&&n()},ref:e=>{e&&e!==i.current&&(i.current=e,e.focus())},role:"button",tabIndex:"0"}),(0,j.jsx)("div",{"aria-modal":"true",className:r.container,onWheel:e=>e.stopPropagation(),ref:o,role:"dialog",children:t}),(0,j.jsx)("div",{onFocus:()=>{i.current.focus()},tabIndex:"0"}),s]}),a):null}const fe=t()("Modal",["container","overlay"],{overlay:"ye2BZo",context:"Szmbbz",ad:"Ah-Nsc",hoc:"Wki41G",container:"gyZ4rc"})(he);he.propTypes={onCancel:O().func,children:O().node,theme:fe.themeType.isRequired},he.defaultProps={onCancel:c.noop,children:null};var me=fe;function be(e){return(0,j.jsx)(Y,{...e,routerLinkType:K.NavLink})}function Ee(e){let{children:t,className:n,ratio:r}=e;const o=r.split(":"),i=100*o[1]/o[0]+"%",a=(0,j.jsx)("div",{style:{paddingBottom:i},className:"EznFz3",children:(0,j.jsx)("div",{className:"_0vb7tq",children:t})});return n?(0,j.jsx)("div",{className:n,children:a}):a}function we(e){let{theme:t}=e;return(0,j.jsxs)("span",{className:(t.container?t.container+" ":"")+"_7zdld4",children:[(0,j.jsx)("span",{className:(t.circle?t.circle+" ":"")+"dBrB4g"}),(0,j.jsx)("span",{className:(t.circle?t.circle+" ":"")+"dBrB4g"}),(0,j.jsx)("span",{className:(t.circle?t.circle+" ":"")+"dBrB4g"})]})}Ee.defaultProps={children:null,className:null,ratio:"1:1"},Ee.propTypes={children:O().node,className:O().string,ratio:O().string},we.defaultProps={theme:{}},we.propTypes={theme:O().shape({container:O().string,circle:O().string})};var ve=t()("Throbber",["circle","container"],{container:"_7zdld4",context:"uIObt7",ad:"XIxe9o",hoc:"YOyORH",circle:"dBrB4g",bouncing:"TJe-6j"})(we);const ge={ABOVE_CURSOR:"ABOVE_CURSOR",ABOVE_ELEMENT:"ABOVE_ELEMENT",BELOW_CURSOR:"BELOW_CURSOR",BELOW_ELEMENT:"BELOW_ELEMENT"},ye=["border-bottom-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";"),xe=["border-top-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");const Te=(0,l.forwardRef)(((e,t)=>{let{children:n,theme:r}=e;const[o,i]=(0,l.useState)(null),a=(e,t,n,r)=>o&&function(e,t,n,r,o){const i=function(e){return{arrow:e.arrow.getBoundingClientRect(),container:e.container.getBoundingClientRect()}}(o),a=function(){const{pageXOffset:e,pageYOffset:t}=window,{documentElement:{clientHeight:n,clientWidth:r}}=document;return{left:e,right:e+r,top:t,bottom:t+n}}(),c=function(e,t,n){const{arrow:r,container:o}=n;return{arrowX:.5*(o.width-r.width),arrowY:o.height,containerX:e-o.width/2,containerY:t-o.height-r.height/1.5,baseArrowStyle:ye}}(e,t,i);if(c.containerX<a.left+6)c.containerX=a.left+6,c.arrowX=Math.max(6,e-c.containerX-i.arrow.width/2);else{const t=a.right-6-i.container.width;c.containerX>t&&(c.containerX=t,c.arrowX=Math.min(i.container.width-6,e-c.containerX-i.arrow.width/2))}c.containerY<a.top+6&&(c.containerY+=i.container.height+2*i.arrow.height,c.arrowY-=i.container.height+i.arrow.height,c.baseArrowStyle=xe);const l=`left:${c.containerX}px;top:${c.containerY}px`;o.container.setAttribute("style",l);const s=`${c.baseArrowStyle};left:${c.arrowX}px;top:${c.arrowY}px`;o.arrow.setAttribute("style",s)}(e,t,0,0,o);return(0,l.useImperativeHandle)(t,(()=>({pointTo:a}))),(0,l.useEffect)((()=>{const e=function(e){const t=document.createElement("div");e.arrow&&t.setAttribute("class",e.arrow);const n=document.createElement("div");e.content&&n.setAttribute("class",e.content);const r=document.createElement("div");return e.container&&r.setAttribute("class",e.container),r.appendChild(t),r.appendChild(n),document.body.appendChild(r),{container:r,arrow:t,content:n}}(r);return i(e),()=>{document.body.removeChild(e.container),i(null)}}),[r]),o?(0,de.createPortal)(n,o.content):null}));Te.propTypes={children:O().node,theme:O().shape().isRequired},Te.defaultProps={children:null};var ke=Te;function Ce(e){let{children:t,placement:n,tip:r,theme:o}=e;const i=(0,l.useRef)(),a=(0,l.useRef)(),[c,s]=(0,l.useState)(!1);return(0,l.useEffect)((()=>{if(c&&null!==r){const e=()=>s(!1);return window.addEventListener("scroll",e),()=>window.removeEventListener("scroll",e)}}),[c,r]),(0,j.jsxs)("div",{className:o.wrapper,onMouseLeave:()=>s(!1),onMouseMove:e=>((e,t)=>{if(c){const r=a.current.getBoundingClientRect();e<r.left||e>r.right||t<r.top||t>r.bottom?s(!1):i.current&&i.current.pointTo(e+window.pageXOffset,t+window.pageYOffset,n,a.current)}else s(!0)})(e.clientX,e.clientY),ref:a,children:[c&&null!==r?(0,j.jsx)(ke,{ref:i,theme:o,children:r}):null,t]})}const Pe=t()("WithTooltip",["appearance","arrow","container","content","wrapper"],{arrow:"M9gywF",ad:"_4xT7zE",hoc:"zd-vnH",context:"GdZucr",container:"f9gY8K",appearance:"L4ubm-",wrapper:"_4qDBRM"})(Ce);Pe.PLACEMENTS=ge,Ce.propTypes={children:O().node,placement:O().oneOf(Object.values(ge)),theme:Pe.themeType.isRequired,tip:O().node},Ce.defaultProps={children:null,placement:ge.ABOVE_CURSOR,tip:null};var Se=Pe,Ne=__webpack_require__(656),qe=__webpack_require__.n(Ne),Re={container:"jTxmOX",context:"dzIcLh",ad:"_5a9XX1",hoc:"_7sH52O"};function Ae(e){let{autoplay:t,src:n,theme:r,title:o}=e,[i,a]=n.split("?");a=a?qe().parse(a):{};const c=a.v||i.match(/\/([a-zA-Z0-9-_]*)$/)[1];return i=`https://www.youtube.com/embed/${c}`,delete a.v,a.autoplay=t?1:0,i+=`?${qe().stringify(a)}`,(0,j.jsxs)(Ee,{className:r.container,ratio:"16:9",children:[(0,j.jsx)(ve,{theme:Re}),(0,j.jsx)("iframe",{allow:"autoplay",allowFullScreen:!0,className:r.video,src:i,title:o})]})}const Le=t()("YouTubeVideo",["container","video"],{container:"sXHM81",context:"veKyYi",ad:"r3ABzd",hoc:"YKcPnR",video:"SlV2zw"})(Ae);Ae.propTypes={autoplay:O().bool,src:O().string.isRequired,theme:Le.themeType.isRequired,title:O().string},Ae.defaultProps={autoplay:!1,title:""};var Oe=Le;const je=n.requireWeak("./server","/")}(),__webpack_exports__}()}));
3
3
  //# sourceMappingURL=web.bundle.js.map