{"version":3,"sources":["display.ts"],"sourcesContent":["import { client_type } from \"../utils/constants.ts\";\nimport { reset } from \"./reset.ts\";\n\nfunction setup() {\n\tif (client_type !== \"deno\" && globalThis.window && globalThis.document) {\n\t\tconst document = globalThis.document;\n\n\t\tdocument.body.style.width = \"100%\"\n\t\tdocument.body.style.height = \"100%\"\n\t\tdocument.body.style.margin = \"0\"\n\t\tdocument.documentElement.style.width = \"100%\"\n\t\tdocument.documentElement.style.height = \"100%\"\n\t\tdocument.head.insertAdjacentHTML('beforeend', '<meta name=\"viewport\" content=\"viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>')\n\t}\n}\n\n\nexport function displayFatalError(code:string, reset_btn = true) {\n\n\t// don't reset in deno\n\tif (client_type === \"deno\") {\n\t\tconsole.error(\"Fatal Error: \", code);\n\t\treturn;\n\t}\n\n\t// disable error screen (at least for now, immediately reset page)\n\tconsole.error `\n\tFATAL ERROR: ${code}\n\tCannot restore the current state. Deleting all caches.\n`\n\treset();\n\treturn;\n\n\t// @ts-ignore\n\tif (client_type !== \"deno\" && globalThis.window && globalThis.document) {\n\t\t// @ts-ignore\n\t\tconst document = globalThis.document;\n\t\tsetup();\n\n\t\tdocument.body.innerHTML = `\n<div style=\"display:flex;flex-direction:column;width:100%;height:100%;background:#0f0f0f;font-family:sans-serif;text-align:center;padding:5px;box-sizing:border-box\">\n\t<div style=\"flex:1;display:flex;flex-direction:column;width:100%;justify-content:center;align-items:center;color:#ddd;\">\n\t\t<h3 style=\"color:#ddd\">Oh no, something bad happened :/</h3>\n\t\t<div style=\"color:#bbb;margin-bottom:15px;\">Your app data on this device might not be recoverable</div>\n\t\t${reset_btn ? `<button style=\"all:unset;background:#333;padding:8px;border-radius:10px;text-align:center;font-size:1.1em\" onclick=\"reset()\">\n\t\t\tReset App\n\t\t</button>` : '' }\n\t</div>\n<span style=\"text-align:center;margin:30px;color:#bfaaaa\">error: ${code}</span>\n</div>`;\n\t}\n\telse {\n\t\tconsole.log `\nFATAL ERROR: ${code}\nCannot restore the current state. Deleting all caches (.datex-cache).\n\t\t`\n\t\t// @ts-ignore\n\t\treset()\n\t}\n}\n\nlet show_init_screen = true;\n\nexport function enableInitScreen(){\n\tshow_init_screen = true;\n}\n\nexport function disableInitScreen(){\n\tshow_init_screen = false;\n}\n\nlet keepScreen = false;\nlet showing_init_screen = false;\n\nexport function displayInit(message?:string) {\n\tif (showing_init_screen) return;\n\tif (!show_init_screen) return;\n\t// @ts-ignore\n\tif (client_type !== \"deno\" && globalThis.window && globalThis.document) {\n\t\t// @ts-ignore\n\t\tconst document = globalThis.document;\n\t\t// already content there, don't show init page\n\t\tif (document.body.children.length) {\n\t\t\tkeepScreen = true;\n\t\t\treturn; \n\t\t}\n\t\tsetup();\n\t\tshowing_init_screen = true;\n\t\tdocument.head.innerHTML += `<style>\n\t\t/**\n\t\t * ==============================================\n\t\t * Experimental: Gooey Effect\n\t\t * Dot Gathering\n\t\t * ==============================================\n\t\t */\n\t\t.dot-gathering {\n\t\t  position: relative;\n\t\t  width: 12px;\n\t\t  height: 12px;\n\t\t  border-radius: 6px;\n\t\t  background-color: #999;\n\t\t  color: transparent;\n\t\t  margin: -1px 0;\n\t\t}\n\t\t.dot-gathering::before, .dot-gathering::after {\n\t\t  content: \"\";\n\t\t  display: inline-block;\n\t\t  position: absolute;\n\t\t  top: 0;\n\t\t  left: -50px;\n\t\t  width: 12px;\n\t\t  height: 12px;\n\t\t  border-radius: 6px;\n\t\t  background-color: #999;\n\t\t  color: transparent;\n\t\t  opacity: 0;\n\t\t  animation: dot-gathering 2s infinite ease-in;\n\t\t}\n\t\t.dot-gathering::after {\n\t\t  animation-delay: 0.5s;\n\t\t}\n\t\t\n\t\t@keyframes dot-gathering {\n\t\t  0% {\n\t\t\topacity: 0;\n\t\t\ttransform: translateX(0);\n\t\t  }\n\t\t  35%, 60% {\n\t\t\topacity: 1;\n\t\t\ttransform: translateX(50px);\n\t\t  }\n\t\t  100% {\n\t\t\topacity: 0;\n\t\t\ttransform: translateX(100px);\n\t\t  }\n\t\t}\t\t\n</style>`\n\n\t\tdocument.body.innerHTML = `\n<div style=\"align-items:center;justify-content:center;display:flex;flex-direction:column;width:100%;height:100%;background:#0f0f0f;font-family:sans-serif;text-align:center;padding:5px;box-sizing:border-box\">\n\t${message ? `<div style=\"margin:10px\">${message}</div>` : ''}\n\t<div class=\"stage filter-contrast\">\n\t\t<div class=\"dot-gathering\"></div>\n\t</div>\n</div>`;\n\t}\n}\n\nexport function displayClear() {\n\tif (!show_init_screen || keepScreen) return;\n\t// @ts-ignore\n\tif (client_type != \"deno\" && globalThis.window && globalThis.document) {\n\t\t// @ts-ignore\n\t\tshowing_init_screen = false;\n\t\tglobalThis.document.body.innerHTML = \"\";\n\t}\n}"],"names":["client_type","reset","setup","globalThis","window","document","body","style","width","height","margin","documentElement","head","insertAdjacentHTML","displayFatalError","code","reset_btn","console","error","show_init_screen","enableInitScreen","disableInitScreen","keepScreen","showing_init_screen","displayInit","message","children","length","innerHTML","displayClear"],"mappings":"AAAA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,SAASC,KAAK,QAAQ,aAAa;AAEnC,SAASC;IACR,IAAIF,AAAgB,WAAhBA,eAA0BG,WAAWC,MAAM,IAAID,WAAWE,QAAQ,EAAE;QACvE,IAAMA,WAAWF,WAAWE,QAAQ;QAEpCA,SAASC,IAAI,CAACC,KAAK,CAACC,KAAK,GAAG,QAC5BH,SAASC,IAAI,CAACC,KAAK,CAACE,MAAM,GAAG,QAC7BJ,SAASC,IAAI,CAACC,KAAK,CAACG,MAAM,GAAG,KAC7BL,SAASM,eAAe,CAACJ,KAAK,CAACC,KAAK,GAAG,QACvCH,SAASM,eAAe,CAACJ,KAAK,CAACE,MAAM,GAAG,QACxCJ,SAASO,IAAI,CAACC,kBAAkB,CAAC,aAAa;IAC/C;AACD;AAGA,OAAO,SAASC,kBAAkBC,IAAW,EAAEC,YAAY,CAAA,CAAI;IAG9D,IAAIhB,AAAg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