{"ast":null,"code":"\"use strict\";\n\nexports.__esModule = true;\nexports[\"default\"] = initializeBuildWatcher;\n\nvar _eventsource = require(\"./error-overlay/eventsource\");\n\nfunction initializeBuildWatcher() {\n var shadowHost = document.createElement('div');\n shadowHost.id = '__next-build-watcher'; // Make sure container is fixed and on a high zIndex so it shows\n\n shadowHost.style.position = 'fixed';\n shadowHost.style.bottom = '10px';\n shadowHost.style.right = '20px';\n shadowHost.style.width = 0;\n shadowHost.style.height = 0;\n shadowHost.style.zIndex = 99999;\n document.body.appendChild(shadowHost);\n var shadowRoot;\n var prefix = '';\n\n if (shadowHost.attachShadow) {\n shadowRoot = shadowHost.attachShadow({\n mode: 'open'\n });\n } else {\n // If attachShadow is undefined then the browser does not support\n // the Shadow DOM, we need to prefix all the names so there\n // will be no conflicts\n shadowRoot = shadowHost;\n prefix = '__next-build-watcher-';\n } // Container\n\n\n var container = createContainer(prefix);\n shadowRoot.appendChild(container); // CSS\n\n var css = createCss(prefix);\n shadowRoot.appendChild(css); // State\n\n var isVisible = false;\n var isBuilding = false;\n var timeoutId = null; // Handle events\n\n var evtSource = (0, _eventsource.getEventSourceWrapper)({\n path: '/_next/webpack-hmr'\n });\n evtSource.addMessageListener(function (event) {\n // This is the heartbeat event\n if (event.data === \"\\uD83D\\uDC93\") {\n return;\n }\n\n try {\n handleMessage(event);\n } catch (_unused) {}\n });\n\n function handleMessage(event) {\n var obj = JSON.parse(event.data); // eslint-disable-next-line default-case\n\n switch (obj.action) {\n case 'building':\n timeoutId && clearTimeout(timeoutId);\n isVisible = true;\n isBuilding = true;\n updateContainer();\n break;\n\n case 'built':\n isBuilding = false; // Wait for the fade out transtion to complete\n\n timeoutId = setTimeout(function () {\n isVisible = false;\n updateContainer();\n }, 100);\n updateContainer();\n break;\n }\n }\n\n function updateContainer() {\n if (isBuilding) {\n container.classList.add(prefix + \"building\");\n } else {\n container.classList.remove(prefix + \"building\");\n }\n\n if (isVisible) {\n container.classList.add(prefix + \"visible\");\n } else {\n container.classList.remove(prefix + \"visible\");\n }\n }\n}\n\nfunction createContainer(prefix) {\n var container = document.createElement('div');\n container.id = prefix + \"container\";\n container.innerHTML = \"\\n