\n
\n ${this.remaining.toFormat(\"m:ss\")}\n
\n
`\n }\n\n updateRemaining() {\n if (this.sessionEndTime == null) return\n this.remaining = this.sessionEndTime.diffNow()\n\n const remainingMills = this.remaining.toMillis()\n\n if (\n this.keepAliveOnRemainMills != null &&\n remainingMills <= this.keepAliveOnRemainMills\n )\n this.revalidateSession()\n\n if (remainingMills <= 0) this._onExpiring()\n }\n\n /**\n * Sends a Session KeepAlive request to the server and refreshes the end session countdown\n * @param revalidateDuration Session Duration\n */\n private async revalidateSession() {\n const endTime = DateTime.now().plus(this.sessionDuration)\n\n const result = await fetch(\"/Account/KeepAlive\")\n if (result.ok) {\n this.sessionEndTime = endTime\n }\n }\n\n private _onExpiring() {\n location.reload()\n }\n\n enableKeepAlive() {\n this.keepAliveOnRemainMills = this.sessionDuration.toMillis() >> 1\n }\n}\n\n;(globalThis as any).scheduleRevalidateSession = () => {\n ;(document.querySelector(\"session-timer\") as SessionTimer).enableKeepAlive()\n}\n","import{property as t}from\"./property.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */function r(r){return t({...r,state:!0,attribute:!1})}export{r as state};\n//# sourceMappingURL=state.js.map\n","// Arrow functions instead of function names\n// to optimize minification\nimport Chart from \"chart.js/auto\"\nimport \"../webcomponents/_SessionTimer\"\n\n/*\n * ------------------------------\n * Charts Section\n * ------------------------------\n */\n\nfunction* colorGenerator(baseColorHex, count) {\n // strip the leading # if it's there\n baseColorHex = baseColorHex.replace(/^\\s*#|\\s*$/g, \"\")\n\n // convert 3 char codes --> 6, e.g. `E0F` --> `EE00FF`\n if (baseColorHex.length === 3) {\n baseColorHex = baseColorHex.replace(/(.)/g, \"$1$1\")\n }\n\n let colors = [\n parseInt(baseColorHex.substr(0, 2), 16),\n parseInt(baseColorHex.substr(2, 2), 16),\n parseInt(baseColorHex.substr(4, 2), 16),\n ]\n\n const topValue = 220\n const tailValue = 90\n const rangeSize = Math.floor((topValue - tailValue) / count)\n\n const maxValue = Math.max.apply(Math, colors)\n const diffToTop = topValue - maxValue\n colors = colors.map((c) => c + diffToTop)\n\n for (let i = 0; i < count; i++) {\n yield `#${colors\n .map((c) => Math.abs(c - rangeSize * i))\n .map((c) => c.toString(16))\n .map((c) => (c.length < 2 ? `0${c}` : c))\n .join(\"\")}`\n }\n}\n\nconst getDefaultColors = (domElement, count, mode) => {\n const accessor = `--bs-${mode}`\n const baseColor = getComputedStyle(domElement)\n .getPropertyValue(accessor)\n .trim()\n\n return Array.from(colorGenerator(baseColor, count))\n}\n\nconst handleColorDefinition = (oColor, elementCount, domElement) => {\n if (typeof oColor !== \"object\" || oColor == null) {\n oColor = { themeColor: \"primary\" }\n }\n\n // Thememfarbe gesetzt\n if (\"themeColor\" in oColor) {\n return getDefaultColors(\n domElement,\n oColor.single ? 1 : elementCount,\n oColor.themeColor\n )\n }\n // Einzelne Farben gesetzt\n if (\"colors\" in oColor) {\n const useColors = oColor.colors\n if (useColors.length === 1) return useColors[0]\n return useColors\n }\n\n // Fallback\n return getDefaultColors(domElement, elementCount, \"primary\")\n}\n\nconst applyDiagrams = () => {\n const uninitializedCharts = document.querySelectorAll(\".chart-inital\")\n\n for (let element of uninitializedCharts) {\n element.classList = [\"chart\"]\n\n const json = JSON.parse(element.dataset.chart)\n const canvas = element.querySelector(\"canvas\")\n const datasets = []\n\n for (let i = 0; i < json.datasets.length; i++) {\n let dataset = json.datasets[i]\n dataset.backgroundColor = handleColorDefinition(\n dataset.backgroundColor,\n dataset.data.length,\n element\n )\n dataset.borderColor = handleColorDefinition(\n dataset.borderColor,\n dataset.data.length,\n element\n )\n\n if (i === 0) {\n dataset.yAxisID = \"y\"\n } else if (i === 1) {\n dataset.yAxisID = \"y1\"\n }\n datasets.push(dataset)\n }\n\n const data = {\n labels: json.labels,\n datasets,\n }\n\n const options = {\n plugins: {\n legend: {\n display: json.options.legend,\n onClick: function (e, legendItem, legend) {\n const index = legendItem.datasetIndex\n const ci = legend.chart\n const meta = ci.getDatasetMeta(index)\n meta.hidden =\n meta.hidden === null\n ? !ci.data.datasets[index].hidden\n : null\n\n if (index === 0) {\n ci.options.scales.y.display = !meta.hidden\n } else if (index === 1) {\n ci.options.scales.y1.display = !meta.hidden\n }\n ci.update()\n },\n },\n tooltip: {\n callbacks: {\n label: function (context) {\n let label = context.dataset.label || \"\"\n if (label) {\n label += \": \"\n }\n label += context.parsed.y\n if (context.datasetIndex === 0) {\n label += \" €\"\n } else if (context.datasetIndex === 1) {\n label += \" kWh\"\n }\n return label\n },\n },\n },\n },\n scales: {\n y: {\n type: \"linear\",\n position: \"left\",\n title: {\n display: true,\n text: \"Preis (in €)\",\n },\n ticks: {\n callback: function (value) {\n return value + \" €\"\n },\n },\n },\n y1: {\n type: \"linear\",\n position: \"right\",\n title: {\n display: true,\n text: \"Verbrauch (in kWh)\",\n },\n grid: {\n drawOnChartArea: false,\n },\n ticks: {\n callback: function (value) {\n return value + \" kWh\"\n },\n },\n },\n },\n responsive: true,\n resizeDelay: 50,\n maintainAspectRatio: false,\n }\n\n const config = {\n type: json.type,\n data,\n options,\n }\n\n new Chart(canvas, config)\n }\n}\n\n/**\n * ------------------------------\n * Dom Watching utilities (to react to new inserted charts)\n * ------------------------------\n */\nconst onDomChange = () => {\n applyDiagrams()\n\n const requiredFields = document.querySelectorAll(\".required\")\n for (let field of requiredFields) {\n field.required = true\n }\n\n mountTooltips()\n}\n\nconst contentPane = document.getElementById(\"content-pane\")\nif (contentPane !== null) {\n let observer = new MutationObserver(onDomChange)\n observer.observe(contentPane, {\n subtree: true,\n childList: true,\n })\n}\n\n/**\n * ------------------------------\n * Cookie Banner\n * ------------------------------\n */\nconst initCookieBanner = () => {\n const button = document.getElementById(\"cookie-accept-banner\")\n\n if (button !== null) {\n button.addEventListener(\"click\", () => {\n document.cookie = button.dataset.cookieString\n document.querySelector(\".cookiebanner\").remove()\n })\n }\n}\n\n/**\n * ------------------------------\n * Conditional Areas\n * ------------------------------\n */\n\n/*\n * Helper um einfach ausblendbare Panels zu bauen, welche mit eine Checkbox bestimmt werden\n * Achtung:\n * - gibt es für den Wert kein Template, bleibt das Target leer\n * - das Target wird bei jeder Änderung (DOM Technisch) neu erzeugt.\n *\n HOWTO:\n \n Trigger (Value muss stimmen) =>\n