{"version":3,"sources":["App.tsx","reportWebVitals.ts","serviceWorkerRegistration.ts","index.tsx"],"names":["PortalApp","React","lazy","hay_error","localStorageProvider","map","Map","JSON","parse","localStorage","getItem","window","addEventListener","console","log","removeItem","appCache","stringify","Array","from","entries","setItem","reload","location","App","props","useEffect","host","hostname","toLowerCase","href","replace","EvaluateInmediateRedirect","fallback","error","titulo","mensaje","tipo","subtitulo","onClick","value","provider","shouldRetryOnError","errorRetryCount","dedupingInterval","revalidateIfStale","revalidateOnFocus","revalidateOnReconnect","reportWebVitals","onPerfEntry","Function","then","getCLS","getFID","getFCP","getLCP","getTTFB","isLocalhost","Boolean","match","registerValidSW","swUrl","config","navigator","serviceWorker","register","registration","onupdatefound","installingWorker","installing","onstatechange","state","controller","waiting","postMessage","type","onUpdate","onSuccess","catch","event","data","ReactDOM","render","StrictMode","document","getElementById","URL","process","origin","fetch","headers","response","contentType","get","status","indexOf","ready","unregister","checkValidServiceWorker","serviceWorkerRegistration","e","ctrlKey","code","keyCode","preventDefault","iframe","getElementsByName","contentWindow","channelMessage","send","print"],"mappings":"2NAKA,MAAMA,EAAYC,IAAMC,MAAK,IAAM,uDAEnC,IAAIC,GAAY,EAEhB,SAASC,IAEP,MAAMC,EAAM,IAAIC,IAAIC,KAAKC,MAAMC,aAAaC,QAAQ,cAAgB,OAepE,OAZAC,OAAOC,iBAAiB,gBAAgB,KACtC,GAAIT,EAKFU,QAAQC,IAAI,iBAAkB,sBAC9BL,aAAaM,WAAW,iBANZ,CACZF,QAAQC,IAAI,iBAAkB,qBAC9B,MAAME,EAAWT,KAAKU,UAAUC,MAAMC,KAAKd,EAAIe,YAC/CX,aAAaY,QAAQ,YAAaL,EACnC,CAGA,IAIIX,CACR,CAED,SAASiB,IACPX,OAAOY,SAASD,QACjB,CAiEcE,MAvBf,SAAaC,GAMX,OAJAC,qBAAU,MA1CZ,WACE,MAAMC,EAAOhB,OAAOY,SAASK,SAASC,cACtC,OAAQF,GAEJ,IAAK,qBACL,IAAK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AEL,CA7FOoF,CAAwBrC,EAAOC,GAI/BC,UAAUC,cAAcgC,MAAM7C,MAAK,KACjCtC,QAAQC,IACN,0GADF,KAOF8C,EAAgBC,EAAOC,EACxB,GAEJ,CACF,CCrCHqC,CAAmC,CACjCvB,SAAWV,IACTrD,QAAQC,IAAI,SAAUoD,GACtBA,EAAa+B,aAAa9C,MAAK,IAAMxC,OAAOY,SAASD,UAArD,IAIJX,OAAOC,iBAAiB,WAAW,SAAUwF,GAC3C,GAAIA,EAAEC,UAAuB,SAAXD,EAAEE,MAAiC,KAAdF,EAAEG,SAAiB,CACxDH,EAAEI,iBACF,MAAMC,EAASrB,SAASsB,kBAAkB,mBAAmB,IAE7D,OAAID,QAAJ,IAAIA,OAAJ,EAAIA,EAAQE,gBACVC,IAAeC,KAAK,CAAElC,KAAM,SAAW8B,EAAOE,eAAe7B,OAAO5C,IAChErB,QAAQqB,MAAM,wCAAyCA,GACvDvB,OAAOmG,OAAP,GAIP,CACF,G","file":"static/js/main.3a6e7864.chunk.js","sourcesContent":["import { ErrorBoundary, PortalSplash } from '@portal/arq-portal-core';\r\nimport React, { Suspense, useEffect } from 'react';\r\n\r\nimport { SWRConfig } from 'swr';\r\n\r\nconst PortalApp = React.lazy(() => import('./PortalApp'));\r\n\r\nlet hay_error = false;\r\n\r\nfunction localStorageProvider() {\r\n // When initializing, we restore the data from `localStorage` into a map.\r\n const map = new Map(JSON.parse(localStorage.getItem('app-cache') || '[]'))\r\n\r\n // Before unloading the app, we write back all the data into `localStorage`.\r\n window.addEventListener('beforeunload', () => {\r\n if(!hay_error){\r\n console.log(\"arq-portal-app\", \"guardar sesión\");\r\n const appCache = JSON.stringify(Array.from(map.entries()))\r\n localStorage.setItem('app-cache', appCache)\r\n }else{\r\n console.log(\"arq-portal-app\", \"eliminar sesión\");\r\n localStorage.removeItem('app-cache');\r\n }\r\n })\r\n\r\n // We still use the map for write & read for performance.\r\n return map\r\n}\r\n\r\nfunction reload(){\r\n window.location.reload();\r\n}\r\n\r\nfunction EvaluateInmediateRedirect() {\r\n const host = window.location.hostname.toLowerCase();\r\n switch (host) {\r\n //DEV\r\n case \"dportal.gco.global\":\r\n case \"dportalsco.gco.global\":\r\n case \"dportalcatalanaoccidente.gco.global\":\r\n case \"dportalcatalanaoccidenteold.gco.global\":\r\n case \"dportalsb.gco.global\":\r\n case \"dportalsegurosbilbao.gco.global\":\r\n case \"dportalsegurosbilbaoold.gco.global\":\r\n case \"dportalpu.gco.global\":\r\n case \"dportalplusultra.gco.global\":\r\n case \"dportalplusultraold.gco.global\":\r\n case \"dportalnortehispana.gco.global\":\r\n // case \"dportalnortehispanaold.gco.global\":\r\n\r\n \r\n window.location.href = window.location.href.replace(host, \"dportaloccident.gco.global\");\r\n break;\r\n \r\n // PRE/PRO \r\n case \"portalsb.gco.global\":\r\n case \"portalsegurosbilbao.gco.global\":\r\n case \"portalsegurosbilbaoold.gco.global\":\r\n case \"portalpu.gco.global\":\r\n case \"portalplusultra.gco.global\":\r\n case \"portalplusultraold.gco.global\":\r\n case \"portalsco.gco.global\":\r\n case \"portalcatalanaoccidente.gco.global\":\r\n case \"portalcatalanaoccidenteold.gco.global\":\r\n case \"portalnortehispana.gco.global\":\r\n // case \"portalnortehispanaold.gco.global\":\r\n\r\n\r\n window.location.href = window.location.href.replace(host, \"portaloccident.gco.global\");\r\n break;\r\n \r\n }\r\n}\r\nfunction App(props: any) {\r\n \r\n useEffect(() => {\r\n EvaluateInmediateRedirect();\r\n }, []);\r\n\r\n return (\r\n {\r\n console.log(\"FALLBACK\", error);\r\n hay_error = true;\r\n localStorage.removeItem('app-cache');\r\n return Actualiza la página o pulsa aquí para volver a intentarlo}}>\r\n }}>\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n );\r\n}\r\n\r\nexport default App;\r\n\r\n\r\n","import { ReportHandler } from 'web-vitals';\r\n\r\nconst reportWebVitals = (onPerfEntry?: ReportHandler) => {\r\n if (onPerfEntry && onPerfEntry instanceof Function) {\r\n import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {\r\n getCLS(onPerfEntry);\r\n getFID(onPerfEntry);\r\n getFCP(onPerfEntry);\r\n getLCP(onPerfEntry);\r\n getTTFB(onPerfEntry);\r\n });\r\n }\r\n};\r\n\r\nexport default reportWebVitals;\r\n","// This optional code is used to register a service worker.\r\n// register() is not called by default.\r\n\r\n// This lets the app load faster on subsequent visits in production, and gives\r\n// it offline capabilities. However, it also means that developers (and users)\r\n// will only see deployed updates on subsequent visits to a page, after all the\r\n// existing tabs open on the page have been closed, since previously cached\r\n// resources are updated in the background.\r\n\r\n// To learn more about the benefits of this model and instructions on how to\r\n// opt-in, read https://cra.link/PWA\r\n\r\nconst isLocalhost = Boolean(\r\n window.location.hostname === 'localhost' ||\r\n // [::1] is the IPv6 localhost address.\r\n window.location.hostname === '[::1]' ||\r\n // 127.0.0.0/8 are considered localhost for IPv4.\r\n window.location.hostname.match(/^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)\r\n );\r\n \r\n type Config = {\r\n onSuccess?: (registration: ServiceWorkerRegistration) => void;\r\n onUpdate?: (registration: ServiceWorkerRegistration) => void;\r\n };\r\n \r\n export function register(config?: Config) {\r\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\r\n // The URL constructor is available in all browsers that support SW.\r\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\r\n if (publicUrl.origin !== window.location.origin) {\r\n // Our service worker won't work if PUBLIC_URL is on a different origin\r\n // from what our page is served on. This might happen if a CDN is used to\r\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\r\n return;\r\n }\r\n \r\n window.addEventListener('load', () => {\r\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\r\n \r\n if (isLocalhost) {\r\n // This is running on localhost. Let's check if a service worker still exists or not.\r\n checkValidServiceWorker(swUrl, config);\r\n \r\n // Add some additional logging to localhost, pointing developers to the\r\n // service worker/PWA documentation.\r\n navigator.serviceWorker.ready.then(() => {\r\n console.log(\r\n 'This web app is being served cache-first by a service ' +\r\n 'worker. To learn more, visit https://cra.link/PWA'\r\n );\r\n });\r\n } else {\r\n // Is not localhost. Just register service worker\r\n registerValidSW(swUrl, config);\r\n }\r\n });\r\n }\r\n }\r\n \r\n function registerValidSW(swUrl: string, config?: Config) {\r\n navigator.serviceWorker\r\n .register(swUrl)\r\n .then((registration) => {\r\n registration.onupdatefound = () => {\r\n const installingWorker = registration.installing;\r\n if (installingWorker == null) {\r\n return;\r\n }\r\n installingWorker.onstatechange = () => {\r\n if (installingWorker.state === 'installed') {\r\n if (navigator.serviceWorker.controller) {\r\n // At this point, the updated precached content has been fetched,\r\n // but the previous service worker will still serve the older\r\n // content until all client tabs are closed.\r\n // Old_cases\r\n // //console.log(\r\n // 'New content is available and will be used when all ' +\r\n // 'tabs for this page are closed. See https://cra.link/PWA.'\r\n // );\r\n // New Case even if there are multiple pages open(2 o more) we do a refresh\r\n if (registration.waiting) {\r\n registration.waiting.postMessage({ type: 'SKIP_WAITING' });\r\n }\r\n \r\n // Execute callback\r\n if (config && config.onUpdate) {\r\n config.onUpdate(registration);\r\n }\r\n } else {\r\n // At this point, everything has been precached.\r\n // It's the perfect time to display a\r\n // \"Content is cached for offline use.\" message.\r\n console.log('Content is cached for offline use.');\r\n \r\n // Execute callback\r\n if (config && config.onSuccess) {\r\n config.onSuccess(registration);\r\n }\r\n }\r\n }\r\n };\r\n };\r\n })\r\n .catch((error) => {\r\n console.error('Error during service worker registration:', error);\r\n });\r\n }\r\n \r\n function checkValidServiceWorker(swUrl: string, config?: Config) {\r\n // Check if the service worker can be found. If it can't reload the page.\r\n fetch(swUrl, {\r\n headers: { 'Service-Worker': 'script' },\r\n })\r\n .then((response) => {\r\n // Ensure service worker exists, and that we really are getting a JS file.\r\n const contentType = response.headers.get('content-type');\r\n if (\r\n response.status === 404 ||\r\n (contentType != null && contentType.indexOf('javascript') === -1)\r\n ) {\r\n // No service worker found. Probably a different app. Reload the page.\r\n navigator.serviceWorker.ready.then((registration) => {\r\n registration.unregister().then(() => {\r\n window.location.reload();\r\n });\r\n });\r\n } else {\r\n // Service worker found. Proceed as normal.\r\n registerValidSW(swUrl, config);\r\n }\r\n })\r\n .catch(() => {\r\n console.log('No internet connection found. App is running in offline mode.');\r\n });\r\n }\r\n \r\n export function unregister() {\r\n if ('serviceWorker' in navigator) {\r\n navigator.serviceWorker.ready\r\n .then((registration) => {\r\n registration.unregister();\r\n })\r\n .catch((error) => {\r\n console.error(error.message);\r\n });\r\n }\r\n }\r\n\r\n navigator.serviceWorker.addEventListener('message', (event) => {\r\n if (event.data && event.data.type === 'NEW_VERSION_ACTIVATED') {\r\n console.log('New Service Worker activated. Reloading page...');\r\n window.location.reload(); // Recarga la página automáticamente\r\n }\r\n });\r\n\r\n ","import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport App from './App';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport * as serviceWorkerRegistration from './serviceWorkerRegistration';\r\nimport { channelMessage } from '@portal/arq-portal-core';\r\n\r\nReactDOM.render(\r\n \r\n \r\n ,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals(console.log);\r\n\r\nserviceWorkerRegistration.register({\r\n onUpdate: (registration) => {\r\n console.log(\"update\", registration);\r\n registration.unregister().then(() => window.location.reload());\r\n }\r\n});\r\n\r\nwindow.addEventListener(\"keydown\", function (e) {\r\n if (e.ctrlKey && (e.code === \"KeyP\" || e.keyCode === 80)) {\r\n e.preventDefault();\r\n const iframe = document.getElementsByName(\"<__MAINFRAME__>\")[0] as HTMLIFrameElement;\r\n\r\n if (iframe?.contentWindow) {\r\n channelMessage.send({ type: 'PRINT' }, iframe.contentWindow).catch((error) => {\r\n console.error(\"Error al enviar el mensaje al iframe:\", error);\r\n window.print();\r\n }\r\n );\r\n }\r\n }\r\n});"],"sourceRoot":""}