diff --git a/lib/AmsConfiguration/include/AmsConfiguration.h b/lib/AmsConfiguration/include/AmsConfiguration.h index 7f267b80..9f077d31 100644 --- a/lib/AmsConfiguration/include/AmsConfiguration.h +++ b/lib/AmsConfiguration/include/AmsConfiguration.h @@ -21,6 +21,7 @@ #define CONFIG_DOMOTICZ_START 856 #define CONFIG_NTP_START 872 #define CONFIG_MQTT_START 1004 +#define CONFIG_HA_START 1680 #define CONFIG_METER_START_93 224 @@ -151,6 +152,13 @@ struct DomoticzConfig { uint16_t cl1idx; }; // 10 +struct HomeAssistantConfig { + uint8_t tag; // Just to find out if we have this config already. Can be removed in v2.3 + char discoveryTopic[64]; + char discoveryHostname[64]; + char discoveryNameTag[16]; +}; // 145 + struct NtpConfig { bool enable; bool dhcp; @@ -253,8 +261,10 @@ public: bool getDomoticzConfig(DomoticzConfig&); bool setDomoticzConfig(DomoticzConfig&); void clearDomo(DomoticzConfig&); - bool isDomoChanged(); - void ackDomoChange(); + + bool getHomeAssistantConfig(HomeAssistantConfig&); + bool setHomeAssistantConfig(HomeAssistantConfig&); + void clearHomeAssistantConfig(HomeAssistantConfig&); bool getNtpConfig(NtpConfig&); bool setNtpConfig(NtpConfig&); @@ -293,7 +303,7 @@ protected: private: uint8_t configVersion = 0; - bool wifiChanged, mqttChanged, meterChanged = true, domoChanged, ntpChanged = true, entsoeChanged = false, energyAccountingChanged = true; + bool wifiChanged, mqttChanged, meterChanged = true, ntpChanged = true, entsoeChanged = false, energyAccountingChanged = true; uint8_t tempSensorCount = 0; TempSensorConfig** tempSensors = NULL; @@ -310,3 +320,4 @@ private: void deleteFromFs(uint8_t version); }; #endif + diff --git a/lib/AmsConfiguration/src/AmsConfiguration.cpp b/lib/AmsConfiguration/src/AmsConfiguration.cpp index c3ae8881..8e6161a6 100644 --- a/lib/AmsConfiguration/src/AmsConfiguration.cpp +++ b/lib/AmsConfiguration/src/AmsConfiguration.cpp @@ -309,15 +309,14 @@ bool AmsConfiguration::getDomoticzConfig(DomoticzConfig& config) { bool AmsConfiguration::setDomoticzConfig(DomoticzConfig& config) { DomoticzConfig existing; if(getDomoticzConfig(existing)) { - domoChanged |= config.elidx != existing.elidx; - domoChanged |= config.vl1idx != existing.vl1idx; - domoChanged |= config.vl2idx != existing.vl2idx; - domoChanged |= config.vl3idx != existing.vl3idx; - domoChanged |= config.cl1idx != existing.cl1idx; + mqttChanged |= config.elidx != existing.elidx; + mqttChanged |= config.vl1idx != existing.vl1idx; + mqttChanged |= config.vl2idx != existing.vl2idx; + mqttChanged |= config.vl3idx != existing.vl3idx; + mqttChanged |= config.cl1idx != existing.cl1idx; } else { - domoChanged = true; + mqttChanged = true; } - mqttChanged = domoChanged; EEPROM.begin(EEPROM_SIZE); EEPROM.put(CONFIG_DOMOTICZ_START, config); bool ret = EEPROM.commit(); @@ -333,12 +332,45 @@ void AmsConfiguration::clearDomo(DomoticzConfig& config) { config.cl1idx = 0; } -bool AmsConfiguration::isDomoChanged() { - return domoChanged; +bool AmsConfiguration::getHomeAssistantConfig(HomeAssistantConfig& config) { + if(hasConfig()) { + EEPROM.begin(EEPROM_SIZE); + EEPROM.get(CONFIG_HA_START, config); + if(config.tag != 0xA7) clearHomeAssistantConfig(config); + EEPROM.end(); + return true; + } else { + clearHomeAssistantConfig(config); + return false; + } } -void AmsConfiguration::ackDomoChange() { - domoChanged = false; +bool AmsConfiguration::setHomeAssistantConfig(HomeAssistantConfig& config) { + HomeAssistantConfig existing; + if(getHomeAssistantConfig(existing)) { + mqttChanged |= strcmp(config.discoveryTopic, existing.discoveryTopic) != 0; + mqttChanged |= strcmp(config.discoveryHostname, existing.discoveryHostname) != 0; + mqttChanged |= strcmp(config.discoveryNameTag, existing.discoveryNameTag) != 0; + } else { + mqttChanged = true; + } + + stripNonAscii((uint8_t*) config.discoveryTopic, 64); + stripNonAscii((uint8_t*) config.discoveryHostname, 64); + stripNonAscii((uint8_t*) config.discoveryNameTag, 16); + + EEPROM.begin(EEPROM_SIZE); + EEPROM.put(CONFIG_HA_START, config); + bool ret = EEPROM.commit(); + EEPROM.end(); + return ret; +} + +void AmsConfiguration::clearHomeAssistantConfig(HomeAssistantConfig& config) { + config.tag = 0xA7; + strcpy(config.discoveryTopic, ""); + strcpy(config.discoveryHostname, ""); + strcpy(config.discoveryNameTag, ""); } bool AmsConfiguration::pinUsed(uint8_t pin, GpioConfig& config) { diff --git a/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h b/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h index 16d179a1..e09463cf 100644 --- a/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h +++ b/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h @@ -3,14 +3,51 @@ #include "AmsMqttHandler.h" #include "HomeAssistantStatic.h" +#include "AmsConfiguration.h" class HomeAssistantMqttHandler : public AmsMqttHandler { public: - HomeAssistantMqttHandler(MQTTClient* mqtt, char* buf, const char* clientId, const char* topic, HwTools* hw) : AmsMqttHandler(mqtt, buf) { + HomeAssistantMqttHandler(MQTTClient* mqtt, char* buf, const char* clientId, const char* topic, uint8_t boardType, HomeAssistantConfig config, HwTools* hw) : AmsMqttHandler(mqtt, buf) { this->clientId = clientId; this->topic = String(topic); + this->config = config; this->hw = hw; l1Init = l2Init = l2eInit = l3Init = l3eInit = l4Init = l4eInit = rtInit = rteInit = pInit = sInit = false; + + if(strlen(config.discoveryNameTag) > 0) { + snprintf_P(buf, 128, PSTR("AMS reader (%s)"), config.discoveryNameTag); + deviceName = String(buf); + snprintf_P(buf, 128, PSTR(" (%s)"), config.discoveryNameTag); + sensorNamePostFix = String(buf); + } else { + deviceName = "AMS reader"; + sensorNamePostFix = ""; + } + deviceModel = boardTypeToString(boardType); + manufacturer = boardManufacturerToString(boardType); + + #if defined(ESP8266) + String hostname = WiFi.hostname(); + #elif defined(ESP32) + String hostname = WiFi.getHostname(); + #endif + + deviceUid = hostname; // Maybe configurable in the future? + + if(strlen(config.discoveryHostname) > 0) { + snprintf_P(buf, 128, PSTR("http://%s.local/"), config.discoveryHostname); + String deviceUrl = String(buf); + } else { + snprintf_P(buf, 128, PSTR("http://%s.local/"), hostname); + String deviceUrl = String(buf); + } + + if(strlen(config.discoveryTopic) > 0) { + discoveryTopic = String(config.discoveryTopic); + if(!discoveryTopic.endsWith("/")) discoveryTopic += "/"; + } else { + discoveryTopic = "homeassistant/sensor/"; + } }; bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); bool publishTemperatures(AmsConfiguration*, HwTools*); @@ -33,15 +70,15 @@ public: void publishSystemSensors(); private: - String haTopic = "homeassistant/sensor/"; + HomeAssistantConfig config; + String deviceName; + String deviceModel; + String deviceUid; + String manufacturer; + String deviceUrl; - String haName = "AMS reader"; - #if defined(ESP32) - String haModel = "ESP32"; - #elif defined(ESP8266) - String haModel = "ESP8266"; - #endif - String haManuf = "AmsToMqttBridge"; + String discoveryTopic; + String sensorNamePostFix; bool l1Init, l2Init, l2eInit, l3Init, l3eInit, l4Init, l4eInit, rtInit, rteInit, pInit, sInit; bool tInit[32] = {false}; @@ -50,5 +87,75 @@ private: String clientId; String topic; HwTools* hw; + + String boardTypeToString(uint8_t b) { + switch(b) { + case 5: + #if defined(ESP8266) + return "Pow-K"; + #elif defined(ESP32) + return "Pow-K+"; + #endif + case 7: + #if defined(ESP8266) + return "Pow-U"; + #elif defined(ESP32) + return "Pow-U+"; + #endif + case 6: + return "Pow-P1"; + case 51: + return "S2 mini"; + case 50: + return "ESP32-S2"; + case 201: + return "LOLIN D32"; + case 202: + return "HUZZAH32"; + case 203: + return "DevKitC"; + case 200: + return "ESP32"; + case 2: + return "HAN Reader 2.0 by Max Spencer"; + case 0: + return "Custom hardware by Roar Fredriksen"; + case 1: + return "Kamstrup module by Egil Opsahl"; + case 3: + return "Pow-K"; + case 4: + return "Pow-U"; + case 101: + return "D1 mini"; + case 100: + return "ESP8266"; + case 70: + return "ESP32-C3"; + case 71: + return "ESP32-C3-DevKitM-1"; + } + #if defined(ESP8266) + return "ESP8266"; + #elif defined(ESP32) + return "ESP32"; + #endif + }; + + String boardManufacturerToString(uint8_t b) { + if(b >= 3 && b <= 7) + return "amsleser.no"; + if(b < 50) + return "Custom"; + switch(b) { + case 51: + case 101: + case 201: + return "Wemos"; + case 202: + return "Adafruit"; + } + return "Espressif"; + }; }; #endif diff --git a/lib/HomeAssistantMqttHandler/json/hadiscover.json b/lib/HomeAssistantMqttHandler/json/hadiscover.json index 67b1add4..9edc1a45 100644 --- a/lib/HomeAssistantMqttHandler/json/hadiscover.json +++ b/lib/HomeAssistantMqttHandler/json/hadiscover.json @@ -1,5 +1,5 @@ { - "name" : "%s", + "name" : "%s%s", "stat_t" : "%s%s", "uniq_id" : "%s_%s", "obj_id" : "%s_%s", diff --git a/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp b/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp index cf9dd2f0..e80fbdfb 100644 --- a/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp +++ b/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp @@ -304,37 +304,30 @@ bool HomeAssistantMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, Energ } void HomeAssistantMqttHandler::publishSensor(const HomeAssistantSensor& sensor) { - #if defined(ESP8266) - String haUID = WiFi.hostname(); - #elif defined(ESP32) - String haUID = WiFi.getHostname(); - #endif - String haUrl = "http://" + haUID + ".local/"; - String uid = String(sensor.path); uid.replace(".", ""); uid.replace("[", ""); uid.replace("]", ""); uid.replace("'", ""); - String uom = String(sensor.uom); snprintf_P(json, BufferSize, HADISCOVER_JSON, sensor.name, + sensorNamePostFix.c_str(), topic.c_str(), sensor.topic, - haUID.c_str(), uid.c_str(), - haUID.c_str(), uid.c_str(), - uom.c_str(), + deviceUid.c_str(), uid.c_str(), + deviceUid.c_str(), uid.c_str(), + sensor.uom, sensor.path, sensor.devcl, - haUID.c_str(), - haName.c_str(), - haModel.c_str(), + deviceUid.c_str(), + deviceName.c_str(), + deviceModel.c_str(), VERSION, - haManuf.c_str(), - haUrl.c_str(), + manufacturer.c_str(), + sensorNamePostFix.c_str(), strlen_P(sensor.stacl) > 0 ? ", \"stat_cla\" :" : "", strlen_P(sensor.stacl) > 0 ? (char *) FPSTR(sensor.stacl) : "" ); - mqtt->publish(haTopic + haUID + "_" + uid.c_str() + "/config", json, true, 0); + mqtt->publish(discoveryTopic + deviceUid + "_" + uid.c_str() + "/config", json, true, 0); } void HomeAssistantMqttHandler::publishList1Sensors() { diff --git a/lib/SvelteUi/app/dist/index.js b/lib/SvelteUi/app/dist/index.js index ffe4f469..4039adf6 100644 --- a/lib/SvelteUi/app/dist/index.js +++ b/lib/SvelteUi/app/dist/index.js @@ -1,14 +1,14 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function l(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerpolicy&&(o.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?o.credentials="include":i.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=l(i);fetch(i.href,o)}})();function ie(){}function Ot(t,e){for(const l in e)t[l]=e[l];return t}function gf(t){return t()}function pr(){return Object.create(null)}function Be(t){t.forEach(gf)}function bf(t){return typeof t=="function"}function ke(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let Xi;function pc(t,e){return Xi||(Xi=document.createElement("a")),Xi.href=e,t===Xi.href}function _c(t){return Object.keys(t).length===0}function Vs(t,...e){if(t==null)return ie;const l=t.subscribe(...e);return l.unsubscribe?()=>l.unsubscribe():l}function jn(t){let e;return Vs(t,l=>e=l)(),e}function Bt(t,e,l){t.$$.on_destroy.push(Vs(e,l))}function Ks(t,e,l,n){if(t){const i=kf(t,e,l,n);return t[0](i)}}function kf(t,e,l,n){return t[1]&&n?Ot(l.ctx.slice(),t[1](n(e))):l.ctx}function Qs(t,e,l,n){if(t[2]&&n){const i=t[2](n(l));if(e.dirty===void 0)return i;if(typeof i=="object"){const o=[],r=Math.max(e.dirty.length,i.length);for(let a=0;a32){const e=[],l=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,l,n)}function cs(t){return function(e){return e.preventDefault(),t.call(this,e)}}function u(t,e,l){l==null?t.removeAttribute(e):t.getAttribute(e)!==l&&t.setAttribute(e,l)}function zt(t,e){const l=Object.getOwnPropertyDescriptors(t.__proto__);for(const n in e)e[n]==null?t.removeAttribute(n):n==="style"?t.style.cssText=e[n]:n==="__value"?t.value=t[n]=e[n]:l[n]&&l[n].set?t[n]=e[n]:u(t,n,e[n])}function me(t){return t===""?null:+t}function dc(t){return Array.from(t.childNodes)}function B(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function Z(t,e){t.value=e==null?"":e}function wf(t,e,l,n){l===null?t.style.removeProperty(e):t.style.setProperty(e,l,n?"important":"")}function Re(t,e){for(let l=0;l{r.source===n.contentWindow&&e()})):(n.src="about:blank",n.onload=()=>{o=K(n.contentWindow,"resize",e)}),s(t,n),()=>{(i||o&&n.contentWindow)&&o(),w(n)}}function gc(t,e,{bubbles:l=!1,cancelable:n=!1}={}){const i=document.createEvent("CustomEvent");return i.initCustomEvent(t,l,n,e),i}let si;function li(t){si=t}function oi(){if(!si)throw new Error("Function called outside component initialization");return si}function bc(t){oi().$$.on_mount.push(t)}function kc(t){oi().$$.on_destroy.push(t)}function wc(){const t=oi();return(e,l,{cancelable:n=!1}={})=>{const i=t.$$.callbacks[e];if(i){const o=gc(e,l,{cancelable:n});return i.slice().forEach(r=>{r.call(t,o)}),!o.defaultPrevented}return!0}}function ni(t,e){return oi().$$.context.set(t,e),e}function wl(t){return oi().$$.context.get(t)}const ei=[],us=[],ns=[],_r=[],yf=Promise.resolve();let Fs=!1;function $f(){Fs||(Fs=!0,yf.then(Cf))}function yc(){return $f(),yf}function ze(t){ns.push(t)}const Ds=new Set;let es=0;function Cf(){const t=si;do{for(;es{is.delete(t),n&&(l&&t.d(1),n())}),t.o(e)}else n&&n()}function Wn(t,e){const l={},n={},i={$$scope:1};let o=t.length;for(;o--;){const r=t[o],a=e[o];if(a){for(const f in r)f in a||(n[f]=1);for(const f in a)i[f]||(l[f]=a[f],i[f]=1);t[o]=a}else for(const f in r)i[f]=1}for(const r in n)r in l||(l[r]=void 0);return l}function dr(t){return typeof t=="object"&&t!==null?t:{}}function Q(t){t&&t.c()}function Y(t,e,l,n){const{fragment:i,on_mount:o,on_destroy:r,after_update:a}=t.$$;i&&i.m(e,l),n||ze(()=>{const f=o.map(gf).filter(bf);r?r.push(...f):Be(f),t.$$.on_mount=[]}),a.forEach(ze)}function V(t,e){const l=t.$$;l.fragment!==null&&(Be(l.on_destroy),l.fragment&&l.fragment.d(e),l.on_destroy=l.fragment=null,l.ctx=[])}function Cc(t,e){t.$$.dirty[0]===-1&&(ei.push(t),$f(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const h=g.length?g[0]:d;return c.ctx&&i(c.ctx[_],c.ctx[_]=h)&&(!c.skip_bound&&c.bound[_]&&c.bound[_](h),p&&Cc(t,_)),d}):[],c.update(),p=!0,Be(c.before_update),c.fragment=n?n(c.ctx):!1,e.target){if(e.hydrate){const _=dc(e.target);c.fragment&&c.fragment.l(_),_.forEach(w)}else c.fragment&&c.fragment.c();e.intro&&P(t.$$.fragment),Y(t,e.target,e.anchor,e.customElement),Cf()}li(f)}class ye{$destroy(){V(this,1),this.$destroy=ie}$on(e,l){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(l),()=>{const i=n.indexOf(l);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!_c(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const vr=t=>typeof t>"u",Tf=t=>typeof t=="function",Sf=t=>typeof t=="number";function Tc(t){return!t.defaultPrevented&&t.button===0&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Pf(){let t=0;return()=>t++}function Sc(){return Math.random().toString(36).substring(2)}const yl=typeof window>"u";function Mf(t,e,l){return t.addEventListener(e,l),()=>t.removeEventListener(e,l)}const Ls=(t,e)=>t?{}:{style:e},qn=t=>({"aria-hidden":"true",...Ls(t,"display:none;")}),On=[];function Df(t,e){return{subscribe:Ze(t,e).subscribe}}function Ze(t,e=ie){let l;const n=new Set;function i(a){if(ke(t,a)&&(t=a,l)){const f=!On.length;for(const c of n)c[1](),On.push(c,t);if(f){for(let c=0;c{n.delete(c),n.size===0&&(l(),l=null)}}return{set:i,update:o,subscribe:r}}function Pc(t,e,l){const n=!Array.isArray(t),i=n?[t]:t,o=e.length<2;return Df(l,r=>{let a=!1;const f=[];let c=0,p=ie;const _=()=>{if(c)return;p();const g=e(n?f[0]:f,r);o?r(g):p=bf(g)?g:ie},d=i.map((g,h)=>Vs(g,b=>{f[h]=b,c&=~(1<{c|=1<`@@svnav-ctx__${t}`,Os=ui("LOCATION"),Gn=ui("ROUTER"),Af=ui("ROUTE"),Mc=ui("ROUTE_PARAMS"),Dc=ui("FOCUS_ELEM"),Nf=/^:(.+)/,ti=(t,e,l)=>t.substr(e,l),qs=(t,e)=>ti(t,0,e.length)===e,Ac=t=>t==="",Nc=t=>Nf.test(t),If=t=>t[0]==="*",Ic=t=>t.replace(/\*.*$/,""),Ef=t=>t.replace(/(^\/+|\/+$)/g,"");function Kt(t,e=!1){const l=Ef(t).split("/");return e?l.filter(Boolean):l}const As=(t,e)=>t+(e?`?${e}`:""),Xs=t=>`/${Ef(t)}`;function ri(...t){const e=n=>Kt(n,!0).join("/"),l=t.map(e).join("/");return Xs(l)}const xs=1,ms=2,Bl=3,Ec=4,Rf=5,Rc=6,Ff=7,Fc=8,Lc=9,Lf=10,Of=11,Oc={[xs]:"Link",[ms]:"Route",[Bl]:"Router",[Ec]:"useFocus",[Rf]:"useLocation",[Rc]:"useMatch",[Ff]:"useNavigate",[Fc]:"useParams",[Lc]:"useResolvable",[Lf]:"useResolve",[Of]:"navigate"},eo=t=>Oc[t];function qc(t,e){let l;return t===ms?l=e.path?`path="${e.path}"`:"default":t===xs?l=`to="${e.to}"`:t===Bl&&(l=`basepath="${e.basepath||""}"`),`<${eo(t)} ${l||""} />`}function Uc(t,e,l,n){const i=l&&qc(n||t,l),o=i?` +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function l(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerpolicy&&(o.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?o.credentials="include":i.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=l(i);fetch(i.href,o)}})();function ie(){}function Ot(t,e){for(const l in e)t[l]=e[l];return t}function wf(t){return t()}function dr(){return Object.create(null)}function Ge(t){t.forEach(wf)}function yf(t){return typeof t=="function"}function we(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let ts;function vc(t,e){return ts||(ts=document.createElement("a")),ts.href=e,t===ts.href}function hc(t){return Object.keys(t).length===0}function Js(t,...e){if(t==null)return ie;const l=t.subscribe(...e);return l.unsubscribe?()=>l.unsubscribe():l}function Gn(t){let e;return Js(t,l=>e=l)(),e}function Bt(t,e,l){t.$$.on_destroy.push(Js(e,l))}function Xs(t,e,l,n){if(t){const i=$f(t,e,l,n);return t[0](i)}}function $f(t,e,l,n){return t[1]&&n?Ot(l.ctx.slice(),t[1](n(e))):l.ctx}function xs(t,e,l,n){if(t[2]&&n){const i=t[2](n(l));if(e.dirty===void 0)return i;if(typeof i=="object"){const o=[],r=Math.max(e.dirty.length,i.length);for(let a=0;a32){const e=[],l=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,l,n)}function _s(t){return function(e){return e.preventDefault(),t.call(this,e)}}function u(t,e,l){l==null?t.removeAttribute(e):t.getAttribute(e)!==l&&t.setAttribute(e,l)}function zt(t,e){const l=Object.getOwnPropertyDescriptors(t.__proto__);for(const n in e)e[n]==null?t.removeAttribute(n):n==="style"?t.style.cssText=e[n]:n==="__value"?t.value=t[n]=e[n]:l[n]&&l[n].set?t[n]=e[n]:u(t,n,e[n])}function me(t){return t===""?null:+t}function gc(t){return Array.from(t.childNodes)}function B(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function Y(t,e){t.value=e==null?"":e}function Cf(t,e,l,n){l===null?t.style.removeProperty(e):t.style.setProperty(e,l,n?"important":"")}function Fe(t,e){for(let l=0;l{r.source===n.contentWindow&&e()})):(n.src="about:blank",n.onload=()=>{o=V(n.contentWindow,"resize",e)}),s(t,n),()=>{(i||o&&n.contentWindow)&&o(),w(n)}}function wc(t,e,{bubbles:l=!1,cancelable:n=!1}={}){const i=document.createEvent("CustomEvent");return i.initCustomEvent(t,l,n,e),i}let si;function li(t){si=t}function oi(){if(!si)throw new Error("Function called outside component initialization");return si}function yc(t){oi().$$.on_mount.push(t)}function $c(t){oi().$$.on_destroy.push(t)}function Cc(){const t=oi();return(e,l,{cancelable:n=!1}={})=>{const i=t.$$.callbacks[e];if(i){const o=wc(e,l,{cancelable:n});return i.slice().forEach(r=>{r.call(t,o)}),!o.defaultPrevented}return!0}}function ni(t,e){return oi().$$.context.set(t,e),e}function wl(t){return oi().$$.context.get(t)}const ei=[],fs=[],os=[],vr=[],Tf=Promise.resolve();let Us=!1;function Sf(){Us||(Us=!0,Tf.then(Pf))}function Tc(){return Sf(),Tf}function Be(t){os.push(t)}const Es=new Set;let ns=0;function Pf(){const t=si;do{for(;ns{us.delete(t),n&&(l&&t.d(1),n())}),t.o(e)}else n&&n()}function Bn(t,e){const l={},n={},i={$$scope:1};let o=t.length;for(;o--;){const r=t[o],a=e[o];if(a){for(const c in r)c in a||(n[c]=1);for(const c in a)i[c]||(l[c]=a[c],i[c]=1);t[o]=a}else for(const c in r)i[c]=1}for(const r in n)r in l||(l[r]=void 0);return l}function hr(t){return typeof t=="object"&&t!==null?t:{}}function Z(t){t&&t.c()}function K(t,e,l,n){const{fragment:i,on_mount:o,on_destroy:r,after_update:a}=t.$$;i&&i.m(e,l),n||Be(()=>{const c=o.map(wf).filter(yf);r?r.push(...c):Ge(c),t.$$.on_mount=[]}),a.forEach(Be)}function Q(t,e){const l=t.$$;l.fragment!==null&&(Ge(l.on_destroy),l.fragment&&l.fragment.d(e),l.on_destroy=l.fragment=null,l.ctx=[])}function Pc(t,e){t.$$.dirty[0]===-1&&(ei.push(t),Sf(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const h=g.length?g[0]:d;return f.ctx&&i(f.ctx[_],f.ctx[_]=h)&&(!f.skip_bound&&f.bound[_]&&f.bound[_](h),p&&Pc(t,_)),d}):[],f.update(),p=!0,Ge(f.before_update),f.fragment=n?n(f.ctx):!1,e.target){if(e.hydrate){const _=gc(e.target);f.fragment&&f.fragment.l(_),_.forEach(w)}else f.fragment&&f.fragment.c();e.intro&&M(t.$$.fragment),K(t,e.target,e.anchor,e.customElement),Pf()}li(c)}class $e{$destroy(){Q(this,1),this.$destroy=ie}$on(e,l){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(l),()=>{const i=n.indexOf(l);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!hc(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const gr=t=>typeof t>"u",Mf=t=>typeof t=="function",Df=t=>typeof t=="number";function Mc(t){return!t.defaultPrevented&&t.button===0&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Af(){let t=0;return()=>t++}function Dc(){return Math.random().toString(36).substring(2)}const yl=typeof window>"u";function Nf(t,e,l){return t.addEventListener(e,l),()=>t.removeEventListener(e,l)}const Hs=(t,e)=>t?{}:{style:e},Hn=t=>({"aria-hidden":"true",...Hs(t,"display:none;")}),Un=[];function If(t,e){return{subscribe:Ze(t,e).subscribe}}function Ze(t,e=ie){let l;const n=new Set;function i(a){if(we(t,a)&&(t=a,l)){const c=!Un.length;for(const f of n)f[1](),Un.push(f,t);if(c){for(let f=0;f{n.delete(f),n.size===0&&(l(),l=null)}}return{set:i,update:o,subscribe:r}}function Ac(t,e,l){const n=!Array.isArray(t),i=n?[t]:t,o=e.length<2;return If(l,r=>{let a=!1;const c=[];let f=0,p=ie;const _=()=>{if(f)return;p();const g=e(n?c[0]:c,r);o?r(g):p=yf(g)?g:ie},d=i.map((g,h)=>Js(g,b=>{c[h]=b,f&=~(1<{f|=1<`@@svnav-ctx__${t}`,js=ui("LOCATION"),zn=ui("ROUTER"),Ef=ui("ROUTE"),Nc=ui("ROUTE_PARAMS"),Ic=ui("FOCUS_ELEM"),Rf=/^:(.+)/,ti=(t,e,l)=>t.substr(e,l),Ws=(t,e)=>ti(t,0,e.length)===e,Ec=t=>t==="",Rc=t=>Rf.test(t),Ff=t=>t[0]==="*",Fc=t=>t.replace(/\*.*$/,""),Lf=t=>t.replace(/(^\/+|\/+$)/g,"");function Kt(t,e=!1){const l=Lf(t).split("/");return e?l.filter(Boolean):l}const Rs=(t,e)=>t+(e?`?${e}`:""),lo=t=>`/${Lf(t)}`;function ri(...t){const e=n=>Kt(n,!0).join("/"),l=t.map(e).join("/");return lo(l)}const no=1,ds=2,Vl=3,Lc=4,Of=5,Oc=6,qf=7,qc=8,Uc=9,Uf=10,Hf=11,Hc={[no]:"Link",[ds]:"Route",[Vl]:"Router",[Lc]:"useFocus",[Of]:"useLocation",[Oc]:"useMatch",[qf]:"useNavigate",[qc]:"useParams",[Uc]:"useResolvable",[Uf]:"useResolve",[Hf]:"navigate"},io=t=>Hc[t];function jc(t,e){let l;return t===ds?l=e.path?`path="${e.path}"`:"default":t===no?l=`to="${e.to}"`:t===Vl&&(l=`basepath="${e.basepath||""}"`),`<${io(t)} ${l||""} />`}function Wc(t,e,l,n){const i=l&&jc(n||t,l),o=i?` -Occurred in: ${i}`:"",r=eo(t),a=Tf(e)?e(r):e;return`<${r}> ${a}${o}`}const qf=t=>(...e)=>t(Uc(...e)),Uf=qf(t=>{throw new Error(t)}),rs=qf(console.warn),hr=4,Hc=3,jc=2,Wc=1,Gc=1;function Bc(t,e){const l=t.default?0:Kt(t.fullPath).reduce((n,i)=>{let o=n;return o+=hr,Ac(i)?o+=Gc:Nc(i)?o+=jc:If(i)?o-=hr+Wc:o+=Hc,o},0);return{route:t,score:l,index:e}}function zc(t){return t.map(Bc).sort((e,l)=>e.scorel.score?-1:e.index-l.index)}function Hf(t,e){let l,n;const[i]=e.split("?"),o=Kt(i),r=o[0]==="",a=zc(t);for(let f=0,c=a.length;f({...p,params:d,uri:k});if(p.default){n=g(e);continue}const h=Kt(p.fullPath),b=Math.max(o.length,h.length);let $=0;for(;${c===".."?f.pop():c!=="."&&f.push(c)}),As(`/${f.join("/")}`,n)}function gr(t,e){const{pathname:l,hash:n="",search:i="",state:o}=t,r=Kt(e,!0),a=Kt(l,!0);for(;r.length;)r[0]!==a[0]&&Uf(Bl,`Invalid state: All locations must begin with the basepath "${e}", found "${l}"`),r.shift(),a.shift();return{pathname:ri(...a),hash:n,search:i,state:o}}const br=t=>t.length===1?"":t,to=t=>{const e=t.indexOf("?"),l=t.indexOf("#"),n=e!==-1,i=l!==-1,o=i?br(ti(t,l)):"",r=i?ti(t,0,l):t,a=n?br(ti(r,e)):"";return{pathname:(n?ti(r,0,e):r)||"/",search:a,hash:o}},Vc=t=>{const{pathname:e,search:l,hash:n}=t;return e+l+n};function Kc(t,e,l){return ri(l,Yc(t,e))}function Qc(t,e){const l=Xs(Ic(t)),n=Kt(l,!0),i=Kt(e,!0).slice(0,n.length),o=jf({fullPath:l},ri(...i));return o&&o.uri}const Ns="POP",Zc="PUSH",Jc="REPLACE";function Is(t){return{...t.location,pathname:encodeURI(decodeURI(t.location.pathname)),state:t.history.state,_key:t.history.state&&t.history.state._key||"initial"}}function Xc(t){let e=[],l=Is(t),n=Ns;const i=(o=e)=>o.forEach(r=>r({location:l,action:n}));return{get location(){return l},listen(o){e.push(o);const r=()=>{l=Is(t),n=Ns,i([o])};i([o]);const a=Mf(t,"popstate",r);return()=>{a(),e=e.filter(f=>f!==o)}},navigate(o,r){const{state:a={},replace:f=!1}=r||{};if(n=f?Jc:Zc,Sf(o))r&&rs(Of,"Navigation options (state or replace) are not supported, when passing a number as the first argument to navigate. They are ignored."),n=Ns,t.history.go(o);else{const c={...a,_key:Sc()};try{t.history[f?"replaceState":"pushState"](c,"",o)}catch{t.location[f?"replace":"assign"](o)}}l=Is(t),i()}}}function Es(t,e){return{...to(e),state:t}}function xc(t="/"){let e=0,l=[Es(null,t)];return{get entries(){return l},get location(){return l[e]},addEventListener(){},removeEventListener(){},history:{get state(){return l[e].state},pushState(n,i,o){e++,l=l.slice(0,e),l.push(Es(n,o))},replaceState(n,i,o){l[e]=Es(n,o)},go(n){const i=e+n;i<0||i>l.length-1||(e=i)}}}}const e1=!!(!yl&&window.document&&window.document.createElement),t1=!yl&&window.location.origin==="null",Wf=Xc(e1&&!t1?window:xc()),{navigate:Un}=Wf;let ul=null,Gf=!0;function l1(t,e){const l=document.querySelectorAll("[data-svnav-router]");for(let n=0;nul.level||t.level===ul.level&&l1(t.routerId,ul.routerId))&&(ul=t)}function i1(){ul=null}function s1(){Gf=!1}function kr(t){if(!t)return!1;const e="tabindex";try{if(!t.hasAttribute(e)){t.setAttribute(e,"-1");let l;l=Mf(t,"blur",()=>{t.removeAttribute(e),l()})}return t.focus(),document.activeElement===t}catch{return!1}}function o1(t,e){return Number(t.dataset.svnavRouteEnd)===e}function u1(t){return/^H[1-6]$/i.test(t.tagName)}function wr(t,e=document){return e.querySelector(t)}function r1(t){let l=wr(`[data-svnav-route-start="${t}"]`).nextElementSibling;for(;!o1(l,t);){if(u1(l))return l;const n=wr("h1,h2,h3,h4,h5,h6",l);if(n)return n;l=l.nextElementSibling}return null}function a1(t){Promise.resolve(jn(t.focusElement)).then(e=>{const l=e||r1(t.id);l||rs(Bl,`Could not find an element to focus. You should always render a header for accessibility reasons, or set a custom focus element via the "useFocus" hook. If you don't want this Route or Router to manage focus, pass "primary={false}" to it.`,t,ms),!kr(l)&&kr(document.documentElement)})}const f1=(t,e,l)=>(n,i)=>yc().then(()=>{if(!ul||Gf){s1();return}if(n&&a1(ul.route),t.announcements&&i){const{path:o,fullPath:r,meta:a,params:f,uri:c}=ul.route,p=t.createAnnouncement({path:o,fullPath:r,meta:a,params:f,uri:c},jn(l));Promise.resolve(p).then(_=>{e.set(_)})}i1()}),yr="position:fixed;top:-1px;left:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";function c1(t){let e,l,n=[{role:"status"},{"aria-atomic":"true"},{"aria-live":"polite"},{"data-svnav-announcer":""},Ls(t[6],yr)],i={};for(let o=0;o`Navigated to ${te.uri}`,announcements:!0,...h},k=p,T=Xs(p),M=wl(Os),E=wl(Gn),S=!M,I=p1(),A=g&&!(E&&!E.manageFocus),R=Ze("");Bt(t,R,te=>l(0,a=te));const H=E?E.disableInlineStyles:b,j=Ze([]);Bt(t,j,te=>l(20,r=te));const F=Ze(null);Bt(t,F,te=>l(18,i=te));let L=!1;const W=S?0:E.level+1,q=S?Ze((()=>gr(yl?to(_):d.location,T))()):M;Bt(t,q,te=>l(17,n=te));const O=Ze(n);Bt(t,O,te=>l(19,o=te));const U=f1($,R,q),X=te=>Me=>Me.filter(_e=>_e.id!==te);function z(te){if(yl){if(L)return;const Me=jf(te,n.pathname);if(Me)return L=!0,Me}else j.update(Me=>{const _e=X(te.id)(Me);return _e.push(te),_e})}function ne(te){j.update(X(te))}return!S&&p!==$r&&rs(Bl,'Only top-level Routers can have a "basepath" prop. It is ignored.',{basepath:p}),S&&(bc(()=>d.listen(Me=>{const _e=gr(Me.location,T);O.set(n),q.set(_e)})),ni(Os,q)),ni(Gn,{activeRoute:F,registerRoute:z,unregisterRoute:ne,manageFocus:A,level:W,id:I,history:S?d:E.history,basepath:S?T:E.basepath,disableInlineStyles:H}),t.$$set=te=>{"basepath"in te&&l(11,p=te.basepath),"url"in te&&l(12,_=te.url),"history"in te&&l(13,d=te.history),"primary"in te&&l(14,g=te.primary),"a11y"in te&&l(15,h=te.a11y),"disableInlineStyles"in te&&l(16,b=te.disableInlineStyles),"$$scope"in te&&l(21,c=te.$$scope)},t.$$.update=()=>{if(t.$$.dirty[0]&2048&&p!==k&&rs(Bl,'You cannot change the "basepath" prop. It is ignored.'),t.$$.dirty[0]&1179648){const te=Hf(r,n.pathname);F.set(te)}if(t.$$.dirty[0]&655360&&S){const te=!!n.hash,Me=!te&&A,_e=!te||n.pathname!==o.pathname;U(Me,_e)}t.$$.dirty[0]&262144&&A&&i&&i.primary&&n1({level:W,routerId:I,route:i})},[a,$,S,I,A,R,H,j,F,q,O,p,_,d,g,h,b,n,i,o,r,c,f]}class Bf extends ye{constructor(e){super(),we(this,e,_1,m1,ke,{basepath:11,url:12,history:13,primary:14,a11y:15,disableInlineStyles:16},null,[-1,-1])}}function ai(t,e,l=Gn,n=Bl){wl(l)||Uf(t,o=>`You cannot use ${o} outside of a ${eo(n)}.`,e)}const d1=t=>{const{subscribe:e}=wl(t);return{subscribe:e}};function zf(){return ai(Rf),d1(Os)}function Yf(){const{history:t}=wl(Gn);return t}function Vf(){const t=wl(Af);return t?Pc(t,e=>e.base):Ze("/")}function Kf(){ai(Lf);const t=Vf(),{basepath:e}=wl(Gn);return n=>Kc(n,jn(t),e)}function v1(){ai(Ff);const t=Kf(),{navigate:e}=Yf();return(n,i)=>{const o=Sf(n)?n:t(n);return e(o,i)}}const h1=t=>({params:t&16,location:t&8}),Cr=t=>({params:yl?jn(t[10]):t[4],location:t[3],navigate:t[11]});function Tr(t){let e,l;return e=new Bf({props:{primary:t[1],$$slots:{default:[k1]},$$scope:{ctx:t}}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.primary=n[1]),i&528409&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function g1(t){let e;const l=t[18].default,n=Ks(l,t,t[19],Cr);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&524312)&&Zs(n,l,i,i[19],e?Qs(l,i[19],o,h1):Js(i[19]),Cr)},i(i){e||(P(n,i),e=!0)},o(i){N(n,i),e=!1},d(i){n&&n.d(i)}}}function b1(t){let e,l,n;const i=[{location:t[3]},{navigate:t[11]},yl?jn(t[10]):t[4],t[12]];var o=t[0];function r(a){let f={};for(let c=0;c{V(p,1)}),Pe()}o?(e=new o(r()),Q(e.$$.fragment),P(e.$$.fragment,1),Y(e,l.parentNode,l)):e=null}else o&&e.$set(c)},i(a){n||(e&&P(e.$$.fragment,a),n=!0)},o(a){e&&N(e.$$.fragment,a),n=!1},d(a){a&&w(l),e&&V(e,a)}}}function k1(t){let e,l,n,i;const o=[b1,g1],r=[];function a(f,c){return f[0]!==null?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=We()},m(f,c){r[e].m(f,c),y(f,n,c),i=!0},p(f,c){let p=e;e=a(f),e===p?r[e].p(f,c):(Se(),N(r[p],1,1,()=>{r[p]=null}),Pe(),l=r[e],l?l.p(f,c):(l=r[e]=o[e](f),l.c()),P(l,1),l.m(n.parentNode,n))},i(f){i||(P(l),i=!0)},o(f){N(l),i=!1},d(f){r[e].d(f),f&&w(n)}}}function w1(t){let e,l,n,i,o,r=[qn(t[7]),{"data-svnav-route-start":t[5]}],a={};for(let _=0;_{f=null}),Pe()),zt(i,p=Wn(c,[qn(_[7]),{"data-svnav-route-end":_[5]}]))},i(_){o||(P(f),o=!0)},o(_){N(f),o=!1},d(_){_&&w(e),_&&w(l),f&&f.d(_),_&&w(n),_&&w(i)}}}const y1=Pf();function $1(t,e,l){let n;const i=["path","component","meta","primary"];let o=os(e,i),r,a,f,c,{$$slots:p={},$$scope:_}=e,{path:d=""}=e,{component:g=null}=e,{meta:h={}}=e,{primary:b=!0}=e;ai(ms,e);const $=y1(),{registerRoute:k,unregisterRoute:T,activeRoute:M,disableInlineStyles:E}=wl(Gn);Bt(t,M,L=>l(16,r=L));const S=Vf();Bt(t,S,L=>l(17,f=L));const I=zf();Bt(t,I,L=>l(3,a=L));const A=Ze(null);let R;const H=Ze(),j=Ze({});Bt(t,j,L=>l(4,c=L)),ni(Af,H),ni(Mc,j),ni(Dc,A);const F=v1();return yl||kc(()=>T($)),t.$$set=L=>{l(24,e=Ot(Ot({},e),ss(L))),l(12,o=os(e,i)),"path"in L&&l(13,d=L.path),"component"in L&&l(0,g=L.component),"meta"in L&&l(14,h=L.meta),"primary"in L&&l(1,b=L.primary),"$$scope"in L&&l(19,_=L.$$scope)},t.$$.update=()=>{if(t.$$.dirty&155658){const L=d==="",W=ri(f,d),G={id:$,path:d,meta:h,default:L,fullPath:L?"":W,base:L?f:Qc(W,a.pathname),primary:b,focusElement:A};H.set(G),l(15,R=k(G))}if(t.$$.dirty&98304&&l(2,n=!!(R||r&&r.id===$)),t.$$.dirty&98308&&n){const{params:L}=R||r;j.set(L)}},e=ss(e),[g,b,n,a,c,$,M,E,S,I,j,F,o,d,h,R,r,f,p,_]}class ol extends ye{constructor(e){super(),we(this,e,$1,w1,ke,{path:13,component:0,meta:14,primary:1})}}function C1(t){let e,l,n,i;const o=t[13].default,r=Ks(o,t,t[12],null);let a=[{href:t[0]},t[2],t[1]],f={};for(let c=0;cl(11,_=A));const M=wc(),E=Kf(),{navigate:S}=Yf();function I(A){M("click",A),Tc(A)&&(A.preventDefault(),S(n,{state:$,replace:r||b}))}return t.$$set=A=>{l(19,e=Ot(Ot({},e),ss(A))),l(18,p=os(e,c)),"to"in A&&l(5,h=A.to),"replace"in A&&l(6,b=A.replace),"state"in A&&l(7,$=A.state),"getProps"in A&&l(8,k=A.getProps),"$$scope"in A&&l(12,g=A.$$scope)},t.$$.update=()=>{t.$$.dirty&2080&&l(0,n=E(h,_)),t.$$.dirty&2049&&l(10,i=qs(_.pathname,n)),t.$$.dirty&2049&&l(9,o=n===_.pathname),t.$$.dirty&2049&&(r=to(n)===Vc(_)),t.$$.dirty&512&&l(2,a=o?{"aria-current":"page"}:{}),l(1,f=(()=>{if(Tf(k)){const A=k({location:_,href:n,isPartiallyCurrent:i,isCurrent:o});return{...p,...A}}return p})())},e=ss(e),[n,f,a,T,I,h,b,$,k,o,i,_,g,d]}class kl extends ye{constructor(e){super(),we(this,e,T1,C1,ke,{to:5,replace:6,state:7,getProps:8})}}let Us=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function bl(t){return t===1?"green":t===2?"yellow":t===3?"red":"gray"}function S1(t){return t>218&&t<242?"#32d900":t>212&&t<248?"#b1d900":t>208&&t<252?"#ffb800":"#d90000"}function Qf(t){return t>90?"#d90000":t>85?"#e32100":t>80?"#ffb800":t>75?"#dcd800":"#32d900"}function P1(t){return t>75?"#32d900":t>50?"#77d900":t>25?"#94d900":"#dcd800"}function as(t){switch(t){case 1:return"Aidon";case 2:return"Kaifa";case 3:return"Kamstrup";case 8:return"Iskra";case 9:return"Landis+Gyr";case 10:return"Sagemcom";default:return""}}function Ae(t){for(t=t.toString();t.length<2;)t="0"+t;return t}function pe(t,e){switch(e){case 5:switch(t){case"esp8266":return"Pow-K (GPIO12)";case"esp32s2":return"Pow-K+"}case 7:switch(t){case"esp8266":return"Pow-U (GPIO12)";case"esp32s2":return"Pow-U+"}case 6:return"Pow-P1";case 51:return"Wemos S2 mini";case 50:return"Generic ESP32-S2";case 201:return"Wemos LOLIN D32";case 202:return"Adafruit HUZZAH32";case 203:return"DevKitC";case 200:return"Generic ESP32";case 2:return"HAN Reader 2.0 by Max Spencer";case 0:return"Custom hardware by Roar Fredriksen";case 1:return"Kamstrup module by Egil Opsahl";case 3:return"Pow-K (UART0)";case 4:return"Pow-U (UART0)";case 101:return"Wemos D1 mini";case 100:return"Generic ESP8266";case 70:return"Generic ESP32-C3";case 71:return"ESP32-C3-DevKitM-1"}}function Sr(t){switch(t){case-1:return"Parse error";case-2:return"Incomplete data received";case-3:return"Payload boundry flag missing";case-4:return"Header checksum error";case-5:return"Footer checksum error";case-9:return"Unknown data received, check meter config";case-41:return"Frame length not equal";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid";case 90:return"No HAN data received last 30s";case 98:return"Exception in code, debugging necessary";case 99:return"Autodetection failed"}return t<0?"Unspecified error "+t:""}function Pr(t){switch(t){case-3:return"Connection failed";case-4:return"Network timeout";case-10:return"Connection denied";case-11:return"Failed to subscribe";case-13:return"Connection lost"}return t<0?"Unspecified error "+t:""}function Mr(t){switch(t){case 401:case 403:return"Unauthorized, check API key";case 404:return"Price unavailable, not found";case 425:return"Server says its too early";case 500:return"Internal server error";case-2:return"Incomplete data received";case-3:return"Invalid data, tag missing";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid"}return t<0?"Unspecified error "+t:""}function Hn(t){switch(t){case 2:case 4:case 7:return!0}return!1}function je(t,e){return t==1||t==2&&e}function Lt(t){return"https://github.com/UtilitechAS/amsreader-firmware/wiki/"+t}function be(t,e){return isNaN(t)?"-":(isNaN(e)&&(e=t<10?1:0),t.toFixed(e))}function ii(t,e){return t.setTime(t.getTime()+e*36e5),t}function Dr(t){if(t.chip=="esp8266")switch(t.boot_reason){case 0:return"Normal";case 1:return"WDT reset";case 2:return"Exception reset";case 3:return"Soft WDT reset";case 4:return"Software restart";case 5:return"Deep sleep";case 6:return"External reset";default:return"Unknown (8266)"}else switch(t.boot_reason){case 1:return"Normal";case 3:return"Software reset";case 4:return"WDT reset";case 5:return"Deep sleep";case 6:return"SLC reset";case 7:return"Timer Group0 WDT reset";case 8:return"Timer Group1 WDT reset";case 9:return"RTC WDT reset";case 10:return"Instrusion test reset";case 11:return"Time Group reset";case 12:return"Software reset CPU";case 13:return"RTC WTD reset CPU";case 14:return"PRO CPU";case 15:return"Unstable Vdd";case 16:return"RTC reset";default:return"Unknown"}}async function $l(t,e={}){const{timeout:l=8e3}=e,n=new AbortController,i=setTimeout(()=>n.abort(),l),o=await fetch(t,{...e,signal:n.signal});return clearTimeout(i),o}let Gt={version:"",chip:"",mac:null,apmac:null,vndcfg:null,usrcfg:null,fwconsent:null,booting:!1,upgrading:!1,ui:{},security:0,trying:null};const yt=Ze(Gt);async function lo(){Gt=await(await $l("/sysinfo.json?t="+Math.floor(Date.now()/1e3))).json(),yt.set(Gt)}let ts=0,Ar=-127,Nr=null,M1={};const D1=Df(M1,t=>{let e;async function l(){$l("/data.json").then(n=>n.json()).then(n=>{t(n),Ar!=n.t&&(Ar=n.t,setTimeout(xf,2e3)),Nr!=n.p&&(Nr=n.p,setTimeout(A1,4e3)),Gt.upgrading?window.location.reload():(!Gt||!Gt.chip||Gt.booting||ts>1&&!Hn(Gt.board))&&(lo(),Wl&&clearTimeout(Wl),Wl=setTimeout(no,2e3),Gl&&clearTimeout(Gl),Gl=setTimeout(io,3e3));let i=5e3;if(Hn(Gt.board)&&n.v>2.5){let o=3.3-Math.min(3.3,n.v);o>0&&(i=Math.max(o,.1)*10*5e3)}i>5e3&&console.log("Scheduling next data fetch in "+i+"ms"),e&&clearTimeout(e),e=setTimeout(l,i),ts=0}).catch(n=>{ts++,ts>3?(t({em:3,hm:0,wm:0,mm:0}),e=setTimeout(l,15e3)):e=setTimeout(l,Hn(Gt.board)?1e4:5e3)})}return l(),function(){clearTimeout(e)}});let Hs={};const Zf=Ze(Hs);async function A1(){Hs=await(await $l("/energyprice.json")).json(),Zf.set(Hs)}let js={},Wl;async function no(){Wl&&(clearTimeout(Wl),Wl=0),js=await(await $l("/dayplot.json")).json(),Jf.set(js);let e=new Date;Wl=setTimeout(no,(60-e.getMinutes())*6e4+20)}const Jf=Ze(js,t=>(no(),function(){}));let Ws={},Gl;async function io(){Gl&&(clearTimeout(Gl),Gl=0),Ws=await(await $l("/monthplot.json")).json(),Xf.set(Ws);let e=new Date;Gl=setTimeout(io,(24-e.getHours())*36e5+40)}const Xf=Ze(Ws,t=>(io(),function(){}));let Gs={};async function xf(){Gs=await(await $l("/temperature.json")).json(),ec.set(Gs)}const ec=Ze(Gs,t=>(xf(),function(){}));let Bs={},ls;async function tc(){ls&&(clearTimeout(ls),ls=0),Bs=await(await $l("/tariff.json")).json(),lc.set(Bs);let e=new Date;ls=setTimeout(tc,(60-e.getMinutes())*6e4+30)}const lc=Ze(Bs,t=>function(){});let zs=[];const so=Ze(zs);async function N1(){zs=await(await $l("https://api.github.com/repos/UtilitechAS/amsreader-firmware/releases")).json(),so.set(zs)}function fs(t){return"WARNING: "+t+" must be connected to an external power supply during firmware upgrade. Failure to do so may cause power-down during upload resulting in non-functioning unit."}async function nc(){await(await fetch("/upgrade",{method:"POST"})).json()}function ic(t,e){if(/^v\d{1,2}\.\d{1,2}\.\d{1,2}$/.test(t)){let l=t.substring(1).split("."),n=parseInt(l[0]),i=parseInt(l[1]),o=parseInt(l[2]),r=[...e];r.reverse();let a,f,c;for(let p=0;po&&(a=_):b==i+1&&(f=_);else if(h==n+1)if(c){let k=c.tag_name.substring(1).split(".");parseInt(k[0]);let T=parseInt(k[1]);parseInt(k[2]),b==T&&(c=_)}else c=_}return f||c||a||!1}else return e[0]}const I1="/github.svg";function Ir(t){let e,l;function n(r,a){return r[1]>1?U1:r[1]>0?q1:r[2]>1?O1:r[2]>0?L1:r[3]>1?F1:r[3]>0?R1:E1}let i=n(t),o=i(t);return{c(){e=C(`Up - `),o.c(),l=We()},m(r,a){y(r,e,a),o.m(r,a),y(r,l,a)},p(r,a){i===(i=n(r))&&o?o.p(r,a):(o.d(1),o=i(r),o&&(o.c(),o.m(l.parentNode,l)))},d(r){r&&w(e),o.d(r),r&&w(l)}}}function E1(t){let e,l;return{c(){e=C(t[0]),l=C(" seconds")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&1&&B(e,n[0])},d(n){n&&w(e),n&&w(l)}}}function R1(t){let e,l;return{c(){e=C(t[3]),l=C(" minute")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&8&&B(e,n[3])},d(n){n&&w(e),n&&w(l)}}}function F1(t){let e,l;return{c(){e=C(t[3]),l=C(" minutes")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&8&&B(e,n[3])},d(n){n&&w(e),n&&w(l)}}}function L1(t){let e,l;return{c(){e=C(t[2]),l=C(" hour")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&4&&B(e,n[2])},d(n){n&&w(e),n&&w(l)}}}function O1(t){let e,l;return{c(){e=C(t[2]),l=C(" hours")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&4&&B(e,n[2])},d(n){n&&w(e),n&&w(l)}}}function q1(t){let e,l;return{c(){e=C(t[1]),l=C(" day")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&2&&B(e,n[1])},d(n){n&&w(e),n&&w(l)}}}function U1(t){let e,l;return{c(){e=C(t[1]),l=C(" days")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&2&&B(e,n[1])},d(n){n&&w(e),n&&w(l)}}}function H1(t){let e,l=t[0]&&Ir(t);return{c(){l&&l.c(),e=We()},m(n,i){l&&l.m(n,i),y(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=Ir(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:ie,o:ie,d(n){l&&l.d(n),n&&w(e)}}}function j1(t,e,l){let{epoch:n}=e,i=0,o=0,r=0;return t.$$set=a=>{"epoch"in a&&l(0,n=a.epoch)},t.$$.update=()=>{t.$$.dirty&1&&(l(1,i=Math.floor(n/86400)),l(2,o=Math.floor(n/3600)),l(3,r=Math.floor(n/60)))},[n,i,o,r]}class W1 extends ye{constructor(e){super(),we(this,e,j1,H1,ke,{epoch:0})}}function G1(t){let e,l,n;return{c(){e=m("span"),l=C(t[2]),u(e,"title",t[1]),u(e,"class",n="bd-"+t[0])},m(i,o){y(i,e,o),s(e,l)},p(i,[o]){o&4&&B(l,i[2]),o&2&&u(e,"title",i[1]),o&1&&n!==(n="bd-"+i[0])&&u(e,"class",n)},i:ie,o:ie,d(i){i&&w(e)}}}function B1(t,e,l){let{color:n}=e,{title:i}=e,{text:o}=e;return t.$$set=r=>{"color"in r&&l(0,n=r.color),"title"in r&&l(1,i=r.title),"text"in r&&l(2,o=r.text)},[n,i,o]}class Yt extends ye{constructor(e){super(),we(this,e,B1,G1,ke,{color:0,title:1,text:2})}}function z1(t){let e,l=`${Ae(t[0].getDate())}.${Ae(t[0].getMonth())}.${t[0].getFullYear()} ${Ae(t[0].getHours())}:${Ae(t[0].getMinutes())}`,n;return{c(){e=m("span"),n=C(l),u(e,"class",t[1])},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=`${Ae(i[0].getDate())}.${Ae(i[0].getMonth())}.${i[0].getFullYear()} ${Ae(i[0].getHours())}:${Ae(i[0].getMinutes())}`)&&B(n,l),o&2&&u(e,"class",i[1])},d(i){i&&w(e)}}}function Y1(t){let e=`${Ae(t[0].getDate())}. ${Us[t[0].getMonth()]} ${Ae(t[0].getHours())}:${Ae(t[0].getMinutes())}`,l;return{c(){l=C(e)},m(n,i){y(n,l,i)},p(n,i){i&1&&e!==(e=`${Ae(n[0].getDate())}. ${Us[n[0].getMonth()]} ${Ae(n[0].getHours())}:${Ae(n[0].getMinutes())}`)&&B(l,e)},d(n){n&&w(l)}}}function V1(t){let e,l;function n(r,a){return a&1&&(e=null),e==null&&(e=Math.abs(new Date().getTime()-r[0].getTime())<3e5),e?Y1:z1}let i=n(t,-1),o=i(t);return{c(){o.c(),l=We()},m(r,a){o.m(r,a),y(r,l,a)},p(r,[a]){i===(i=n(r,a))&&o?o.p(r,a):(o.d(1),o=i(r),o&&(o.c(),o.m(l.parentNode,l)))},i:ie,o:ie,d(r){o.d(r),r&&w(l)}}}function K1(t,e,l){let{timestamp:n}=e,{fullTimeColor:i}=e;return t.$$set=o=>{"timestamp"in o&&l(0,n=o.timestamp),"fullTimeColor"in o&&l(1,i=o.fullTimeColor)},[n,i]}class sc extends ye{constructor(e){super(),we(this,e,K1,V1,ke,{timestamp:0,fullTimeColor:1})}}function Q1(t){let e,l,n;return{c(){e=Oe("svg"),l=Oe("path"),n=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"),u(n,"stroke-linecap","round"),u(n,"stroke-linejoin","round"),u(n,"d","M15 12a3 3 0 11-6 0 3 3 0 016 0z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(i,o){y(i,e,o),s(e,l),s(e,n)},p:ie,i:ie,o:ie,d(i){i&&w(e)}}}class Z1 extends ye{constructor(e){super(),we(this,e,null,Q1,ke,{})}}function J1(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){y(n,e,i),s(e,l)},p:ie,i:ie,o:ie,d(n){n&&w(e)}}}class X1 extends ye{constructor(e){super(),we(this,e,null,J1,ke,{})}}function x1(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){y(n,e,i),s(e,l)},p:ie,i:ie,o:ie,d(n){n&&w(e)}}}class Ft extends ye{constructor(e){super(),we(this,e,null,x1,ke,{})}}function em(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15M9 12l3 3m0 0l3-3m-3 3V2.25"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){y(n,e,i),s(e,l)},p:ie,i:ie,o:ie,d(n){n&&w(e)}}}class oc extends ye{constructor(e){super(),we(this,e,null,em,ke,{})}}function tm(t){let e,l,n=t[1].version+"",i;return{c(){e=C("AMS reader "),l=m("span"),i=C(n)},m(o,r){y(o,e,r),y(o,l,r),s(l,i)},p(o,r){r&2&&n!==(n=o[1].version+"")&&B(i,n)},d(o){o&&w(e),o&&w(l)}}}function Er(t){let e,l=(t[0].t>-50?t[0].t.toFixed(1):"-")+"",n,i;return{c(){e=m("div"),n=C(l),i=C("\xB0C"),u(e,"class","flex-none my-auto")},m(o,r){y(o,e,r),s(e,n),s(e,i)},p(o,r){r&1&&l!==(l=(o[0].t>-50?o[0].t.toFixed(1):"-")+"")&&B(n,l)},d(o){o&&w(e)}}}function Rr(t){let e,l="HAN: "+Sr(t[0].he),n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="HAN: "+Sr(i[0].he))&&B(n,l)},d(i){i&&w(e)}}}function Fr(t){let e,l="MQTT: "+Pr(t[0].me),n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="MQTT: "+Pr(i[0].me))&&B(n,l)},d(i){i&&w(e)}}}function Lr(t){let e,l="PriceAPI: "+Mr(t[0].ee),n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="PriceAPI: "+Mr(i[0].ee))&&B(n,l)},d(i){i&&w(e)}}}function Or(t){let e,l,n,i,o,r;return l=new kl({props:{to:"/configuration",$$slots:{default:[lm]},$$scope:{ctx:t}}}),o=new kl({props:{to:"/status",$$slots:{default:[nm]},$$scope:{ctx:t}}}),{c(){e=m("div"),Q(l.$$.fragment),n=v(),i=m("div"),Q(o.$$.fragment),u(e,"class","flex-none px-1 mt-1"),u(e,"title","Configuration"),u(i,"class","flex-none px-1 mt-1"),u(i,"title","Device information")},m(a,f){y(a,e,f),Y(l,e,null),y(a,n,f),y(a,i,f),Y(o,i,null),r=!0},i(a){r||(P(l.$$.fragment,a),P(o.$$.fragment,a),r=!0)},o(a){N(l.$$.fragment,a),N(o.$$.fragment,a),r=!1},d(a){a&&w(e),V(l),a&&w(n),a&&w(i),V(o)}}}function lm(t){let e,l;return e=new Z1({}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function nm(t){let e,l;return e=new X1({}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function qr(t){let e,l,n,i,o;const r=[sm,im],a=[];function f(c,p){return c[1].security==0||c[0].a?0:1}return l=f(t),n=a[l]=r[l](t),{c(){e=m("div"),n.c(),u(e,"class","flex-none mr-3 text-yellow-500"),u(e,"title",i="New version: "+t[2].tag_name)},m(c,p){y(c,e,p),a[l].m(e,null),o=!0},p(c,p){let _=l;l=f(c),l===_?a[l].p(c,p):(Se(),N(a[_],1,1,()=>{a[_]=null}),Pe(),n=a[l],n?n.p(c,p):(n=a[l]=r[l](c),n.c()),P(n,1),n.m(e,null)),(!o||p&4&&i!==(i="New version: "+c[2].tag_name))&&u(e,"title",i)},i(c){o||(P(n),o=!0)},o(c){N(n),o=!1},d(c){c&&w(e),a[l].d()}}}function im(t){let e,l,n=t[2].tag_name+"",i;return{c(){e=m("span"),l=C("New version: "),i=C(n)},m(o,r){y(o,e,r),s(e,l),s(e,i)},p(o,r){r&4&&n!==(n=o[2].tag_name+"")&&B(i,n)},i:ie,o:ie,d(o){o&&w(e)}}}function sm(t){let e,l,n,i=t[2].tag_name+"",o,r,a,f,c,p;return a=new oc({}),{c(){e=m("button"),l=m("span"),n=C("New version: "),o=C(i),r=v(),Q(a.$$.fragment),u(l,"class","mt-1"),u(e,"class","flex")},m(_,d){y(_,e,d),s(e,l),s(l,n),s(l,o),s(e,r),Y(a,e,null),f=!0,c||(p=K(e,"click",t[3]),c=!0)},p(_,d){(!f||d&4)&&i!==(i=_[2].tag_name+"")&&B(o,i)},i(_){f||(P(a.$$.fragment,_),f=!0)},o(_){N(a.$$.fragment,_),f=!1},d(_){_&&w(e),V(a),c=!1,p()}}}function om(t){let e,l,n,i,o,r,a,f,c,p,_,d,g=(t[0].m?(t[0].m/1e3).toFixed(1):"-")+"",h,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W,G,q,O,U,X,z,ne,te,Me,_e,Ne,Ie,Fe,Ee;i=new kl({props:{to:"/",$$slots:{default:[tm]},$$scope:{ctx:t}}}),f=new W1({props:{epoch:t[0].u}});let $e=t[0].t>-50&&Er(t);T=new Yt({props:{title:"ESP",text:t[1].booting?"Booting":t[0].v>2?t[0].v.toFixed(2)+"V":"ESP",color:bl(t[1].booting?2:t[0].em)}}),E=new Yt({props:{title:"HAN",text:"HAN",color:bl(t[1].booting?9:t[0].hm)}}),I=new Yt({props:{title:"WiFi",text:t[0].r?t[0].r.toFixed(0)+"dBm":"WiFi",color:bl(t[1].booting?9:t[0].wm)}}),R=new Yt({props:{title:"MQTT",text:"MQTT",color:bl(t[1].booting?9:t[0].mm)}});let ge=(t[0].he<0||t[0].he>0)&&Rr(t),fe=t[0].me<0&&Fr(t),ae=(t[0].ee>0||t[0].ee<0)&&Lr(t);ne=new sc({props:{timestamp:t[0].c?new Date(t[0].c*1e3):new Date(0),fullTimeColor:"text-red-500"}});let ce=t[1].vndcfg&&t[1].usrcfg&&Or(t);Ie=new Ft({});let ue=t[1].fwconsent===1&&t[2]&&qr(t);return{c(){e=m("nav"),l=m("div"),n=m("div"),Q(i.$$.fragment),o=v(),r=m("div"),a=m("div"),Q(f.$$.fragment),c=v(),$e&&$e.c(),p=v(),_=m("div"),d=C("Free mem: "),h=C(g),b=C("kb"),$=v(),k=m("div"),Q(T.$$.fragment),M=v(),Q(E.$$.fragment),S=v(),Q(I.$$.fragment),A=v(),Q(R.$$.fragment),H=v(),ge&&ge.c(),j=v(),fe&&fe.c(),F=v(),ae&&ae.c(),L=v(),W=m("div"),G=m("div"),q=m("a"),O=m("img"),X=v(),z=m("div"),Q(ne.$$.fragment),te=v(),ce&&ce.c(),Me=v(),_e=m("div"),Ne=m("a"),Q(Ie.$$.fragment),Fe=v(),ue&&ue.c(),u(n,"class","flex text-lg text-gray-100 p-2"),u(a,"class","flex-none my-auto"),u(_,"class","flex-none my-auto"),u(r,"class","flex-none my-auto p-2 flex space-x-4"),u(k,"class","flex-auto flex-wrap my-auto justify-center p-2"),u(O,"class","gh-logo"),pc(O.src,U=I1)||u(O,"src",U),u(O,"alt","GitHub repo"),u(q,"class","float-right"),u(q,"href","https://github.com/UtilitechAS/amsreader-firmware"),u(q,"target","_blank"),u(q,"rel","noreferrer"),u(q,"aria-label","GitHub"),u(G,"class","flex-none"),u(z,"class","flex-none my-auto px-2"),u(Ne,"href",Lt("")),u(Ne,"target","_blank"),u(Ne,"rel","noreferrer"),u(_e,"class","flex-none px-1 mt-1"),u(_e,"title","Documentation"),u(W,"class","flex-auto p-2 flex flex-row-reverse flex-wrap"),u(l,"class","flex flex-wrap space-x-4 text-sm text-gray-300"),u(e,"class","bg-violet-600 p-1 rounded-md mx-2")},m(J,se){y(J,e,se),s(e,l),s(l,n),Y(i,n,null),s(l,o),s(l,r),s(r,a),Y(f,a,null),s(r,c),$e&&$e.m(r,null),s(r,p),s(r,_),s(_,d),s(_,h),s(_,b),s(l,$),s(l,k),Y(T,k,null),s(k,M),Y(E,k,null),s(k,S),Y(I,k,null),s(k,A),Y(R,k,null),s(l,H),ge&&ge.m(l,null),s(l,j),fe&&fe.m(l,null),s(l,F),ae&&ae.m(l,null),s(l,L),s(l,W),s(W,G),s(G,q),s(q,O),s(W,X),s(W,z),Y(ne,z,null),s(W,te),ce&&ce.m(W,null),s(W,Me),s(W,_e),s(_e,Ne),Y(Ie,Ne,null),s(W,Fe),ue&&ue.m(W,null),Ee=!0},p(J,[se]){const Ce={};se&18&&(Ce.$$scope={dirty:se,ctx:J}),i.$set(Ce);const x={};se&1&&(x.epoch=J[0].u),f.$set(x),J[0].t>-50?$e?$e.p(J,se):($e=Er(J),$e.c(),$e.m(r,p)):$e&&($e.d(1),$e=null),(!Ee||se&1)&&g!==(g=(J[0].m?(J[0].m/1e3).toFixed(1):"-")+"")&&B(h,g);const oe={};se&3&&(oe.text=J[1].booting?"Booting":J[0].v>2?J[0].v.toFixed(2)+"V":"ESP"),se&3&&(oe.color=bl(J[1].booting?2:J[0].em)),T.$set(oe);const He={};se&3&&(He.color=bl(J[1].booting?9:J[0].hm)),E.$set(He);const Te={};se&1&&(Te.text=J[0].r?J[0].r.toFixed(0)+"dBm":"WiFi"),se&3&&(Te.color=bl(J[1].booting?9:J[0].wm)),I.$set(Te);const de={};se&3&&(de.color=bl(J[1].booting?9:J[0].mm)),R.$set(de),J[0].he<0||J[0].he>0?ge?ge.p(J,se):(ge=Rr(J),ge.c(),ge.m(l,j)):ge&&(ge.d(1),ge=null),J[0].me<0?fe?fe.p(J,se):(fe=Fr(J),fe.c(),fe.m(l,F)):fe&&(fe.d(1),fe=null),J[0].ee>0||J[0].ee<0?ae?ae.p(J,se):(ae=Lr(J),ae.c(),ae.m(l,L)):ae&&(ae.d(1),ae=null);const ve={};se&1&&(ve.timestamp=J[0].c?new Date(J[0].c*1e3):new Date(0)),ne.$set(ve),J[1].vndcfg&&J[1].usrcfg?ce?se&2&&P(ce,1):(ce=Or(J),ce.c(),P(ce,1),ce.m(W,Me)):ce&&(Se(),N(ce,1,1,()=>{ce=null}),Pe()),J[1].fwconsent===1&&J[2]?ue?(ue.p(J,se),se&6&&P(ue,1)):(ue=qr(J),ue.c(),P(ue,1),ue.m(W,null)):ue&&(Se(),N(ue,1,1,()=>{ue=null}),Pe())},i(J){Ee||(P(i.$$.fragment,J),P(f.$$.fragment,J),P(T.$$.fragment,J),P(E.$$.fragment,J),P(I.$$.fragment,J),P(R.$$.fragment,J),P(ne.$$.fragment,J),P(ce),P(Ie.$$.fragment,J),P(ue),Ee=!0)},o(J){N(i.$$.fragment,J),N(f.$$.fragment,J),N(T.$$.fragment,J),N(E.$$.fragment,J),N(I.$$.fragment,J),N(R.$$.fragment,J),N(ne.$$.fragment,J),N(ce),N(Ie.$$.fragment,J),N(ue),Ee=!1},d(J){J&&w(e),V(i),V(f),$e&&$e.d(),V(T),V(E),V(I),V(R),ge&&ge.d(),fe&&fe.d(),ae&&ae.d(),V(ne),ce&&ce.d(),V(Ie),ue&&ue.d()}}}function um(t,e,l){let{data:n={}}=e,i={},o={};function r(){confirm("Do you want to upgrade this device to "+o.tag_name+"?")&&(!Hn(i.board)||confirm(fs(pe(i.chip,i.board))))&&(yt.update(a=>(a.upgrading=!0,a)),nc())}return yt.subscribe(a=>{l(1,i=a),a.fwconsent===1&&N1()}),so.subscribe(a=>{l(2,o=ic(i.version,a))}),t.$$set=a=>{"data"in a&&l(0,n=a.data)},[n,i,o,r]}class rm extends ye{constructor(e){super(),we(this,e,um,om,ke,{data:0})}}function am(t){let e,l,n,i;return{c(){e=Oe("svg"),l=Oe("path"),n=Oe("path"),u(l,"d",Rs(150,150,115,210,510)),u(l,"stroke","#eee"),u(l,"fill","none"),u(l,"stroke-width","55"),u(n,"d",i=Rs(150,150,115,210,210+300*t[0]/100)),u(n,"stroke",t[1]),u(n,"fill","none"),u(n,"stroke-width","55"),u(e,"viewBox","0 0 300 300"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"height","100%")},m(o,r){y(o,e,r),s(e,l),s(e,n)},p(o,[r]){r&1&&i!==(i=Rs(150,150,115,210,210+300*o[0]/100))&&u(n,"d",i),r&2&&u(n,"stroke",o[1])},i:ie,o:ie,d(o){o&&w(e)}}}function Ur(t,e,l,n){var i=(n-90)*Math.PI/180;return{x:t+l*Math.cos(i),y:e+l*Math.sin(i)}}function Rs(t,e,l,n,i){var o=Ur(t,e,l,i),r=Ur(t,e,l,n),a=i-n<=180?"0":"1",f=["M",o.x,o.y,"A",l,l,0,a,0,r.x,r.y].join(" ");return f}function fm(t,e,l){let{pct:n=0}=e,{color:i="red"}=e;return t.$$set=o=>{"pct"in o&&l(0,n=o.pct),"color"in o&&l(1,i=o.color)},[n,i]}class cm extends ye{constructor(e){super(),we(this,e,fm,am,ke,{pct:0,color:1})}}function Hr(t){let e,l,n,i,o,r,a,f;return{c(){e=m("br"),l=v(),n=m("span"),i=C(t[3]),o=v(),r=m("span"),a=C(t[4]),f=C("/kWh"),u(n,"class","pl-sub"),u(r,"class","pl-snt")},m(c,p){y(c,e,p),y(c,l,p),y(c,n,p),s(n,i),y(c,o,p),y(c,r,p),s(r,a),s(r,f)},p(c,p){p&8&&B(i,c[3]),p&16&&B(a,c[4])},d(c){c&&w(e),c&&w(l),c&&w(n),c&&w(o),c&&w(r)}}}function mm(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$;l=new cm({props:{pct:t[6],color:t[5](t[6])}});let k=t[3]&&Hr(t);return{c(){e=m("div"),Q(l.$$.fragment),n=v(),i=m("span"),o=m("span"),r=C(t[2]),a=v(),f=m("br"),c=v(),p=m("span"),_=C(t[0]),d=v(),g=m("span"),h=C(t[1]),b=v(),k&&k.c(),u(o,"class","pl-lab"),u(p,"class","pl-val"),u(g,"class","pl-unt"),u(i,"class","pl-ov"),u(e,"class","pl-root")},m(T,M){y(T,e,M),Y(l,e,null),s(e,n),s(e,i),s(i,o),s(o,r),s(i,a),s(i,f),s(i,c),s(i,p),s(p,_),s(i,d),s(i,g),s(g,h),s(i,b),k&&k.m(i,null),$=!0},p(T,[M]){const E={};M&64&&(E.pct=T[6]),M&96&&(E.color=T[5](T[6])),l.$set(E),(!$||M&4)&&B(r,T[2]),(!$||M&1)&&B(_,T[0]),(!$||M&2)&&B(h,T[1]),T[3]?k?k.p(T,M):(k=Hr(T),k.c(),k.m(i,null)):k&&(k.d(1),k=null)},i(T){$||(P(l.$$.fragment,T),$=!0)},o(T){N(l.$$.fragment,T),$=!1},d(T){T&&w(e),V(l),k&&k.d()}}}function pm(t,e,l){let{val:n}=e,{max:i}=e,{unit:o}=e,{label:r}=e,{sub:a=""}=e,{subunit:f=""}=e,{colorFn:c}=e,p=0;return t.$$set=_=>{"val"in _&&l(0,n=_.val),"max"in _&&l(7,i=_.max),"unit"in _&&l(1,o=_.unit),"label"in _&&l(2,r=_.label),"sub"in _&&l(3,a=_.sub),"subunit"in _&&l(4,f=_.subunit),"colorFn"in _&&l(5,c=_.colorFn)},t.$$.update=()=>{t.$$.dirty&129&&l(6,p=Math.min(n,i)/i*100)},[n,o,r,a,f,c,p,i]}class uc extends ye{constructor(e){super(),we(this,e,pm,mm,ke,{val:0,max:7,unit:1,label:2,sub:3,subunit:4,colorFn:5})}}function jr(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function Wr(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function Gr(t,e,l){const n=t.slice();return n[13]=e[l],n}function Br(t){let e,l=t[0].title+"",n;return{c(){e=m("strong"),n=C(l),u(e,"class","text-sm")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=i[0].title+"")&&B(n,l)},d(i){i&&w(e)}}}function zr(t){let e,l,n,i=t[13].label+"",o,r,a,f;return{c(){e=Oe("g"),l=Oe("line"),n=Oe("text"),o=C(i),u(l,"x2","100%"),u(n,"y","-4"),u(n,"x",r=t[13].align=="right"?"85%":""),u(e,"class",a="tick tick-"+t[13].value+" tick-"+t[13].color),u(e,"transform",f="translate(0, "+t[6](t[13].value)+")")},m(c,p){y(c,e,p),s(e,l),s(e,n),s(n,o)},p(c,p){p&1&&i!==(i=c[13].label+"")&&B(o,i),p&1&&r!==(r=c[13].align=="right"?"85%":"")&&u(n,"x",r),p&1&&a!==(a="tick tick-"+c[13].value+" tick-"+c[13].color)&&u(e,"class",a),p&65&&f!==(f="translate(0, "+c[6](c[13].value)+")")&&u(e,"transform",f)},d(c){c&&w(e)}}}function Yr(t){let e,l,n=t[9].label+"",i,o,r;return{c(){e=Oe("g"),l=Oe("text"),i=C(n),u(l,"x",o=t[3]/2),u(l,"y","-4"),u(e,"class","tick"),u(e,"transform",r="translate("+t[5](t[11])+","+t[4]+")")},m(a,f){y(a,e,f),s(e,l),s(l,i)},p(a,f){f&1&&n!==(n=a[9].label+"")&&B(i,n),f&8&&o!==(o=a[3]/2)&&u(l,"x",o),f&48&&r!==(r="translate("+a[5](a[11])+","+a[4]+")")&&u(e,"transform",r)},d(a){a&&w(e)}}}function Vr(t){let e,l,n,i,o,r,a,f=t[3]>15&&Kr(t);return{c(){e=Oe("rect"),f&&f.c(),a=We(),u(e,"x",l=t[5](t[11])+2),u(e,"y",n=t[6](t[9].value)),u(e,"width",i=t[3]-4),u(e,"height",o=t[6](t[0].y.min)-t[6](Math.min(t[0].y.min,0)+t[9].value)),u(e,"fill",r=t[9].color)},m(c,p){y(c,e,p),f&&f.m(c,p),y(c,a,p)},p(c,p){p&32&&l!==(l=c[5](c[11])+2)&&u(e,"x",l),p&65&&n!==(n=c[6](c[9].value))&&u(e,"y",n),p&8&&i!==(i=c[3]-4)&&u(e,"width",i),p&65&&o!==(o=c[6](c[0].y.min)-c[6](Math.min(c[0].y.min,0)+c[9].value))&&u(e,"height",o),p&1&&r!==(r=c[9].color)&&u(e,"fill",r),c[3]>15?f?f.p(c,p):(f=Kr(c),f.c(),f.m(a.parentNode,a)):f&&(f.d(1),f=null)},d(c){c&&w(e),f&&f.d(c),c&&w(a)}}}function Kr(t){let e,l=t[9].label+"",n,i,o,r,a,f,c;return{c(){e=Oe("text"),n=C(l),u(e,"y",i=t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+10),u(e,"x",o=t[5](t[11])+t[3]/2),u(e,"width",r=t[3]-4),u(e,"dominant-baseline","middle"),u(e,"text-anchor",a=t[3]<25?"left":"middle"),u(e,"fill",f=t[6](t[9].value)>t[6](0)-t[7]?t[9].color:"white"),u(e,"transform",c="rotate("+(t[3]<25?90:0)+", "+(t[5](t[11])+t[3]/2)+", "+(t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+9)+")")},m(p,_){y(p,e,_),s(e,n)},p(p,_){_&1&&l!==(l=p[9].label+"")&&B(n,l),_&193&&i!==(i=p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+10)&&u(e,"y",i),_&40&&o!==(o=p[5](p[11])+p[3]/2)&&u(e,"x",o),_&8&&r!==(r=p[3]-4)&&u(e,"width",r),_&8&&a!==(a=p[3]<25?"left":"middle")&&u(e,"text-anchor",a),_&193&&f!==(f=p[6](p[9].value)>p[6](0)-p[7]?p[9].color:"white")&&u(e,"fill",f),_&233&&c!==(c="rotate("+(p[3]<25?90:0)+", "+(p[5](p[11])+p[3]/2)+", "+(p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+9)+")")&&u(e,"transform",c)},d(p){p&&w(e)}}}function Qr(t){let e,l,n,i,o,r,a,f=t[3]>15&&Zr(t);return{c(){e=Oe("rect"),f&&f.c(),a=We(),u(e,"x",l=t[5](t[11])+2),u(e,"y",n=t[6](0)),u(e,"width",i=t[3]-4),u(e,"height",o=t[6](t[0].y.min)-t[6](t[0].y.min+t[9].value2)),u(e,"fill",r=t[9].color)},m(c,p){y(c,e,p),f&&f.m(c,p),y(c,a,p)},p(c,p){p&32&&l!==(l=c[5](c[11])+2)&&u(e,"x",l),p&64&&n!==(n=c[6](0))&&u(e,"y",n),p&8&&i!==(i=c[3]-4)&&u(e,"width",i),p&65&&o!==(o=c[6](c[0].y.min)-c[6](c[0].y.min+c[9].value2))&&u(e,"height",o),p&1&&r!==(r=c[9].color)&&u(e,"fill",r),c[3]>15?f?f.p(c,p):(f=Zr(c),f.c(),f.m(a.parentNode,a)):f&&(f.d(1),f=null)},d(c){c&&w(e),f&&f.d(c),c&&w(a)}}}function Zr(t){let e,l=t[9].label2+"",n,i,o,r,a,f,c;return{c(){e=Oe("text"),n=C(l),u(e,"y",i=t[6](-t[9].value2)t[6](0)-12?t[6](t[9].value2-t[0].y.min)-12:t[6](t[9].value2-t[0].y.min)+9)+")")},m(p,_){y(p,e,_),s(e,n)},p(p,_){_&1&&l!==(l=p[9].label2+"")&&B(n,l),_&65&&i!==(i=p[6](-p[9].value2)p[6](0)-12?p[6](p[9].value2-p[0].y.min)-12:p[6](p[9].value2-p[0].y.min)+9)+")")&&u(e,"transform",c)},d(p){p&&w(e)}}}function Jr(t){let e,l,n=t[9].value!==void 0&&Vr(t),i=t[9].value2>1e-4&&Qr(t);return{c(){n&&n.c(),e=We(),i&&i.c(),l=We()},m(o,r){n&&n.m(o,r),y(o,e,r),i&&i.m(o,r),y(o,l,r)},p(o,r){o[9].value!==void 0?n?n.p(o,r):(n=Vr(o),n.c(),n.m(e.parentNode,e)):n&&(n.d(1),n=null),o[9].value2>1e-4?i?i.p(o,r):(i=Qr(o),i.c(),i.m(l.parentNode,l)):i&&(i.d(1),i=null)},d(o){n&&n.d(o),o&&w(e),i&&i.d(o),o&&w(l)}}}function _m(t){let e,l,n,i,o,r,a,f=t[0].title&&Br(t),c=t[0].y.ticks,p=[];for(let b=0;bt[8].call(e))},m(b,$){y(b,e,$),f&&f.m(e,null),s(e,l),s(e,n),s(n,i);for(let k=0;k{"config"in d&&l(0,n=d.config)},t.$$.update=()=>{if(t.$$.dirty&31){l(4,c=o-(n.title?20:0));let d=i-(n.padding.left+n.padding.right);l(3,r=d/n.points.length),l(7,p=r<25?28:17);let g=(c-n.padding.top-n.padding.bottom)/(n.y.max-n.y.min);l(5,a=function(h){return h*r+n.padding.left}),l(6,f=function(h){let b=0;return h>n.y.max?b=n.padding.bottom:hc||b<0?0:b})}},[n,i,o,r,c,a,f,p,_]}class zl extends ye{constructor(e){super(),we(this,e,dm,_m,ke,{config:0})}}function vm(t){let e,l;return e=new zl({props:{config:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function hm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{ds:r}=e,a={};function f(c){return{label:be(c)+"V",value:isNaN(c)?0:c,color:S1(c||0)}}return t.$$set=c=>{"u1"in c&&l(1,n=c.u1),"u2"in c&&l(2,i=c.u2),"u3"in c&&l(3,o=c.u3),"ds"in c&&l(4,r=c.ds)},t.$$.update=()=>{if(t.$$.dirty&30){let c=[],p=[];n>0&&(c.push({label:r===1?"L1-L2":"L1"}),p.push(f(n))),i>0&&(c.push({label:r===1?"L1-L3":"L2"}),p.push(f(i))),o>0&&(c.push({label:r===1?"L2-L3":"L3"}),p.push(f(o))),l(0,a={padding:{top:20,right:15,bottom:20,left:35},y:{min:200,max:260,ticks:[{value:207,label:"-10%"},{value:230,label:"230v"},{value:253,label:"+10%"}]},x:{ticks:c},points:p})}},[a,n,i,o,r]}class gm extends ye{constructor(e){super(),we(this,e,hm,vm,ke,{u1:1,u2:2,u3:3,ds:4})}}function bm(t){let e,l;return e=new zl({props:{config:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function km(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{i1:r}=e,{i2:a}=e,{i3:f}=e,{max:c}=e,p={};function _(d){return{label:be(d)+"A",value:isNaN(d)?0:d,color:Qf(d?d/c*100:0)}}return t.$$set=d=>{"u1"in d&&l(1,n=d.u1),"u2"in d&&l(2,i=d.u2),"u3"in d&&l(3,o=d.u3),"i1"in d&&l(4,r=d.i1),"i2"in d&&l(5,a=d.i2),"i3"in d&&l(6,f=d.i3),"max"in d&&l(7,c=d.max)},t.$$.update=()=>{if(t.$$.dirty&254){let d=[],g=[];n>0&&(d.push({label:"L1"}),g.push(_(r))),i>0&&(d.push({label:"L2"}),g.push(_(a))),o>0&&(d.push({label:"L3"}),g.push(_(f))),l(0,p={padding:{top:20,right:15,bottom:20,left:35},y:{min:0,max:c,ticks:[{value:0,label:"0%"},{value:c/4,label:"25%"},{value:c/2,label:"50%"},{value:c/4*3,label:"75%"},{value:c,label:"100%"}]},x:{ticks:d},points:g})}},[p,n,i,o,r,a,f,c]}class wm extends ye{constructor(e){super(),we(this,e,km,bm,ke,{u1:1,u2:2,u3:3,i1:4,i2:5,i3:6,max:7})}}function ym(t){let e,l,n,i,o,r,a,f=(typeof t[0]<"u"?t[0].toFixed(0):"-")+"",c,p,_,d,g,h,b=(typeof t[1]<"u"?t[1].toFixed(0):"-")+"",$,k,T,M,E,S,I,A=(typeof t[2]<"u"?t[2].toFixed(1):"-")+"",R,H,j,F,L,W,G=(typeof t[3]<"u"?t[3].toFixed(1):"-")+"",q,O;return{c(){e=m("div"),l=m("strong"),l.textContent="Reactive",n=v(),i=m("div"),o=m("div"),o.textContent="Instant in",r=v(),a=m("div"),c=C(f),p=C(" VAr"),_=v(),d=m("div"),d.textContent="Instant out",g=v(),h=m("div"),$=C(b),k=C(" VAr"),T=v(),M=m("div"),E=m("div"),E.textContent="Total in",S=v(),I=m("div"),R=C(A),H=C(" kVArh"),j=v(),F=m("div"),F.textContent="Total out",L=v(),W=m("div"),q=C(G),O=C(" kVArh"),u(a,"class","text-right"),u(h,"class","text-right"),u(i,"class","grid grid-cols-2 mt-4"),u(I,"class","text-right"),u(W,"class","text-right"),u(M,"class","grid grid-cols-2 mt-4"),u(e,"class","mx-2 text-sm")},m(U,X){y(U,e,X),s(e,l),s(e,n),s(e,i),s(i,o),s(i,r),s(i,a),s(a,c),s(a,p),s(i,_),s(i,d),s(i,g),s(i,h),s(h,$),s(h,k),s(e,T),s(e,M),s(M,E),s(M,S),s(M,I),s(I,R),s(I,H),s(M,j),s(M,F),s(M,L),s(M,W),s(W,q),s(W,O)},p(U,[X]){X&1&&f!==(f=(typeof U[0]<"u"?U[0].toFixed(0):"-")+"")&&B(c,f),X&2&&b!==(b=(typeof U[1]<"u"?U[1].toFixed(0):"-")+"")&&B($,b),X&4&&A!==(A=(typeof U[2]<"u"?U[2].toFixed(1):"-")+"")&&B(R,A),X&8&&G!==(G=(typeof U[3]<"u"?U[3].toFixed(1):"-")+"")&&B(q,G)},i:ie,o:ie,d(U){U&&w(e)}}}function $m(t,e,l){let{importInstant:n}=e,{exportInstant:i}=e,{importTotal:o}=e,{exportTotal:r}=e;return t.$$set=a=>{"importInstant"in a&&l(0,n=a.importInstant),"exportInstant"in a&&l(1,i=a.exportInstant),"importTotal"in a&&l(2,o=a.importTotal),"exportTotal"in a&&l(3,r=a.exportTotal)},[n,i,o,r]}class Cm extends ye{constructor(e){super(),we(this,e,$m,ym,ke,{importInstant:0,exportInstant:1,importTotal:2,exportTotal:3})}}function Xr(t){let e;function l(o,r){return o[2]?Sm:Tm}let n=l(t),i=n(t);return{c(){i.c(),e=We()},m(o,r){i.m(o,r),y(o,e,r)},p(o,r){n===(n=l(o))&&i?i.p(o,r):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){i.d(o),o&&w(e)}}}function Tm(t){let e,l,n,i,o,r,a=be(t[0].h.u,2)+"",f,c,p,_,d,g,h=be(t[0].d.u,1)+"",b,$,k,T,M,E,S=be(t[0].m.u)+"",I,A,R,H,j=t[1]&&xr(t);return{c(){e=m("strong"),e.textContent="Consumption",l=v(),n=m("div"),i=m("div"),i.textContent="Hour",o=v(),r=m("div"),f=C(a),c=C(" kWh"),p=v(),_=m("div"),_.textContent="Day",d=v(),g=m("div"),b=C(h),$=C(" kWh"),k=v(),T=m("div"),T.textContent="Month",M=v(),E=m("div"),I=C(S),A=C(" kWh"),R=v(),j&&j.c(),H=We(),u(r,"class","text-right"),u(g,"class","text-right"),u(E,"class","text-right"),u(n,"class","grid grid-cols-2 mb-3")},m(F,L){y(F,e,L),y(F,l,L),y(F,n,L),s(n,i),s(n,o),s(n,r),s(r,f),s(r,c),s(n,p),s(n,_),s(n,d),s(n,g),s(g,b),s(g,$),s(n,k),s(n,T),s(n,M),s(n,E),s(E,I),s(E,A),y(F,R,L),j&&j.m(F,L),y(F,H,L)},p(F,L){L&1&&a!==(a=be(F[0].h.u,2)+"")&&B(f,a),L&1&&h!==(h=be(F[0].d.u,1)+"")&&B(b,h),L&1&&S!==(S=be(F[0].m.u)+"")&&B(I,S),F[1]?j?j.p(F,L):(j=xr(F),j.c(),j.m(H.parentNode,H)):j&&(j.d(1),j=null)},d(F){F&&w(e),F&&w(l),F&&w(n),F&&w(R),j&&j.d(F),F&&w(H)}}}function Sm(t){let e,l,n,i,o,r,a=be(t[0].h.u,2)+"",f,c,p,_,d,g,h,b=be(t[0].d.u,1)+"",$,k,T,M,E,S,I,A=be(t[0].m.u)+"",R,H,j,F,L,W,G,q,O,U,X,z=be(t[0].h.p,2)+"",ne,te,Me,_e,Ne,Ie,Fe,Ee=be(t[0].d.p,1)+"",$e,ge,fe,ae,ce,ue,J,se=be(t[0].m.p)+"",Ce,x,oe,He,Te=t[1]&&ea(t),de=t[1]&&ta(t),ve=t[1]&&la(t),le=t[1]&&na(t),he=t[1]&&ia(t),qe=t[1]&&sa(t);return{c(){e=m("strong"),e.textContent="Import",l=v(),n=m("div"),i=m("div"),i.textContent="Hour",o=v(),r=m("div"),f=C(a),c=C(" kWh"),p=v(),Te&&Te.c(),_=v(),d=m("div"),d.textContent="Day",g=v(),h=m("div"),$=C(b),k=C(" kWh"),T=v(),de&&de.c(),M=v(),E=m("div"),E.textContent="Month",S=v(),I=m("div"),R=C(A),H=C(" kWh"),j=v(),ve&&ve.c(),L=v(),W=m("strong"),W.textContent="Export",G=v(),q=m("div"),O=m("div"),O.textContent="Hour",U=v(),X=m("div"),ne=C(z),te=C(" kWh"),Me=v(),le&&le.c(),_e=v(),Ne=m("div"),Ne.textContent="Day",Ie=v(),Fe=m("div"),$e=C(Ee),ge=C(" kWh"),fe=v(),he&&he.c(),ae=v(),ce=m("div"),ce.textContent="Month",ue=v(),J=m("div"),Ce=C(se),x=C(" kWh"),oe=v(),qe&&qe.c(),u(r,"class","text-right"),u(h,"class","text-right"),u(I,"class","text-right"),u(n,"class",F="grid grid-cols-"+t[3]+" mb-3"),u(X,"class","text-right"),u(Fe,"class","text-right"),u(J,"class","text-right"),u(q,"class",He="grid grid-cols-"+t[3])},m(re,De){y(re,e,De),y(re,l,De),y(re,n,De),s(n,i),s(n,o),s(n,r),s(r,f),s(r,c),s(n,p),Te&&Te.m(n,null),s(n,_),s(n,d),s(n,g),s(n,h),s(h,$),s(h,k),s(n,T),de&&de.m(n,null),s(n,M),s(n,E),s(n,S),s(n,I),s(I,R),s(I,H),s(n,j),ve&&ve.m(n,null),y(re,L,De),y(re,W,De),y(re,G,De),y(re,q,De),s(q,O),s(q,U),s(q,X),s(X,ne),s(X,te),s(q,Me),le&&le.m(q,null),s(q,_e),s(q,Ne),s(q,Ie),s(q,Fe),s(Fe,$e),s(Fe,ge),s(q,fe),he&&he.m(q,null),s(q,ae),s(q,ce),s(q,ue),s(q,J),s(J,Ce),s(J,x),s(q,oe),qe&&qe.m(q,null)},p(re,De){De&1&&a!==(a=be(re[0].h.u,2)+"")&&B(f,a),re[1]?Te?Te.p(re,De):(Te=ea(re),Te.c(),Te.m(n,_)):Te&&(Te.d(1),Te=null),De&1&&b!==(b=be(re[0].d.u,1)+"")&&B($,b),re[1]?de?de.p(re,De):(de=ta(re),de.c(),de.m(n,M)):de&&(de.d(1),de=null),De&1&&A!==(A=be(re[0].m.u)+"")&&B(R,A),re[1]?ve?ve.p(re,De):(ve=la(re),ve.c(),ve.m(n,null)):ve&&(ve.d(1),ve=null),De&8&&F!==(F="grid grid-cols-"+re[3]+" mb-3")&&u(n,"class",F),De&1&&z!==(z=be(re[0].h.p,2)+"")&&B(ne,z),re[1]?le?le.p(re,De):(le=na(re),le.c(),le.m(q,_e)):le&&(le.d(1),le=null),De&1&&Ee!==(Ee=be(re[0].d.p,1)+"")&&B($e,Ee),re[1]?he?he.p(re,De):(he=ia(re),he.c(),he.m(q,ae)):he&&(he.d(1),he=null),De&1&&se!==(se=be(re[0].m.p)+"")&&B(Ce,se),re[1]?qe?qe.p(re,De):(qe=sa(re),qe.c(),qe.m(q,null)):qe&&(qe.d(1),qe=null),De&8&&He!==(He="grid grid-cols-"+re[3])&&u(q,"class",He)},d(re){re&&w(e),re&&w(l),re&&w(n),Te&&Te.d(),de&&de.d(),ve&&ve.d(),re&&w(L),re&&w(W),re&&w(G),re&&w(q),le&&le.d(),he&&he.d(),qe&&qe.d()}}}function xr(t){let e,l,n,i,o,r,a=be(t[0].h.c,2)+"",f,c,p,_,d,g,h,b=be(t[0].d.c,1)+"",$,k,T,M,E,S,I,A=be(t[0].m.c)+"",R,H,j;return{c(){e=m("strong"),e.textContent="Cost",l=v(),n=m("div"),i=m("div"),i.textContent="Hour",o=v(),r=m("div"),f=C(a),c=v(),p=C(t[1]),_=v(),d=m("div"),d.textContent="Day",g=v(),h=m("div"),$=C(b),k=v(),T=C(t[1]),M=v(),E=m("div"),E.textContent="Month",S=v(),I=m("div"),R=C(A),H=v(),j=C(t[1]),u(r,"class","text-right"),u(h,"class","text-right"),u(I,"class","text-right"),u(n,"class","grid grid-cols-2")},m(F,L){y(F,e,L),y(F,l,L),y(F,n,L),s(n,i),s(n,o),s(n,r),s(r,f),s(r,c),s(r,p),s(n,_),s(n,d),s(n,g),s(n,h),s(h,$),s(h,k),s(h,T),s(n,M),s(n,E),s(n,S),s(n,I),s(I,R),s(I,H),s(I,j)},p(F,L){L&1&&a!==(a=be(F[0].h.c,2)+"")&&B(f,a),L&2&&B(p,F[1]),L&1&&b!==(b=be(F[0].d.c,1)+"")&&B($,b),L&2&&B(T,F[1]),L&1&&A!==(A=be(F[0].m.c)+"")&&B(R,A),L&2&&B(j,F[1])},d(F){F&&w(e),F&&w(l),F&&w(n)}}}function ea(t){let e,l=be(t[0].h.c,2)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=be(r[0].h.c,2)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function ta(t){let e,l=be(t[0].d.c,1)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=be(r[0].d.c,1)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function la(t){let e,l=be(t[0].m.c)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=be(r[0].m.c)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function na(t){let e,l=be(t[0].h.i,2)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=be(r[0].h.i,2)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function ia(t){let e,l=be(t[0].d.i,1)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=be(r[0].d.i,1)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function sa(t){let e,l=be(t[0].m.i)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=be(r[0].m.i)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function Pm(t){let e,l,n,i,o,r,a=t[0]&&Xr(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Real time calculation",n=v(),i=m("br"),o=m("br"),r=v(),a&&a.c(),u(e,"class","mx-2 text-sm")},m(f,c){y(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),s(e,r),a&&a.m(e,null)},p(f,[c]){f[0]?a?a.p(f,c):(a=Xr(f),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},i:ie,o:ie,d(f){f&&w(e),a&&a.d()}}}function Mm(t,e,l){let{data:n}=e,{currency:i}=e,{hasExport:o}=e,r=3;return t.$$set=a=>{"data"in a&&l(0,n=a.data),"currency"in a&&l(1,i=a.currency),"hasExport"in a&&l(2,o=a.hasExport)},t.$$.update=()=>{t.$$.dirty&2&&l(3,r=i?3:2)},[n,i,o,r]}class Dm extends ye{constructor(e){super(),we(this,e,Mm,Pm,ke,{data:0,currency:1,hasExport:2})}}function Am(t){let e,l,n,i;return n=new zl({props:{config:t[0]}}),{c(){e=m("a"),e.textContent="Provided by ENTSO-E",l=v(),Q(n.$$.fragment),u(e,"href","https://transparency.entsoe.eu/"),u(e,"target","_blank"),u(e,"class","text-xs float-right z-40")},m(o,r){y(o,e,r),y(o,l,r),Y(n,o,r),i=!0},p(o,[r]){const a={};r&1&&(a.config=o[0]),n.$set(a)},i(o){i||(P(n.$$.fragment,o),i=!0)},o(o){N(n.$$.fragment,o),i=!1},d(o){o&&w(e),o&&w(l),V(n,o)}}}function Nm(t,e,l){let{json:n}=e,i={},o=0,r=0;return t.$$set=a=>{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=new Date().getUTCHours(),f=0,c=0,p=0,_=n[20]==null?2:1,d=[],g=[],h=[],b=new Date;for(f=a;f<24&&(c=n[Ae(p++)],c!=null);f++)g.push({label:Ae(b.getHours())}),h.push({label:c>0?c.toFixed(_):"",value:c>0?Math.abs(c*100):0,label2:c<0?c.toFixed(_):"",value2:c<0?Math.abs(c*100):0,color:"#7c3aed"}),l(3,r=Math.min(r,c*100)),l(2,o=Math.max(o,c*100)),ii(b,1);for(f=0;f<24&&(c=n[Ae(p++)],c!=null);f++)g.push({label:Ae(b.getHours())}),h.push({label:c>0?c.toFixed(_):"",value:c>0?Math.abs(c*100):0,label2:c<0?c.toFixed(_):"",value2:c<0?Math.abs(c*100):0,color:"#7c3aed"}),l(3,r=Math.min(r,c*100)),l(2,o=Math.max(o,c*100)),ii(b,1);if(l(2,o=Math.ceil(o)),l(3,r=Math.floor(r)),r<0){let k=r/4;for(f=1;f<5;f++){let T=k*f;d.push({value:T,label:(T/100).toFixed(2)})}}let $=o/4;for(f=0;f<5;f++){let k=$*f;d.push({value:k,label:(k/100).toFixed(2)})}l(0,i={title:"Future energy price ("+n.currency+")",padding:{top:20,right:15,bottom:20,left:35},y:{min:r,max:o,ticks:d},x:{ticks:g},points:h})}},[i,n,o,r]}class Im extends ye{constructor(e){super(),we(this,e,Nm,Am,ke,{json:1})}}function Em(t){let e,l;return e=new zl({props:{config:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Rm(t,e,l){let{json:n}=e,i={},o=0,r=0;return t.$$set=a=>{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,f=[],c=[],p=[],_=ii(new Date,-24),d=new Date().getUTCHours();for(a=d;a<24;a++){let b=n["i"+Ae(a)],$=n["e"+Ae(a)];b===void 0&&(b=0),$===void 0&&($=0),c.push({label:Ae(_.getHours())}),p.push({label:b.toFixed(1),value:b*10,label2:$.toFixed(1),value2:$*10,color:"#7c3aed"}),l(3,r=Math.max(r,$*10)),l(2,o=Math.max(o,b*10)),ii(_,1)}for(a=0;a{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,f=[],c=[],p=[],_=new Date,d=new Date;for(d.setDate(0),a=_.getDate();a<=d.getDate();a++){let b=n["i"+Ae(a)],$=n["e"+Ae(a)];b===void 0&&(b=0),$===void 0&&($=0),c.push({label:Ae(a)}),p.push({label:b.toFixed(0),value:b,label2:$.toFixed(0),value2:$,color:"#7c3aed"}),l(3,r=Math.max(r,$)),l(2,o=Math.max(o,b))}for(a=1;a<_.getDate();a++){let b=n["i"+Ae(a)],$=n["e"+Ae(a)];b===void 0&&(b=0),$===void 0&&($=0),c.push({label:Ae(a)}),p.push({label:b.toFixed(0),value:b,label2:$.toFixed(0),value2:$,color:"#7c3aed"}),l(3,r=Math.max(r,$)),l(2,o=Math.max(o,b))}let g=Math.ceil(Math.max(r,o)/10)*10;if(l(2,o=g),l(3,r=r==0?0:g*-1),r<0){let b=r/4;for(a=0;a<5;a++){let $=b*a;f.push({value:$,label:$.toFixed(0)})}}let h=o/4;for(a=0;a<5;a++){let b=h*a;f.push({value:b,label:b.toFixed(0)})}l(0,i={title:"Energy use last month (kWh)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:r,max:o,ticks:f},x:{ticks:c},points:p})}},[i,n,o,r]}class qm extends ye{constructor(e){super(),we(this,e,Om,Lm,ke,{json:1})}}function Um(t){let e,l;return e=new zl({props:{config:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Hm(t,e,l){let{json:n}=e,i={},o=0,r=0;return t.$$set=a=>{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,f=0,c=[],p=[],_=[];n.s&&n.s.forEach((h,b)=>{var $=h.n?h.n:h.a;f=h.v,f==-127&&(f=0),p.push({label:$.slice(-4)}),_.push({label:f.toFixed(1),value:f,color:"#7c3aed"}),l(3,r=Math.min(r,f)),l(2,o=Math.max(o,f))}),l(2,o=Math.ceil(o)),l(3,r=Math.floor(r));let d=o;r<0&&(d+=Math.abs(r));let g=d/4;for(a=0;a<5;a++)f=r+g*a,c.push({value:f,label:f.toFixed(1)});l(0,i={title:"Temperature sensors (\xB0C)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:r,max:o,ticks:c},x:{ticks:p},points:_})}},[i,n,o,r]}class jm extends ye{constructor(e){super(),we(this,e,Hm,Um,ke,{json:1})}}function Wm(t){let e,l;return e=new zl({props:{config:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}let Gm=0;function Bm(t,e,l){let n={},i=0,o;return lc.subscribe(r=>{l(2,o=r)}),tc(),t.$$.update=()=>{if(t.$$.dirty&6){let r=0,a=[],f=[],c=[];if(a.push({value:0,label:0}),o&&o.p)for(r=0;r0?Ae(p.d)+"."+Us[new Date().getMonth()]:"-"}),l(1,i=Math.max(i,p.v))}if(o&&o.t){for(r=0;r=i)break;a.push({value:p,label:p})}a.push({label:o.m.toFixed(1),align:"right",color:"green",value:o.m})}o&&o.c&&(a.push({label:o.c.toFixed(0),color:"orange",value:o.c}),l(1,i=Math.max(i,o.c))),l(1,i=Math.ceil(i)),l(0,n={title:"Tariff peaks",padding:{top:20,right:35,bottom:20,left:35},y:{min:Gm,max:i,ticks:a},x:{ticks:f},points:c})}},[n,i,o]}class zm extends ye{constructor(e){super(),we(this,e,Bm,Wm,ke,{})}}function oa(t){let e,l,n,i,o,r,a=(t[0].mt?as(t[0].mt):"-")+"",f,c,p,_=(t[0].ic?t[0].ic.toFixed(1):"-")+"",d,g,h;return i=new uc({props:{val:t[0].i?t[0].i:0,max:t[0].im?t[0].im:15e3,unit:"W",label:"Import",sub:t[0].p,subunit:t[2].currency,colorFn:Qf}}),{c(){e=m("div"),l=m("div"),n=m("div"),Q(i.$$.fragment),o=v(),r=m("div"),f=C(a),c=v(),p=m("div"),d=C(_),g=C(" kWh"),u(n,"class","col-span-2"),u(p,"class","text-right"),u(l,"class","grid grid-cols-2"),u(e,"class","cnt")},m(b,$){y(b,e,$),s(e,l),s(l,n),Y(i,n,null),s(l,o),s(l,r),s(r,f),s(l,c),s(l,p),s(p,d),s(p,g),h=!0},p(b,$){const k={};$&1&&(k.val=b[0].i?b[0].i:0),$&1&&(k.max=b[0].im?b[0].im:15e3),$&1&&(k.sub=b[0].p),$&4&&(k.subunit=b[2].currency),i.$set(k),(!h||$&1)&&a!==(a=(b[0].mt?as(b[0].mt):"-")+"")&&B(f,a),(!h||$&1)&&_!==(_=(b[0].ic?b[0].ic.toFixed(1):"-")+"")&&B(d,_)},i(b){h||(P(i.$$.fragment,b),h=!0)},o(b){N(i.$$.fragment,b),h=!1},d(b){b&&w(e),V(i)}}}function ua(t){let e,l,n,i,o,r,a,f,c=(t[0].ec?t[0].ec.toFixed(1):"-")+"",p,_,d;return i=new uc({props:{val:t[0].e?t[0].e:0,max:t[0].om?t[0].om*1e3:1e4,unit:"W",label:"Export",colorFn:P1}}),{c(){e=m("div"),l=m("div"),n=m("div"),Q(i.$$.fragment),o=v(),r=m("div"),a=v(),f=m("div"),p=C(c),_=C(" kWh"),u(n,"class","col-span-2"),u(f,"class","text-right"),u(l,"class","grid grid-cols-2"),u(e,"class","cnt")},m(g,h){y(g,e,h),s(e,l),s(l,n),Y(i,n,null),s(l,o),s(l,r),s(l,a),s(l,f),s(f,p),s(f,_),d=!0},p(g,h){const b={};h&1&&(b.val=g[0].e?g[0].e:0),h&1&&(b.max=g[0].om?g[0].om*1e3:1e4),i.$set(b),(!d||h&1)&&c!==(c=(g[0].ec?g[0].ec.toFixed(1):"-")+"")&&B(p,c)},i(g){d||(P(i.$$.fragment,g),d=!0)},o(g){N(i.$$.fragment,g),d=!1},d(g){g&&w(e),V(i)}}}function ra(t){let e,l,n;return l=new gm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,ds:t[0].ds}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.u1=i[0].u1),o&1&&(r.u2=i[0].u2),o&1&&(r.u3=i[0].u3),o&1&&(r.ds=i[0].ds),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function aa(t){let e,l,n;return l=new wm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,i1:t[0].i1,i2:t[0].i2,i3:t[0].i3,max:t[0].mf?t[0].mf:32}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.u1=i[0].u1),o&1&&(r.u2=i[0].u2),o&1&&(r.u3=i[0].u3),o&1&&(r.i1=i[0].i1),o&1&&(r.i2=i[0].i2),o&1&&(r.i3=i[0].i3),o&1&&(r.max=i[0].mf?i[0].mf:32),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function fa(t){let e,l,n;return l=new Cm({props:{importInstant:t[0].ri,exportInstant:t[0].re,importTotal:t[0].ric,exportTotal:t[0].rec}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.importInstant=i[0].ri),o&1&&(r.exportInstant=i[0].re),o&1&&(r.importTotal=i[0].ric),o&1&&(r.exportTotal=i[0].rec),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function ca(t){let e,l,n;return l=new Dm({props:{data:t[0].ea,currency:t[2].currency,hasExport:t[0].om>0||t[0].e>0}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.data=i[0].ea),o&4&&(r.currency=i[2].currency),o&1&&(r.hasExport=i[0].om>0||i[0].e>0),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function ma(t){let e,l,n;return l=new zm({}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt h-64")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function pa(t){let e,l,n;return l=new Im({props:{json:t[2]}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&4&&(r.json=i[2]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function _a(t){let e,l,n;return l=new Fm({props:{json:t[3]}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&8&&(r.json=i[3]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function da(t){let e,l,n;return l=new qm({props:{json:t[4]}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&16&&(r.json=i[4]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function va(t){let e,l,n;return l=new jm({props:{json:t[5]}}),{c(){e=m("div"),Q(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),Y(l,e,null),n=!0},p(i,o){const r={};o&32&&(r.json=i[5]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){N(l.$$.fragment,i),n=!1},d(i){i&&w(e),V(l)}}}function Ym(t){let e,l=je(t[1].ui.i,t[0].i),n,i=je(t[1].ui.e,t[0].om||t[0].e>0),o,r=je(t[1].ui.v,t[0].u1>100||t[0].u2>100||t[0].u3>100),a,f=je(t[1].ui.a,t[0].i1>.01||t[0].i2>.01||t[0].i3>.01),c,p=je(t[1].ui.r,t[0].ri>0||t[0].re>0||t[0].ric>0||t[0].rec>0),_,d=je(t[1].ui.c,t[0].ea),g,h=je(t[1].ui.t,t[0].pr&&(t[0].pr.startsWith("10YNO")||t[0].pr=="10Y1001A1001A48H")),b,$=je(t[1].ui.p,typeof t[0].p=="number"&&!Number.isNaN(t[0].p)),k,T=je(t[1].ui.d,t[3]),M,E=je(t[1].ui.m,t[4]),S,I=je(t[1].ui.s,t[0].t&&t[0].t!=-127&&t[5].c>1),A,R=l&&oa(t),H=i&&ua(t),j=r&&ra(t),F=f&&aa(t),L=p&&fa(t),W=d&&ca(t),G=h&&ma(),q=$&&pa(t),O=T&&_a(t),U=E&&da(t),X=I&&va(t);return{c(){e=m("div"),R&&R.c(),n=v(),H&&H.c(),o=v(),j&&j.c(),a=v(),F&&F.c(),c=v(),L&&L.c(),_=v(),W&&W.c(),g=v(),G&&G.c(),b=v(),q&&q.c(),k=v(),O&&O.c(),M=v(),U&&U.c(),S=v(),X&&X.c(),u(e,"class","grid 2xl:grid-cols-6 xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-2")},m(z,ne){y(z,e,ne),R&&R.m(e,null),s(e,n),H&&H.m(e,null),s(e,o),j&&j.m(e,null),s(e,a),F&&F.m(e,null),s(e,c),L&&L.m(e,null),s(e,_),W&&W.m(e,null),s(e,g),G&&G.m(e,null),s(e,b),q&&q.m(e,null),s(e,k),O&&O.m(e,null),s(e,M),U&&U.m(e,null),s(e,S),X&&X.m(e,null),A=!0},p(z,[ne]){ne&3&&(l=je(z[1].ui.i,z[0].i)),l?R?(R.p(z,ne),ne&3&&P(R,1)):(R=oa(z),R.c(),P(R,1),R.m(e,n)):R&&(Se(),N(R,1,1,()=>{R=null}),Pe()),ne&3&&(i=je(z[1].ui.e,z[0].om||z[0].e>0)),i?H?(H.p(z,ne),ne&3&&P(H,1)):(H=ua(z),H.c(),P(H,1),H.m(e,o)):H&&(Se(),N(H,1,1,()=>{H=null}),Pe()),ne&3&&(r=je(z[1].ui.v,z[0].u1>100||z[0].u2>100||z[0].u3>100)),r?j?(j.p(z,ne),ne&3&&P(j,1)):(j=ra(z),j.c(),P(j,1),j.m(e,a)):j&&(Se(),N(j,1,1,()=>{j=null}),Pe()),ne&3&&(f=je(z[1].ui.a,z[0].i1>.01||z[0].i2>.01||z[0].i3>.01)),f?F?(F.p(z,ne),ne&3&&P(F,1)):(F=aa(z),F.c(),P(F,1),F.m(e,c)):F&&(Se(),N(F,1,1,()=>{F=null}),Pe()),ne&3&&(p=je(z[1].ui.r,z[0].ri>0||z[0].re>0||z[0].ric>0||z[0].rec>0)),p?L?(L.p(z,ne),ne&3&&P(L,1)):(L=fa(z),L.c(),P(L,1),L.m(e,_)):L&&(Se(),N(L,1,1,()=>{L=null}),Pe()),ne&3&&(d=je(z[1].ui.c,z[0].ea)),d?W?(W.p(z,ne),ne&3&&P(W,1)):(W=ca(z),W.c(),P(W,1),W.m(e,g)):W&&(Se(),N(W,1,1,()=>{W=null}),Pe()),ne&3&&(h=je(z[1].ui.t,z[0].pr&&(z[0].pr.startsWith("10YNO")||z[0].pr=="10Y1001A1001A48H"))),h?G?ne&3&&P(G,1):(G=ma(),G.c(),P(G,1),G.m(e,b)):G&&(Se(),N(G,1,1,()=>{G=null}),Pe()),ne&3&&($=je(z[1].ui.p,typeof z[0].p=="number"&&!Number.isNaN(z[0].p))),$?q?(q.p(z,ne),ne&3&&P(q,1)):(q=pa(z),q.c(),P(q,1),q.m(e,k)):q&&(Se(),N(q,1,1,()=>{q=null}),Pe()),ne&10&&(T=je(z[1].ui.d,z[3])),T?O?(O.p(z,ne),ne&10&&P(O,1)):(O=_a(z),O.c(),P(O,1),O.m(e,M)):O&&(Se(),N(O,1,1,()=>{O=null}),Pe()),ne&18&&(E=je(z[1].ui.m,z[4])),E?U?(U.p(z,ne),ne&18&&P(U,1)):(U=da(z),U.c(),P(U,1),U.m(e,S)):U&&(Se(),N(U,1,1,()=>{U=null}),Pe()),ne&35&&(I=je(z[1].ui.s,z[0].t&&z[0].t!=-127&&z[5].c>1)),I?X?(X.p(z,ne),ne&35&&P(X,1)):(X=va(z),X.c(),P(X,1),X.m(e,null)):X&&(Se(),N(X,1,1,()=>{X=null}),Pe())},i(z){A||(P(R),P(H),P(j),P(F),P(L),P(W),P(G),P(q),P(O),P(U),P(X),A=!0)},o(z){N(R),N(H),N(j),N(F),N(L),N(W),N(G),N(q),N(O),N(U),N(X),A=!1},d(z){z&&w(e),R&&R.d(),H&&H.d(),j&&j.d(),F&&F.d(),L&&L.d(),W&&W.d(),G&&G.d(),q&&q.d(),O&&O.d(),U&&U.d(),X&&X.d()}}}function Vm(t,e,l){let{data:n={}}=e,{sysinfo:i={}}=e,o={},r={},a={},f={};return Zf.subscribe(c=>{l(2,o=c)}),Jf.subscribe(c=>{l(3,r=c)}),Xf.subscribe(c=>{l(4,a=c)}),ec.subscribe(c=>{l(5,f=c)}),t.$$set=c=>{"data"in c&&l(0,n=c.data),"sysinfo"in c&&l(1,i=c.sysinfo)},[n,i,o,r,a,f]}class Km extends ye{constructor(e){super(),we(this,e,Vm,Ym,ke,{data:0,sysinfo:1})}}let Ys={};const rc=Ze(Ys);async function Qm(){Ys=await(await fetch("/configuration.json")).json(),rc.set(Ys)}function ha(t,e,l){const n=t.slice();return n[2]=e[l],n[4]=l,n}function ga(t){let e;return{c(){e=m("option"),e.textContent="UART2",e.__value=113,e.value=e.__value},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function ba(t){let e,l,n;return{c(){e=m("option"),e.textContent="UART1",l=v(),n=m("option"),n.textContent="UART2",e.__value=9,e.value=e.__value,n.__value=16,n.value=n.__value},m(i,o){y(i,e,o),y(i,l,o),y(i,n,o)},d(i){i&&w(e),i&&w(l),i&&w(n)}}}function ka(t){let e;return{c(){e=m("option"),e.textContent="UART1",e.__value=18,e.value=e.__value},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function wa(t){let e,l,n;return{c(){e=m("option"),l=C("GPIO"),n=C(t[4]),e.__value=t[4],e.value=e.__value},m(i,o){y(i,e,o),s(e,l),s(e,n)},d(i){i&&w(e)}}}function ya(t){let e,l=t[4]>3&&!(t[0]=="esp32"&&(t[4]==9||t[4]==16))&&!(t[0]=="esp32s2"&&t[4]==18)&&!(t[0]=="esp8266"&&(t[4]==3||t[4]==113))&&wa(t);return{c(){l&&l.c(),e=We()},m(n,i){l&&l.m(n,i),y(n,e,i)},p(n,i){n[4]>3&&!(n[0]=="esp32"&&(n[4]==9||n[4]==16))&&!(n[0]=="esp32s2"&&n[4]==18)&&!(n[0]=="esp8266"&&(n[4]==3||n[4]==113))?l||(l=wa(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},d(n){l&&l.d(n),n&&w(e)}}}function Zm(t){let e,l,n,i,o,r,a=t[0]=="esp8266"&&ga(),f=(t[0]=="esp32"||t[0]=="esp32solo")&&ba(),c=t[0]=="esp32s2"&&ka(),p={length:t[1]+1},_=[];for(let d=0;d{"chip"in o&&l(0,n=o.chip)},t.$$.update=()=>{t.$$.dirty&1&&l(1,i=n=="esp8266"?16:n=="esp32s2"?44:39)},[n,i]}class ac extends ye{constructor(e){super(),we(this,e,Jm,Zm,ke,{chip:0})}}function $a(t){let e,l,n=t[1]&&Ca(t);return{c(){e=m("div"),l=m("div"),n&&n.c(),u(l,"class","fixed inset-0 bg-gray-500 bg-opacity-50 flex items-center justify-center"),u(e,"class","z-50"),u(e,"aria-modal","true")},m(i,o){y(i,e,o),s(e,l),n&&n.m(l,null)},p(i,o){i[1]?n?n.p(i,o):(n=Ca(i),n.c(),n.m(l,null)):n&&(n.d(1),n=null)},d(i){i&&w(e),n&&n.d()}}}function Ca(t){let e,l;return{c(){e=m("div"),l=C(t[1]),u(e,"class","bg-white m-2 p-3 rounded-md shadow-lg pb-4 text-gray-700 w-96")},m(n,i){y(n,e,i),s(e,l)},p(n,i){i&2&&B(l,n[1])},d(n){n&&w(e)}}}function Xm(t){let e,l=t[0]&&$a(t);return{c(){l&&l.c(),e=We()},m(n,i){l&&l.m(n,i),y(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=$a(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:ie,o:ie,d(n){l&&l.d(n),n&&w(e)}}}function xm(t,e,l){let{active:n}=e,{message:i}=e;return t.$$set=o=>{"active"in o&&l(0,n=o.active),"message"in o&&l(1,i=o.message)},[n,i]}class gt extends ye{constructor(e){super(),we(this,e,xm,Xm,ke,{active:0,message:1})}}function Ta(t,e,l){const n=t.slice();return n[1]=e[l],n}function Sa(t){let e,l,n=t[1]+"",i;return{c(){e=m("option"),l=C("Europe/"),i=C(n),e.__value="Europe/"+t[1],e.value=e.__value},m(o,r){y(o,e,r),s(e,l),s(e,i)},p:ie,d(o){o&&w(e)}}}function ep(t){let e,l,n,i=t[0],o=[];for(let r=0;r{r[p]=null}),Pe(),l=r[e],l||(l=r[e]=o[e](f),l.c()),P(l,1),l.m(n.parentNode,n))},i(f){i||(P(l),i=!0)},o(f){N(l),i=!1},d(f){r[e].d(f),f&&w(n)}}}function cp(t){let e,l;return e=new Yt({props:{color:"blue",text:"Upload cert",title:"Click here to upload certificate"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function mp(t){let e,l;return e=new Yt({props:{color:"green",text:"Cert OK",title:"Click here to replace certificate"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function pp(t){let e,l,n,i;const o=[mp,cp],r=[];function a(f,c){return f[3].q.s.r?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=We()},m(f,c){r[e].m(f,c),y(f,n,c),i=!0},p(f,c){let p=e;e=a(f),e!==p&&(Se(),N(r[p],1,1,()=>{r[p]=null}),Pe(),l=r[e],l||(l=r[e]=o[e](f),l.c()),P(l,1),l.m(n.parentNode,n))},i(f){i||(P(l),i=!0)},o(f){N(l),i=!1},d(f){r[e].d(f),f&&w(n)}}}function _p(t){let e,l;return e=new Yt({props:{color:"blue",text:"Upload key",title:"Click here to upload key"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function dp(t){let e,l;return e=new Yt({props:{color:"green",text:"Key OK",title:"Click here to replace key"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function vp(t){let e,l,n,i;const o=[dp,_p],r=[];function a(f,c){return f[3].q.s.k?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=We()},m(f,c){r[e].m(f,c),y(f,n,c),i=!0},p(f,c){let p=e;e=a(f),e!==p&&(Se(),N(r[p],1,1,()=>{r[p]=null}),Pe(),l=r[e],l||(l=r[e]=o[e](f),l.c()),P(l,1),l.m(n.parentNode,n))},i(f){i||(P(l),i=!0)},o(f){N(l),i=!1},d(f){r[e].d(f),f&&w(n)}}}function Oa(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W,G,q,O;return o=new Ft({}),{c(){e=m("div"),l=m("strong"),l.textContent="Domoticz",n=v(),i=m("a"),Q(o.$$.fragment),r=v(),a=m("input"),f=v(),c=m("div"),p=m("div"),_=C("Electricity IDX"),d=m("br"),g=v(),h=m("input"),b=v(),$=m("div"),k=C("Current IDX"),T=m("br"),M=v(),E=m("input"),S=v(),I=m("div"),A=C(`Voltage IDX: L1, L2 & L3 - `),R=m("div"),H=m("input"),j=v(),F=m("input"),L=v(),W=m("input"),u(l,"class","text-sm"),u(i,"href",Lt("MQTT-configuration#domoticz")),u(i,"target","_blank"),u(i,"class","float-right"),u(a,"type","hidden"),u(a,"name","o"),a.value="true",u(h,"name","oe"),u(h,"type","text"),u(h,"class","in-f tr w-full"),u(p,"class","w-1/2"),u(E,"name","oc"),u(E,"type","text"),u(E,"class","in-l tr w-full"),u($,"class","w-1/2"),u(c,"class","my-1 flex"),u(H,"name","ou1"),u(H,"type","text"),u(H,"class","in-f tr w-1/3"),u(F,"name","ou2"),u(F,"type","text"),u(F,"class","in-m tr w-1/3"),u(W,"name","ou3"),u(W,"type","text"),u(W,"class","in-l tr w-1/3"),u(R,"class","flex"),u(I,"class","my-1"),u(e,"class","cnt")},m(U,X){y(U,e,X),s(e,l),s(e,n),s(e,i),Y(o,i,null),s(e,r),s(e,a),s(e,f),s(e,c),s(c,p),s(p,_),s(p,d),s(p,g),s(p,h),Z(h,t[3].o.e),s(c,b),s(c,$),s($,k),s($,T),s($,M),s($,E),Z(E,t[3].o.c),s(e,S),s(e,I),s(I,A),s(I,R),s(R,H),Z(H,t[3].o.u1),s(R,j),s(R,F),Z(F,t[3].o.u2),s(R,L),s(R,W),Z(W,t[3].o.u3),G=!0,q||(O=[K(h,"input",t[58]),K(E,"input",t[59]),K(H,"input",t[60]),K(F,"input",t[61]),K(W,"input",t[62])],q=!0)},p(U,X){X[0]&8&&h.value!==U[3].o.e&&Z(h,U[3].o.e),X[0]&8&&E.value!==U[3].o.c&&Z(E,U[3].o.c),X[0]&8&&H.value!==U[3].o.u1&&Z(H,U[3].o.u1),X[0]&8&&F.value!==U[3].o.u2&&Z(F,U[3].o.u2),X[0]&8&&W.value!==U[3].o.u3&&Z(W,U[3].o.u3)},i(U){G||(P(o.$$.fragment,U),G=!0)},o(U){N(o.$$.fragment,U),G=!1},d(U){U&&w(e),V(o),q=!1,Be(O)}}}function qa(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M;o=new Ft({});let E={length:9},S=[];for(let I=0;I20&&Wa(t),p=t[0].chip=="esp8266"&&za(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Hardware",n=v(),i=m("a"),Q(o.$$.fragment),r=v(),c&&c.c(),a=v(),p&&p.c(),u(l,"class","text-sm"),u(i,"href",Lt("GPIO-configuration")),u(i,"target","_blank"),u(i,"class","float-right"),u(e,"class","cnt")},m(_,d){y(_,e,d),s(e,l),s(e,n),s(e,i),Y(o,i,null),s(e,r),c&&c.m(e,null),s(e,a),p&&p.m(e,null),f=!0},p(_,d){_[0].board>20?c?(c.p(_,d),d[0]&1&&P(c,1)):(c=Wa(_),c.c(),P(c,1),c.m(e,a)):c&&(Se(),N(c,1,1,()=>{c=null}),Pe()),_[0].chip=="esp8266"?p?p.p(_,d):(p=za(_),p.c(),p.m(e,null)):p&&(p.d(1),p=null)},i(_){f||(P(o.$$.fragment,_),P(c),f=!0)},o(_){N(o.$$.fragment,_),N(c),f=!1},d(_){_&&w(e),V(o),c&&c.d(),p&&p.d()}}}function Wa(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W,G,q,O,U,X,z,ne,te,Me,_e,Ne,Ie,Fe,Ee,$e,ge,fe,ae,ce,ue,J,se,Ce,x,oe,He,Te;c=new ac({props:{chip:t[0].chip}});let de=t[0].chip!="esp8266"&&Ga(t),ve=t[3].i.v.p>0&&Ba(t);return{c(){e=m("input"),l=v(),n=m("div"),i=m("div"),o=C("HAN"),r=m("br"),a=v(),f=m("select"),Q(c.$$.fragment),p=v(),_=m("div"),d=C("AP button"),g=m("br"),h=v(),b=m("input"),$=v(),k=m("div"),T=C("LED"),M=m("label"),E=m("input"),S=C(" inv"),I=m("br"),A=v(),R=m("div"),H=m("input"),j=v(),F=m("div"),L=C("RGB"),W=m("label"),G=m("input"),q=C(" inverted"),O=m("br"),U=v(),X=m("div"),z=m("input"),ne=v(),te=m("input"),Me=v(),_e=m("input"),Ne=v(),Ie=m("div"),Fe=C("Temperature"),Ee=m("br"),$e=v(),ge=m("input"),fe=v(),ae=m("div"),ce=C("Analog temp"),ue=m("br"),J=v(),se=m("input"),Ce=v(),de&&de.c(),x=v(),ve&&ve.c(),u(e,"type","hidden"),u(e,"name","i"),e.value="true",u(f,"name","ih"),u(f,"class","in-f w-full"),t[3].i.h===void 0&&ze(()=>t[66].call(f)),u(i,"class","w-1/3"),u(b,"name","ia"),u(b,"type","number"),u(b,"min","0"),u(b,"max",t[6]),u(b,"class","in-m tr w-full"),u(_,"class","w-1/3"),u(E,"name","ili"),E.__value="true",E.value=E.__value,u(E,"type","checkbox"),u(E,"class","rounded mb-1"),u(M,"class","ml-4"),u(H,"name","ilp"),u(H,"type","number"),u(H,"min","0"),u(H,"max",t[6]),u(H,"class","in-l tr w-full"),u(R,"class","flex"),u(k,"class","w-1/3"),u(G,"name","iri"),G.__value="true",G.value=G.__value,u(G,"type","checkbox"),u(G,"class","rounded mb-1"),u(W,"class","ml-4"),u(z,"name","irr"),u(z,"type","number"),u(z,"min","0"),u(z,"max",t[6]),u(z,"class","in-f tr w-1/3"),u(te,"name","irg"),u(te,"type","number"),u(te,"min","0"),u(te,"max",t[6]),u(te,"class","in-m tr w-1/3"),u(_e,"name","irb"),u(_e,"type","number"),u(_e,"min","0"),u(_e,"max",t[6]),u(_e,"class","in-l tr w-1/3"),u(X,"class","flex"),u(F,"class","w-full"),u(ge,"name","itd"),u(ge,"type","number"),u(ge,"min","0"),u(ge,"max",t[6]),u(ge,"class","in-f tr w-full"),u(Ie,"class","my-1 w-1/3"),u(se,"name","ita"),u(se,"type","number"),u(se,"min","0"),u(se,"max",t[6]),u(se,"class","in-l tr w-full"),u(ae,"class","my-1 pr-1 w-1/3"),u(n,"class","flex flex-wrap")},m(le,he){y(le,e,he),y(le,l,he),y(le,n,he),s(n,i),s(i,o),s(i,r),s(i,a),s(i,f),Y(c,f,null),Re(f,t[3].i.h),s(n,p),s(n,_),s(_,d),s(_,g),s(_,h),s(_,b),Z(b,t[3].i.a),s(n,$),s(n,k),s(k,T),s(k,M),s(M,E),E.checked=t[3].i.l.i,s(M,S),s(k,I),s(k,A),s(k,R),s(R,H),Z(H,t[3].i.l.p),s(n,j),s(n,F),s(F,L),s(F,W),s(W,G),G.checked=t[3].i.r.i,s(W,q),s(F,O),s(F,U),s(F,X),s(X,z),Z(z,t[3].i.r.r),s(X,ne),s(X,te),Z(te,t[3].i.r.g),s(X,Me),s(X,_e),Z(_e,t[3].i.r.b),s(n,Ne),s(n,Ie),s(Ie,Fe),s(Ie,Ee),s(Ie,$e),s(Ie,ge),Z(ge,t[3].i.t.d),s(n,fe),s(n,ae),s(ae,ce),s(ae,ue),s(ae,J),s(ae,se),Z(se,t[3].i.t.a),s(n,Ce),de&&de.m(n,null),s(n,x),ve&&ve.m(n,null),oe=!0,He||(Te=[K(f,"change",t[66]),K(b,"input",t[67]),K(E,"change",t[68]),K(H,"input",t[69]),K(G,"change",t[70]),K(z,"input",t[71]),K(te,"input",t[72]),K(_e,"input",t[73]),K(ge,"input",t[74]),K(se,"input",t[75])],He=!0)},p(le,he){const qe={};he[0]&1&&(qe.chip=le[0].chip),c.$set(qe),he[0]&8&&Re(f,le[3].i.h),(!oe||he[0]&64)&&u(b,"max",le[6]),he[0]&8&&me(b.value)!==le[3].i.a&&Z(b,le[3].i.a),he[0]&8&&(E.checked=le[3].i.l.i),(!oe||he[0]&64)&&u(H,"max",le[6]),he[0]&8&&me(H.value)!==le[3].i.l.p&&Z(H,le[3].i.l.p),he[0]&8&&(G.checked=le[3].i.r.i),(!oe||he[0]&64)&&u(z,"max",le[6]),he[0]&8&&me(z.value)!==le[3].i.r.r&&Z(z,le[3].i.r.r),(!oe||he[0]&64)&&u(te,"max",le[6]),he[0]&8&&me(te.value)!==le[3].i.r.g&&Z(te,le[3].i.r.g),(!oe||he[0]&64)&&u(_e,"max",le[6]),he[0]&8&&me(_e.value)!==le[3].i.r.b&&Z(_e,le[3].i.r.b),(!oe||he[0]&64)&&u(ge,"max",le[6]),he[0]&8&&me(ge.value)!==le[3].i.t.d&&Z(ge,le[3].i.t.d),(!oe||he[0]&64)&&u(se,"max",le[6]),he[0]&8&&me(se.value)!==le[3].i.t.a&&Z(se,le[3].i.t.a),le[0].chip!="esp8266"?de?de.p(le,he):(de=Ga(le),de.c(),de.m(n,x)):de&&(de.d(1),de=null),le[3].i.v.p>0?ve?ve.p(le,he):(ve=Ba(le),ve.c(),ve.m(n,null)):ve&&(ve.d(1),ve=null)},i(le){oe||(P(c.$$.fragment,le),oe=!0)},o(le){N(c.$$.fragment,le),oe=!1},d(le){le&&w(e),le&&w(l),le&&w(n),V(c),de&&de.d(),ve&&ve.d(),He=!1,Be(Te)}}}function Ga(t){let e,l,n,i,o,r,a;return{c(){e=m("div"),l=C("Vcc"),n=m("br"),i=v(),o=m("input"),u(o,"name","ivp"),u(o,"type","number"),u(o,"min","0"),u(o,"max",t[6]),u(o,"class","in-s tr w-full"),u(e,"class","my-1 pl-1 w-1/3")},m(f,c){y(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),Z(o,t[3].i.v.p),r||(a=K(o,"input",t[76]),r=!0)},p(f,c){c[0]&64&&u(o,"max",f[6]),c[0]&8&&me(o.value)!==f[3].i.v.p&&Z(o,f[3].i.v.p)},d(f){f&&w(e),r=!1,a()}}}function Ba(t){let e,l,n,i,o,r,a,f,c,p;return{c(){e=m("div"),l=C("Voltage divider"),n=m("br"),i=v(),o=m("div"),r=m("input"),a=v(),f=m("input"),u(r,"name","ivdv"),u(r,"type","number"),u(r,"min","0"),u(r,"max","65535"),u(r,"class","in-f tr w-full"),u(r,"placeholder","VCC"),u(f,"name","ivdg"),u(f,"type","number"),u(f,"min","0"),u(f,"max","65535"),u(f,"class","in-l tr w-full"),u(f,"placeholder","GND"),u(o,"class","flex"),u(e,"class","my-1")},m(_,d){y(_,e,d),s(e,l),s(e,n),s(e,i),s(e,o),s(o,r),Z(r,t[3].i.v.d.v),s(o,a),s(o,f),Z(f,t[3].i.v.d.g),c||(p=[K(r,"input",t[77]),K(f,"input",t[78])],c=!0)},p(_,d){d[0]&8&&me(r.value)!==_[3].i.v.d.v&&Z(r,_[3].i.v.d.v),d[0]&8&&me(f.value)!==_[3].i.v.d.g&&Z(f,_[3].i.v.d.g)},d(_){_&&w(e),c=!1,Be(p)}}}function za(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T=(t[0].board==2||t[0].board==100)&&Ya(t);return{c(){e=m("input"),l=v(),n=m("div"),i=m("div"),o=C("Vcc offset"),r=m("br"),a=v(),f=m("input"),c=v(),p=m("div"),_=C("Multiplier"),d=m("br"),g=v(),h=m("input"),b=v(),T&&T.c(),u(e,"type","hidden"),u(e,"name","iv"),e.value="true",u(f,"name","ivo"),u(f,"type","number"),u(f,"min","0.0"),u(f,"max","3.5"),u(f,"step","0.01"),u(f,"class","in-f tr w-full"),u(i,"class","w-1/3"),u(h,"name","ivm"),u(h,"type","number"),u(h,"min","0.1"),u(h,"max","10"),u(h,"step","0.01"),u(h,"class","in-l tr w-full"),u(p,"class","w-1/3 pr-1"),u(n,"class","my-1 flex flex-wrap")},m(M,E){y(M,e,E),y(M,l,E),y(M,n,E),s(n,i),s(i,o),s(i,r),s(i,a),s(i,f),Z(f,t[3].i.v.o),s(n,c),s(n,p),s(p,_),s(p,d),s(p,g),s(p,h),Z(h,t[3].i.v.m),s(n,b),T&&T.m(n,null),$||(k=[K(f,"input",t[79]),K(h,"input",t[80])],$=!0)},p(M,E){E[0]&8&&me(f.value)!==M[3].i.v.o&&Z(f,M[3].i.v.o),E[0]&8&&me(h.value)!==M[3].i.v.m&&Z(h,M[3].i.v.m),M[0].board==2||M[0].board==100?T?T.p(M,E):(T=Ya(M),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},d(M){M&&w(e),M&&w(l),M&&w(n),T&&T.d(),$=!1,Be(k)}}}function Ya(t){let e,l,n,i,o,r,a;return{c(){e=m("div"),l=C("Boot limit"),n=m("br"),i=v(),o=m("input"),u(o,"name","ivb"),u(o,"type","number"),u(o,"min","2.5"),u(o,"max","3.5"),u(o,"step","0.1"),u(o,"class","in-s tr w-full"),u(e,"class","w-1/3 pl-1")},m(f,c){y(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),Z(o,t[3].i.v.b),r||(a=K(o,"input",t[81]),r=!0)},p(f,c){c[0]&8&&me(o.value)!==f[3].i.v.b&&Z(o,f[3].i.v.b)},d(f){f&&w(e),r=!1,a()}}}function Va(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k=t[3].d.t&&Ka();return{c(){e=m("div"),e.textContent="Debug can cause sudden reboots. Do not leave on!",l=v(),n=m("div"),i=m("label"),o=m("input"),r=C(" Enable telnet"),a=v(),k&&k.c(),f=v(),c=m("div"),p=m("select"),_=m("option"),_.textContent="Verbose",d=m("option"),d.textContent="Debug",g=m("option"),g.textContent="Info",h=m("option"),h.textContent="Warning",u(e,"class","bd-red"),u(o,"type","checkbox"),u(o,"name","dt"),o.__value="true",o.value=o.__value,u(o,"class","rounded mb-1"),u(n,"class","my-1"),_.__value=1,_.value=_.__value,d.__value=2,d.value=d.__value,g.__value=3,g.value=g.__value,h.__value=4,h.value=h.__value,u(p,"name","dl"),u(p,"class","in-s"),t[3].d.l===void 0&&ze(()=>t[84].call(p)),u(c,"class","my-1")},m(T,M){y(T,e,M),y(T,l,M),y(T,n,M),s(n,i),s(i,o),o.checked=t[3].d.t,s(i,r),y(T,a,M),k&&k.m(T,M),y(T,f,M),y(T,c,M),s(c,p),s(p,_),s(p,d),s(p,g),s(p,h),Re(p,t[3].d.l),b||($=[K(o,"change",t[83]),K(p,"change",t[84])],b=!0)},p(T,M){M[0]&8&&(o.checked=T[3].d.t),T[3].d.t?k||(k=Ka(),k.c(),k.m(f.parentNode,f)):k&&(k.d(1),k=null),M[0]&8&&Re(p,T[3].d.l)},d(T){T&&w(e),T&&w(l),T&&w(n),T&&w(a),k&&k.d(T),T&&w(f),T&&w(c),b=!1,Be($)}}}function Ka(t){let e;return{c(){e=m("div"),e.textContent="Telnet is unsafe and should be off when not in use",u(e,"class","bd-red")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function hp(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W,G,q,O,U,X,z,ne,te,Me,_e,Ne,Ie,Fe,Ee,$e,ge,fe,ae,ce,ue,J,se,Ce,x,oe,He,Te,de,ve,le,he,qe,re,De,fi,ci,mi,$t,pi,Qt,_i,di,vi,tt,hi,Zt,Yl,pt,gi,bi,ki,Jt,wi,yi,$i,_t,rl,al,Ue,Bn,Cl,Le,Vl,fl,cl,ml,uo,zn,ro,Kl,ps,ao,pl,qt,_l,fo,Ci,co,xe,dl,mo,Ti,Ql,Zl,Jl,Xl,Si,po,Yn,Ct,_o,vo,Tl,ho,go,bo,Ut,xl,en,ko,tn,Sl,wo,yo,$o,ln,Tt,Co,Pi,To,Pl,So,Po,Mo,nn,St,Do,Mi,Ao,_s,No,Ml,Di,Pt,Io,Eo,Ro,ds,Ai,Mt,Fo,Lo,Oo,Xe,Ni,qo,sn,on,Uo,Vn,Ho,Dl,jo,Wo,Go,Xt,Bo,Al,zo,Yo,Vo,xt,Ko,un,Nl,Qo,Zo,Jo,bt,rn,an,fn,cn,Xo,Il,xo,eu,tu,mn,kt,lu,Ii,nu,Ei,Ri,Dt,iu,su,Je,Fi,ou,pn,_n,uu,El,ru,au,fu,vl,Ht,dn,vn,cu,dt,Li,Oi,mu,vt,hn,qi,Ui,pu,vs,Hi,ji,At,_u,du,Kn,vu,hl,hu,Qn,Nt,gu,bu,ku,Wi,el,wu,Ge,Gi,yu,gn,bn,$u,Zn,Cu,jt,Tu,hs,Su,Pu,kn,tl,Mu,It,Du,gs,Rl,Au,Nu,Iu,ll,Eu,Fl,Ru,Fu,Lu,nl,Ou,wn,yn,qu,Uu,Hu,il,ju,$n,Wu,Gu,Bu,lt,Cn,Tn,Sn,Pn,Mn,Dn,zu,Ll,Yu,Vu,Ku,sl,Qu,bs,ks=t[3].p.r.startsWith("10YNO")||t[3].p.r=="10Y1001A1001A48H",ws,Wt,Bi,Zu,An,Nn,Ju,Jn,Xu,Xn,xu,ys,ht,zi,er,In,En,tr,xn,lr,Yi,Vi,Et,nr,ir,sr,gl,$s,Rn,or,Ki,Fn,ur,Qi,Cs,Ol,Ts,ql,Ss,Ul,Ps,Hl,Rt,Ms,rr;a=new Ft({}),R=new lp({});let cc=["NOK","SEK","DKK","EUR"],Zi=[];for(let D=0;D<4;D+=1)Zi[D]=op(sp(t,cc,D));let nt=t[3].p.e&&t[0].chip!="esp8266"&&Da(t),it=t[3].g.s>0&&Aa(t);ml=new Ft({});let mc=[24,48,96,192,384,576,1152],Ji=[];for(let D=0;D<7;D+=1)Ji[D]=up(ip(t,mc,D));let st=t[3].m.e.e&&Na(t),ot=t[3].m.e.e&&Ia(t),ut=t[3].m.m.e&&Ea(t);on=new Ft({}),_n=new Ft({}),hn=new fc({});let rt=t[3].n.m=="static"&&Ra(t);bn=new Ft({});let at=t[0].chip!="esp8266"&&Fa(t),Ye=t[3].q.s.e&&La(t),Ve=t[3].q.m==3&&Oa(t),Ke=ks&&qa(t);Nn=new Ft({});let Ln=t[7],ft=[];for(let D=0;D20||t[0].chip=="esp8266")&&ja(t);En=new Ft({});let ct=t[3].d.s&&Va(t);return Ol=new gt({props:{active:t[1],message:"Loading configuration"}}),ql=new gt({props:{active:t[2],message:"Saving configuration"}}),Ul=new gt({props:{active:t[4],message:"Performing factory reset"}}),Hl=new gt({props:{active:t[5],message:"Device have been factory reset and switched to AP mode"}}),{c(){e=m("form"),l=m("div"),n=m("div"),i=m("strong"),i.textContent="General",o=v(),r=m("a"),Q(a.$$.fragment),f=v(),c=m("input"),p=v(),_=m("div"),d=m("div"),g=m("div"),h=C("Hostname"),b=m("br"),$=v(),k=m("input"),T=v(),M=m("div"),E=C("Time zone"),S=m("br"),I=v(),A=m("select"),Q(R.$$.fragment),H=v(),j=m("input"),F=v(),L=m("div"),W=C("Price region"),G=m("br"),q=v(),O=m("select"),U=m("optgroup"),X=m("option"),X.textContent="NO1",z=m("option"),z.textContent="NO2",ne=m("option"),ne.textContent="NO3",te=m("option"),te.textContent="NO4",Me=m("option"),Me.textContent="NO5",_e=m("optgroup"),Ne=m("option"),Ne.textContent="SE1",Ie=m("option"),Ie.textContent="SE2",Fe=m("option"),Fe.textContent="SE3",Ee=m("option"),Ee.textContent="SE4",$e=m("optgroup"),ge=m("option"),ge.textContent="DK1",fe=m("option"),fe.textContent="DK2",ae=m("option"),ae.textContent="Austria",ce=m("option"),ce.textContent="Belgium",ue=m("option"),ue.textContent="Czech Republic",J=m("option"),J.textContent="Estonia",se=m("option"),se.textContent="Finland",Ce=m("option"),Ce.textContent="France",x=m("option"),x.textContent="Germany",oe=m("option"),oe.textContent="Great Britain",He=m("option"),He.textContent="Latvia",Te=m("option"),Te.textContent="Lithuania",de=m("option"),de.textContent="Netherland",ve=m("option"),ve.textContent="Poland",le=m("option"),le.textContent="Switzerland",he=v(),qe=m("div"),re=m("div"),De=m("div"),fi=C("Currency"),ci=m("br"),mi=v(),$t=m("select");for(let D=0;D<4;D+=1)Zi[D].c();pi=v(),Qt=m("div"),_i=C("Multiplier"),di=m("br"),vi=v(),tt=m("input"),hi=v(),Zt=m("div"),Yl=m("label"),pt=m("input"),gi=C(" Enable price fetch from remote server"),bi=v(),nt&&nt.c(),ki=v(),Jt=m("div"),wi=C("Security"),yi=m("br"),$i=v(),_t=m("select"),rl=m("option"),rl.textContent="None",al=m("option"),al.textContent="Only configuration",Ue=m("option"),Ue.textContent="Everything",Bn=v(),it&&it.c(),Cl=v(),Le=m("div"),Vl=m("strong"),Vl.textContent="Meter",fl=v(),cl=m("a"),Q(ml.$$.fragment),uo=v(),zn=m("input"),ro=v(),Kl=m("div"),ps=m("span"),ps.textContent="Serial configuration",ao=v(),pl=m("div"),qt=m("select"),_l=m("option"),fo=C("Autodetect");for(let D=0;D<7;D+=1)Ji[D].c();co=v(),xe=m("select"),dl=m("option"),mo=C("-"),Ql=m("option"),Ql.textContent="7N1",Zl=m("option"),Zl.textContent="8N1",Jl=m("option"),Jl.textContent="7E1",Xl=m("option"),Xl.textContent="8E1",po=v(),Yn=m("label"),Ct=m("input"),_o=C(" inverted"),vo=v(),Tl=m("div"),ho=C("Voltage"),go=m("br"),bo=v(),Ut=m("select"),xl=m("option"),xl.textContent="400V (TN)",en=m("option"),en.textContent="230V (IT/TT)",ko=v(),tn=m("div"),Sl=m("div"),wo=C("Main fuse"),yo=m("br"),$o=v(),ln=m("label"),Tt=m("input"),Co=v(),Pi=m("span"),Pi.textContent="A",To=v(),Pl=m("div"),So=C("Production"),Po=m("br"),Mo=v(),nn=m("label"),St=m("input"),Do=v(),Mi=m("span"),Mi.textContent="kWp",Ao=v(),_s=m("div"),No=v(),Ml=m("div"),Di=m("label"),Pt=m("input"),Io=C(" Meter is encrypted"),Eo=v(),st&&st.c(),Ro=v(),ot&&ot.c(),ds=v(),Ai=m("label"),Mt=m("input"),Fo=C(" Multipliers"),Lo=v(),ut&&ut.c(),Oo=v(),Xe=m("div"),Ni=m("strong"),Ni.textContent="WiFi",qo=v(),sn=m("a"),Q(on.$$.fragment),Uo=v(),Vn=m("input"),Ho=v(),Dl=m("div"),jo=C("SSID"),Wo=m("br"),Go=v(),Xt=m("input"),Bo=v(),Al=m("div"),zo=C("Password"),Yo=m("br"),Vo=v(),xt=m("input"),Ko=v(),un=m("div"),Nl=m("div"),Qo=C("Power saving"),Zo=m("br"),Jo=v(),bt=m("select"),rn=m("option"),rn.textContent="Default",an=m("option"),an.textContent="Off",fn=m("option"),fn.textContent="Minimum",cn=m("option"),cn.textContent="Maximum",Xo=v(),Il=m("div"),xo=C("Power"),eu=m("br"),tu=v(),mn=m("div"),kt=m("input"),lu=v(),Ii=m("span"),Ii.textContent="dBm",nu=v(),Ei=m("div"),Ri=m("label"),Dt=m("input"),iu=C(" Auto reboot on connection problem"),su=v(),Je=m("div"),Fi=m("strong"),Fi.textContent="Network",ou=v(),pn=m("a"),Q(_n.$$.fragment),uu=v(),El=m("div"),ru=C("IP"),au=m("br"),fu=v(),vl=m("div"),Ht=m("select"),dn=m("option"),dn.textContent="DHCP",vn=m("option"),vn.textContent="Static",cu=v(),dt=m("input"),mu=v(),vt=m("select"),Q(hn.$$.fragment),pu=v(),rt&&rt.c(),vs=v(),Hi=m("div"),ji=m("label"),At=m("input"),_u=C(" enable mDNS"),du=v(),Kn=m("input"),vu=v(),hl=m("div"),hu=C("NTP "),Qn=m("label"),Nt=m("input"),gu=C(" obtain from DHCP"),bu=m("br"),ku=v(),Wi=m("div"),el=m("input"),wu=v(),Ge=m("div"),Gi=m("strong"),Gi.textContent="MQTT",yu=v(),gn=m("a"),Q(bn.$$.fragment),$u=v(),Zn=m("input"),Cu=v(),jt=m("div"),Tu=C(`Server - `),at&&at.c(),hs=v(),Su=m("br"),Pu=v(),kn=m("div"),tl=m("input"),Mu=v(),It=m("input"),Du=v(),Ye&&Ye.c(),gs=v(),Rl=m("div"),Au=C("Username"),Nu=m("br"),Iu=v(),ll=m("input"),Eu=v(),Fl=m("div"),Ru=C("Password"),Fu=m("br"),Lu=v(),nl=m("input"),Ou=v(),wn=m("div"),yn=m("div"),qu=C("Client ID"),Uu=m("br"),Hu=v(),il=m("input"),ju=v(),$n=m("div"),Wu=C("Payload"),Gu=m("br"),Bu=v(),lt=m("select"),Cn=m("option"),Cn.textContent="JSON",Tn=m("option"),Tn.textContent="Raw (minimal)",Sn=m("option"),Sn.textContent="Raw (full)",Pn=m("option"),Pn.textContent="Domoticz",Mn=m("option"),Mn.textContent="HomeAssistant",Dn=m("option"),Dn.textContent="HEX dump",zu=v(),Ll=m("div"),Yu=C("Publish topic"),Vu=m("br"),Ku=v(),sl=m("input"),Qu=v(),Ve&&Ve.c(),bs=v(),Ke&&Ke.c(),ws=v(),Wt=m("div"),Bi=m("strong"),Bi.textContent="User interface",Zu=v(),An=m("a"),Q(Nn.$$.fragment),Ju=v(),Jn=m("input"),Xu=v(),Xn=m("div");for(let D=0;DSave',Cs=v(),Q(Ol.$$.fragment),Ts=v(),Q(ql.$$.fragment),Ss=v(),Q(Ul.$$.fragment),Ps=v(),Q(Hl.$$.fragment),u(i,"class","text-sm"),u(r,"href",Lt("General-configuration")),u(r,"target","_blank"),u(r,"class","float-right"),u(c,"type","hidden"),u(c,"name","g"),c.value="true",u(k,"name","gh"),u(k,"type","text"),u(k,"class","in-f w-full"),u(k,"pattern","[A-Za-z0-9-]+"),u(A,"name","gt"),u(A,"class","in-l w-full"),t[3].g.t===void 0&&ze(()=>t[13].call(A)),u(d,"class","flex"),u(_,"class","my-1"),u(j,"type","hidden"),u(j,"name","p"),j.value="true",X.__value="10YNO-1--------2",X.value=X.__value,z.__value="10YNO-2--------T",z.value=z.__value,ne.__value="10YNO-3--------J",ne.value=ne.__value,te.__value="10YNO-4--------9",te.value=te.__value,Me.__value="10Y1001A1001A48H",Me.value=Me.__value,u(U,"label","Norway"),Ne.__value="10Y1001A1001A44P",Ne.value=Ne.__value,Ie.__value="10Y1001A1001A45N",Ie.value=Ie.__value,Fe.__value="10Y1001A1001A46L",Fe.value=Fe.__value,Ee.__value="10Y1001A1001A47J",Ee.value=Ee.__value,u(_e,"label","Sweden"),ge.__value="10YDK-1--------W",ge.value=ge.__value,fe.__value="10YDK-2--------M",fe.value=fe.__value,u($e,"label","Denmark"),ae.__value="10YAT-APG------L",ae.value=ae.__value,ce.__value="10YBE----------2",ce.value=ce.__value,ue.__value="10YCZ-CEPS-----N",ue.value=ue.__value,J.__value="10Y1001A1001A39I",J.value=J.__value,se.__value="10YFI-1--------U",se.value=se.__value,Ce.__value="10YFR-RTE------C",Ce.value=Ce.__value,x.__value="10Y1001A1001A83F",x.value=x.__value,oe.__value="10YGB----------A",oe.value=oe.__value,He.__value="10YLV-1001A00074",He.value=He.__value,Te.__value="10YLT-1001A0008Q",Te.value=Te.__value,de.__value="10YNL----------L",de.value=de.__value,ve.__value="10YPL-AREA-----S",ve.value=ve.__value,le.__value="10YCH-SWISSGRIDZ",le.value=le.__value,u(O,"name","pr"),u(O,"class","in-s"),t[3].p.r===void 0&&ze(()=>t[14].call(O)),u(L,"class","my-1"),u($t,"name","pc"),u($t,"class","in-f w-full"),t[3].p.c===void 0&&ze(()=>t[15].call($t)),u(De,"class","w-1/2"),u(tt,"name","pm"),u(tt,"type","number"),u(tt,"min","0.001"),u(tt,"max","1000"),u(tt,"step","0.001"),u(tt,"class","in-l tr w-full"),u(Qt,"class","w-1/2"),u(re,"class","flex"),u(qe,"class","my-1"),u(pt,"type","checkbox"),u(pt,"name","pe"),pt.__value="true",pt.value=pt.__value,u(pt,"class","rounded mb-1"),u(Zt,"class","my-1"),rl.__value=0,rl.value=rl.__value,al.__value=1,al.value=al.__value,Ue.__value=2,Ue.value=Ue.__value,u(_t,"name","gs"),u(_t,"class","in-s"),t[3].g.s===void 0&&ze(()=>t[19].call(_t)),u(Jt,"class","my-1"),u(n,"class","cnt"),u(Vl,"class","text-sm"),u(cl,"href",Lt("Meter-configuration")),u(cl,"target","_blank"),u(cl,"class","float-right"),u(zn,"type","hidden"),u(zn,"name","m"),zn.value="true",_l.__value=0,_l.value=_l.__value,_l.disabled=Ci=t[3].m.b!=0,u(qt,"name","mb"),u(qt,"class","in-f"),t[3].m.b===void 0&&ze(()=>t[22].call(qt)),dl.__value=0,dl.value=dl.__value,dl.disabled=Ti=t[3].m.b!=0,Ql.__value=2,Ql.value=Ql.__value,Zl.__value=3,Zl.value=Zl.__value,Jl.__value=10,Jl.value=Jl.__value,Xl.__value=11,Xl.value=Xl.__value,u(xe,"name","mp"),u(xe,"class","in-l"),xe.disabled=Si=t[3].m.b==0,t[3].m.p===void 0&&ze(()=>t[23].call(xe)),u(Ct,"name","mi"),Ct.__value="true",Ct.value=Ct.__value,u(Ct,"type","checkbox"),u(Ct,"class","rounded mb-1"),u(Yn,"class","mt-2 ml-3 whitespace-nowrap"),u(pl,"class","flex"),u(Kl,"class","my-1"),xl.__value=2,xl.value=xl.__value,en.__value=1,en.value=en.__value,u(Ut,"name","md"),u(Ut,"class","in-s"),t[3].m.d===void 0&&ze(()=>t[25].call(Ut)),u(Tl,"class","my-1"),u(Tt,"name","mf"),u(Tt,"type","number"),u(Tt,"min","5"),u(Tt,"max","65535"),u(Tt,"class","in-f tr w-full"),u(Pi,"class","in-post"),u(ln,"class","flex"),u(Sl,"class","mx-1"),u(St,"name","mr"),u(St,"type","number"),u(St,"min","0"),u(St,"max","65535"),u(St,"class","in-f tr w-full"),u(Mi,"class","in-post"),u(nn,"class","flex"),u(Pl,"class","mx-1"),u(tn,"class","my-1 flex"),u(_s,"class","my-1"),u(Pt,"type","checkbox"),u(Pt,"name","me"),Pt.__value="true",Pt.value=Pt.__value,u(Pt,"class","rounded mb-1"),u(Ml,"class","my-1"),u(Mt,"type","checkbox"),u(Mt,"name","mm"),Mt.__value="true",Mt.value=Mt.__value,u(Mt,"class","rounded mb-1"),u(Le,"class","cnt"),u(Ni,"class","text-sm"),u(sn,"href",Lt("WiFi-configuration")),u(sn,"target","_blank"),u(sn,"class","float-right"),u(Vn,"type","hidden"),u(Vn,"name","w"),Vn.value="true",u(Xt,"name","ws"),u(Xt,"type","text"),u(Xt,"class","in-s"),u(Dl,"class","my-1"),u(xt,"name","wp"),u(xt,"type","password"),u(xt,"class","in-s"),u(Al,"class","my-1"),rn.__value=255,rn.value=rn.__value,an.__value=0,an.value=an.__value,fn.__value=1,fn.value=fn.__value,cn.__value=2,cn.value=cn.__value,u(bt,"name","wz"),u(bt,"class","in-s"),t[3].w.z===void 0&&ze(()=>t[38].call(bt)),u(Nl,"class","w-1/2"),u(kt,"name","ww"),u(kt,"type","number"),u(kt,"min","0"),u(kt,"max","20.5"),u(kt,"step","0.5"),u(kt,"class","in-f tr w-full"),u(Ii,"class","in-post"),u(mn,"class","flex"),u(Il,"class","ml-2 w-1/2"),u(un,"class","my-1 flex"),u(Dt,"type","checkbox"),u(Dt,"name","wa"),Dt.__value="true",Dt.value=Dt.__value,u(Dt,"class","rounded mb-1"),u(Ei,"class","my-3"),u(Xe,"class","cnt"),u(Fi,"class","text-sm"),u(pn,"href",Lt("Network-configuration")),u(pn,"target","_blank"),u(pn,"class","float-right"),dn.__value="dhcp",dn.value=dn.__value,vn.__value="static",vn.value=vn.__value,u(Ht,"name","nm"),u(Ht,"class","in-f"),t[3].n.m===void 0&&ze(()=>t[41].call(Ht)),u(dt,"name","ni"),u(dt,"type","text"),u(dt,"class","in-m w-full"),dt.disabled=Li=t[3].n.m=="dhcp",dt.required=Oi=t[3].n.m=="static",u(vt,"name","ns"),u(vt,"class","in-l"),vt.disabled=qi=t[3].n.m=="dhcp",vt.required=Ui=t[3].n.m=="static",t[3].n.s===void 0&&ze(()=>t[43].call(vt)),u(vl,"class","flex"),u(El,"class","my-1"),u(At,"name","nd"),At.__value="true",At.value=At.__value,u(At,"type","checkbox"),u(At,"class","rounded mb-1"),u(Hi,"class","my-1"),u(Kn,"type","hidden"),u(Kn,"name","ntp"),Kn.value="true",u(Nt,"name","ntpd"),Nt.__value="true",Nt.value=Nt.__value,u(Nt,"type","checkbox"),u(Nt,"class","rounded mb-1"),u(Qn,"class","ml-4"),u(el,"name","ntph"),u(el,"type","text"),u(el,"class","in-s"),u(Wi,"class","flex"),u(hl,"class","my-1"),u(Je,"class","cnt"),u(Gi,"class","text-sm"),u(gn,"href",Lt("MQTT-configuration")),u(gn,"target","_blank"),u(gn,"class","float-right"),u(Zn,"type","hidden"),u(Zn,"name","q"),Zn.value="true",u(tl,"name","qh"),u(tl,"type","text"),u(tl,"class","in-f w-3/4"),u(It,"name","qp"),u(It,"type","number"),u(It,"min","1024"),u(It,"max","65535"),u(It,"class","in-l tr w-1/4"),u(kn,"class","flex"),u(jt,"class","my-1"),u(ll,"name","qu"),u(ll,"type","text"),u(ll,"class","in-s"),u(Rl,"class","my-1"),u(nl,"name","qa"),u(nl,"type","password"),u(nl,"class","in-s"),u(Fl,"class","my-1"),u(il,"name","qc"),u(il,"type","text"),u(il,"class","in-f w-full"),Cn.__value=0,Cn.value=Cn.__value,Tn.__value=1,Tn.value=Tn.__value,Sn.__value=2,Sn.value=Sn.__value,Pn.__value=3,Pn.value=Pn.__value,Mn.__value=4,Mn.value=Mn.__value,Dn.__value=255,Dn.value=Dn.__value,u(lt,"name","qm"),u(lt,"class","in-l"),t[3].q.m===void 0&&ze(()=>t[56].call(lt)),u(wn,"class","my-1 flex"),u(sl,"name","qb"),u(sl,"type","text"),u(sl,"class","in-s"),u(Ll,"class","my-1"),u(Ge,"class","cnt"),u(Bi,"class","text-sm"),u(An,"href",Lt("User-interface")),u(An,"target","_blank"),u(An,"class","float-right"),u(Jn,"type","hidden"),u(Jn,"name","u"),Jn.value="true",u(Xn,"class","flex flex-wrap"),u(Wt,"class","cnt"),u(zi,"class","text-sm"),u(In,"href","https://amsleser.no/blog/post/24-telnet-debug"),u(In,"target","_blank"),u(In,"class","float-right"),u(xn,"type","hidden"),u(xn,"name","d"),xn.value="true",u(Et,"type","checkbox"),u(Et,"name","ds"),Et.__value="true",Et.value=Et.__value,u(Et,"class","rounded mb-1"),u(Yi,"class","mt-3"),u(ht,"class","cnt"),u(l,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2"),u(Rn,"type","button"),u(Rn,"class","py-2 px-4 rounded bg-red-500 text-white ml-2"),u(Fn,"type","button"),u(Fn,"class","py-2 px-4 rounded bg-yellow-500 text-white"),u(Ki,"class","text-center"),u(Qi,"class","text-right"),u(gl,"class","grid grid-cols-3"),u(e,"autocomplete","off")},m(D,ee){y(D,e,ee),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),Y(a,r,null),s(n,f),s(n,c),s(n,p),s(n,_),s(_,d),s(d,g),s(g,h),s(g,b),s(g,$),s(g,k),Z(k,t[3].g.h),s(d,T),s(d,M),s(M,E),s(M,S),s(M,I),s(M,A),Y(R,A,null),Re(A,t[3].g.t),s(n,H),s(n,j),s(n,F),s(n,L),s(L,W),s(L,G),s(L,q),s(L,O),s(O,U),s(U,X),s(U,z),s(U,ne),s(U,te),s(U,Me),s(O,_e),s(_e,Ne),s(_e,Ie),s(_e,Fe),s(_e,Ee),s(O,$e),s($e,ge),s($e,fe),s(O,ae),s(O,ce),s(O,ue),s(O,J),s(O,se),s(O,Ce),s(O,x),s(O,oe),s(O,He),s(O,Te),s(O,de),s(O,ve),s(O,le),Re(O,t[3].p.r),s(n,he),s(n,qe),s(qe,re),s(re,De),s(De,fi),s(De,ci),s(De,mi),s(De,$t);for(let mt=0;mt<4;mt+=1)Zi[mt].m($t,null);Re($t,t[3].p.c),s(re,pi),s(re,Qt),s(Qt,_i),s(Qt,di),s(Qt,vi),s(Qt,tt),Z(tt,t[3].p.m),s(n,hi),s(n,Zt),s(Zt,Yl),s(Yl,pt),pt.checked=t[3].p.e,s(Yl,gi),s(Zt,bi),nt&&nt.m(Zt,null),s(n,ki),s(n,Jt),s(Jt,wi),s(Jt,yi),s(Jt,$i),s(Jt,_t),s(_t,rl),s(_t,al),s(_t,Ue),Re(_t,t[3].g.s),s(n,Bn),it&&it.m(n,null),s(l,Cl),s(l,Le),s(Le,Vl),s(Le,fl),s(Le,cl),Y(ml,cl,null),s(Le,uo),s(Le,zn),s(Le,ro),s(Le,Kl),s(Kl,ps),s(Kl,ao),s(Kl,pl),s(pl,qt),s(qt,_l),s(_l,fo);for(let mt=0;mt<7;mt+=1)Ji[mt].m(qt,null);Re(qt,t[3].m.b),s(pl,co),s(pl,xe),s(xe,dl),s(dl,mo),s(xe,Ql),s(xe,Zl),s(xe,Jl),s(xe,Xl),Re(xe,t[3].m.p),s(pl,po),s(pl,Yn),s(Yn,Ct),Ct.checked=t[3].m.i,s(Yn,_o),s(Le,vo),s(Le,Tl),s(Tl,ho),s(Tl,go),s(Tl,bo),s(Tl,Ut),s(Ut,xl),s(Ut,en),Re(Ut,t[3].m.d),s(Le,ko),s(Le,tn),s(tn,Sl),s(Sl,wo),s(Sl,yo),s(Sl,$o),s(Sl,ln),s(ln,Tt),Z(Tt,t[3].m.f),s(ln,Co),s(ln,Pi),s(tn,To),s(tn,Pl),s(Pl,So),s(Pl,Po),s(Pl,Mo),s(Pl,nn),s(nn,St),Z(St,t[3].m.r),s(nn,Do),s(nn,Mi),s(Le,Ao),s(Le,_s),s(Le,No),s(Le,Ml),s(Ml,Di),s(Di,Pt),Pt.checked=t[3].m.e.e,s(Di,Io),s(Ml,Eo),st&&st.m(Ml,null),s(Le,Ro),ot&&ot.m(Le,null),s(Le,ds),s(Le,Ai),s(Ai,Mt),Mt.checked=t[3].m.m.e,s(Ai,Fo),s(Le,Lo),ut&&ut.m(Le,null),s(l,Oo),s(l,Xe),s(Xe,Ni),s(Xe,qo),s(Xe,sn),Y(on,sn,null),s(Xe,Uo),s(Xe,Vn),s(Xe,Ho),s(Xe,Dl),s(Dl,jo),s(Dl,Wo),s(Dl,Go),s(Dl,Xt),Z(Xt,t[3].w.s),s(Xe,Bo),s(Xe,Al),s(Al,zo),s(Al,Yo),s(Al,Vo),s(Al,xt),Z(xt,t[3].w.p),s(Xe,Ko),s(Xe,un),s(un,Nl),s(Nl,Qo),s(Nl,Zo),s(Nl,Jo),s(Nl,bt),s(bt,rn),s(bt,an),s(bt,fn),s(bt,cn),Re(bt,t[3].w.z),s(un,Xo),s(un,Il),s(Il,xo),s(Il,eu),s(Il,tu),s(Il,mn),s(mn,kt),Z(kt,t[3].w.w),s(mn,lu),s(mn,Ii),s(Xe,nu),s(Xe,Ei),s(Ei,Ri),s(Ri,Dt),Dt.checked=t[3].w.a,s(Ri,iu),s(l,su),s(l,Je),s(Je,Fi),s(Je,ou),s(Je,pn),Y(_n,pn,null),s(Je,uu),s(Je,El),s(El,ru),s(El,au),s(El,fu),s(El,vl),s(vl,Ht),s(Ht,dn),s(Ht,vn),Re(Ht,t[3].n.m),s(vl,cu),s(vl,dt),Z(dt,t[3].n.i),s(vl,mu),s(vl,vt),Y(hn,vt,null),Re(vt,t[3].n.s),s(Je,pu),rt&&rt.m(Je,null),s(Je,vs),s(Je,Hi),s(Hi,ji),s(ji,At),At.checked=t[3].n.d,s(ji,_u),s(Je,du),s(Je,Kn),s(Je,vu),s(Je,hl),s(hl,hu),s(hl,Qn),s(Qn,Nt),Nt.checked=t[3].n.h,s(Qn,gu),s(hl,bu),s(hl,ku),s(hl,Wi),s(Wi,el),Z(el,t[3].n.n1),s(l,wu),s(l,Ge),s(Ge,Gi),s(Ge,yu),s(Ge,gn),Y(bn,gn,null),s(Ge,$u),s(Ge,Zn),s(Ge,Cu),s(Ge,jt),s(jt,Tu),at&&at.m(jt,null),s(jt,hs),s(jt,Su),s(jt,Pu),s(jt,kn),s(kn,tl),Z(tl,t[3].q.h),s(kn,Mu),s(kn,It),Z(It,t[3].q.p),s(Ge,Du),Ye&&Ye.m(Ge,null),s(Ge,gs),s(Ge,Rl),s(Rl,Au),s(Rl,Nu),s(Rl,Iu),s(Rl,ll),Z(ll,t[3].q.u),s(Ge,Eu),s(Ge,Fl),s(Fl,Ru),s(Fl,Fu),s(Fl,Lu),s(Fl,nl),Z(nl,t[3].q.a),s(Ge,Ou),s(Ge,wn),s(wn,yn),s(yn,qu),s(yn,Uu),s(yn,Hu),s(yn,il),Z(il,t[3].q.c),s(wn,ju),s(wn,$n),s($n,Wu),s($n,Gu),s($n,Bu),s($n,lt),s(lt,Cn),s(lt,Tn),s(lt,Sn),s(lt,Pn),s(lt,Mn),s(lt,Dn),Re(lt,t[3].q.m),s(Ge,zu),s(Ge,Ll),s(Ll,Yu),s(Ll,Vu),s(Ll,Ku),s(Ll,sl),Z(sl,t[3].q.b),s(l,Qu),Ve&&Ve.m(l,null),s(l,bs),Ke&&Ke.m(l,null),s(l,ws),s(l,Wt),s(Wt,Bi),s(Wt,Zu),s(Wt,An),Y(Nn,An,null),s(Wt,Ju),s(Wt,Jn),s(Wt,Xu),s(Wt,Xn);for(let mt=0;mt0?it?it.p(D,ee):(it=Aa(D),it.c(),it.m(n,null)):it&&(it.d(1),it=null),(!Rt||ee[0]&8&&Ci!==(Ci=D[3].m.b!=0))&&(_l.disabled=Ci),ee[0]&8&&Re(qt,D[3].m.b),(!Rt||ee[0]&8&&Ti!==(Ti=D[3].m.b!=0))&&(dl.disabled=Ti),(!Rt||ee[0]&8&&Si!==(Si=D[3].m.b==0))&&(xe.disabled=Si),ee[0]&8&&Re(xe,D[3].m.p),ee[0]&8&&(Ct.checked=D[3].m.i),ee[0]&8&&Re(Ut,D[3].m.d),ee[0]&8&&me(Tt.value)!==D[3].m.f&&Z(Tt,D[3].m.f),ee[0]&8&&me(St.value)!==D[3].m.r&&Z(St,D[3].m.r),ee[0]&8&&(Pt.checked=D[3].m.e.e),D[3].m.e.e?st?st.p(D,ee):(st=Na(D),st.c(),st.m(Ml,null)):st&&(st.d(1),st=null),D[3].m.e.e?ot?ot.p(D,ee):(ot=Ia(D),ot.c(),ot.m(Le,ds)):ot&&(ot.d(1),ot=null),ee[0]&8&&(Mt.checked=D[3].m.m.e),D[3].m.m.e?ut?ut.p(D,ee):(ut=Ea(D),ut.c(),ut.m(Le,null)):ut&&(ut.d(1),ut=null),ee[0]&8&&Xt.value!==D[3].w.s&&Z(Xt,D[3].w.s),ee[0]&8&&xt.value!==D[3].w.p&&Z(xt,D[3].w.p),ee[0]&8&&Re(bt,D[3].w.z),ee[0]&8&&me(kt.value)!==D[3].w.w&&Z(kt,D[3].w.w),ee[0]&8&&(Dt.checked=D[3].w.a),ee[0]&8&&Re(Ht,D[3].n.m),(!Rt||ee[0]&8&&Li!==(Li=D[3].n.m=="dhcp"))&&(dt.disabled=Li),(!Rt||ee[0]&8&&Oi!==(Oi=D[3].n.m=="static"))&&(dt.required=Oi),ee[0]&8&&dt.value!==D[3].n.i&&Z(dt,D[3].n.i),(!Rt||ee[0]&8&&qi!==(qi=D[3].n.m=="dhcp"))&&(vt.disabled=qi),(!Rt||ee[0]&8&&Ui!==(Ui=D[3].n.m=="static"))&&(vt.required=Ui),ee[0]&8&&Re(vt,D[3].n.s),D[3].n.m=="static"?rt?rt.p(D,ee):(rt=Ra(D),rt.c(),rt.m(Je,vs)):rt&&(rt.d(1),rt=null),ee[0]&8&&(At.checked=D[3].n.d),ee[0]&8&&(Nt.checked=D[3].n.h),ee[0]&8&&el.value!==D[3].n.n1&&Z(el,D[3].n.n1),D[0].chip!="esp8266"?at?at.p(D,ee):(at=Fa(D),at.c(),at.m(jt,hs)):at&&(at.d(1),at=null),ee[0]&8&&tl.value!==D[3].q.h&&Z(tl,D[3].q.h),ee[0]&8&&me(It.value)!==D[3].q.p&&Z(It,D[3].q.p),D[3].q.s.e?Ye?(Ye.p(D,ee),ee[0]&8&&P(Ye,1)):(Ye=La(D),Ye.c(),P(Ye,1),Ye.m(Ge,gs)):Ye&&(Se(),N(Ye,1,1,()=>{Ye=null}),Pe()),ee[0]&8&&ll.value!==D[3].q.u&&Z(ll,D[3].q.u),ee[0]&8&&nl.value!==D[3].q.a&&Z(nl,D[3].q.a),ee[0]&8&&il.value!==D[3].q.c&&Z(il,D[3].q.c),ee[0]&8&&Re(lt,D[3].q.m),ee[0]&8&&sl.value!==D[3].q.b&&Z(sl,D[3].q.b),D[3].q.m==3?Ve?(Ve.p(D,ee),ee[0]&8&&P(Ve,1)):(Ve=Oa(D),Ve.c(),P(Ve,1),Ve.m(l,bs)):Ve&&(Se(),N(Ve,1,1,()=>{Ve=null}),Pe()),ee[0]&8&&(ks=D[3].p.r.startsWith("10YNO")||D[3].p.r=="10Y1001A1001A48H"),ks?Ke?(Ke.p(D,ee),ee[0]&8&&P(Ke,1)):(Ke=qa(D),Ke.c(),P(Ke,1),Ke.m(l,ws)):Ke&&(Se(),N(Ke,1,1,()=>{Ke=null}),Pe()),ee[0]&136){Ln=D[7];let wt;for(wt=0;wt20||D[0].chip=="esp8266"?Qe?(Qe.p(D,ee),ee[0]&1&&P(Qe,1)):(Qe=ja(D),Qe.c(),P(Qe,1),Qe.m(l,ys)):Qe&&(Se(),N(Qe,1,1,()=>{Qe=null}),Pe()),ee[0]&8&&(Et.checked=D[3].d.s),D[3].d.s?ct?ct.p(D,ee):(ct=Va(D),ct.c(),ct.m(ht,null)):ct&&(ct.d(1),ct=null);const mt={};ee[0]&2&&(mt.active=D[1]),Ol.$set(mt);const ar={};ee[0]&4&&(ar.active=D[2]),ql.$set(ar);const fr={};ee[0]&16&&(fr.active=D[4]),Ul.$set(fr);const cr={};ee[0]&32&&(cr.active=D[5]),Hl.$set(cr)},i(D){Rt||(P(a.$$.fragment,D),P(R.$$.fragment,D),P(ml.$$.fragment,D),P(on.$$.fragment,D),P(_n.$$.fragment,D),P(hn.$$.fragment,D),P(bn.$$.fragment,D),P(Ye),P(Ve),P(Ke),P(Nn.$$.fragment,D),P(Qe),P(En.$$.fragment,D),P(Ol.$$.fragment,D),P(ql.$$.fragment,D),P(Ul.$$.fragment,D),P(Hl.$$.fragment,D),Rt=!0)},o(D){N(a.$$.fragment,D),N(R.$$.fragment,D),N(ml.$$.fragment,D),N(on.$$.fragment,D),N(_n.$$.fragment,D),N(hn.$$.fragment,D),N(bn.$$.fragment,D),N(Ye),N(Ve),N(Ke),N(Nn.$$.fragment,D),N(Qe),N(En.$$.fragment,D),N(Ol.$$.fragment,D),N(ql.$$.fragment,D),N(Ul.$$.fragment,D),N(Hl.$$.fragment,D),Rt=!1},d(D){D&&w(e),V(a),V(R),Vt(Zi,D),nt&&nt.d(),it&&it.d(),V(ml),Vt(Ji,D),st&&st.d(),ot&&ot.d(),ut&&ut.d(),V(on),V(_n),V(hn),rt&&rt.d(),V(bn),at&&at.d(),Ye&&Ye.d(),Ve&&Ve.d(),Ke&&Ke.d(),V(Nn),Vt(ft,D),Qe&&Qe.d(),V(En),ct&&ct.d(),D&&w(Cs),V(Ol,D),D&&w(Ts),V(ql,D),D&&w(Ss),V(Ul,D),D&&w(Ps),V(Hl,D),Ms=!1,Be(rr)}}}async function gp(){await(await fetch("/reboot",{method:"POST"})).json()}function bp(t,e,l){let{sysinfo:n={}}=e,i=[{name:"Import gauge",key:"i"},{name:"Export gauge",key:"e"},{name:"Voltage",key:"v"},{name:"Amperage",key:"a"},{name:"Reactive",key:"r"},{name:"Realtime",key:"c"},{name:"Peaks",key:"t"},{name:"Price",key:"p"},{name:"Day plot",key:"d"},{name:"Month plot",key:"m"},{name:"Temperature plot",key:"s"}],o=!0,r=!1,a={g:{t:"",h:"",s:0,u:"",p:""},m:{b:2400,p:11,i:!1,d:0,f:0,r:0,e:{e:!1,k:"",a:""},m:{e:!1,w:!1,v:!1,a:!1,c:!1}},w:{s:"",p:"",w:0,z:255,a:!0},n:{m:"",i:"",s:"",g:"",d1:"",d2:"",d:!1,n1:"",n2:"",h:!1},q:{h:"",p:1883,u:"",a:"",b:"",s:{e:!1,c:!1,r:!0,k:!1}},o:{e:"",c:"",u1:"",u2:"",u3:""},t:{t:[0,0,0,0,0,0,0,0,0,0],h:1},p:{e:!1,t:"",r:"",c:"",m:1},d:{s:!1,t:!1,l:5},u:{i:0,e:0,v:0,a:0,r:0,c:0,t:0,p:0,d:0,m:0,s:0},i:{h:null,a:null,l:{p:null,i:!1},r:{r:null,g:null,b:null,i:!1},t:{d:null,a:null},v:{p:null,d:{v:null,g:null},o:null,m:null,b:null}}};rc.subscribe(Ue=>{Ue.version&&(l(3,a=Ue),l(1,o=!1))}),Qm();let f=!1,c=!1;async function p(){if(confirm("Are you sure you want to factory reset the device?")){l(4,f=!0);const Ue=new URLSearchParams;Ue.append("perform","true");let Cl=await(await fetch("/reset",{method:"POST",body:Ue})).json();l(4,f=!1),l(5,c=Cl.success)}}async function _(Ue){l(2,r=!0);const Bn=new FormData(Ue.target),Cl=new URLSearchParams;for(let fl of Bn){const[cl,ml]=fl;Cl.append(cl,ml)}let Vl=await(await fetch("/save",{method:"POST",body:Cl})).json();yt.update(fl=>(fl.booting=Vl.reboot,fl.ui=a.u,fl)),l(2,r=!1),Un("/")}const d=function(){confirm("Are you sure you want to reboot the device?")&&(yt.update(Ue=>(Ue.booting=!0,Ue)),gp())},g=function(){a.q.s.e?a.q.p==1883&&l(3,a.q.p=8883,a):a.q.p==8883&&l(3,a.q.p=1883,a)};let h=44;function b(){a.g.h=this.value,l(3,a)}function $(){a.g.t=et(this),l(3,a)}function k(){a.p.r=et(this),l(3,a)}function T(){a.p.c=et(this),l(3,a)}function M(){a.p.m=me(this.value),l(3,a)}function E(){a.p.e=this.checked,l(3,a)}function S(){a.p.t=this.value,l(3,a)}function I(){a.g.s=et(this),l(3,a)}function A(){a.g.u=this.value,l(3,a)}function R(){a.g.p=this.value,l(3,a)}function H(){a.m.b=et(this),l(3,a)}function j(){a.m.p=et(this),l(3,a)}function F(){a.m.i=this.checked,l(3,a)}function L(){a.m.d=et(this),l(3,a)}function W(){a.m.f=me(this.value),l(3,a)}function G(){a.m.r=me(this.value),l(3,a)}function q(){a.m.e.e=this.checked,l(3,a)}function O(){a.m.e.k=this.value,l(3,a)}function U(){a.m.e.a=this.value,l(3,a)}function X(){a.m.m.e=this.checked,l(3,a)}function z(){a.m.m.w=me(this.value),l(3,a)}function ne(){a.m.m.v=me(this.value),l(3,a)}function te(){a.m.m.a=me(this.value),l(3,a)}function Me(){a.m.m.c=me(this.value),l(3,a)}function _e(){a.w.s=this.value,l(3,a)}function Ne(){a.w.p=this.value,l(3,a)}function Ie(){a.w.z=et(this),l(3,a)}function Fe(){a.w.w=me(this.value),l(3,a)}function Ee(){a.w.a=this.checked,l(3,a)}function $e(){a.n.m=et(this),l(3,a)}function ge(){a.n.i=this.value,l(3,a)}function fe(){a.n.s=et(this),l(3,a)}function ae(){a.n.g=this.value,l(3,a)}function ce(){a.n.d1=this.value,l(3,a)}function ue(){a.n.d2=this.value,l(3,a)}function J(){a.n.d=this.checked,l(3,a)}function se(){a.n.h=this.checked,l(3,a)}function Ce(){a.n.n1=this.value,l(3,a)}function x(){a.q.s.e=this.checked,l(3,a)}function oe(){a.q.h=this.value,l(3,a)}function He(){a.q.p=me(this.value),l(3,a)}function Te(){a.q.u=this.value,l(3,a)}function de(){a.q.a=this.value,l(3,a)}function ve(){a.q.c=this.value,l(3,a)}function le(){a.q.m=et(this),l(3,a)}function he(){a.q.b=this.value,l(3,a)}function qe(){a.o.e=this.value,l(3,a)}function re(){a.o.c=this.value,l(3,a)}function De(){a.o.u1=this.value,l(3,a)}function fi(){a.o.u2=this.value,l(3,a)}function ci(){a.o.u3=this.value,l(3,a)}function mi(Ue){a.t.t[Ue]=me(this.value),l(3,a)}function $t(){a.t.h=me(this.value),l(3,a)}function pi(Ue){a.u[Ue.key]=et(this),l(3,a)}function Qt(){a.i.h=et(this),l(3,a)}function _i(){a.i.a=me(this.value),l(3,a)}function di(){a.i.l.i=this.checked,l(3,a)}function vi(){a.i.l.p=me(this.value),l(3,a)}function tt(){a.i.r.i=this.checked,l(3,a)}function hi(){a.i.r.r=me(this.value),l(3,a)}function Zt(){a.i.r.g=me(this.value),l(3,a)}function Yl(){a.i.r.b=me(this.value),l(3,a)}function pt(){a.i.t.d=me(this.value),l(3,a)}function gi(){a.i.t.a=me(this.value),l(3,a)}function bi(){a.i.v.p=me(this.value),l(3,a)}function ki(){a.i.v.d.v=me(this.value),l(3,a)}function Jt(){a.i.v.d.g=me(this.value),l(3,a)}function wi(){a.i.v.o=me(this.value),l(3,a)}function yi(){a.i.v.m=me(this.value),l(3,a)}function $i(){a.i.v.b=me(this.value),l(3,a)}function _t(){a.d.s=this.checked,l(3,a)}function rl(){a.d.t=this.checked,l(3,a)}function al(){a.d.l=et(this),l(3,a)}return t.$$set=Ue=>{"sysinfo"in Ue&&l(0,n=Ue.sysinfo)},t.$$.update=()=>{t.$$.dirty[0]&1&&l(6,h=n.chip=="esp8266"?16:n.chip=="esp32s2"?44:39)},[n,o,r,a,f,c,h,i,p,_,d,g,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W,G,q,O,U,X,z,ne,te,Me,_e,Ne,Ie,Fe,Ee,$e,ge,fe,ae,ce,ue,J,se,Ce,x,oe,He,Te,de,ve,le,he,qe,re,De,fi,ci,mi,$t,pi,Qt,_i,di,vi,tt,hi,Zt,Yl,pt,gi,bi,ki,Jt,wi,yi,$i,_t,rl,al]}class kp extends ye{constructor(e){super(),we(this,e,bp,hp,ke,{sysinfo:0},null,[-1,-1,-1,-1])}}function Qa(t,e,l){const n=t.slice();return n[20]=e[l],n}function wp(t){let e=pe(t[1].chip,t[1].board)+"",l;return{c(){l=C(e)},m(n,i){y(n,l,i)},p(n,i){i&2&&e!==(e=pe(n[1].chip,n[1].board)+"")&&B(l,e)},d(n){n&&w(l)}}}function Za(t){let e,l,n=t[1].apmac+"",i,o,r,a,f,c,p,_,d,g=Dr(t[1])+"",h,b,$=t[1].boot_reason+"",k,T,M;const E=[$p,yp],S=[];function I(A,R){return A[0].u>0?0:1}return f=I(t),c=S[f]=E[f](t),{c(){e=m("div"),l=C("AP MAC: "),i=C(n),o=v(),r=m("div"),a=C(`Last boot: - `),c.c(),p=v(),_=m("div"),d=C("Reason: "),h=C(g),b=C(" ("),k=C($),T=C(")"),u(e,"class","my-2"),u(r,"class","my-2"),u(_,"class","my-2")},m(A,R){y(A,e,R),s(e,l),s(e,i),y(A,o,R),y(A,r,R),s(r,a),S[f].m(r,null),y(A,p,R),y(A,_,R),s(_,d),s(_,h),s(_,b),s(_,k),s(_,T),M=!0},p(A,R){(!M||R&2)&&n!==(n=A[1].apmac+"")&&B(i,n);let H=f;f=I(A),f===H?S[f].p(A,R):(Se(),N(S[H],1,1,()=>{S[H]=null}),Pe(),c=S[f],c?c.p(A,R):(c=S[f]=E[f](A),c.c()),P(c,1),c.m(r,null)),(!M||R&2)&&g!==(g=Dr(A[1])+"")&&B(h,g),(!M||R&2)&&$!==($=A[1].boot_reason+"")&&B(k,$)},i(A){M||(P(c),M=!0)},o(A){N(c),M=!1},d(A){A&&w(e),A&&w(o),A&&w(r),S[f].d(),A&&w(p),A&&w(_)}}}function yp(t){let e;return{c(){e=C("-")},m(l,n){y(l,e,n)},p:ie,i:ie,o:ie,d(l){l&&w(e)}}}function $p(t){let e,l;return e=new sc({props:{timestamp:new Date(new Date().getTime()-t[0].u*1e3),fullTimeColor:""}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.timestamp=new Date(new Date().getTime()-n[0].u*1e3)),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Cp(t){let e;return{c(){e=m("span"),e.textContent="Update consents",u(e,"class","btn-pri-sm")},m(l,n){y(l,e,n)},p:ie,d(l){l&&w(e)}}}function Ja(t){let e,l,n,i,o,r=as(t[1].meter.mfg)+"",a,f,c,p,_=t[1].meter.model+"",d,g,h,b,$=t[1].meter.id+"",k;return{c(){e=m("div"),l=m("strong"),l.textContent="Meter",n=v(),i=m("div"),o=C("Manufacturer: "),a=C(r),f=v(),c=m("div"),p=C("Model: "),d=C(_),g=v(),h=m("div"),b=C("ID: "),k=C($),u(l,"class","text-sm"),u(i,"class","my-2"),u(c,"class","my-2"),u(h,"class","my-2"),u(e,"class","cnt")},m(T,M){y(T,e,M),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(e,f),s(e,c),s(c,p),s(c,d),s(e,g),s(e,h),s(h,b),s(h,k)},p(T,M){M&2&&r!==(r=as(T[1].meter.mfg)+"")&&B(a,r),M&2&&_!==(_=T[1].meter.model+"")&&B(d,_),M&2&&$!==($=T[1].meter.id+"")&&B(k,$)},d(T){T&&w(e)}}}function Xa(t){let e,l,n,i,o,r=t[1].net.ip+"",a,f,c,p,_=t[1].net.mask+"",d,g,h,b,$=t[1].net.gw+"",k,T,M,E,S=t[1].net.dns1+"",I,A,R=t[1].net.dns2&&xa(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Network",n=v(),i=m("div"),o=C("IP: "),a=C(r),f=v(),c=m("div"),p=C("Mask: "),d=C(_),g=v(),h=m("div"),b=C("Gateway: "),k=C($),T=v(),M=m("div"),E=C("DNS: "),I=C(S),A=v(),R&&R.c(),u(l,"class","text-sm"),u(i,"class","my-2"),u(c,"class","my-2"),u(h,"class","my-2"),u(M,"class","my-2"),u(e,"class","cnt")},m(H,j){y(H,e,j),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(e,f),s(e,c),s(c,p),s(c,d),s(e,g),s(e,h),s(h,b),s(h,k),s(e,T),s(e,M),s(M,E),s(M,I),s(M,A),R&&R.m(M,null)},p(H,j){j&2&&r!==(r=H[1].net.ip+"")&&B(a,r),j&2&&_!==(_=H[1].net.mask+"")&&B(d,_),j&2&&$!==($=H[1].net.gw+"")&&B(k,$),j&2&&S!==(S=H[1].net.dns1+"")&&B(I,S),H[1].net.dns2?R?R.p(H,j):(R=xa(H),R.c(),R.m(M,null)):R&&(R.d(1),R=null)},d(H){H&&w(e),R&&R.d()}}}function xa(t){let e,l=t[1].net.dns2+"",n;return{c(){e=C("/ "),n=C(l)},m(i,o){y(i,e,o),y(i,n,o)},p(i,o){o&2&&l!==(l=i[1].net.dns2+"")&&B(n,l)},d(i){i&&w(e),i&&w(n)}}}function ef(t){let e,l,n,i=t[2].tag_name+"",o,r,a,f,c,p,_=(t[1].security==0||t[0].a)&&t[1].fwconsent===1&&t[2]&&t[2].tag_name&&tf(t),d=t[1].fwconsent===2&&lf();return{c(){e=m("div"),l=C(`Latest version: - `),n=m("a"),o=C(i),a=v(),_&&_.c(),f=v(),d&&d.c(),c=We(),u(n,"href",r=t[2].html_url),u(n,"class","ml-2 text-blue-600 hover:text-blue-800"),u(n,"target","_blank"),u(n,"rel","noreferrer"),u(e,"class","my-2 flex")},m(g,h){y(g,e,h),s(e,l),s(e,n),s(n,o),s(e,a),_&&_.m(e,null),y(g,f,h),d&&d.m(g,h),y(g,c,h),p=!0},p(g,h){(!p||h&4)&&i!==(i=g[2].tag_name+"")&&B(o,i),(!p||h&4&&r!==(r=g[2].html_url))&&u(n,"href",r),(g[1].security==0||g[0].a)&&g[1].fwconsent===1&&g[2]&&g[2].tag_name?_?(_.p(g,h),h&7&&P(_,1)):(_=tf(g),_.c(),P(_,1),_.m(e,null)):_&&(Se(),N(_,1,1,()=>{_=null}),Pe()),g[1].fwconsent===2?d||(d=lf(),d.c(),d.m(c.parentNode,c)):d&&(d.d(1),d=null)},i(g){p||(P(_),p=!0)},o(g){N(_),p=!1},d(g){g&&w(e),_&&_.d(),g&&w(f),d&&d.d(g),g&&w(c)}}}function tf(t){let e,l,n,i,o,r;return n=new oc({}),{c(){e=m("div"),l=m("button"),Q(n.$$.fragment),u(e,"class","flex-none ml-2 text-green-500"),u(e,"title","Install this version")},m(a,f){y(a,e,f),s(e,l),Y(n,l,null),i=!0,o||(r=K(l,"click",t[10]),o=!0)},p:ie,i(a){i||(P(n.$$.fragment,a),i=!0)},o(a){N(n.$$.fragment,a),i=!1},d(a){a&&w(e),V(n),o=!1,r()}}}function lf(t){let e;return{c(){e=m("div"),e.innerHTML='
You have disabled one-click firmware upgrade, link to self-upgrade is disabled
',u(e,"class","my-2")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function nf(t){let e,l=fs(pe(t[1].chip,t[1].board))+"",n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&2&&l!==(l=fs(pe(i[1].chip,i[1].board))+"")&&B(n,l)},d(i){i&&w(e)}}}function sf(t){let e,l,n,i,o,r;function a(p,_){return p[4].length==0?Sp:Tp}let f=a(t),c=f(t);return{c(){e=m("div"),l=m("form"),n=m("input"),i=v(),c.c(),wf(n,"display","none"),u(n,"name","file"),u(n,"type","file"),u(n,"accept",".bin"),u(l,"action","/firmware"),u(l,"enctype","multipart/form-data"),u(l,"method","post"),u(l,"autocomplete","off"),u(e,"class","my-2 flex")},m(p,_){y(p,e,_),s(e,l),s(l,n),t[12](n),s(l,i),c.m(l,null),o||(r=[K(n,"change",t[13]),K(l,"submit",t[15])],o=!0)},p(p,_){f===(f=a(p))&&c?c.p(p,_):(c.d(1),c=f(p),c&&(c.c(),c.m(l,null)))},d(p){p&&w(e),t[12](null),c.d(),o=!1,Be(r)}}}function Tp(t){let e=t[4][0].name+"",l,n,i;return{c(){l=C(e),n=v(),i=m("button"),i.textContent="Upload",u(i,"type","submit"),u(i,"class","btn-pri-sm float-right")},m(o,r){y(o,l,r),y(o,n,r),y(o,i,r)},p(o,r){r&16&&e!==(e=o[4][0].name+"")&&B(l,e)},d(o){o&&w(l),o&&w(n),o&&w(i)}}}function Sp(t){let e,l,n;return{c(){e=m("button"),e.textContent="Select firmware file for upgrade",u(e,"type","button"),u(e,"class","btn-pri-sm float-right")},m(i,o){y(i,e,o),l||(n=K(e,"click",t[14]),l=!0)},p:ie,d(i){i&&w(e),l=!1,n()}}}function of(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b=t[9],$=[];for(let S=0;S Include Secrets
(SSID, PSK, passwords and tokens)',f=v(),k&&k.c(),c=v(),p=m("form"),_=m("input"),d=v(),E.c(),u(l,"class","text-sm"),u(a,"class","my-1 mx-3 col-span-2"),u(o,"class","grid grid-cols-2"),u(i,"method","get"),u(i,"action","/configfile.cfg"),u(i,"autocomplete","off"),wf(_,"display","none"),u(_,"name","file"),u(_,"type","file"),u(_,"accept",".cfg"),u(p,"action","/configfile"),u(p,"enctype","multipart/form-data"),u(p,"method","post"),u(p,"autocomplete","off"),u(e,"class","cnt")},m(S,I){y(S,e,I),s(e,l),s(e,n),s(e,i),s(i,o);for(let A=0;A<$.length;A+=1)$[A].m(o,null);s(o,r),s(o,a),s(i,f),k&&k.m(i,null),s(e,c),s(e,p),s(p,_),t[16](_),s(p,d),E.m(p,null),g||(h=[K(_,"change",t[17]),K(p,"submit",t[19])],g=!0)},p(S,I){if(I&512){b=S[9];let A;for(A=0;A{fe=null}),Pe());const Te={};oe&8388608&&(Te.$$scope={dirty:oe,ctx:x}),S.$set(Te),x[1].meter?ae?ae.p(x,oe):(ae=Ja(x),ae.c(),ae.m(e,H)):ae&&(ae.d(1),ae=null),x[1].net?ce?ce.p(x,oe):(ce=Xa(x),ce.c(),ce.m(e,j)):ce&&(ce.d(1),ce=null),(!Ee||oe&2)&&O!==(O=x[1].version+"")&&B(U,O),x[2]?ue?(ue.p(x,oe),oe&4&&P(ue,1)):(ue=ef(x),ue.c(),P(ue,1),ue.m(F,z)):ue&&(Se(),N(ue,1,1,()=>{ue=null}),Pe()),oe&3&&(ne=(x[1].security==0||x[0].a)&&Hn(x[1].board)),ne?J?J.p(x,oe):(J=nf(x),J.c(),J.m(F,te)):J&&(J.d(1),J=null),x[1].security==0||x[0].a?se?se.p(x,oe):(se=sf(x),se.c(),se.m(F,null)):se&&(se.d(1),se=null),x[1].security==0||x[0].a?Ce?Ce.p(x,oe):(Ce=of(x),Ce.c(),Ce.m(e,null)):Ce&&(Ce.d(1),Ce=null);const de={};oe&32&&(de.active=x[5]),Ne.$set(de);const ve={};oe&256&&(ve.active=x[8]),Fe.$set(ve)},i(x){Ee||(P(d.$$.fragment,x),P(fe),P(S.$$.fragment,x),P(ue),P(Ne.$$.fragment,x),P(Fe.$$.fragment,x),Ee=!0)},o(x){N(d.$$.fragment,x),N(fe),N(S.$$.fragment,x),N(ue),N(Ne.$$.fragment,x),N(Fe.$$.fragment,x),Ee=!1},d(x){x&&w(e),V(d),fe&&fe.d(),V(S),ae&&ae.d(),ce&&ce.d(),ue&&ue.d(),J&&J.d(),se&&se.d(),Ce&&Ce.d(),x&&w(_e),V(Ne,x),x&&w(Ie),V(Fe,x),$e=!1,ge()}}}async function Ap(){await(await fetch("/reboot",{method:"POST"})).json()}function Np(t,e,l){let{data:n}=e,{sysinfo:i}=e,o=[{name:"WiFi",key:"iw"},{name:"MQTT",key:"im"},{name:"Web",key:"ie"},{name:"Meter",key:"it"},{name:"Thresholds",key:"ih"},{name:"GPIO",key:"ig"},{name:"Domoticz",key:"id"},{name:"NTP",key:"in"},{name:"Price API",key:"is"}],r={};so.subscribe(A=>{l(2,r=ic(i.version,A)),r||l(2,r=A[0])});function a(){confirm("Do you want to upgrade this device to "+r.tag_name+"?")&&(i.board!=2&&i.board!=4&&i.board!=7||confirm(fs(pe(i.chip,i.board))))&&(yt.update(A=>(A.upgrading=!0,A)),nc())}const f=function(){confirm("Are you sure you want to reboot the device?")&&(yt.update(A=>(A.booting=!0,A)),Ap())};let c,p=[],_=!1,d,g=[],h=!1;lo();function b(A){us[A?"unshift":"push"](()=>{c=A,l(3,c)})}function $(){p=this.files,l(4,p)}const k=()=>{c.click()},T=()=>l(5,_=!0);function M(A){us[A?"unshift":"push"](()=>{d=A,l(6,d)})}function E(){g=this.files,l(7,g)}const S=()=>{d.click()},I=()=>l(8,h=!0);return t.$$set=A=>{"data"in A&&l(0,n=A.data),"sysinfo"in A&&l(1,i=A.sysinfo)},[n,i,r,c,p,_,d,g,h,o,a,f,b,$,k,T,M,E,S,I]}class Ip extends ye{constructor(e){super(),we(this,e,Np,Dp,ke,{data:0,sysinfo:1})}}function af(t){let e,l,n=pe(t[0],7)+"",i,o,r=pe(t[0],5)+"",a,f,c=pe(t[0],4)+"",p,_,d=pe(t[0],3)+"",g,h,b,$,k=pe(t[0],2)+"",T,M,E=pe(t[0],1)+"",S,I,A=pe(t[0],0)+"",R,H,j,F,L=pe(t[0],101)+"",W,G,q=pe(t[0],100)+"",O;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),f=m("option"),p=C(c),_=m("option"),g=C(d),h=v(),b=m("optgroup"),$=m("option"),T=C(k),M=m("option"),S=C(E),I=m("option"),R=C(A),H=v(),j=m("optgroup"),F=m("option"),W=C(L),G=m("option"),O=C(q),l.__value=7,l.value=l.__value,o.__value=5,o.value=o.__value,f.__value=4,f.value=f.__value,_.__value=3,_.value=_.__value,u(e,"label","amsleser.no"),$.__value=2,$.value=$.__value,M.__value=1,M.value=M.__value,I.__value=0,I.value=I.__value,u(b,"label","Custom hardware"),F.__value=101,F.value=F.__value,G.__value=100,G.value=G.__value,u(j,"label","Generic hardware")},m(U,X){y(U,e,X),s(e,l),s(l,i),s(e,o),s(o,a),s(e,f),s(f,p),s(e,_),s(_,g),y(U,h,X),y(U,b,X),s(b,$),s($,T),s(b,M),s(M,S),s(b,I),s(I,R),y(U,H,X),y(U,j,X),s(j,F),s(F,W),s(j,G),s(G,O)},p(U,X){X&1&&n!==(n=pe(U[0],7)+"")&&B(i,n),X&1&&r!==(r=pe(U[0],5)+"")&&B(a,r),X&1&&c!==(c=pe(U[0],4)+"")&&B(p,c),X&1&&d!==(d=pe(U[0],3)+"")&&B(g,d),X&1&&k!==(k=pe(U[0],2)+"")&&B(T,k),X&1&&E!==(E=pe(U[0],1)+"")&&B(S,E),X&1&&A!==(A=pe(U[0],0)+"")&&B(R,A),X&1&&L!==(L=pe(U[0],101)+"")&&B(W,L),X&1&&q!==(q=pe(U[0],100)+"")&&B(O,q)},d(U){U&&w(e),U&&w(h),U&&w(b),U&&w(H),U&&w(j)}}}function ff(t){let e,l,n=pe(t[0],201)+"",i,o,r=pe(t[0],202)+"",a,f,c=pe(t[0],203)+"",p,_,d=pe(t[0],200)+"",g;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),f=m("option"),p=C(c),_=m("option"),g=C(d),l.__value=201,l.value=l.__value,o.__value=202,o.value=o.__value,f.__value=203,f.value=f.__value,_.__value=200,_.value=_.__value,u(e,"label","Generic hardware")},m(h,b){y(h,e,b),s(e,l),s(l,i),s(e,o),s(o,a),s(e,f),s(f,p),s(e,_),s(_,g)},p(h,b){b&1&&n!==(n=pe(h[0],201)+"")&&B(i,n),b&1&&r!==(r=pe(h[0],202)+"")&&B(a,r),b&1&&c!==(c=pe(h[0],203)+"")&&B(p,c),b&1&&d!==(d=pe(h[0],200)+"")&&B(g,d)},d(h){h&&w(e)}}}function cf(t){let e,l,n=pe(t[0],7)+"",i,o,r=pe(t[0],6)+"",a,f,c=pe(t[0],5)+"",p,_,d,g,h=pe(t[0],51)+"",b,$,k=pe(t[0],50)+"",T;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),f=m("option"),p=C(c),_=v(),d=m("optgroup"),g=m("option"),b=C(h),$=m("option"),T=C(k),l.__value=7,l.value=l.__value,o.__value=6,o.value=o.__value,f.__value=5,f.value=f.__value,u(e,"label","amsleser.no"),g.__value=51,g.value=g.__value,$.__value=50,$.value=$.__value,u(d,"label","Generic hardware")},m(M,E){y(M,e,E),s(e,l),s(l,i),s(e,o),s(o,a),s(e,f),s(f,p),y(M,_,E),y(M,d,E),s(d,g),s(g,b),s(d,$),s($,T)},p(M,E){E&1&&n!==(n=pe(M[0],7)+"")&&B(i,n),E&1&&r!==(r=pe(M[0],6)+"")&&B(a,r),E&1&&c!==(c=pe(M[0],5)+"")&&B(p,c),E&1&&h!==(h=pe(M[0],51)+"")&&B(b,h),E&1&&k!==(k=pe(M[0],50)+"")&&B(T,k)},d(M){M&&w(e),M&&w(_),M&&w(d)}}}function mf(t){let e,l,n=pe(t[0],71)+"",i,o,r=pe(t[0],70)+"",a;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),l.__value=71,l.value=l.__value,o.__value=70,o.value=o.__value,u(e,"label","Generic hardware")},m(f,c){y(f,e,c),s(e,l),s(l,i),s(e,o),s(o,a)},p(f,c){c&1&&n!==(n=pe(f[0],71)+"")&&B(i,n),c&1&&r!==(r=pe(f[0],70)+"")&&B(a,r)},d(f){f&&w(e)}}}function pf(t){let e,l,n=pe(t[0],200)+"",i;return{c(){e=m("optgroup"),l=m("option"),i=C(n),l.__value=200,l.value=l.__value,u(e,"label","Generic hardware")},m(o,r){y(o,e,r),s(e,l),s(l,i)},p(o,r){r&1&&n!==(n=pe(o[0],200)+"")&&B(i,n)},d(o){o&&w(e)}}}function Ep(t){let e,l,n,i,o,r,a,f=t[0]=="esp8266"&&af(t),c=t[0]=="esp32"&&ff(t),p=t[0]=="esp32s2"&&cf(t),_=t[0]=="esp32c3"&&mf(t),d=t[0]=="esp32solo"&&pf(t);return{c(){e=m("option"),l=v(),f&&f.c(),n=v(),c&&c.c(),i=v(),p&&p.c(),o=v(),_&&_.c(),r=v(),d&&d.c(),a=We(),e.__value=-1,e.value=e.__value},m(g,h){y(g,e,h),y(g,l,h),f&&f.m(g,h),y(g,n,h),c&&c.m(g,h),y(g,i,h),p&&p.m(g,h),y(g,o,h),_&&_.m(g,h),y(g,r,h),d&&d.m(g,h),y(g,a,h)},p(g,[h]){g[0]=="esp8266"?f?f.p(g,h):(f=af(g),f.c(),f.m(n.parentNode,n)):f&&(f.d(1),f=null),g[0]=="esp32"?c?c.p(g,h):(c=ff(g),c.c(),c.m(i.parentNode,i)):c&&(c.d(1),c=null),g[0]=="esp32s2"?p?p.p(g,h):(p=cf(g),p.c(),p.m(o.parentNode,o)):p&&(p.d(1),p=null),g[0]=="esp32c3"?_?_.p(g,h):(_=mf(g),_.c(),_.m(r.parentNode,r)):_&&(_.d(1),_=null),g[0]=="esp32solo"?d?d.p(g,h):(d=pf(g),d.c(),d.m(a.parentNode,a)):d&&(d.d(1),d=null)},i:ie,o:ie,d(g){g&&w(e),g&&w(l),f&&f.d(g),g&&w(n),c&&c.d(g),g&&w(i),p&&p.d(g),g&&w(o),_&&_.d(g),g&&w(r),d&&d.d(g),g&&w(a)}}}function Rp(t,e,l){let{chip:n}=e;return t.$$set=i=>{"chip"in i&&l(0,n=i.chip)},[n]}class Fp extends ye{constructor(e){super(),we(this,e,Rp,Ep,ke,{chip:0})}}function _f(t){let e;return{c(){e=m("div"),e.textContent="WARNING: Changing this configuration will affect basic configuration of your device. Only make changes here if instructed by vendor",u(e,"class","bd-red")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function df(t){let e,l,n,i,o,r,a;return r=new ac({props:{chip:t[0].chip}}),{c(){e=m("div"),l=C("HAN GPIO"),n=m("br"),i=v(),o=m("select"),Q(r.$$.fragment),u(o,"name","vh"),u(o,"class","in-s"),u(e,"class","my-3")},m(f,c){y(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),Y(r,o,null),a=!0},p(f,c){const p={};c&1&&(p.chip=f[0].chip),r.$set(p)},i(f){a||(P(r.$$.fragment,f),a=!0)},o(f){N(r.$$.fragment,f),a=!1},d(f){f&&w(e),V(r)}}}function Lp(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W,G=t[0].usrcfg&&_f();h=new Fp({props:{chip:t[0].chip}});let q=t[0].board&&t[0].board>20&&df(t);return j=new gt({props:{active:t[1],message:"Saving device configuration"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=v(),r=m("strong"),r.textContent="Initial configuration",a=v(),G&&G.c(),f=v(),c=m("div"),p=C("Board type"),_=m("br"),d=v(),g=m("select"),Q(h.$$.fragment),b=v(),q&&q.c(),$=v(),k=m("div"),T=m("label"),M=m("input"),E=C(" Clear all other configuration"),S=v(),I=m("div"),I.innerHTML='',A=v(),R=m("span"),R.textContent="\xA0",H=v(),Q(j.$$.fragment),u(i,"type","hidden"),u(i,"name","v"),i.value="true",u(r,"class","text-sm"),u(g,"name","vb"),u(g,"class","in-s"),t[0].board===void 0&&ze(()=>t[4].call(g)),u(c,"class","my-3"),u(M,"type","checkbox"),u(M,"name","vr"),M.__value="true",M.value=M.__value,u(M,"class","rounded mb-1"),u(k,"class","my-3"),u(I,"class","my-3"),u(R,"class","clear-both"),u(n,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(O,U){y(O,e,U),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),G&&G.m(n,null),s(n,f),s(n,c),s(c,p),s(c,_),s(c,d),s(c,g),Y(h,g,null),Re(g,t[0].board),s(n,b),q&&q.m(n,null),s(n,$),s(n,k),s(k,T),s(T,M),M.checked=t[2],s(T,E),s(n,S),s(n,I),s(n,A),s(n,R),y(O,H,U),Y(j,O,U),F=!0,L||(W=[K(g,"change",t[4]),K(M,"change",t[5]),K(n,"submit",cs(t[3]))],L=!0)},p(O,[U]){O[0].usrcfg?G||(G=_f(),G.c(),G.m(n,f)):G&&(G.d(1),G=null);const X={};U&1&&(X.chip=O[0].chip),h.$set(X),U&1&&Re(g,O[0].board),O[0].board&&O[0].board>20?q?(q.p(O,U),U&1&&P(q,1)):(q=df(O),q.c(),P(q,1),q.m(n,$)):q&&(Se(),N(q,1,1,()=>{q=null}),Pe()),U&4&&(M.checked=O[2]);const z={};U&2&&(z.active=O[1]),j.$set(z)},i(O){F||(P(h.$$.fragment,O),P(q),P(j.$$.fragment,O),F=!0)},o(O){N(h.$$.fragment,O),N(q),N(j.$$.fragment,O),F=!1},d(O){O&&w(e),G&&G.d(),V(h),q&&q.d(),O&&w(H),V(j,O),L=!1,Be(W)}}}function Op(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(c){l(1,i=!0);const p=new FormData(c.target),_=new URLSearchParams;for(let h of p){const[b,$]=h;_.append(b,$)}let g=await(await fetch("/save",{method:"POST",body:_})).json();l(1,i=!1),yt.update(h=>(h.vndcfg=g.success,h.booting=g.reboot,h)),Un(n.usrcfg?"/":"/setup")}let r=!1;function a(){n.board=et(this),l(0,n)}function f(){r=this.checked,l(2,r),l(0,n)}return t.$$set=c=>{"sysinfo"in c&&l(0,n=c.sysinfo)},t.$$.update=()=>{t.$$.dirty&1&&l(2,r=!n.usrcfg)},[n,i,r,o,a,f]}class qp extends ye{constructor(e){super(),we(this,e,Op,Lp,ke,{sysinfo:0})}}function vf(t){let e,l,n,i,o,r,a,f;return a=new fc({}),{c(){e=m("br"),l=v(),n=m("div"),i=m("input"),o=v(),r=m("select"),Q(a.$$.fragment),u(i,"name","si"),u(i,"type","text"),u(i,"class","in-f w-full"),i.required=t[1],u(r,"name","su"),u(r,"class","in-l"),r.required=t[1],u(n,"class","flex")},m(c,p){y(c,e,p),y(c,l,p),y(c,n,p),s(n,i),s(n,o),s(n,r),Y(a,r,null),f=!0},p(c,p){(!f||p&2)&&(i.required=c[1]),(!f||p&2)&&(r.required=c[1])},i(c){f||(P(a.$$.fragment,c),f=!0)},o(c){N(a.$$.fragment,c),f=!1},d(c){c&&w(e),c&&w(l),c&&w(n),V(a)}}}function hf(t){let e;return{c(){e=m("div"),e.innerHTML=`
Gateway
+Occurred in: ${i}`:"",r=io(t),a=Mf(e)?e(r):e;return`<${r}> ${a}${o}`}const jf=t=>(...e)=>t(Wc(...e)),Wf=jf(t=>{throw new Error(t)}),cs=jf(console.warn),br=4,Gc=3,Bc=2,zc=1,Yc=1;function Vc(t,e){const l=t.default?0:Kt(t.fullPath).reduce((n,i)=>{let o=n;return o+=br,Ec(i)?o+=Yc:Rc(i)?o+=Bc:Ff(i)?o-=br+zc:o+=Gc,o},0);return{route:t,score:l,index:e}}function Kc(t){return t.map(Vc).sort((e,l)=>e.scorel.score?-1:e.index-l.index)}function Gf(t,e){let l,n;const[i]=e.split("?"),o=Kt(i),r=o[0]==="",a=Kc(t);for(let c=0,f=a.length;c({...p,params:d,uri:k});if(p.default){n=g(e);continue}const h=Kt(p.fullPath),b=Math.max(o.length,h.length);let $=0;for(;${f===".."?c.pop():f!=="."&&c.push(f)}),Rs(`/${c.join("/")}`,n)}function kr(t,e){const{pathname:l,hash:n="",search:i="",state:o}=t,r=Kt(e,!0),a=Kt(l,!0);for(;r.length;)r[0]!==a[0]&&Wf(Vl,`Invalid state: All locations must begin with the basepath "${e}", found "${l}"`),r.shift(),a.shift();return{pathname:ri(...a),hash:n,search:i,state:o}}const wr=t=>t.length===1?"":t,so=t=>{const e=t.indexOf("?"),l=t.indexOf("#"),n=e!==-1,i=l!==-1,o=i?wr(ti(t,l)):"",r=i?ti(t,0,l):t,a=n?wr(ti(r,e)):"";return{pathname:(n?ti(r,0,e):r)||"/",search:a,hash:o}},Zc=t=>{const{pathname:e,search:l,hash:n}=t;return e+l+n};function Jc(t,e,l){return ri(l,Qc(t,e))}function Xc(t,e){const l=lo(Fc(t)),n=Kt(l,!0),i=Kt(e,!0).slice(0,n.length),o=Bf({fullPath:l},ri(...i));return o&&o.uri}const Fs="POP",xc="PUSH",e1="REPLACE";function Ls(t){return{...t.location,pathname:encodeURI(decodeURI(t.location.pathname)),state:t.history.state,_key:t.history.state&&t.history.state._key||"initial"}}function t1(t){let e=[],l=Ls(t),n=Fs;const i=(o=e)=>o.forEach(r=>r({location:l,action:n}));return{get location(){return l},listen(o){e.push(o);const r=()=>{l=Ls(t),n=Fs,i([o])};i([o]);const a=Nf(t,"popstate",r);return()=>{a(),e=e.filter(c=>c!==o)}},navigate(o,r){const{state:a={},replace:c=!1}=r||{};if(n=c?e1:xc,Df(o))r&&cs(Hf,"Navigation options (state or replace) are not supported, when passing a number as the first argument to navigate. They are ignored."),n=Fs,t.history.go(o);else{const f={...a,_key:Dc()};try{t.history[c?"replaceState":"pushState"](f,"",o)}catch{t.location[c?"replace":"assign"](o)}}l=Ls(t),i()}}}function Os(t,e){return{...so(e),state:t}}function l1(t="/"){let e=0,l=[Os(null,t)];return{get entries(){return l},get location(){return l[e]},addEventListener(){},removeEventListener(){},history:{get state(){return l[e].state},pushState(n,i,o){e++,l=l.slice(0,e),l.push(Os(n,o))},replaceState(n,i,o){l[e]=Os(n,o)},go(n){const i=e+n;i<0||i>l.length-1||(e=i)}}}}const n1=!!(!yl&&window.document&&window.document.createElement),i1=!yl&&window.location.origin==="null",zf=t1(n1&&!i1?window:l1()),{navigate:jn}=zf;let ul=null,Yf=!0;function s1(t,e){const l=document.querySelectorAll("[data-svnav-router]");for(let n=0;nul.level||t.level===ul.level&&s1(t.routerId,ul.routerId))&&(ul=t)}function u1(){ul=null}function r1(){Yf=!1}function yr(t){if(!t)return!1;const e="tabindex";try{if(!t.hasAttribute(e)){t.setAttribute(e,"-1");let l;l=Nf(t,"blur",()=>{t.removeAttribute(e),l()})}return t.focus(),document.activeElement===t}catch{return!1}}function a1(t,e){return Number(t.dataset.svnavRouteEnd)===e}function f1(t){return/^H[1-6]$/i.test(t.tagName)}function $r(t,e=document){return e.querySelector(t)}function c1(t){let l=$r(`[data-svnav-route-start="${t}"]`).nextElementSibling;for(;!a1(l,t);){if(f1(l))return l;const n=$r("h1,h2,h3,h4,h5,h6",l);if(n)return n;l=l.nextElementSibling}return null}function m1(t){Promise.resolve(Gn(t.focusElement)).then(e=>{const l=e||c1(t.id);l||cs(Vl,`Could not find an element to focus. You should always render a header for accessibility reasons, or set a custom focus element via the "useFocus" hook. If you don't want this Route or Router to manage focus, pass "primary={false}" to it.`,t,ds),!yr(l)&&yr(document.documentElement)})}const p1=(t,e,l)=>(n,i)=>Tc().then(()=>{if(!ul||Yf){r1();return}if(n&&m1(ul.route),t.announcements&&i){const{path:o,fullPath:r,meta:a,params:c,uri:f}=ul.route,p=t.createAnnouncement({path:o,fullPath:r,meta:a,params:c,uri:f},Gn(l));Promise.resolve(p).then(_=>{e.set(_)})}u1()}),Cr="position:fixed;top:-1px;left:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";function _1(t){let e,l,n=[{role:"status"},{"aria-atomic":"true"},{"aria-live":"polite"},{"data-svnav-announcer":""},Hs(t[6],Cr)],i={};for(let o=0;o`Navigated to ${te.uri}`,announcements:!0,...h},k=p,T=lo(p),P=wl(js),E=wl(zn),S=!P,N=v1(),A=g&&!(E&&!E.manageFocus),R=Ze("");Bt(t,R,te=>l(0,a=te));const H=E?E.disableInlineStyles:b,U=Ze([]);Bt(t,U,te=>l(20,r=te));const F=Ze(null);Bt(t,F,te=>l(18,i=te));let L=!1;const G=S?0:E.level+1,O=S?Ze((()=>kr(yl?so(_):d.location,T))()):P;Bt(t,O,te=>l(17,n=te));const q=Ze(n);Bt(t,q,te=>l(19,o=te));const W=p1($,R,O),X=te=>De=>De.filter(_e=>_e.id!==te);function z(te){if(yl){if(L)return;const De=Bf(te,n.pathname);if(De)return L=!0,De}else U.update(De=>{const _e=X(te.id)(De);return _e.push(te),_e})}function ne(te){U.update(X(te))}return!S&&p!==Tr&&cs(Vl,'Only top-level Routers can have a "basepath" prop. It is ignored.',{basepath:p}),S&&(yc(()=>d.listen(De=>{const _e=kr(De.location,T);q.set(n),O.set(_e)})),ni(js,O)),ni(zn,{activeRoute:F,registerRoute:z,unregisterRoute:ne,manageFocus:A,level:G,id:N,history:S?d:E.history,basepath:S?T:E.basepath,disableInlineStyles:H}),t.$$set=te=>{"basepath"in te&&l(11,p=te.basepath),"url"in te&&l(12,_=te.url),"history"in te&&l(13,d=te.history),"primary"in te&&l(14,g=te.primary),"a11y"in te&&l(15,h=te.a11y),"disableInlineStyles"in te&&l(16,b=te.disableInlineStyles),"$$scope"in te&&l(21,f=te.$$scope)},t.$$.update=()=>{if(t.$$.dirty[0]&2048&&p!==k&&cs(Vl,'You cannot change the "basepath" prop. It is ignored.'),t.$$.dirty[0]&1179648){const te=Gf(r,n.pathname);F.set(te)}if(t.$$.dirty[0]&655360&&S){const te=!!n.hash,De=!te&&A,_e=!te||n.pathname!==o.pathname;W(De,_e)}t.$$.dirty[0]&262144&&A&&i&&i.primary&&o1({level:G,routerId:N,route:i})},[a,$,S,N,A,R,H,U,F,O,q,p,_,d,g,h,b,n,i,o,r,f,c]}class Vf extends $e{constructor(e){super(),ye(this,e,h1,d1,we,{basepath:11,url:12,history:13,primary:14,a11y:15,disableInlineStyles:16},null,[-1,-1])}}function ai(t,e,l=zn,n=Vl){wl(l)||Wf(t,o=>`You cannot use ${o} outside of a ${io(n)}.`,e)}const g1=t=>{const{subscribe:e}=wl(t);return{subscribe:e}};function Kf(){return ai(Of),g1(js)}function Qf(){const{history:t}=wl(zn);return t}function Zf(){const t=wl(Ef);return t?Ac(t,e=>e.base):Ze("/")}function Jf(){ai(Uf);const t=Zf(),{basepath:e}=wl(zn);return n=>Jc(n,Gn(t),e)}function b1(){ai(qf);const t=Jf(),{navigate:e}=Qf();return(n,i)=>{const o=Df(n)?n:t(n);return e(o,i)}}const k1=t=>({params:t&16,location:t&8}),Sr=t=>({params:yl?Gn(t[10]):t[4],location:t[3],navigate:t[11]});function Pr(t){let e,l;return e=new Vf({props:{primary:t[1],$$slots:{default:[$1]},$$scope:{ctx:t}}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.primary=n[1]),i&528409&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function w1(t){let e;const l=t[18].default,n=Xs(l,t,t[19],Sr);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&524312)&&eo(n,l,i,i[19],e?xs(l,i[19],o,k1):to(i[19]),Sr)},i(i){e||(M(n,i),e=!0)},o(i){I(n,i),e=!1},d(i){n&&n.d(i)}}}function y1(t){let e,l,n;const i=[{location:t[3]},{navigate:t[11]},yl?Gn(t[10]):t[4],t[12]];var o=t[0];function r(a){let c={};for(let f=0;f{Q(p,1)}),Te()}o?(e=new o(r()),Z(e.$$.fragment),M(e.$$.fragment,1),K(e,l.parentNode,l)):e=null}else o&&e.$set(f)},i(a){n||(e&&M(e.$$.fragment,a),n=!0)},o(a){e&&I(e.$$.fragment,a),n=!1},d(a){a&&w(l),e&&Q(e,a)}}}function $1(t){let e,l,n,i;const o=[y1,w1],r=[];function a(c,f){return c[0]!==null?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=je()},m(c,f){r[e].m(c,f),y(c,n,f),i=!0},p(c,f){let p=e;e=a(c),e===p?r[e].p(c,f):(Ce(),I(r[p],1,1,()=>{r[p]=null}),Te(),l=r[e],l?l.p(c,f):(l=r[e]=o[e](c),l.c()),M(l,1),l.m(n.parentNode,n))},i(c){i||(M(l),i=!0)},o(c){I(l),i=!1},d(c){r[e].d(c),c&&w(n)}}}function C1(t){let e,l,n,i,o,r=[Hn(t[7]),{"data-svnav-route-start":t[5]}],a={};for(let _=0;_{c=null}),Te()),zt(i,p=Bn(f,[Hn(_[7]),{"data-svnav-route-end":_[5]}]))},i(_){o||(M(c),o=!0)},o(_){I(c),o=!1},d(_){_&&w(e),_&&w(l),c&&c.d(_),_&&w(n),_&&w(i)}}}const T1=Af();function S1(t,e,l){let n;const i=["path","component","meta","primary"];let o=as(e,i),r,a,c,f,{$$slots:p={},$$scope:_}=e,{path:d=""}=e,{component:g=null}=e,{meta:h={}}=e,{primary:b=!0}=e;ai(ds,e);const $=T1(),{registerRoute:k,unregisterRoute:T,activeRoute:P,disableInlineStyles:E}=wl(zn);Bt(t,P,L=>l(16,r=L));const S=Zf();Bt(t,S,L=>l(17,c=L));const N=Kf();Bt(t,N,L=>l(3,a=L));const A=Ze(null);let R;const H=Ze(),U=Ze({});Bt(t,U,L=>l(4,f=L)),ni(Ef,H),ni(Nc,U),ni(Ic,A);const F=b1();return yl||$c(()=>T($)),t.$$set=L=>{l(24,e=Ot(Ot({},e),rs(L))),l(12,o=as(e,i)),"path"in L&&l(13,d=L.path),"component"in L&&l(0,g=L.component),"meta"in L&&l(14,h=L.meta),"primary"in L&&l(1,b=L.primary),"$$scope"in L&&l(19,_=L.$$scope)},t.$$.update=()=>{if(t.$$.dirty&155658){const L=d==="",G=ri(c,d),j={id:$,path:d,meta:h,default:L,fullPath:L?"":G,base:L?c:Xc(G,a.pathname),primary:b,focusElement:A};H.set(j),l(15,R=k(j))}if(t.$$.dirty&98304&&l(2,n=!!(R||r&&r.id===$)),t.$$.dirty&98308&&n){const{params:L}=R||r;U.set(L)}},e=rs(e),[g,b,n,a,f,$,P,E,S,N,U,F,o,d,h,R,r,c,p,_]}class ol extends $e{constructor(e){super(),ye(this,e,S1,C1,we,{path:13,component:0,meta:14,primary:1})}}function P1(t){let e,l,n,i;const o=t[13].default,r=Xs(o,t,t[12],null);let a=[{href:t[0]},t[2],t[1]],c={};for(let f=0;fl(11,_=A));const P=Cc(),E=Jf(),{navigate:S}=Qf();function N(A){P("click",A),Mc(A)&&(A.preventDefault(),S(n,{state:$,replace:r||b}))}return t.$$set=A=>{l(19,e=Ot(Ot({},e),rs(A))),l(18,p=as(e,f)),"to"in A&&l(5,h=A.to),"replace"in A&&l(6,b=A.replace),"state"in A&&l(7,$=A.state),"getProps"in A&&l(8,k=A.getProps),"$$scope"in A&&l(12,g=A.$$scope)},t.$$.update=()=>{t.$$.dirty&2080&&l(0,n=E(h,_)),t.$$.dirty&2049&&l(10,i=Ws(_.pathname,n)),t.$$.dirty&2049&&l(9,o=n===_.pathname),t.$$.dirty&2049&&(r=so(n)===Zc(_)),t.$$.dirty&512&&l(2,a=o?{"aria-current":"page"}:{}),l(1,c=(()=>{if(Mf(k)){const A=k({location:_,href:n,isPartiallyCurrent:i,isCurrent:o});return{...p,...A}}return p})())},e=rs(e),[n,c,a,T,N,h,b,$,k,o,i,_,g,d]}class kl extends $e{constructor(e){super(),ye(this,e,M1,P1,we,{to:5,replace:6,state:7,getProps:8})}}let Gs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function bl(t){return t===1?"green":t===2?"yellow":t===3?"red":"gray"}function D1(t){return t>218&&t<242?"#32d900":t>212&&t<248?"#b1d900":t>208&&t<252?"#ffb800":"#d90000"}function Xf(t){return t>90?"#d90000":t>85?"#e32100":t>80?"#ffb800":t>75?"#dcd800":"#32d900"}function A1(t){return t>75?"#32d900":t>50?"#77d900":t>25?"#94d900":"#dcd800"}function ms(t){switch(t){case 1:return"Aidon";case 2:return"Kaifa";case 3:return"Kamstrup";case 8:return"Iskra";case 9:return"Landis+Gyr";case 10:return"Sagemcom";default:return""}}function Ne(t){for(t=t.toString();t.length<2;)t="0"+t;return t}function pe(t,e){switch(e){case 5:switch(t){case"esp8266":return"Pow-K (GPIO12)";case"esp32s2":return"Pow-K+"}case 7:switch(t){case"esp8266":return"Pow-U (GPIO12)";case"esp32s2":return"Pow-U+"}case 6:return"Pow-P1";case 51:return"Wemos S2 mini";case 50:return"Generic ESP32-S2";case 201:return"Wemos LOLIN D32";case 202:return"Adafruit HUZZAH32";case 203:return"DevKitC";case 200:return"Generic ESP32";case 2:return"HAN Reader 2.0 by Max Spencer";case 0:return"Custom hardware by Roar Fredriksen";case 1:return"Kamstrup module by Egil Opsahl";case 3:return"Pow-K (UART0)";case 4:return"Pow-U (UART0)";case 101:return"Wemos D1 mini";case 100:return"Generic ESP8266";case 70:return"Generic ESP32-C3";case 71:return"ESP32-C3-DevKitM-1"}}function Mr(t){switch(t){case-1:return"Parse error";case-2:return"Incomplete data received";case-3:return"Payload boundry flag missing";case-4:return"Header checksum error";case-5:return"Footer checksum error";case-9:return"Unknown data received, check meter config";case-41:return"Frame length not equal";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid";case 90:return"No HAN data received last 30s";case 98:return"Exception in code, debugging necessary";case 99:return"Autodetection failed"}return t<0?"Unspecified error "+t:""}function Dr(t){switch(t){case-3:return"Connection failed";case-4:return"Network timeout";case-10:return"Connection denied";case-11:return"Failed to subscribe";case-13:return"Connection lost"}return t<0?"Unspecified error "+t:""}function Ar(t){switch(t){case 401:case 403:return"Unauthorized, check API key";case 404:return"Price unavailable, not found";case 425:return"Server says its too early";case 500:return"Internal server error";case-2:return"Incomplete data received";case-3:return"Invalid data, tag missing";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid"}return t<0?"Unspecified error "+t:""}function Wn(t){switch(t){case 2:case 4:case 7:return!0}return!1}function He(t,e){return t==1||t==2&&e}function $t(t){return"https://github.com/UtilitechAS/amsreader-firmware/wiki/"+t}function ke(t,e){return isNaN(t)?"-":(isNaN(e)&&(e=t<10?1:0),t.toFixed(e))}function ii(t,e){return t.setTime(t.getTime()+e*36e5),t}function Nr(t){if(t.chip=="esp8266")switch(t.boot_reason){case 0:return"Normal";case 1:return"WDT reset";case 2:return"Exception reset";case 3:return"Soft WDT reset";case 4:return"Software restart";case 5:return"Deep sleep";case 6:return"External reset";default:return"Unknown (8266)"}else switch(t.boot_reason){case 1:return"Normal";case 3:return"Software reset";case 4:return"WDT reset";case 5:return"Deep sleep";case 6:return"SLC reset";case 7:return"Timer Group0 WDT reset";case 8:return"Timer Group1 WDT reset";case 9:return"RTC WDT reset";case 10:return"Instrusion test reset";case 11:return"Time Group reset";case 12:return"Software reset CPU";case 13:return"RTC WTD reset CPU";case 14:return"PRO CPU";case 15:return"Unstable Vdd";case 16:return"RTC reset";default:return"Unknown"}}async function $l(t,e={}){const{timeout:l=8e3}=e,n=new AbortController,i=setTimeout(()=>n.abort(),l),o=await fetch(t,{...e,signal:n.signal});return clearTimeout(i),o}let Gt={version:"",chip:"",mac:null,apmac:null,vndcfg:null,usrcfg:null,fwconsent:null,booting:!1,upgrading:!1,ui:{},security:0,trying:null};const Ct=Ze(Gt);async function oo(){Gt=await(await $l("/sysinfo.json?t="+Math.floor(Date.now()/1e3))).json(),Ct.set(Gt)}let is=0,Ir=-127,Er=null,N1={};const I1=If(N1,t=>{let e;async function l(){$l("/data.json").then(n=>n.json()).then(n=>{t(n),Ir!=n.t&&(Ir=n.t,setTimeout(lc,2e3)),Er!=n.p&&(Er=n.p,setTimeout(E1,4e3)),Gt.upgrading?window.location.reload():(!Gt||!Gt.chip||Gt.booting||is>1&&!Wn(Gt.board))&&(oo(),zl&&clearTimeout(zl),zl=setTimeout(uo,2e3),Yl&&clearTimeout(Yl),Yl=setTimeout(ro,3e3));let i=5e3;if(Wn(Gt.board)&&n.v>2.5){let o=3.3-Math.min(3.3,n.v);o>0&&(i=Math.max(o,.1)*10*5e3)}i>5e3&&console.log("Scheduling next data fetch in "+i+"ms"),e&&clearTimeout(e),e=setTimeout(l,i),is=0}).catch(n=>{is++,is>3?(t({em:3,hm:0,wm:0,mm:0}),e=setTimeout(l,15e3)):e=setTimeout(l,Wn(Gt.board)?1e4:5e3)})}return l(),function(){clearTimeout(e)}});let Bs={};const xf=Ze(Bs);async function E1(){Bs=await(await $l("/energyprice.json")).json(),xf.set(Bs)}let zs={},zl;async function uo(){zl&&(clearTimeout(zl),zl=0),zs=await(await $l("/dayplot.json")).json(),ec.set(zs);let e=new Date;zl=setTimeout(uo,(60-e.getMinutes())*6e4+20)}const ec=Ze(zs,t=>(uo(),function(){}));let Ys={},Yl;async function ro(){Yl&&(clearTimeout(Yl),Yl=0),Ys=await(await $l("/monthplot.json")).json(),tc.set(Ys);let e=new Date;Yl=setTimeout(ro,(24-e.getHours())*36e5+40)}const tc=Ze(Ys,t=>(ro(),function(){}));let Vs={};async function lc(){Vs=await(await $l("/temperature.json")).json(),nc.set(Vs)}const nc=Ze(Vs,t=>(lc(),function(){}));let Ks={},ss;async function ic(){ss&&(clearTimeout(ss),ss=0),Ks=await(await $l("/tariff.json")).json(),sc.set(Ks);let e=new Date;ss=setTimeout(ic,(60-e.getMinutes())*6e4+30)}const sc=Ze(Ks,t=>function(){});let Qs=[];const ao=Ze(Qs);async function R1(){Qs=await(await $l("https://api.github.com/repos/UtilitechAS/amsreader-firmware/releases")).json(),ao.set(Qs)}function ps(t){return"WARNING: "+t+" must be connected to an external power supply during firmware upgrade. Failure to do so may cause power-down during upload resulting in non-functioning unit."}async function oc(){await(await fetch("/upgrade",{method:"POST"})).json()}function uc(t,e){if(/^v\d{1,2}\.\d{1,2}\.\d{1,2}$/.test(t)){let l=t.substring(1).split("."),n=parseInt(l[0]),i=parseInt(l[1]),o=parseInt(l[2]),r=[...e];r.reverse();let a,c,f;for(let p=0;po&&(a=_):b==i+1&&(c=_);else if(h==n+1)if(f){let k=f.tag_name.substring(1).split(".");parseInt(k[0]);let T=parseInt(k[1]);parseInt(k[2]),b==T&&(f=_)}else f=_}return c||f||a||!1}else return e[0]}const F1="/github.svg";function Rr(t){let e,l;function n(r,a){return r[1]>1?W1:r[1]>0?j1:r[2]>1?H1:r[2]>0?U1:r[3]>1?q1:r[3]>0?O1:L1}let i=n(t),o=i(t);return{c(){e=C(`Up + `),o.c(),l=je()},m(r,a){y(r,e,a),o.m(r,a),y(r,l,a)},p(r,a){i===(i=n(r))&&o?o.p(r,a):(o.d(1),o=i(r),o&&(o.c(),o.m(l.parentNode,l)))},d(r){r&&w(e),o.d(r),r&&w(l)}}}function L1(t){let e,l;return{c(){e=C(t[0]),l=C(" seconds")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&1&&B(e,n[0])},d(n){n&&w(e),n&&w(l)}}}function O1(t){let e,l;return{c(){e=C(t[3]),l=C(" minute")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&8&&B(e,n[3])},d(n){n&&w(e),n&&w(l)}}}function q1(t){let e,l;return{c(){e=C(t[3]),l=C(" minutes")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&8&&B(e,n[3])},d(n){n&&w(e),n&&w(l)}}}function U1(t){let e,l;return{c(){e=C(t[2]),l=C(" hour")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&4&&B(e,n[2])},d(n){n&&w(e),n&&w(l)}}}function H1(t){let e,l;return{c(){e=C(t[2]),l=C(" hours")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&4&&B(e,n[2])},d(n){n&&w(e),n&&w(l)}}}function j1(t){let e,l;return{c(){e=C(t[1]),l=C(" day")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&2&&B(e,n[1])},d(n){n&&w(e),n&&w(l)}}}function W1(t){let e,l;return{c(){e=C(t[1]),l=C(" days")},m(n,i){y(n,e,i),y(n,l,i)},p(n,i){i&2&&B(e,n[1])},d(n){n&&w(e),n&&w(l)}}}function G1(t){let e,l=t[0]&&Rr(t);return{c(){l&&l.c(),e=je()},m(n,i){l&&l.m(n,i),y(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=Rr(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:ie,o:ie,d(n){l&&l.d(n),n&&w(e)}}}function B1(t,e,l){let{epoch:n}=e,i=0,o=0,r=0;return t.$$set=a=>{"epoch"in a&&l(0,n=a.epoch)},t.$$.update=()=>{t.$$.dirty&1&&(l(1,i=Math.floor(n/86400)),l(2,o=Math.floor(n/3600)),l(3,r=Math.floor(n/60)))},[n,i,o,r]}class z1 extends $e{constructor(e){super(),ye(this,e,B1,G1,we,{epoch:0})}}function Y1(t){let e,l,n;return{c(){e=m("span"),l=C(t[2]),u(e,"title",t[1]),u(e,"class",n="bd-"+t[0])},m(i,o){y(i,e,o),s(e,l)},p(i,[o]){o&4&&B(l,i[2]),o&2&&u(e,"title",i[1]),o&1&&n!==(n="bd-"+i[0])&&u(e,"class",n)},i:ie,o:ie,d(i){i&&w(e)}}}function V1(t,e,l){let{color:n}=e,{title:i}=e,{text:o}=e;return t.$$set=r=>{"color"in r&&l(0,n=r.color),"title"in r&&l(1,i=r.title),"text"in r&&l(2,o=r.text)},[n,i,o]}class Yt extends $e{constructor(e){super(),ye(this,e,V1,Y1,we,{color:0,title:1,text:2})}}function K1(t){let e,l=`${Ne(t[0].getDate())}.${Ne(t[0].getMonth())}.${t[0].getFullYear()} ${Ne(t[0].getHours())}:${Ne(t[0].getMinutes())}`,n;return{c(){e=m("span"),n=C(l),u(e,"class",t[1])},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=`${Ne(i[0].getDate())}.${Ne(i[0].getMonth())}.${i[0].getFullYear()} ${Ne(i[0].getHours())}:${Ne(i[0].getMinutes())}`)&&B(n,l),o&2&&u(e,"class",i[1])},d(i){i&&w(e)}}}function Q1(t){let e=`${Ne(t[0].getDate())}. ${Gs[t[0].getMonth()]} ${Ne(t[0].getHours())}:${Ne(t[0].getMinutes())}`,l;return{c(){l=C(e)},m(n,i){y(n,l,i)},p(n,i){i&1&&e!==(e=`${Ne(n[0].getDate())}. ${Gs[n[0].getMonth()]} ${Ne(n[0].getHours())}:${Ne(n[0].getMinutes())}`)&&B(l,e)},d(n){n&&w(l)}}}function Z1(t){let e,l;function n(r,a){return a&1&&(e=null),e==null&&(e=Math.abs(new Date().getTime()-r[0].getTime())<3e5),e?Q1:K1}let i=n(t,-1),o=i(t);return{c(){o.c(),l=je()},m(r,a){o.m(r,a),y(r,l,a)},p(r,[a]){i===(i=n(r,a))&&o?o.p(r,a):(o.d(1),o=i(r),o&&(o.c(),o.m(l.parentNode,l)))},i:ie,o:ie,d(r){o.d(r),r&&w(l)}}}function J1(t,e,l){let{timestamp:n}=e,{fullTimeColor:i}=e;return t.$$set=o=>{"timestamp"in o&&l(0,n=o.timestamp),"fullTimeColor"in o&&l(1,i=o.fullTimeColor)},[n,i]}class rc extends $e{constructor(e){super(),ye(this,e,J1,Z1,we,{timestamp:0,fullTimeColor:1})}}function X1(t){let e,l,n;return{c(){e=Oe("svg"),l=Oe("path"),n=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"),u(n,"stroke-linecap","round"),u(n,"stroke-linejoin","round"),u(n,"d","M15 12a3 3 0 11-6 0 3 3 0 016 0z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(i,o){y(i,e,o),s(e,l),s(e,n)},p:ie,i:ie,o:ie,d(i){i&&w(e)}}}class x1 extends $e{constructor(e){super(),ye(this,e,null,X1,we,{})}}function em(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){y(n,e,i),s(e,l)},p:ie,i:ie,o:ie,d(n){n&&w(e)}}}class tm extends $e{constructor(e){super(),ye(this,e,null,em,we,{})}}function lm(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){y(n,e,i),s(e,l)},p:ie,i:ie,o:ie,d(n){n&&w(e)}}}class yt extends $e{constructor(e){super(),ye(this,e,null,lm,we,{})}}function nm(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15M9 12l3 3m0 0l3-3m-3 3V2.25"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){y(n,e,i),s(e,l)},p:ie,i:ie,o:ie,d(n){n&&w(e)}}}class ac extends $e{constructor(e){super(),ye(this,e,null,nm,we,{})}}function im(t){let e,l,n=t[1].version+"",i;return{c(){e=C("AMS reader "),l=m("span"),i=C(n)},m(o,r){y(o,e,r),y(o,l,r),s(l,i)},p(o,r){r&2&&n!==(n=o[1].version+"")&&B(i,n)},d(o){o&&w(e),o&&w(l)}}}function Fr(t){let e,l=(t[0].t>-50?t[0].t.toFixed(1):"-")+"",n,i;return{c(){e=m("div"),n=C(l),i=C("\xB0C"),u(e,"class","flex-none my-auto")},m(o,r){y(o,e,r),s(e,n),s(e,i)},p(o,r){r&1&&l!==(l=(o[0].t>-50?o[0].t.toFixed(1):"-")+"")&&B(n,l)},d(o){o&&w(e)}}}function Lr(t){let e,l="HAN: "+Mr(t[0].he),n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="HAN: "+Mr(i[0].he))&&B(n,l)},d(i){i&&w(e)}}}function Or(t){let e,l="MQTT: "+Dr(t[0].me),n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="MQTT: "+Dr(i[0].me))&&B(n,l)},d(i){i&&w(e)}}}function qr(t){let e,l="PriceAPI: "+Ar(t[0].ee),n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="PriceAPI: "+Ar(i[0].ee))&&B(n,l)},d(i){i&&w(e)}}}function Ur(t){let e,l,n,i,o,r;return l=new kl({props:{to:"/configuration",$$slots:{default:[sm]},$$scope:{ctx:t}}}),o=new kl({props:{to:"/status",$$slots:{default:[om]},$$scope:{ctx:t}}}),{c(){e=m("div"),Z(l.$$.fragment),n=v(),i=m("div"),Z(o.$$.fragment),u(e,"class","flex-none px-1 mt-1"),u(e,"title","Configuration"),u(i,"class","flex-none px-1 mt-1"),u(i,"title","Device information")},m(a,c){y(a,e,c),K(l,e,null),y(a,n,c),y(a,i,c),K(o,i,null),r=!0},i(a){r||(M(l.$$.fragment,a),M(o.$$.fragment,a),r=!0)},o(a){I(l.$$.fragment,a),I(o.$$.fragment,a),r=!1},d(a){a&&w(e),Q(l),a&&w(n),a&&w(i),Q(o)}}}function sm(t){let e,l;return e=new x1({}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function om(t){let e,l;return e=new tm({}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function Hr(t){let e,l,n,i,o;const r=[rm,um],a=[];function c(f,p){return f[1].security==0||f[0].a?0:1}return l=c(t),n=a[l]=r[l](t),{c(){e=m("div"),n.c(),u(e,"class","flex-none mr-3 text-yellow-500"),u(e,"title",i="New version: "+t[2].tag_name)},m(f,p){y(f,e,p),a[l].m(e,null),o=!0},p(f,p){let _=l;l=c(f),l===_?a[l].p(f,p):(Ce(),I(a[_],1,1,()=>{a[_]=null}),Te(),n=a[l],n?n.p(f,p):(n=a[l]=r[l](f),n.c()),M(n,1),n.m(e,null)),(!o||p&4&&i!==(i="New version: "+f[2].tag_name))&&u(e,"title",i)},i(f){o||(M(n),o=!0)},o(f){I(n),o=!1},d(f){f&&w(e),a[l].d()}}}function um(t){let e,l,n=t[2].tag_name+"",i;return{c(){e=m("span"),l=C("New version: "),i=C(n)},m(o,r){y(o,e,r),s(e,l),s(e,i)},p(o,r){r&4&&n!==(n=o[2].tag_name+"")&&B(i,n)},i:ie,o:ie,d(o){o&&w(e)}}}function rm(t){let e,l,n,i=t[2].tag_name+"",o,r,a,c,f,p;return a=new ac({}),{c(){e=m("button"),l=m("span"),n=C("New version: "),o=C(i),r=v(),Z(a.$$.fragment),u(l,"class","mt-1"),u(e,"class","flex")},m(_,d){y(_,e,d),s(e,l),s(l,n),s(l,o),s(e,r),K(a,e,null),c=!0,f||(p=V(e,"click",t[3]),f=!0)},p(_,d){(!c||d&4)&&i!==(i=_[2].tag_name+"")&&B(o,i)},i(_){c||(M(a.$$.fragment,_),c=!0)},o(_){I(a.$$.fragment,_),c=!1},d(_){_&&w(e),Q(a),f=!1,p()}}}function am(t){let e,l,n,i,o,r,a,c,f,p,_,d,g=(t[0].m?(t[0].m/1e3).toFixed(1):"-")+"",h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G,j,O,q,W,X,z,ne,te,De,_e,Ie,Ee,Le,Re;i=new kl({props:{to:"/",$$slots:{default:[im]},$$scope:{ctx:t}}}),c=new z1({props:{epoch:t[0].u}});let Se=t[0].t>-50&&Fr(t);T=new Yt({props:{title:"ESP",text:t[1].booting?"Booting":t[0].v>2?t[0].v.toFixed(2)+"V":"ESP",color:bl(t[1].booting?2:t[0].em)}}),E=new Yt({props:{title:"HAN",text:"HAN",color:bl(t[1].booting?9:t[0].hm)}}),N=new Yt({props:{title:"WiFi",text:t[0].r?t[0].r.toFixed(0)+"dBm":"WiFi",color:bl(t[1].booting?9:t[0].wm)}}),R=new Yt({props:{title:"MQTT",text:"MQTT",color:bl(t[1].booting?9:t[0].mm)}});let be=(t[0].he<0||t[0].he>0)&&Lr(t),fe=t[0].me<0&&Or(t),ae=(t[0].ee>0||t[0].ee<0)&&qr(t);ne=new rc({props:{timestamp:t[0].c?new Date(t[0].c*1e3):new Date(0),fullTimeColor:"text-red-500"}});let ce=t[1].vndcfg&&t[1].usrcfg&&Ur(t);Ee=new yt({});let ue=t[1].fwconsent===1&&t[2]&&Hr(t);return{c(){e=m("nav"),l=m("div"),n=m("div"),Z(i.$$.fragment),o=v(),r=m("div"),a=m("div"),Z(c.$$.fragment),f=v(),Se&&Se.c(),p=v(),_=m("div"),d=C("Free mem: "),h=C(g),b=C("kb"),$=v(),k=m("div"),Z(T.$$.fragment),P=v(),Z(E.$$.fragment),S=v(),Z(N.$$.fragment),A=v(),Z(R.$$.fragment),H=v(),be&&be.c(),U=v(),fe&&fe.c(),F=v(),ae&&ae.c(),L=v(),G=m("div"),j=m("div"),O=m("a"),q=m("img"),X=v(),z=m("div"),Z(ne.$$.fragment),te=v(),ce&&ce.c(),De=v(),_e=m("div"),Ie=m("a"),Z(Ee.$$.fragment),Le=v(),ue&&ue.c(),u(n,"class","flex text-lg text-gray-100 p-2"),u(a,"class","flex-none my-auto"),u(_,"class","flex-none my-auto"),u(r,"class","flex-none my-auto p-2 flex space-x-4"),u(k,"class","flex-auto flex-wrap my-auto justify-center p-2"),u(q,"class","gh-logo"),vc(q.src,W=F1)||u(q,"src",W),u(q,"alt","GitHub repo"),u(O,"class","float-right"),u(O,"href","https://github.com/UtilitechAS/amsreader-firmware"),u(O,"target","_blank"),u(O,"rel","noreferrer"),u(O,"aria-label","GitHub"),u(j,"class","flex-none"),u(z,"class","flex-none my-auto px-2"),u(Ie,"href",$t("")),u(Ie,"target","_blank"),u(Ie,"rel","noreferrer"),u(_e,"class","flex-none px-1 mt-1"),u(_e,"title","Documentation"),u(G,"class","flex-auto p-2 flex flex-row-reverse flex-wrap"),u(l,"class","flex flex-wrap space-x-4 text-sm text-gray-300"),u(e,"class","bg-violet-600 p-1 rounded-md mx-2")},m(J,se){y(J,e,se),s(e,l),s(l,n),K(i,n,null),s(l,o),s(l,r),s(r,a),K(c,a,null),s(r,f),Se&&Se.m(r,null),s(r,p),s(r,_),s(_,d),s(_,h),s(_,b),s(l,$),s(l,k),K(T,k,null),s(k,P),K(E,k,null),s(k,S),K(N,k,null),s(k,A),K(R,k,null),s(l,H),be&&be.m(l,null),s(l,U),fe&&fe.m(l,null),s(l,F),ae&&ae.m(l,null),s(l,L),s(l,G),s(G,j),s(j,O),s(O,q),s(G,X),s(G,z),K(ne,z,null),s(G,te),ce&&ce.m(G,null),s(G,De),s(G,_e),s(_e,Ie),K(Ee,Ie,null),s(G,Le),ue&&ue.m(G,null),Re=!0},p(J,[se]){const Pe={};se&18&&(Pe.$$scope={dirty:se,ctx:J}),i.$set(Pe);const ee={};se&1&&(ee.epoch=J[0].u),c.$set(ee),J[0].t>-50?Se?Se.p(J,se):(Se=Fr(J),Se.c(),Se.m(r,p)):Se&&(Se.d(1),Se=null),(!Re||se&1)&&g!==(g=(J[0].m?(J[0].m/1e3).toFixed(1):"-")+"")&&B(h,g);const oe={};se&3&&(oe.text=J[1].booting?"Booting":J[0].v>2?J[0].v.toFixed(2)+"V":"ESP"),se&3&&(oe.color=bl(J[1].booting?2:J[0].em)),T.$set(oe);const Ue={};se&3&&(Ue.color=bl(J[1].booting?9:J[0].hm)),E.$set(Ue);const Me={};se&1&&(Me.text=J[0].r?J[0].r.toFixed(0)+"dBm":"WiFi"),se&3&&(Me.color=bl(J[1].booting?9:J[0].wm)),N.$set(Me);const de={};se&3&&(de.color=bl(J[1].booting?9:J[0].mm)),R.$set(de),J[0].he<0||J[0].he>0?be?be.p(J,se):(be=Lr(J),be.c(),be.m(l,U)):be&&(be.d(1),be=null),J[0].me<0?fe?fe.p(J,se):(fe=Or(J),fe.c(),fe.m(l,F)):fe&&(fe.d(1),fe=null),J[0].ee>0||J[0].ee<0?ae?ae.p(J,se):(ae=qr(J),ae.c(),ae.m(l,L)):ae&&(ae.d(1),ae=null);const ve={};se&1&&(ve.timestamp=J[0].c?new Date(J[0].c*1e3):new Date(0)),ne.$set(ve),J[1].vndcfg&&J[1].usrcfg?ce?se&2&&M(ce,1):(ce=Ur(J),ce.c(),M(ce,1),ce.m(G,De)):ce&&(Ce(),I(ce,1,1,()=>{ce=null}),Te()),J[1].fwconsent===1&&J[2]?ue?(ue.p(J,se),se&6&&M(ue,1)):(ue=Hr(J),ue.c(),M(ue,1),ue.m(G,null)):ue&&(Ce(),I(ue,1,1,()=>{ue=null}),Te())},i(J){Re||(M(i.$$.fragment,J),M(c.$$.fragment,J),M(T.$$.fragment,J),M(E.$$.fragment,J),M(N.$$.fragment,J),M(R.$$.fragment,J),M(ne.$$.fragment,J),M(ce),M(Ee.$$.fragment,J),M(ue),Re=!0)},o(J){I(i.$$.fragment,J),I(c.$$.fragment,J),I(T.$$.fragment,J),I(E.$$.fragment,J),I(N.$$.fragment,J),I(R.$$.fragment,J),I(ne.$$.fragment,J),I(ce),I(Ee.$$.fragment,J),I(ue),Re=!1},d(J){J&&w(e),Q(i),Q(c),Se&&Se.d(),Q(T),Q(E),Q(N),Q(R),be&&be.d(),fe&&fe.d(),ae&&ae.d(),Q(ne),ce&&ce.d(),Q(Ee),ue&&ue.d()}}}function fm(t,e,l){let{data:n={}}=e,i={},o={};function r(){confirm("Do you want to upgrade this device to "+o.tag_name+"?")&&(!Wn(i.board)||confirm(ps(pe(i.chip,i.board))))&&(Ct.update(a=>(a.upgrading=!0,a)),oc())}return Ct.subscribe(a=>{l(1,i=a),a.fwconsent===1&&R1()}),ao.subscribe(a=>{l(2,o=uc(i.version,a))}),t.$$set=a=>{"data"in a&&l(0,n=a.data)},[n,i,o,r]}class cm extends $e{constructor(e){super(),ye(this,e,fm,am,we,{data:0})}}function mm(t){let e,l,n,i;return{c(){e=Oe("svg"),l=Oe("path"),n=Oe("path"),u(l,"d",qs(150,150,115,210,510)),u(l,"stroke","#eee"),u(l,"fill","none"),u(l,"stroke-width","55"),u(n,"d",i=qs(150,150,115,210,210+300*t[0]/100)),u(n,"stroke",t[1]),u(n,"fill","none"),u(n,"stroke-width","55"),u(e,"viewBox","0 0 300 300"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"height","100%")},m(o,r){y(o,e,r),s(e,l),s(e,n)},p(o,[r]){r&1&&i!==(i=qs(150,150,115,210,210+300*o[0]/100))&&u(n,"d",i),r&2&&u(n,"stroke",o[1])},i:ie,o:ie,d(o){o&&w(e)}}}function jr(t,e,l,n){var i=(n-90)*Math.PI/180;return{x:t+l*Math.cos(i),y:e+l*Math.sin(i)}}function qs(t,e,l,n,i){var o=jr(t,e,l,i),r=jr(t,e,l,n),a=i-n<=180?"0":"1",c=["M",o.x,o.y,"A",l,l,0,a,0,r.x,r.y].join(" ");return c}function pm(t,e,l){let{pct:n=0}=e,{color:i="red"}=e;return t.$$set=o=>{"pct"in o&&l(0,n=o.pct),"color"in o&&l(1,i=o.color)},[n,i]}class _m extends $e{constructor(e){super(),ye(this,e,pm,mm,we,{pct:0,color:1})}}function Wr(t){let e,l,n,i,o,r,a,c;return{c(){e=m("br"),l=v(),n=m("span"),i=C(t[3]),o=v(),r=m("span"),a=C(t[4]),c=C("/kWh"),u(n,"class","pl-sub"),u(r,"class","pl-snt")},m(f,p){y(f,e,p),y(f,l,p),y(f,n,p),s(n,i),y(f,o,p),y(f,r,p),s(r,a),s(r,c)},p(f,p){p&8&&B(i,f[3]),p&16&&B(a,f[4])},d(f){f&&w(e),f&&w(l),f&&w(n),f&&w(o),f&&w(r)}}}function dm(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$;l=new _m({props:{pct:t[6],color:t[5](t[6])}});let k=t[3]&&Wr(t);return{c(){e=m("div"),Z(l.$$.fragment),n=v(),i=m("span"),o=m("span"),r=C(t[2]),a=v(),c=m("br"),f=v(),p=m("span"),_=C(t[0]),d=v(),g=m("span"),h=C(t[1]),b=v(),k&&k.c(),u(o,"class","pl-lab"),u(p,"class","pl-val"),u(g,"class","pl-unt"),u(i,"class","pl-ov"),u(e,"class","pl-root")},m(T,P){y(T,e,P),K(l,e,null),s(e,n),s(e,i),s(i,o),s(o,r),s(i,a),s(i,c),s(i,f),s(i,p),s(p,_),s(i,d),s(i,g),s(g,h),s(i,b),k&&k.m(i,null),$=!0},p(T,[P]){const E={};P&64&&(E.pct=T[6]),P&96&&(E.color=T[5](T[6])),l.$set(E),(!$||P&4)&&B(r,T[2]),(!$||P&1)&&B(_,T[0]),(!$||P&2)&&B(h,T[1]),T[3]?k?k.p(T,P):(k=Wr(T),k.c(),k.m(i,null)):k&&(k.d(1),k=null)},i(T){$||(M(l.$$.fragment,T),$=!0)},o(T){I(l.$$.fragment,T),$=!1},d(T){T&&w(e),Q(l),k&&k.d()}}}function vm(t,e,l){let{val:n}=e,{max:i}=e,{unit:o}=e,{label:r}=e,{sub:a=""}=e,{subunit:c=""}=e,{colorFn:f}=e,p=0;return t.$$set=_=>{"val"in _&&l(0,n=_.val),"max"in _&&l(7,i=_.max),"unit"in _&&l(1,o=_.unit),"label"in _&&l(2,r=_.label),"sub"in _&&l(3,a=_.sub),"subunit"in _&&l(4,c=_.subunit),"colorFn"in _&&l(5,f=_.colorFn)},t.$$.update=()=>{t.$$.dirty&129&&l(6,p=Math.min(n,i)/i*100)},[n,o,r,a,c,f,p,i]}class fc extends $e{constructor(e){super(),ye(this,e,vm,dm,we,{val:0,max:7,unit:1,label:2,sub:3,subunit:4,colorFn:5})}}function Gr(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function Br(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function zr(t,e,l){const n=t.slice();return n[13]=e[l],n}function Yr(t){let e,l=t[0].title+"",n;return{c(){e=m("strong"),n=C(l),u(e,"class","text-sm")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=i[0].title+"")&&B(n,l)},d(i){i&&w(e)}}}function Vr(t){let e,l,n,i=t[13].label+"",o,r,a,c;return{c(){e=Oe("g"),l=Oe("line"),n=Oe("text"),o=C(i),u(l,"x2","100%"),u(n,"y","-4"),u(n,"x",r=t[13].align=="right"?"85%":""),u(e,"class",a="tick tick-"+t[13].value+" tick-"+t[13].color),u(e,"transform",c="translate(0, "+t[6](t[13].value)+")")},m(f,p){y(f,e,p),s(e,l),s(e,n),s(n,o)},p(f,p){p&1&&i!==(i=f[13].label+"")&&B(o,i),p&1&&r!==(r=f[13].align=="right"?"85%":"")&&u(n,"x",r),p&1&&a!==(a="tick tick-"+f[13].value+" tick-"+f[13].color)&&u(e,"class",a),p&65&&c!==(c="translate(0, "+f[6](f[13].value)+")")&&u(e,"transform",c)},d(f){f&&w(e)}}}function Kr(t){let e,l,n=t[9].label+"",i,o,r;return{c(){e=Oe("g"),l=Oe("text"),i=C(n),u(l,"x",o=t[3]/2),u(l,"y","-4"),u(e,"class","tick"),u(e,"transform",r="translate("+t[5](t[11])+","+t[4]+")")},m(a,c){y(a,e,c),s(e,l),s(l,i)},p(a,c){c&1&&n!==(n=a[9].label+"")&&B(i,n),c&8&&o!==(o=a[3]/2)&&u(l,"x",o),c&48&&r!==(r="translate("+a[5](a[11])+","+a[4]+")")&&u(e,"transform",r)},d(a){a&&w(e)}}}function Qr(t){let e,l,n,i,o,r,a,c=t[3]>15&&Zr(t);return{c(){e=Oe("rect"),c&&c.c(),a=je(),u(e,"x",l=t[5](t[11])+2),u(e,"y",n=t[6](t[9].value)),u(e,"width",i=t[3]-4),u(e,"height",o=t[6](t[0].y.min)-t[6](Math.min(t[0].y.min,0)+t[9].value)),u(e,"fill",r=t[9].color)},m(f,p){y(f,e,p),c&&c.m(f,p),y(f,a,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&u(e,"x",l),p&65&&n!==(n=f[6](f[9].value))&&u(e,"y",n),p&8&&i!==(i=f[3]-4)&&u(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](Math.min(f[0].y.min,0)+f[9].value))&&u(e,"height",o),p&1&&r!==(r=f[9].color)&&u(e,"fill",r),f[3]>15?c?c.p(f,p):(c=Zr(f),c.c(),c.m(a.parentNode,a)):c&&(c.d(1),c=null)},d(f){f&&w(e),c&&c.d(f),f&&w(a)}}}function Zr(t){let e,l=t[9].label+"",n,i,o,r,a,c,f;return{c(){e=Oe("text"),n=C(l),u(e,"y",i=t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+10),u(e,"x",o=t[5](t[11])+t[3]/2),u(e,"width",r=t[3]-4),u(e,"dominant-baseline","middle"),u(e,"text-anchor",a=t[3]<25?"left":"middle"),u(e,"fill",c=t[6](t[9].value)>t[6](0)-t[7]?t[9].color:"white"),u(e,"transform",f="rotate("+(t[3]<25?90:0)+", "+(t[5](t[11])+t[3]/2)+", "+(t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+9)+")")},m(p,_){y(p,e,_),s(e,n)},p(p,_){_&1&&l!==(l=p[9].label+"")&&B(n,l),_&193&&i!==(i=p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+10)&&u(e,"y",i),_&40&&o!==(o=p[5](p[11])+p[3]/2)&&u(e,"x",o),_&8&&r!==(r=p[3]-4)&&u(e,"width",r),_&8&&a!==(a=p[3]<25?"left":"middle")&&u(e,"text-anchor",a),_&193&&c!==(c=p[6](p[9].value)>p[6](0)-p[7]?p[9].color:"white")&&u(e,"fill",c),_&233&&f!==(f="rotate("+(p[3]<25?90:0)+", "+(p[5](p[11])+p[3]/2)+", "+(p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+9)+")")&&u(e,"transform",f)},d(p){p&&w(e)}}}function Jr(t){let e,l,n,i,o,r,a,c=t[3]>15&&Xr(t);return{c(){e=Oe("rect"),c&&c.c(),a=je(),u(e,"x",l=t[5](t[11])+2),u(e,"y",n=t[6](0)),u(e,"width",i=t[3]-4),u(e,"height",o=t[6](t[0].y.min)-t[6](t[0].y.min+t[9].value2)),u(e,"fill",r=t[9].color)},m(f,p){y(f,e,p),c&&c.m(f,p),y(f,a,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&u(e,"x",l),p&64&&n!==(n=f[6](0))&&u(e,"y",n),p&8&&i!==(i=f[3]-4)&&u(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](f[0].y.min+f[9].value2))&&u(e,"height",o),p&1&&r!==(r=f[9].color)&&u(e,"fill",r),f[3]>15?c?c.p(f,p):(c=Xr(f),c.c(),c.m(a.parentNode,a)):c&&(c.d(1),c=null)},d(f){f&&w(e),c&&c.d(f),f&&w(a)}}}function Xr(t){let e,l=t[9].label2+"",n,i,o,r,a,c,f;return{c(){e=Oe("text"),n=C(l),u(e,"y",i=t[6](-t[9].value2)t[6](0)-12?t[6](t[9].value2-t[0].y.min)-12:t[6](t[9].value2-t[0].y.min)+9)+")")},m(p,_){y(p,e,_),s(e,n)},p(p,_){_&1&&l!==(l=p[9].label2+"")&&B(n,l),_&65&&i!==(i=p[6](-p[9].value2)p[6](0)-12?p[6](p[9].value2-p[0].y.min)-12:p[6](p[9].value2-p[0].y.min)+9)+")")&&u(e,"transform",f)},d(p){p&&w(e)}}}function xr(t){let e,l,n=t[9].value!==void 0&&Qr(t),i=t[9].value2>1e-4&&Jr(t);return{c(){n&&n.c(),e=je(),i&&i.c(),l=je()},m(o,r){n&&n.m(o,r),y(o,e,r),i&&i.m(o,r),y(o,l,r)},p(o,r){o[9].value!==void 0?n?n.p(o,r):(n=Qr(o),n.c(),n.m(e.parentNode,e)):n&&(n.d(1),n=null),o[9].value2>1e-4?i?i.p(o,r):(i=Jr(o),i.c(),i.m(l.parentNode,l)):i&&(i.d(1),i=null)},d(o){n&&n.d(o),o&&w(e),i&&i.d(o),o&&w(l)}}}function hm(t){let e,l,n,i,o,r,a,c=t[0].title&&Yr(t),f=t[0].y.ticks,p=[];for(let b=0;bt[8].call(e))},m(b,$){y(b,e,$),c&&c.m(e,null),s(e,l),s(e,n),s(n,i);for(let k=0;k{"config"in d&&l(0,n=d.config)},t.$$.update=()=>{if(t.$$.dirty&31){l(4,f=o-(n.title?20:0));let d=i-(n.padding.left+n.padding.right);l(3,r=d/n.points.length),l(7,p=r<25?28:17);let g=(f-n.padding.top-n.padding.bottom)/(n.y.max-n.y.min);l(5,a=function(h){return h*r+n.padding.left}),l(6,c=function(h){let b=0;return h>n.y.max?b=n.padding.bottom:hf||b<0?0:b})}},[n,i,o,r,f,a,c,p,_]}class Kl extends $e{constructor(e){super(),ye(this,e,gm,hm,we,{config:0})}}function bm(t){let e,l;return e=new Kl({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function km(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{ds:r}=e,a={};function c(f){return{label:ke(f)+"V",value:isNaN(f)?0:f,color:D1(f||0)}}return t.$$set=f=>{"u1"in f&&l(1,n=f.u1),"u2"in f&&l(2,i=f.u2),"u3"in f&&l(3,o=f.u3),"ds"in f&&l(4,r=f.ds)},t.$$.update=()=>{if(t.$$.dirty&30){let f=[],p=[];n>0&&(f.push({label:r===1?"L1-L2":"L1"}),p.push(c(n))),i>0&&(f.push({label:r===1?"L1-L3":"L2"}),p.push(c(i))),o>0&&(f.push({label:r===1?"L2-L3":"L3"}),p.push(c(o))),l(0,a={padding:{top:20,right:15,bottom:20,left:35},y:{min:200,max:260,ticks:[{value:207,label:"-10%"},{value:230,label:"230v"},{value:253,label:"+10%"}]},x:{ticks:f},points:p})}},[a,n,i,o,r]}class wm extends $e{constructor(e){super(),ye(this,e,km,bm,we,{u1:1,u2:2,u3:3,ds:4})}}function ym(t){let e,l;return e=new Kl({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function $m(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{i1:r}=e,{i2:a}=e,{i3:c}=e,{max:f}=e,p={};function _(d){return{label:ke(d)+"A",value:isNaN(d)?0:d,color:Xf(d?d/f*100:0)}}return t.$$set=d=>{"u1"in d&&l(1,n=d.u1),"u2"in d&&l(2,i=d.u2),"u3"in d&&l(3,o=d.u3),"i1"in d&&l(4,r=d.i1),"i2"in d&&l(5,a=d.i2),"i3"in d&&l(6,c=d.i3),"max"in d&&l(7,f=d.max)},t.$$.update=()=>{if(t.$$.dirty&254){let d=[],g=[];n>0&&(d.push({label:"L1"}),g.push(_(r))),i>0&&(d.push({label:"L2"}),g.push(_(a))),o>0&&(d.push({label:"L3"}),g.push(_(c))),l(0,p={padding:{top:20,right:15,bottom:20,left:35},y:{min:0,max:f,ticks:[{value:0,label:"0%"},{value:f/4,label:"25%"},{value:f/2,label:"50%"},{value:f/4*3,label:"75%"},{value:f,label:"100%"}]},x:{ticks:d},points:g})}},[p,n,i,o,r,a,c,f]}class Cm extends $e{constructor(e){super(),ye(this,e,$m,ym,we,{u1:1,u2:2,u3:3,i1:4,i2:5,i3:6,max:7})}}function Tm(t){let e,l,n,i,o,r,a,c=(typeof t[0]<"u"?t[0].toFixed(0):"-")+"",f,p,_,d,g,h,b=(typeof t[1]<"u"?t[1].toFixed(0):"-")+"",$,k,T,P,E,S,N,A=(typeof t[2]<"u"?t[2].toFixed(1):"-")+"",R,H,U,F,L,G,j=(typeof t[3]<"u"?t[3].toFixed(1):"-")+"",O,q;return{c(){e=m("div"),l=m("strong"),l.textContent="Reactive",n=v(),i=m("div"),o=m("div"),o.textContent="Instant in",r=v(),a=m("div"),f=C(c),p=C(" VAr"),_=v(),d=m("div"),d.textContent="Instant out",g=v(),h=m("div"),$=C(b),k=C(" VAr"),T=v(),P=m("div"),E=m("div"),E.textContent="Total in",S=v(),N=m("div"),R=C(A),H=C(" kVArh"),U=v(),F=m("div"),F.textContent="Total out",L=v(),G=m("div"),O=C(j),q=C(" kVArh"),u(a,"class","text-right"),u(h,"class","text-right"),u(i,"class","grid grid-cols-2 mt-4"),u(N,"class","text-right"),u(G,"class","text-right"),u(P,"class","grid grid-cols-2 mt-4"),u(e,"class","mx-2 text-sm")},m(W,X){y(W,e,X),s(e,l),s(e,n),s(e,i),s(i,o),s(i,r),s(i,a),s(a,f),s(a,p),s(i,_),s(i,d),s(i,g),s(i,h),s(h,$),s(h,k),s(e,T),s(e,P),s(P,E),s(P,S),s(P,N),s(N,R),s(N,H),s(P,U),s(P,F),s(P,L),s(P,G),s(G,O),s(G,q)},p(W,[X]){X&1&&c!==(c=(typeof W[0]<"u"?W[0].toFixed(0):"-")+"")&&B(f,c),X&2&&b!==(b=(typeof W[1]<"u"?W[1].toFixed(0):"-")+"")&&B($,b),X&4&&A!==(A=(typeof W[2]<"u"?W[2].toFixed(1):"-")+"")&&B(R,A),X&8&&j!==(j=(typeof W[3]<"u"?W[3].toFixed(1):"-")+"")&&B(O,j)},i:ie,o:ie,d(W){W&&w(e)}}}function Sm(t,e,l){let{importInstant:n}=e,{exportInstant:i}=e,{importTotal:o}=e,{exportTotal:r}=e;return t.$$set=a=>{"importInstant"in a&&l(0,n=a.importInstant),"exportInstant"in a&&l(1,i=a.exportInstant),"importTotal"in a&&l(2,o=a.importTotal),"exportTotal"in a&&l(3,r=a.exportTotal)},[n,i,o,r]}class Pm extends $e{constructor(e){super(),ye(this,e,Sm,Tm,we,{importInstant:0,exportInstant:1,importTotal:2,exportTotal:3})}}function ea(t){let e;function l(o,r){return o[2]?Dm:Mm}let n=l(t),i=n(t);return{c(){i.c(),e=je()},m(o,r){i.m(o,r),y(o,e,r)},p(o,r){n===(n=l(o))&&i?i.p(o,r):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){i.d(o),o&&w(e)}}}function Mm(t){let e,l,n,i,o,r,a=ke(t[0].h.u,2)+"",c,f,p,_,d,g,h=ke(t[0].d.u,1)+"",b,$,k,T,P,E,S=ke(t[0].m.u)+"",N,A,R,H,U=t[1]&&ta(t);return{c(){e=m("strong"),e.textContent="Consumption",l=v(),n=m("div"),i=m("div"),i.textContent="Hour",o=v(),r=m("div"),c=C(a),f=C(" kWh"),p=v(),_=m("div"),_.textContent="Day",d=v(),g=m("div"),b=C(h),$=C(" kWh"),k=v(),T=m("div"),T.textContent="Month",P=v(),E=m("div"),N=C(S),A=C(" kWh"),R=v(),U&&U.c(),H=je(),u(r,"class","text-right"),u(g,"class","text-right"),u(E,"class","text-right"),u(n,"class","grid grid-cols-2 mb-3")},m(F,L){y(F,e,L),y(F,l,L),y(F,n,L),s(n,i),s(n,o),s(n,r),s(r,c),s(r,f),s(n,p),s(n,_),s(n,d),s(n,g),s(g,b),s(g,$),s(n,k),s(n,T),s(n,P),s(n,E),s(E,N),s(E,A),y(F,R,L),U&&U.m(F,L),y(F,H,L)},p(F,L){L&1&&a!==(a=ke(F[0].h.u,2)+"")&&B(c,a),L&1&&h!==(h=ke(F[0].d.u,1)+"")&&B(b,h),L&1&&S!==(S=ke(F[0].m.u)+"")&&B(N,S),F[1]?U?U.p(F,L):(U=ta(F),U.c(),U.m(H.parentNode,H)):U&&(U.d(1),U=null)},d(F){F&&w(e),F&&w(l),F&&w(n),F&&w(R),U&&U.d(F),F&&w(H)}}}function Dm(t){let e,l,n,i,o,r,a=ke(t[0].h.u,2)+"",c,f,p,_,d,g,h,b=ke(t[0].d.u,1)+"",$,k,T,P,E,S,N,A=ke(t[0].m.u)+"",R,H,U,F,L,G,j,O,q,W,X,z=ke(t[0].h.p,2)+"",ne,te,De,_e,Ie,Ee,Le,Re=ke(t[0].d.p,1)+"",Se,be,fe,ae,ce,ue,J,se=ke(t[0].m.p)+"",Pe,ee,oe,Ue,Me=t[1]&&la(t),de=t[1]&&na(t),ve=t[1]&&ia(t),le=t[1]&&sa(t),he=t[1]&&oa(t),qe=t[1]&&ua(t);return{c(){e=m("strong"),e.textContent="Import",l=v(),n=m("div"),i=m("div"),i.textContent="Hour",o=v(),r=m("div"),c=C(a),f=C(" kWh"),p=v(),Me&&Me.c(),_=v(),d=m("div"),d.textContent="Day",g=v(),h=m("div"),$=C(b),k=C(" kWh"),T=v(),de&&de.c(),P=v(),E=m("div"),E.textContent="Month",S=v(),N=m("div"),R=C(A),H=C(" kWh"),U=v(),ve&&ve.c(),L=v(),G=m("strong"),G.textContent="Export",j=v(),O=m("div"),q=m("div"),q.textContent="Hour",W=v(),X=m("div"),ne=C(z),te=C(" kWh"),De=v(),le&&le.c(),_e=v(),Ie=m("div"),Ie.textContent="Day",Ee=v(),Le=m("div"),Se=C(Re),be=C(" kWh"),fe=v(),he&&he.c(),ae=v(),ce=m("div"),ce.textContent="Month",ue=v(),J=m("div"),Pe=C(se),ee=C(" kWh"),oe=v(),qe&&qe.c(),u(r,"class","text-right"),u(h,"class","text-right"),u(N,"class","text-right"),u(n,"class",F="grid grid-cols-"+t[3]+" mb-3"),u(X,"class","text-right"),u(Le,"class","text-right"),u(J,"class","text-right"),u(O,"class",Ue="grid grid-cols-"+t[3])},m(re,Ae){y(re,e,Ae),y(re,l,Ae),y(re,n,Ae),s(n,i),s(n,o),s(n,r),s(r,c),s(r,f),s(n,p),Me&&Me.m(n,null),s(n,_),s(n,d),s(n,g),s(n,h),s(h,$),s(h,k),s(n,T),de&&de.m(n,null),s(n,P),s(n,E),s(n,S),s(n,N),s(N,R),s(N,H),s(n,U),ve&&ve.m(n,null),y(re,L,Ae),y(re,G,Ae),y(re,j,Ae),y(re,O,Ae),s(O,q),s(O,W),s(O,X),s(X,ne),s(X,te),s(O,De),le&&le.m(O,null),s(O,_e),s(O,Ie),s(O,Ee),s(O,Le),s(Le,Se),s(Le,be),s(O,fe),he&&he.m(O,null),s(O,ae),s(O,ce),s(O,ue),s(O,J),s(J,Pe),s(J,ee),s(O,oe),qe&&qe.m(O,null)},p(re,Ae){Ae&1&&a!==(a=ke(re[0].h.u,2)+"")&&B(c,a),re[1]?Me?Me.p(re,Ae):(Me=la(re),Me.c(),Me.m(n,_)):Me&&(Me.d(1),Me=null),Ae&1&&b!==(b=ke(re[0].d.u,1)+"")&&B($,b),re[1]?de?de.p(re,Ae):(de=na(re),de.c(),de.m(n,P)):de&&(de.d(1),de=null),Ae&1&&A!==(A=ke(re[0].m.u)+"")&&B(R,A),re[1]?ve?ve.p(re,Ae):(ve=ia(re),ve.c(),ve.m(n,null)):ve&&(ve.d(1),ve=null),Ae&8&&F!==(F="grid grid-cols-"+re[3]+" mb-3")&&u(n,"class",F),Ae&1&&z!==(z=ke(re[0].h.p,2)+"")&&B(ne,z),re[1]?le?le.p(re,Ae):(le=sa(re),le.c(),le.m(O,_e)):le&&(le.d(1),le=null),Ae&1&&Re!==(Re=ke(re[0].d.p,1)+"")&&B(Se,Re),re[1]?he?he.p(re,Ae):(he=oa(re),he.c(),he.m(O,ae)):he&&(he.d(1),he=null),Ae&1&&se!==(se=ke(re[0].m.p)+"")&&B(Pe,se),re[1]?qe?qe.p(re,Ae):(qe=ua(re),qe.c(),qe.m(O,null)):qe&&(qe.d(1),qe=null),Ae&8&&Ue!==(Ue="grid grid-cols-"+re[3])&&u(O,"class",Ue)},d(re){re&&w(e),re&&w(l),re&&w(n),Me&&Me.d(),de&&de.d(),ve&&ve.d(),re&&w(L),re&&w(G),re&&w(j),re&&w(O),le&&le.d(),he&&he.d(),qe&&qe.d()}}}function ta(t){let e,l,n,i,o,r,a=ke(t[0].h.c,2)+"",c,f,p,_,d,g,h,b=ke(t[0].d.c,1)+"",$,k,T,P,E,S,N,A=ke(t[0].m.c)+"",R,H,U;return{c(){e=m("strong"),e.textContent="Cost",l=v(),n=m("div"),i=m("div"),i.textContent="Hour",o=v(),r=m("div"),c=C(a),f=v(),p=C(t[1]),_=v(),d=m("div"),d.textContent="Day",g=v(),h=m("div"),$=C(b),k=v(),T=C(t[1]),P=v(),E=m("div"),E.textContent="Month",S=v(),N=m("div"),R=C(A),H=v(),U=C(t[1]),u(r,"class","text-right"),u(h,"class","text-right"),u(N,"class","text-right"),u(n,"class","grid grid-cols-2")},m(F,L){y(F,e,L),y(F,l,L),y(F,n,L),s(n,i),s(n,o),s(n,r),s(r,c),s(r,f),s(r,p),s(n,_),s(n,d),s(n,g),s(n,h),s(h,$),s(h,k),s(h,T),s(n,P),s(n,E),s(n,S),s(n,N),s(N,R),s(N,H),s(N,U)},p(F,L){L&1&&a!==(a=ke(F[0].h.c,2)+"")&&B(c,a),L&2&&B(p,F[1]),L&1&&b!==(b=ke(F[0].d.c,1)+"")&&B($,b),L&2&&B(T,F[1]),L&1&&A!==(A=ke(F[0].m.c)+"")&&B(R,A),L&2&&B(U,F[1])},d(F){F&&w(e),F&&w(l),F&&w(n)}}}function la(t){let e,l=ke(t[0].h.c,2)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=ke(r[0].h.c,2)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function na(t){let e,l=ke(t[0].d.c,1)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=ke(r[0].d.c,1)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function ia(t){let e,l=ke(t[0].m.c)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=ke(r[0].m.c)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function sa(t){let e,l=ke(t[0].h.i,2)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=ke(r[0].h.i,2)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function oa(t){let e,l=ke(t[0].d.i,1)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=ke(r[0].d.i,1)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function ua(t){let e,l=ke(t[0].m.i)+"",n,i,o;return{c(){e=m("div"),n=C(l),i=v(),o=C(t[1]),u(e,"class","text-right")},m(r,a){y(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=ke(r[0].m.i)+"")&&B(n,l),a&2&&B(o,r[1])},d(r){r&&w(e)}}}function Am(t){let e,l,n,i,o,r,a=t[0]&&ea(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Real time calculation",n=v(),i=m("br"),o=m("br"),r=v(),a&&a.c(),u(e,"class","mx-2 text-sm")},m(c,f){y(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),s(e,r),a&&a.m(e,null)},p(c,[f]){c[0]?a?a.p(c,f):(a=ea(c),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},i:ie,o:ie,d(c){c&&w(e),a&&a.d()}}}function Nm(t,e,l){let{data:n}=e,{currency:i}=e,{hasExport:o}=e,r=3;return t.$$set=a=>{"data"in a&&l(0,n=a.data),"currency"in a&&l(1,i=a.currency),"hasExport"in a&&l(2,o=a.hasExport)},t.$$.update=()=>{t.$$.dirty&2&&l(3,r=i?3:2)},[n,i,o,r]}class Im extends $e{constructor(e){super(),ye(this,e,Nm,Am,we,{data:0,currency:1,hasExport:2})}}function Em(t){let e,l,n,i;return n=new Kl({props:{config:t[0]}}),{c(){e=m("a"),e.textContent="Provided by ENTSO-E",l=v(),Z(n.$$.fragment),u(e,"href","https://transparency.entsoe.eu/"),u(e,"target","_blank"),u(e,"class","text-xs float-right z-40")},m(o,r){y(o,e,r),y(o,l,r),K(n,o,r),i=!0},p(o,[r]){const a={};r&1&&(a.config=o[0]),n.$set(a)},i(o){i||(M(n.$$.fragment,o),i=!0)},o(o){I(n.$$.fragment,o),i=!1},d(o){o&&w(e),o&&w(l),Q(n,o)}}}function Rm(t,e,l){let{json:n}=e,i={},o=0,r=0;return t.$$set=a=>{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=new Date().getUTCHours(),c=0,f=0,p=0,_=n[20]==null?2:1,d=[],g=[],h=[],b=new Date;for(c=a;c<24&&(f=n[Ne(p++)],f!=null);c++)g.push({label:Ne(b.getHours())}),h.push({label:f>0?f.toFixed(_):"",value:f>0?Math.abs(f*100):0,label2:f<0?f.toFixed(_):"",value2:f<0?Math.abs(f*100):0,color:"#7c3aed"}),l(3,r=Math.min(r,f*100)),l(2,o=Math.max(o,f*100)),ii(b,1);for(c=0;c<24&&(f=n[Ne(p++)],f!=null);c++)g.push({label:Ne(b.getHours())}),h.push({label:f>0?f.toFixed(_):"",value:f>0?Math.abs(f*100):0,label2:f<0?f.toFixed(_):"",value2:f<0?Math.abs(f*100):0,color:"#7c3aed"}),l(3,r=Math.min(r,f*100)),l(2,o=Math.max(o,f*100)),ii(b,1);if(l(2,o=Math.ceil(o)),l(3,r=Math.floor(r)),r<0){let k=r/4;for(c=1;c<5;c++){let T=k*c;d.push({value:T,label:(T/100).toFixed(2)})}}let $=o/4;for(c=0;c<5;c++){let k=$*c;d.push({value:k,label:(k/100).toFixed(2)})}l(0,i={title:"Future energy price ("+n.currency+")",padding:{top:20,right:15,bottom:20,left:35},y:{min:r,max:o,ticks:d},x:{ticks:g},points:h})}},[i,n,o,r]}class Fm extends $e{constructor(e){super(),ye(this,e,Rm,Em,we,{json:1})}}function Lm(t){let e,l;return e=new Kl({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function Om(t,e,l){let{json:n}=e,i={},o=0,r=0;return t.$$set=a=>{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,c=[],f=[],p=[],_=ii(new Date,-24),d=new Date().getUTCHours();for(a=d;a<24;a++){let b=n["i"+Ne(a)],$=n["e"+Ne(a)];b===void 0&&(b=0),$===void 0&&($=0),f.push({label:Ne(_.getHours())}),p.push({label:b.toFixed(1),value:b*10,label2:$.toFixed(1),value2:$*10,color:"#7c3aed"}),l(3,r=Math.max(r,$*10)),l(2,o=Math.max(o,b*10)),ii(_,1)}for(a=0;a{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,c=[],f=[],p=[],_=new Date,d=new Date;for(d.setDate(0),a=_.getDate();a<=d.getDate();a++){let b=n["i"+Ne(a)],$=n["e"+Ne(a)];b===void 0&&(b=0),$===void 0&&($=0),f.push({label:Ne(a)}),p.push({label:b.toFixed(0),value:b,label2:$.toFixed(0),value2:$,color:"#7c3aed"}),l(3,r=Math.max(r,$)),l(2,o=Math.max(o,b))}for(a=1;a<_.getDate();a++){let b=n["i"+Ne(a)],$=n["e"+Ne(a)];b===void 0&&(b=0),$===void 0&&($=0),f.push({label:Ne(a)}),p.push({label:b.toFixed(0),value:b,label2:$.toFixed(0),value2:$,color:"#7c3aed"}),l(3,r=Math.max(r,$)),l(2,o=Math.max(o,b))}let g=Math.ceil(Math.max(r,o)/10)*10;if(l(2,o=g),l(3,r=r==0?0:g*-1),r<0){let b=r/4;for(a=0;a<5;a++){let $=b*a;c.push({value:$,label:$.toFixed(0)})}}let h=o/4;for(a=0;a<5;a++){let b=h*a;c.push({value:b,label:b.toFixed(0)})}l(0,i={title:"Energy use last month (kWh)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:r,max:o,ticks:c},x:{ticks:f},points:p})}},[i,n,o,r]}class jm extends $e{constructor(e){super(),ye(this,e,Hm,Um,we,{json:1})}}function Wm(t){let e,l;return e=new Kl({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function Gm(t,e,l){let{json:n}=e,i={},o=0,r=0;return t.$$set=a=>{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,c=0,f=[],p=[],_=[];n.s&&n.s.forEach((h,b)=>{var $=h.n?h.n:h.a;c=h.v,c==-127&&(c=0),p.push({label:$.slice(-4)}),_.push({label:c.toFixed(1),value:c,color:"#7c3aed"}),l(3,r=Math.min(r,c)),l(2,o=Math.max(o,c))}),l(2,o=Math.ceil(o)),l(3,r=Math.floor(r));let d=o;r<0&&(d+=Math.abs(r));let g=d/4;for(a=0;a<5;a++)c=r+g*a,f.push({value:c,label:c.toFixed(1)});l(0,i={title:"Temperature sensors (\xB0C)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:r,max:o,ticks:f},x:{ticks:p},points:_})}},[i,n,o,r]}class Bm extends $e{constructor(e){super(),ye(this,e,Gm,Wm,we,{json:1})}}function zm(t){let e,l;return e=new Kl({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}let Ym=0;function Vm(t,e,l){let n={},i=0,o;return sc.subscribe(r=>{l(2,o=r)}),ic(),t.$$.update=()=>{if(t.$$.dirty&6){let r=0,a=[],c=[],f=[];if(a.push({value:0,label:0}),o&&o.p)for(r=0;r0?Ne(p.d)+"."+Gs[new Date().getMonth()]:"-"}),l(1,i=Math.max(i,p.v))}if(o&&o.t){for(r=0;r=i)break;a.push({value:p,label:p})}a.push({label:o.m.toFixed(1),align:"right",color:"green",value:o.m})}o&&o.c&&(a.push({label:o.c.toFixed(0),color:"orange",value:o.c}),l(1,i=Math.max(i,o.c))),l(1,i=Math.ceil(i)),l(0,n={title:"Tariff peaks",padding:{top:20,right:35,bottom:20,left:35},y:{min:Ym,max:i,ticks:a},x:{ticks:c},points:f})}},[n,i,o]}class Km extends $e{constructor(e){super(),ye(this,e,Vm,zm,we,{})}}function ra(t){let e,l,n,i,o,r,a=(t[0].mt?ms(t[0].mt):"-")+"",c,f,p,_=(t[0].ic?t[0].ic.toFixed(1):"-")+"",d,g,h;return i=new fc({props:{val:t[0].i?t[0].i:0,max:t[0].im?t[0].im:15e3,unit:"W",label:"Import",sub:t[0].p,subunit:t[2].currency,colorFn:Xf}}),{c(){e=m("div"),l=m("div"),n=m("div"),Z(i.$$.fragment),o=v(),r=m("div"),c=C(a),f=v(),p=m("div"),d=C(_),g=C(" kWh"),u(n,"class","col-span-2"),u(p,"class","text-right"),u(l,"class","grid grid-cols-2"),u(e,"class","cnt")},m(b,$){y(b,e,$),s(e,l),s(l,n),K(i,n,null),s(l,o),s(l,r),s(r,c),s(l,f),s(l,p),s(p,d),s(p,g),h=!0},p(b,$){const k={};$&1&&(k.val=b[0].i?b[0].i:0),$&1&&(k.max=b[0].im?b[0].im:15e3),$&1&&(k.sub=b[0].p),$&4&&(k.subunit=b[2].currency),i.$set(k),(!h||$&1)&&a!==(a=(b[0].mt?ms(b[0].mt):"-")+"")&&B(c,a),(!h||$&1)&&_!==(_=(b[0].ic?b[0].ic.toFixed(1):"-")+"")&&B(d,_)},i(b){h||(M(i.$$.fragment,b),h=!0)},o(b){I(i.$$.fragment,b),h=!1},d(b){b&&w(e),Q(i)}}}function aa(t){let e,l,n,i,o,r,a,c,f=(t[0].ec?t[0].ec.toFixed(1):"-")+"",p,_,d;return i=new fc({props:{val:t[0].e?t[0].e:0,max:t[0].om?t[0].om*1e3:1e4,unit:"W",label:"Export",colorFn:A1}}),{c(){e=m("div"),l=m("div"),n=m("div"),Z(i.$$.fragment),o=v(),r=m("div"),a=v(),c=m("div"),p=C(f),_=C(" kWh"),u(n,"class","col-span-2"),u(c,"class","text-right"),u(l,"class","grid grid-cols-2"),u(e,"class","cnt")},m(g,h){y(g,e,h),s(e,l),s(l,n),K(i,n,null),s(l,o),s(l,r),s(l,a),s(l,c),s(c,p),s(c,_),d=!0},p(g,h){const b={};h&1&&(b.val=g[0].e?g[0].e:0),h&1&&(b.max=g[0].om?g[0].om*1e3:1e4),i.$set(b),(!d||h&1)&&f!==(f=(g[0].ec?g[0].ec.toFixed(1):"-")+"")&&B(p,f)},i(g){d||(M(i.$$.fragment,g),d=!0)},o(g){I(i.$$.fragment,g),d=!1},d(g){g&&w(e),Q(i)}}}function fa(t){let e,l,n;return l=new wm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,ds:t[0].ds}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.u1=i[0].u1),o&1&&(r.u2=i[0].u2),o&1&&(r.u3=i[0].u3),o&1&&(r.ds=i[0].ds),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function ca(t){let e,l,n;return l=new Cm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,i1:t[0].i1,i2:t[0].i2,i3:t[0].i3,max:t[0].mf?t[0].mf:32}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.u1=i[0].u1),o&1&&(r.u2=i[0].u2),o&1&&(r.u3=i[0].u3),o&1&&(r.i1=i[0].i1),o&1&&(r.i2=i[0].i2),o&1&&(r.i3=i[0].i3),o&1&&(r.max=i[0].mf?i[0].mf:32),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function ma(t){let e,l,n;return l=new Pm({props:{importInstant:t[0].ri,exportInstant:t[0].re,importTotal:t[0].ric,exportTotal:t[0].rec}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.importInstant=i[0].ri),o&1&&(r.exportInstant=i[0].re),o&1&&(r.importTotal=i[0].ric),o&1&&(r.exportTotal=i[0].rec),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function pa(t){let e,l,n;return l=new Im({props:{data:t[0].ea,currency:t[2].currency,hasExport:t[0].om>0||t[0].e>0}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.data=i[0].ea),o&4&&(r.currency=i[2].currency),o&1&&(r.hasExport=i[0].om>0||i[0].e>0),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function _a(t){let e,l,n;return l=new Km({}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt h-64")},m(i,o){y(i,e,o),K(l,e,null),n=!0},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function da(t){let e,l,n;return l=new Fm({props:{json:t[2]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&4&&(r.json=i[2]),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function va(t){let e,l,n;return l=new qm({props:{json:t[3]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&8&&(r.json=i[3]),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function ha(t){let e,l,n;return l=new jm({props:{json:t[4]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&16&&(r.json=i[4]),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function ga(t){let e,l,n;return l=new Bm({props:{json:t[5]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){y(i,e,o),K(l,e,null),n=!0},p(i,o){const r={};o&32&&(r.json=i[5]),l.$set(r)},i(i){n||(M(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&w(e),Q(l)}}}function Qm(t){let e,l=He(t[1].ui.i,t[0].i),n,i=He(t[1].ui.e,t[0].om||t[0].e>0),o,r=He(t[1].ui.v,t[0].u1>100||t[0].u2>100||t[0].u3>100),a,c=He(t[1].ui.a,t[0].i1>.01||t[0].i2>.01||t[0].i3>.01),f,p=He(t[1].ui.r,t[0].ri>0||t[0].re>0||t[0].ric>0||t[0].rec>0),_,d=He(t[1].ui.c,t[0].ea),g,h=He(t[1].ui.t,t[0].pr&&(t[0].pr.startsWith("10YNO")||t[0].pr=="10Y1001A1001A48H")),b,$=He(t[1].ui.p,typeof t[0].p=="number"&&!Number.isNaN(t[0].p)),k,T=He(t[1].ui.d,t[3]),P,E=He(t[1].ui.m,t[4]),S,N=He(t[1].ui.s,t[0].t&&t[0].t!=-127&&t[5].c>1),A,R=l&&ra(t),H=i&&aa(t),U=r&&fa(t),F=c&&ca(t),L=p&&ma(t),G=d&&pa(t),j=h&&_a(),O=$&&da(t),q=T&&va(t),W=E&&ha(t),X=N&&ga(t);return{c(){e=m("div"),R&&R.c(),n=v(),H&&H.c(),o=v(),U&&U.c(),a=v(),F&&F.c(),f=v(),L&&L.c(),_=v(),G&&G.c(),g=v(),j&&j.c(),b=v(),O&&O.c(),k=v(),q&&q.c(),P=v(),W&&W.c(),S=v(),X&&X.c(),u(e,"class","grid 2xl:grid-cols-6 xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-2")},m(z,ne){y(z,e,ne),R&&R.m(e,null),s(e,n),H&&H.m(e,null),s(e,o),U&&U.m(e,null),s(e,a),F&&F.m(e,null),s(e,f),L&&L.m(e,null),s(e,_),G&&G.m(e,null),s(e,g),j&&j.m(e,null),s(e,b),O&&O.m(e,null),s(e,k),q&&q.m(e,null),s(e,P),W&&W.m(e,null),s(e,S),X&&X.m(e,null),A=!0},p(z,[ne]){ne&3&&(l=He(z[1].ui.i,z[0].i)),l?R?(R.p(z,ne),ne&3&&M(R,1)):(R=ra(z),R.c(),M(R,1),R.m(e,n)):R&&(Ce(),I(R,1,1,()=>{R=null}),Te()),ne&3&&(i=He(z[1].ui.e,z[0].om||z[0].e>0)),i?H?(H.p(z,ne),ne&3&&M(H,1)):(H=aa(z),H.c(),M(H,1),H.m(e,o)):H&&(Ce(),I(H,1,1,()=>{H=null}),Te()),ne&3&&(r=He(z[1].ui.v,z[0].u1>100||z[0].u2>100||z[0].u3>100)),r?U?(U.p(z,ne),ne&3&&M(U,1)):(U=fa(z),U.c(),M(U,1),U.m(e,a)):U&&(Ce(),I(U,1,1,()=>{U=null}),Te()),ne&3&&(c=He(z[1].ui.a,z[0].i1>.01||z[0].i2>.01||z[0].i3>.01)),c?F?(F.p(z,ne),ne&3&&M(F,1)):(F=ca(z),F.c(),M(F,1),F.m(e,f)):F&&(Ce(),I(F,1,1,()=>{F=null}),Te()),ne&3&&(p=He(z[1].ui.r,z[0].ri>0||z[0].re>0||z[0].ric>0||z[0].rec>0)),p?L?(L.p(z,ne),ne&3&&M(L,1)):(L=ma(z),L.c(),M(L,1),L.m(e,_)):L&&(Ce(),I(L,1,1,()=>{L=null}),Te()),ne&3&&(d=He(z[1].ui.c,z[0].ea)),d?G?(G.p(z,ne),ne&3&&M(G,1)):(G=pa(z),G.c(),M(G,1),G.m(e,g)):G&&(Ce(),I(G,1,1,()=>{G=null}),Te()),ne&3&&(h=He(z[1].ui.t,z[0].pr&&(z[0].pr.startsWith("10YNO")||z[0].pr=="10Y1001A1001A48H"))),h?j?ne&3&&M(j,1):(j=_a(),j.c(),M(j,1),j.m(e,b)):j&&(Ce(),I(j,1,1,()=>{j=null}),Te()),ne&3&&($=He(z[1].ui.p,typeof z[0].p=="number"&&!Number.isNaN(z[0].p))),$?O?(O.p(z,ne),ne&3&&M(O,1)):(O=da(z),O.c(),M(O,1),O.m(e,k)):O&&(Ce(),I(O,1,1,()=>{O=null}),Te()),ne&10&&(T=He(z[1].ui.d,z[3])),T?q?(q.p(z,ne),ne&10&&M(q,1)):(q=va(z),q.c(),M(q,1),q.m(e,P)):q&&(Ce(),I(q,1,1,()=>{q=null}),Te()),ne&18&&(E=He(z[1].ui.m,z[4])),E?W?(W.p(z,ne),ne&18&&M(W,1)):(W=ha(z),W.c(),M(W,1),W.m(e,S)):W&&(Ce(),I(W,1,1,()=>{W=null}),Te()),ne&35&&(N=He(z[1].ui.s,z[0].t&&z[0].t!=-127&&z[5].c>1)),N?X?(X.p(z,ne),ne&35&&M(X,1)):(X=ga(z),X.c(),M(X,1),X.m(e,null)):X&&(Ce(),I(X,1,1,()=>{X=null}),Te())},i(z){A||(M(R),M(H),M(U),M(F),M(L),M(G),M(j),M(O),M(q),M(W),M(X),A=!0)},o(z){I(R),I(H),I(U),I(F),I(L),I(G),I(j),I(O),I(q),I(W),I(X),A=!1},d(z){z&&w(e),R&&R.d(),H&&H.d(),U&&U.d(),F&&F.d(),L&&L.d(),G&&G.d(),j&&j.d(),O&&O.d(),q&&q.d(),W&&W.d(),X&&X.d()}}}function Zm(t,e,l){let{data:n={}}=e,{sysinfo:i={}}=e,o={},r={},a={},c={};return xf.subscribe(f=>{l(2,o=f)}),ec.subscribe(f=>{l(3,r=f)}),tc.subscribe(f=>{l(4,a=f)}),nc.subscribe(f=>{l(5,c=f)}),t.$$set=f=>{"data"in f&&l(0,n=f.data),"sysinfo"in f&&l(1,i=f.sysinfo)},[n,i,o,r,a,c]}class Jm extends $e{constructor(e){super(),ye(this,e,Zm,Qm,we,{data:0,sysinfo:1})}}let Zs={};const cc=Ze(Zs);async function Xm(){Zs=await(await fetch("/configuration.json")).json(),cc.set(Zs)}function ba(t,e,l){const n=t.slice();return n[2]=e[l],n[4]=l,n}function ka(t){let e;return{c(){e=m("option"),e.textContent="UART2",e.__value=113,e.value=e.__value},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function wa(t){let e,l,n;return{c(){e=m("option"),e.textContent="UART1",l=v(),n=m("option"),n.textContent="UART2",e.__value=9,e.value=e.__value,n.__value=16,n.value=n.__value},m(i,o){y(i,e,o),y(i,l,o),y(i,n,o)},d(i){i&&w(e),i&&w(l),i&&w(n)}}}function ya(t){let e;return{c(){e=m("option"),e.textContent="UART1",e.__value=18,e.value=e.__value},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function $a(t){let e,l,n;return{c(){e=m("option"),l=C("GPIO"),n=C(t[4]),e.__value=t[4],e.value=e.__value},m(i,o){y(i,e,o),s(e,l),s(e,n)},d(i){i&&w(e)}}}function Ca(t){let e,l=t[4]>3&&!(t[0]=="esp32"&&(t[4]==9||t[4]==16))&&!(t[0]=="esp32s2"&&t[4]==18)&&!(t[0]=="esp8266"&&(t[4]==3||t[4]==113))&&$a(t);return{c(){l&&l.c(),e=je()},m(n,i){l&&l.m(n,i),y(n,e,i)},p(n,i){n[4]>3&&!(n[0]=="esp32"&&(n[4]==9||n[4]==16))&&!(n[0]=="esp32s2"&&n[4]==18)&&!(n[0]=="esp8266"&&(n[4]==3||n[4]==113))?l||(l=$a(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},d(n){l&&l.d(n),n&&w(e)}}}function xm(t){let e,l,n,i,o,r,a=t[0]=="esp8266"&&ka(),c=(t[0]=="esp32"||t[0]=="esp32solo")&&wa(),f=t[0]=="esp32s2"&&ya(),p={length:t[1]+1},_=[];for(let d=0;d{"chip"in o&&l(0,n=o.chip)},t.$$.update=()=>{t.$$.dirty&1&&l(1,i=n=="esp8266"?16:n=="esp32s2"?44:39)},[n,i]}class mc extends $e{constructor(e){super(),ye(this,e,ep,xm,we,{chip:0})}}function Ta(t){let e,l,n=t[1]&&Sa(t);return{c(){e=m("div"),l=m("div"),n&&n.c(),u(l,"class","fixed inset-0 bg-gray-500 bg-opacity-50 flex items-center justify-center"),u(e,"class","z-50"),u(e,"aria-modal","true")},m(i,o){y(i,e,o),s(e,l),n&&n.m(l,null)},p(i,o){i[1]?n?n.p(i,o):(n=Sa(i),n.c(),n.m(l,null)):n&&(n.d(1),n=null)},d(i){i&&w(e),n&&n.d()}}}function Sa(t){let e,l;return{c(){e=m("div"),l=C(t[1]),u(e,"class","bg-white m-2 p-3 rounded-md shadow-lg pb-4 text-gray-700 w-96")},m(n,i){y(n,e,i),s(e,l)},p(n,i){i&2&&B(l,n[1])},d(n){n&&w(e)}}}function tp(t){let e,l=t[0]&&Ta(t);return{c(){l&&l.c(),e=je()},m(n,i){l&&l.m(n,i),y(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=Ta(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:ie,o:ie,d(n){l&&l.d(n),n&&w(e)}}}function lp(t,e,l){let{active:n}=e,{message:i}=e;return t.$$set=o=>{"active"in o&&l(0,n=o.active),"message"in o&&l(1,i=o.message)},[n,i]}class gt extends $e{constructor(e){super(),ye(this,e,lp,tp,we,{active:0,message:1})}}function Pa(t,e,l){const n=t.slice();return n[1]=e[l],n}function Ma(t){let e,l,n=t[1]+"",i;return{c(){e=m("option"),l=C("Europe/"),i=C(n),e.__value="Europe/"+t[1],e.value=e.__value},m(o,r){y(o,e,r),s(e,l),s(e,i)},p:ie,d(o){o&&w(e)}}}function np(t){let e,l,n,i=t[0],o=[];for(let r=0;r{r[p]=null}),Te(),l=r[e],l||(l=r[e]=o[e](c),l.c()),M(l,1),l.m(n.parentNode,n))},i(c){i||(M(l),i=!0)},o(c){I(l),i=!1},d(c){r[e].d(c),c&&w(n)}}}function _p(t){let e,l;return e=new Yt({props:{color:"blue",text:"Upload cert",title:"Click here to upload certificate"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function dp(t){let e,l;return e=new Yt({props:{color:"green",text:"Cert OK",title:"Click here to replace certificate"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function vp(t){let e,l,n,i;const o=[dp,_p],r=[];function a(c,f){return c[3].q.s.r?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=je()},m(c,f){r[e].m(c,f),y(c,n,f),i=!0},p(c,f){let p=e;e=a(c),e!==p&&(Ce(),I(r[p],1,1,()=>{r[p]=null}),Te(),l=r[e],l||(l=r[e]=o[e](c),l.c()),M(l,1),l.m(n.parentNode,n))},i(c){i||(M(l),i=!0)},o(c){I(l),i=!1},d(c){r[e].d(c),c&&w(n)}}}function hp(t){let e,l;return e=new Yt({props:{color:"blue",text:"Upload key",title:"Click here to upload key"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function gp(t){let e,l;return e=new Yt({props:{color:"green",text:"Key OK",title:"Click here to replace key"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function bp(t){let e,l,n,i;const o=[gp,hp],r=[];function a(c,f){return c[3].q.s.k?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=je()},m(c,f){r[e].m(c,f),y(c,n,f),i=!0},p(c,f){let p=e;e=a(c),e!==p&&(Ce(),I(r[p],1,1,()=>{r[p]=null}),Te(),l=r[e],l||(l=r[e]=o[e](c),l.c()),M(l,1),l.m(n.parentNode,n))},i(c){i||(M(l),i=!0)},o(c){I(l),i=!1},d(c){r[e].d(c),c&&w(n)}}}function Ua(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G,j,O,q;return o=new yt({}),{c(){e=m("div"),l=m("strong"),l.textContent="Domoticz",n=v(),i=m("a"),Z(o.$$.fragment),r=v(),a=m("input"),c=v(),f=m("div"),p=m("div"),_=C("Electricity IDX"),d=m("br"),g=v(),h=m("input"),b=v(),$=m("div"),k=C("Current IDX"),T=m("br"),P=v(),E=m("input"),S=v(),N=m("div"),A=C(`Voltage IDX: L1, L2 & L3 + `),R=m("div"),H=m("input"),U=v(),F=m("input"),L=v(),G=m("input"),u(l,"class","text-sm"),u(i,"href",$t("MQTT-configuration#domoticz")),u(i,"target","_blank"),u(i,"class","float-right"),u(a,"type","hidden"),u(a,"name","o"),a.value="true",u(h,"name","oe"),u(h,"type","text"),u(h,"class","in-f tr w-full"),u(p,"class","w-1/2"),u(E,"name","oc"),u(E,"type","text"),u(E,"class","in-l tr w-full"),u($,"class","w-1/2"),u(f,"class","my-1 flex"),u(H,"name","ou1"),u(H,"type","text"),u(H,"class","in-f tr w-1/3"),u(F,"name","ou2"),u(F,"type","text"),u(F,"class","in-m tr w-1/3"),u(G,"name","ou3"),u(G,"type","text"),u(G,"class","in-l tr w-1/3"),u(R,"class","flex"),u(N,"class","my-1"),u(e,"class","cnt")},m(W,X){y(W,e,X),s(e,l),s(e,n),s(e,i),K(o,i,null),s(e,r),s(e,a),s(e,c),s(e,f),s(f,p),s(p,_),s(p,d),s(p,g),s(p,h),Y(h,t[3].o.e),s(f,b),s(f,$),s($,k),s($,T),s($,P),s($,E),Y(E,t[3].o.c),s(e,S),s(e,N),s(N,A),s(N,R),s(R,H),Y(H,t[3].o.u1),s(R,U),s(R,F),Y(F,t[3].o.u2),s(R,L),s(R,G),Y(G,t[3].o.u3),j=!0,O||(q=[V(h,"input",t[58]),V(E,"input",t[59]),V(H,"input",t[60]),V(F,"input",t[61]),V(G,"input",t[62])],O=!0)},p(W,X){X[0]&8&&h.value!==W[3].o.e&&Y(h,W[3].o.e),X[0]&8&&E.value!==W[3].o.c&&Y(E,W[3].o.c),X[0]&8&&H.value!==W[3].o.u1&&Y(H,W[3].o.u1),X[0]&8&&F.value!==W[3].o.u2&&Y(F,W[3].o.u2),X[0]&8&&G.value!==W[3].o.u3&&Y(G,W[3].o.u3)},i(W){j||(M(o.$$.fragment,W),j=!0)},o(W){I(o.$$.fragment,W),j=!1},d(W){W&&w(e),Q(o),O=!1,Ge(q)}}}function Ha(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G;return o=new yt({}),{c(){e=m("div"),l=m("strong"),l.textContent="Home-Assistant",n=v(),i=m("a"),Z(o.$$.fragment),r=v(),a=m("input"),c=v(),f=m("div"),p=C("Discovery topic"),_=m("br"),d=v(),g=m("input"),h=v(),b=m("div"),$=C("Hostname for URL"),k=m("br"),T=v(),P=m("input"),S=v(),N=m("div"),A=C("Name tag"),R=m("br"),H=v(),U=m("input"),u(l,"class","text-sm"),u(i,"href",$t("MQTT-configuration#home-assistant")),u(i,"target","_blank"),u(i,"class","float-right"),u(a,"type","hidden"),u(a,"name","h"),a.value="true",u(g,"name","ht"),u(g,"type","text"),u(g,"class","in-s"),u(g,"placeholder","homeassistant/sensor"),u(f,"class","my-1"),u(P,"name","hh"),u(P,"type","text"),u(P,"class","in-s"),u(P,"placeholder",E=t[3].g.h+".local"),u(b,"class","my-1"),u(U,"name","hn"),u(U,"type","text"),u(U,"class","in-s"),u(N,"class","my-1"),u(e,"class","cnt")},m(j,O){y(j,e,O),s(e,l),s(e,n),s(e,i),K(o,i,null),s(e,r),s(e,a),s(e,c),s(e,f),s(f,p),s(f,_),s(f,d),s(f,g),Y(g,t[3].h.t),s(e,h),s(e,b),s(b,$),s(b,k),s(b,T),s(b,P),Y(P,t[3].h.h),s(e,S),s(e,N),s(N,A),s(N,R),s(N,H),s(N,U),Y(U,t[3].h.n),F=!0,L||(G=[V(g,"input",t[63]),V(P,"input",t[64]),V(U,"input",t[65])],L=!0)},p(j,O){O[0]&8&&g.value!==j[3].h.t&&Y(g,j[3].h.t),(!F||O[0]&8&&E!==(E=j[3].g.h+".local"))&&u(P,"placeholder",E),O[0]&8&&P.value!==j[3].h.h&&Y(P,j[3].h.h),O[0]&8&&U.value!==j[3].h.n&&Y(U,j[3].h.n)},i(j){F||(M(o.$$.fragment,j),F=!0)},o(j){I(o.$$.fragment,j),F=!1},d(j){j&&w(e),Q(o),L=!1,Ge(G)}}}function ja(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P;o=new yt({});let E={length:9},S=[];for(let N=0;N20&&za(t),p=t[0].chip=="esp8266"&&Ka(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Hardware",n=v(),i=m("a"),Z(o.$$.fragment),r=v(),f&&f.c(),a=v(),p&&p.c(),u(l,"class","text-sm"),u(i,"href",$t("GPIO-configuration")),u(i,"target","_blank"),u(i,"class","float-right"),u(e,"class","cnt")},m(_,d){y(_,e,d),s(e,l),s(e,n),s(e,i),K(o,i,null),s(e,r),f&&f.m(e,null),s(e,a),p&&p.m(e,null),c=!0},p(_,d){_[0].board>20?f?(f.p(_,d),d[0]&1&&M(f,1)):(f=za(_),f.c(),M(f,1),f.m(e,a)):f&&(Ce(),I(f,1,1,()=>{f=null}),Te()),_[0].chip=="esp8266"?p?p.p(_,d):(p=Ka(_),p.c(),p.m(e,null)):p&&(p.d(1),p=null)},i(_){c||(M(o.$$.fragment,_),M(f),c=!0)},o(_){I(o.$$.fragment,_),I(f),c=!1},d(_){_&&w(e),Q(o),f&&f.d(),p&&p.d()}}}function za(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G,j,O,q,W,X,z,ne,te,De,_e,Ie,Ee,Le,Re,Se,be,fe,ae,ce,ue,J,se,Pe,ee,oe,Ue,Me;f=new mc({props:{chip:t[0].chip}});let de=t[0].chip!="esp8266"&&Ya(t),ve=t[3].i.v.p>0&&Va(t);return{c(){e=m("input"),l=v(),n=m("div"),i=m("div"),o=C("HAN"),r=m("br"),a=v(),c=m("select"),Z(f.$$.fragment),p=v(),_=m("div"),d=C("AP button"),g=m("br"),h=v(),b=m("input"),$=v(),k=m("div"),T=C("LED"),P=m("label"),E=m("input"),S=C(" inv"),N=m("br"),A=v(),R=m("div"),H=m("input"),U=v(),F=m("div"),L=C("RGB"),G=m("label"),j=m("input"),O=C(" inverted"),q=m("br"),W=v(),X=m("div"),z=m("input"),ne=v(),te=m("input"),De=v(),_e=m("input"),Ie=v(),Ee=m("div"),Le=C("Temperature"),Re=m("br"),Se=v(),be=m("input"),fe=v(),ae=m("div"),ce=C("Analog temp"),ue=m("br"),J=v(),se=m("input"),Pe=v(),de&&de.c(),ee=v(),ve&&ve.c(),u(e,"type","hidden"),u(e,"name","i"),e.value="true",u(c,"name","ih"),u(c,"class","in-f w-full"),t[3].i.h===void 0&&Be(()=>t[69].call(c)),u(i,"class","w-1/3"),u(b,"name","ia"),u(b,"type","number"),u(b,"min","0"),u(b,"max",t[6]),u(b,"class","in-m tr w-full"),u(_,"class","w-1/3"),u(E,"name","ili"),E.__value="true",E.value=E.__value,u(E,"type","checkbox"),u(E,"class","rounded mb-1"),u(P,"class","ml-4"),u(H,"name","ilp"),u(H,"type","number"),u(H,"min","0"),u(H,"max",t[6]),u(H,"class","in-l tr w-full"),u(R,"class","flex"),u(k,"class","w-1/3"),u(j,"name","iri"),j.__value="true",j.value=j.__value,u(j,"type","checkbox"),u(j,"class","rounded mb-1"),u(G,"class","ml-4"),u(z,"name","irr"),u(z,"type","number"),u(z,"min","0"),u(z,"max",t[6]),u(z,"class","in-f tr w-1/3"),u(te,"name","irg"),u(te,"type","number"),u(te,"min","0"),u(te,"max",t[6]),u(te,"class","in-m tr w-1/3"),u(_e,"name","irb"),u(_e,"type","number"),u(_e,"min","0"),u(_e,"max",t[6]),u(_e,"class","in-l tr w-1/3"),u(X,"class","flex"),u(F,"class","w-full"),u(be,"name","itd"),u(be,"type","number"),u(be,"min","0"),u(be,"max",t[6]),u(be,"class","in-f tr w-full"),u(Ee,"class","my-1 w-1/3"),u(se,"name","ita"),u(se,"type","number"),u(se,"min","0"),u(se,"max",t[6]),u(se,"class","in-l tr w-full"),u(ae,"class","my-1 pr-1 w-1/3"),u(n,"class","flex flex-wrap")},m(le,he){y(le,e,he),y(le,l,he),y(le,n,he),s(n,i),s(i,o),s(i,r),s(i,a),s(i,c),K(f,c,null),Fe(c,t[3].i.h),s(n,p),s(n,_),s(_,d),s(_,g),s(_,h),s(_,b),Y(b,t[3].i.a),s(n,$),s(n,k),s(k,T),s(k,P),s(P,E),E.checked=t[3].i.l.i,s(P,S),s(k,N),s(k,A),s(k,R),s(R,H),Y(H,t[3].i.l.p),s(n,U),s(n,F),s(F,L),s(F,G),s(G,j),j.checked=t[3].i.r.i,s(G,O),s(F,q),s(F,W),s(F,X),s(X,z),Y(z,t[3].i.r.r),s(X,ne),s(X,te),Y(te,t[3].i.r.g),s(X,De),s(X,_e),Y(_e,t[3].i.r.b),s(n,Ie),s(n,Ee),s(Ee,Le),s(Ee,Re),s(Ee,Se),s(Ee,be),Y(be,t[3].i.t.d),s(n,fe),s(n,ae),s(ae,ce),s(ae,ue),s(ae,J),s(ae,se),Y(se,t[3].i.t.a),s(n,Pe),de&&de.m(n,null),s(n,ee),ve&&ve.m(n,null),oe=!0,Ue||(Me=[V(c,"change",t[69]),V(b,"input",t[70]),V(E,"change",t[71]),V(H,"input",t[72]),V(j,"change",t[73]),V(z,"input",t[74]),V(te,"input",t[75]),V(_e,"input",t[76]),V(be,"input",t[77]),V(se,"input",t[78])],Ue=!0)},p(le,he){const qe={};he[0]&1&&(qe.chip=le[0].chip),f.$set(qe),he[0]&8&&Fe(c,le[3].i.h),(!oe||he[0]&64)&&u(b,"max",le[6]),he[0]&8&&me(b.value)!==le[3].i.a&&Y(b,le[3].i.a),he[0]&8&&(E.checked=le[3].i.l.i),(!oe||he[0]&64)&&u(H,"max",le[6]),he[0]&8&&me(H.value)!==le[3].i.l.p&&Y(H,le[3].i.l.p),he[0]&8&&(j.checked=le[3].i.r.i),(!oe||he[0]&64)&&u(z,"max",le[6]),he[0]&8&&me(z.value)!==le[3].i.r.r&&Y(z,le[3].i.r.r),(!oe||he[0]&64)&&u(te,"max",le[6]),he[0]&8&&me(te.value)!==le[3].i.r.g&&Y(te,le[3].i.r.g),(!oe||he[0]&64)&&u(_e,"max",le[6]),he[0]&8&&me(_e.value)!==le[3].i.r.b&&Y(_e,le[3].i.r.b),(!oe||he[0]&64)&&u(be,"max",le[6]),he[0]&8&&me(be.value)!==le[3].i.t.d&&Y(be,le[3].i.t.d),(!oe||he[0]&64)&&u(se,"max",le[6]),he[0]&8&&me(se.value)!==le[3].i.t.a&&Y(se,le[3].i.t.a),le[0].chip!="esp8266"?de?de.p(le,he):(de=Ya(le),de.c(),de.m(n,ee)):de&&(de.d(1),de=null),le[3].i.v.p>0?ve?ve.p(le,he):(ve=Va(le),ve.c(),ve.m(n,null)):ve&&(ve.d(1),ve=null)},i(le){oe||(M(f.$$.fragment,le),oe=!0)},o(le){I(f.$$.fragment,le),oe=!1},d(le){le&&w(e),le&&w(l),le&&w(n),Q(f),de&&de.d(),ve&&ve.d(),Ue=!1,Ge(Me)}}}function Ya(t){let e,l,n,i,o,r,a;return{c(){e=m("div"),l=C("Vcc"),n=m("br"),i=v(),o=m("input"),u(o,"name","ivp"),u(o,"type","number"),u(o,"min","0"),u(o,"max",t[6]),u(o,"class","in-s tr w-full"),u(e,"class","my-1 pl-1 w-1/3")},m(c,f){y(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),Y(o,t[3].i.v.p),r||(a=V(o,"input",t[79]),r=!0)},p(c,f){f[0]&64&&u(o,"max",c[6]),f[0]&8&&me(o.value)!==c[3].i.v.p&&Y(o,c[3].i.v.p)},d(c){c&&w(e),r=!1,a()}}}function Va(t){let e,l,n,i,o,r,a,c,f,p;return{c(){e=m("div"),l=C("Voltage divider"),n=m("br"),i=v(),o=m("div"),r=m("input"),a=v(),c=m("input"),u(r,"name","ivdv"),u(r,"type","number"),u(r,"min","0"),u(r,"max","65535"),u(r,"class","in-f tr w-full"),u(r,"placeholder","VCC"),u(c,"name","ivdg"),u(c,"type","number"),u(c,"min","0"),u(c,"max","65535"),u(c,"class","in-l tr w-full"),u(c,"placeholder","GND"),u(o,"class","flex"),u(e,"class","my-1")},m(_,d){y(_,e,d),s(e,l),s(e,n),s(e,i),s(e,o),s(o,r),Y(r,t[3].i.v.d.v),s(o,a),s(o,c),Y(c,t[3].i.v.d.g),f||(p=[V(r,"input",t[80]),V(c,"input",t[81])],f=!0)},p(_,d){d[0]&8&&me(r.value)!==_[3].i.v.d.v&&Y(r,_[3].i.v.d.v),d[0]&8&&me(c.value)!==_[3].i.v.d.g&&Y(c,_[3].i.v.d.g)},d(_){_&&w(e),f=!1,Ge(p)}}}function Ka(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T=(t[0].board==2||t[0].board==100)&&Qa(t);return{c(){e=m("input"),l=v(),n=m("div"),i=m("div"),o=C("Vcc offset"),r=m("br"),a=v(),c=m("input"),f=v(),p=m("div"),_=C("Multiplier"),d=m("br"),g=v(),h=m("input"),b=v(),T&&T.c(),u(e,"type","hidden"),u(e,"name","iv"),e.value="true",u(c,"name","ivo"),u(c,"type","number"),u(c,"min","0.0"),u(c,"max","3.5"),u(c,"step","0.01"),u(c,"class","in-f tr w-full"),u(i,"class","w-1/3"),u(h,"name","ivm"),u(h,"type","number"),u(h,"min","0.1"),u(h,"max","10"),u(h,"step","0.01"),u(h,"class","in-l tr w-full"),u(p,"class","w-1/3 pr-1"),u(n,"class","my-1 flex flex-wrap")},m(P,E){y(P,e,E),y(P,l,E),y(P,n,E),s(n,i),s(i,o),s(i,r),s(i,a),s(i,c),Y(c,t[3].i.v.o),s(n,f),s(n,p),s(p,_),s(p,d),s(p,g),s(p,h),Y(h,t[3].i.v.m),s(n,b),T&&T.m(n,null),$||(k=[V(c,"input",t[82]),V(h,"input",t[83])],$=!0)},p(P,E){E[0]&8&&me(c.value)!==P[3].i.v.o&&Y(c,P[3].i.v.o),E[0]&8&&me(h.value)!==P[3].i.v.m&&Y(h,P[3].i.v.m),P[0].board==2||P[0].board==100?T?T.p(P,E):(T=Qa(P),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},d(P){P&&w(e),P&&w(l),P&&w(n),T&&T.d(),$=!1,Ge(k)}}}function Qa(t){let e,l,n,i,o,r,a;return{c(){e=m("div"),l=C("Boot limit"),n=m("br"),i=v(),o=m("input"),u(o,"name","ivb"),u(o,"type","number"),u(o,"min","2.5"),u(o,"max","3.5"),u(o,"step","0.1"),u(o,"class","in-s tr w-full"),u(e,"class","w-1/3 pl-1")},m(c,f){y(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),Y(o,t[3].i.v.b),r||(a=V(o,"input",t[84]),r=!0)},p(c,f){f[0]&8&&me(o.value)!==c[3].i.v.b&&Y(o,c[3].i.v.b)},d(c){c&&w(e),r=!1,a()}}}function Za(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k=t[3].d.t&&Ja();return{c(){e=m("div"),e.textContent="Debug can cause sudden reboots. Do not leave on!",l=v(),n=m("div"),i=m("label"),o=m("input"),r=C(" Enable telnet"),a=v(),k&&k.c(),c=v(),f=m("div"),p=m("select"),_=m("option"),_.textContent="Verbose",d=m("option"),d.textContent="Debug",g=m("option"),g.textContent="Info",h=m("option"),h.textContent="Warning",u(e,"class","bd-red"),u(o,"type","checkbox"),u(o,"name","dt"),o.__value="true",o.value=o.__value,u(o,"class","rounded mb-1"),u(n,"class","my-1"),_.__value=1,_.value=_.__value,d.__value=2,d.value=d.__value,g.__value=3,g.value=g.__value,h.__value=4,h.value=h.__value,u(p,"name","dl"),u(p,"class","in-s"),t[3].d.l===void 0&&Be(()=>t[87].call(p)),u(f,"class","my-1")},m(T,P){y(T,e,P),y(T,l,P),y(T,n,P),s(n,i),s(i,o),o.checked=t[3].d.t,s(i,r),y(T,a,P),k&&k.m(T,P),y(T,c,P),y(T,f,P),s(f,p),s(p,_),s(p,d),s(p,g),s(p,h),Fe(p,t[3].d.l),b||($=[V(o,"change",t[86]),V(p,"change",t[87])],b=!0)},p(T,P){P[0]&8&&(o.checked=T[3].d.t),T[3].d.t?k||(k=Ja(),k.c(),k.m(c.parentNode,c)):k&&(k.d(1),k=null),P[0]&8&&Fe(p,T[3].d.l)},d(T){T&&w(e),T&&w(l),T&&w(n),T&&w(a),k&&k.d(T),T&&w(c),T&&w(f),b=!1,Ge($)}}}function Ja(t){let e;return{c(){e=m("div"),e.textContent="Telnet is unsafe and should be off when not in use",u(e,"class","bd-red")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function kp(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G,j,O,q,W,X,z,ne,te,De,_e,Ie,Ee,Le,Re,Se,be,fe,ae,ce,ue,J,se,Pe,ee,oe,Ue,Me,de,ve,le,he,qe,re,Ae,fi,ci,mi,Tt,pi,Qt,_i,di,vi,tt,hi,Zt,Ql,pt,gi,bi,ki,Jt,wi,yi,$i,_t,rl,al,fl,Ci,Ti,ge,Cl,Tl,Sl,cl,ml,Pl,Si,Zl,vs,co,pl,qt,_l,mo,Pi,po,xe,dl,_o,Mi,Jl,Xl,xl,en,Di,vo,Yn,St,ho,go,Ml,bo,ko,wo,Ut,tn,ln,yo,nn,Dl,$o,Co,To,sn,Pt,So,Ai,Po,Al,Mo,Do,Ao,on,Mt,No,Ni,Io,hs,Eo,Nl,Ii,Dt,Ro,Fo,Lo,gs,Ei,At,Oo,qo,Uo,Xe,Ri,Ho,un,rn,jo,Vn,Wo,Il,Go,Bo,zo,Xt,Yo,El,Vo,Ko,Qo,xt,Zo,an,Rl,Jo,Xo,xo,bt,fn,cn,mn,pn,eu,Fl,tu,lu,nu,_n,kt,iu,Fi,su,Li,Oi,Nt,ou,uu,Je,qi,ru,dn,vn,au,Ll,fu,cu,mu,vl,Ht,hn,gn,pu,dt,Ui,Hi,_u,vt,bn,ji,Wi,du,bs,Gi,Bi,It,vu,hu,Kn,gu,hl,bu,Qn,Et,ku,wu,yu,zi,el,$u,We,Yi,Cu,kn,wn,Tu,Zn,Su,jt,Pu,ks,Mu,Du,yn,tl,Au,Rt,Nu,ws,Ol,Iu,Eu,Ru,ll,Fu,ql,Lu,Ou,qu,nl,Uu,$n,Cn,Hu,ju,Wu,il,Gu,Tn,Bu,zu,Yu,lt,Sn,Pn,Mn,Dn,An,Nn,Vu,Ul,Ku,Qu,Zu,sl,Ju,ys,$s,Cs=t[3].p.r.startsWith("10YNO")||t[3].p.r=="10Y1001A1001A48H",Ts,Wt,Vi,Xu,In,En,xu,Jn,er,Xn,tr,Ss,ht,Ki,lr,Rn,Fn,nr,xn,ir,Qi,Zi,Ft,sr,or,ur,gl,Ps,Ln,rr,Ji,On,ar,Xi,Ms,Hl,Ds,jl,As,Wl,Ns,Gl,Lt,Is,fr;a=new yt({}),R=new sp({});let _c=["NOK","SEK","DKK","EUR"],xi=[];for(let D=0;D<4;D+=1)xi[D]=ap(rp(t,_c,D));let nt=t[3].p.e&&t[0].chip!="esp8266"&&Na(t),it=t[3].g.s>0&&Ia(t);cl=new yt({});let dc=[24,48,96,192,384,576,1152],es=[];for(let D=0;D<7;D+=1)es[D]=fp(up(t,dc,D));let st=t[3].m.e.e&&Ea(t),ot=t[3].m.e.e&&Ra(t),ut=t[3].m.m.e&&Fa(t);rn=new yt({}),vn=new yt({}),bn=new pc({});let rt=t[3].n.m=="static"&&La(t);wn=new yt({});let at=t[0].chip!="esp8266"&&Oa(t),ze=t[3].q.s.e&&qa(t),Ye=t[3].q.m==3&&Ua(t),Ve=t[3].q.m==4&&Ha(t),Ke=Cs&&ja(t);En=new yt({});let qn=t[7],ft=[];for(let D=0;D20||t[0].chip=="esp8266")&&Ba(t);Fn=new yt({});let ct=t[3].d.s&&Za(t);return Hl=new gt({props:{active:t[1],message:"Loading configuration"}}),jl=new gt({props:{active:t[2],message:"Saving configuration"}}),Wl=new gt({props:{active:t[4],message:"Performing factory reset"}}),Gl=new gt({props:{active:t[5],message:"Device have been factory reset and switched to AP mode"}}),{c(){e=m("form"),l=m("div"),n=m("div"),i=m("strong"),i.textContent="General",o=v(),r=m("a"),Z(a.$$.fragment),c=v(),f=m("input"),p=v(),_=m("div"),d=m("div"),g=m("div"),h=C("Hostname"),b=m("br"),$=v(),k=m("input"),T=v(),P=m("div"),E=C("Time zone"),S=m("br"),N=v(),A=m("select"),Z(R.$$.fragment),H=v(),U=m("input"),F=v(),L=m("div"),G=C("Price region"),j=m("br"),O=v(),q=m("select"),W=m("optgroup"),X=m("option"),X.textContent="NO1",z=m("option"),z.textContent="NO2",ne=m("option"),ne.textContent="NO3",te=m("option"),te.textContent="NO4",De=m("option"),De.textContent="NO5",_e=m("optgroup"),Ie=m("option"),Ie.textContent="SE1",Ee=m("option"),Ee.textContent="SE2",Le=m("option"),Le.textContent="SE3",Re=m("option"),Re.textContent="SE4",Se=m("optgroup"),be=m("option"),be.textContent="DK1",fe=m("option"),fe.textContent="DK2",ae=m("option"),ae.textContent="Austria",ce=m("option"),ce.textContent="Belgium",ue=m("option"),ue.textContent="Czech Republic",J=m("option"),J.textContent="Estonia",se=m("option"),se.textContent="Finland",Pe=m("option"),Pe.textContent="France",ee=m("option"),ee.textContent="Germany",oe=m("option"),oe.textContent="Great Britain",Ue=m("option"),Ue.textContent="Latvia",Me=m("option"),Me.textContent="Lithuania",de=m("option"),de.textContent="Netherland",ve=m("option"),ve.textContent="Poland",le=m("option"),le.textContent="Switzerland",he=v(),qe=m("div"),re=m("div"),Ae=m("div"),fi=C("Currency"),ci=m("br"),mi=v(),Tt=m("select");for(let D=0;D<4;D+=1)xi[D].c();pi=v(),Qt=m("div"),_i=C("Multiplier"),di=m("br"),vi=v(),tt=m("input"),hi=v(),Zt=m("div"),Ql=m("label"),pt=m("input"),gi=C(" Enable price fetch from remote server"),bi=v(),nt&&nt.c(),ki=v(),Jt=m("div"),wi=C("Security"),yi=m("br"),$i=v(),_t=m("select"),rl=m("option"),rl.textContent="None",al=m("option"),al.textContent="Only configuration",fl=m("option"),fl.textContent="Everything",Ci=v(),it&&it.c(),Ti=v(),ge=m("div"),Cl=m("strong"),Cl.textContent="Meter",Tl=v(),Sl=m("a"),Z(cl.$$.fragment),ml=v(),Pl=m("input"),Si=v(),Zl=m("div"),vs=m("span"),vs.textContent="Serial configuration",co=v(),pl=m("div"),qt=m("select"),_l=m("option"),mo=C("Autodetect");for(let D=0;D<7;D+=1)es[D].c();po=v(),xe=m("select"),dl=m("option"),_o=C("-"),Jl=m("option"),Jl.textContent="7N1",Xl=m("option"),Xl.textContent="8N1",xl=m("option"),xl.textContent="7E1",en=m("option"),en.textContent="8E1",vo=v(),Yn=m("label"),St=m("input"),ho=C(" inverted"),go=v(),Ml=m("div"),bo=C("Voltage"),ko=m("br"),wo=v(),Ut=m("select"),tn=m("option"),tn.textContent="400V (TN)",ln=m("option"),ln.textContent="230V (IT/TT)",yo=v(),nn=m("div"),Dl=m("div"),$o=C("Main fuse"),Co=m("br"),To=v(),sn=m("label"),Pt=m("input"),So=v(),Ai=m("span"),Ai.textContent="A",Po=v(),Al=m("div"),Mo=C("Production"),Do=m("br"),Ao=v(),on=m("label"),Mt=m("input"),No=v(),Ni=m("span"),Ni.textContent="kWp",Io=v(),hs=m("div"),Eo=v(),Nl=m("div"),Ii=m("label"),Dt=m("input"),Ro=C(" Meter is encrypted"),Fo=v(),st&&st.c(),Lo=v(),ot&&ot.c(),gs=v(),Ei=m("label"),At=m("input"),Oo=C(" Multipliers"),qo=v(),ut&&ut.c(),Uo=v(),Xe=m("div"),Ri=m("strong"),Ri.textContent="WiFi",Ho=v(),un=m("a"),Z(rn.$$.fragment),jo=v(),Vn=m("input"),Wo=v(),Il=m("div"),Go=C("SSID"),Bo=m("br"),zo=v(),Xt=m("input"),Yo=v(),El=m("div"),Vo=C("Password"),Ko=m("br"),Qo=v(),xt=m("input"),Zo=v(),an=m("div"),Rl=m("div"),Jo=C("Power saving"),Xo=m("br"),xo=v(),bt=m("select"),fn=m("option"),fn.textContent="Default",cn=m("option"),cn.textContent="Off",mn=m("option"),mn.textContent="Minimum",pn=m("option"),pn.textContent="Maximum",eu=v(),Fl=m("div"),tu=C("Power"),lu=m("br"),nu=v(),_n=m("div"),kt=m("input"),iu=v(),Fi=m("span"),Fi.textContent="dBm",su=v(),Li=m("div"),Oi=m("label"),Nt=m("input"),ou=C(" Auto reboot on connection problem"),uu=v(),Je=m("div"),qi=m("strong"),qi.textContent="Network",ru=v(),dn=m("a"),Z(vn.$$.fragment),au=v(),Ll=m("div"),fu=C("IP"),cu=m("br"),mu=v(),vl=m("div"),Ht=m("select"),hn=m("option"),hn.textContent="DHCP",gn=m("option"),gn.textContent="Static",pu=v(),dt=m("input"),_u=v(),vt=m("select"),Z(bn.$$.fragment),du=v(),rt&&rt.c(),bs=v(),Gi=m("div"),Bi=m("label"),It=m("input"),vu=C(" enable mDNS"),hu=v(),Kn=m("input"),gu=v(),hl=m("div"),bu=C("NTP "),Qn=m("label"),Et=m("input"),ku=C(" obtain from DHCP"),wu=m("br"),yu=v(),zi=m("div"),el=m("input"),$u=v(),We=m("div"),Yi=m("strong"),Yi.textContent="MQTT",Cu=v(),kn=m("a"),Z(wn.$$.fragment),Tu=v(),Zn=m("input"),Su=v(),jt=m("div"),Pu=C(`Server + `),at&&at.c(),ks=v(),Mu=m("br"),Du=v(),yn=m("div"),tl=m("input"),Au=v(),Rt=m("input"),Nu=v(),ze&&ze.c(),ws=v(),Ol=m("div"),Iu=C("Username"),Eu=m("br"),Ru=v(),ll=m("input"),Fu=v(),ql=m("div"),Lu=C("Password"),Ou=m("br"),qu=v(),nl=m("input"),Uu=v(),$n=m("div"),Cn=m("div"),Hu=C("Client ID"),ju=m("br"),Wu=v(),il=m("input"),Gu=v(),Tn=m("div"),Bu=C("Payload"),zu=m("br"),Yu=v(),lt=m("select"),Sn=m("option"),Sn.textContent="JSON",Pn=m("option"),Pn.textContent="Raw (minimal)",Mn=m("option"),Mn.textContent="Raw (full)",Dn=m("option"),Dn.textContent="Domoticz",An=m("option"),An.textContent="HomeAssistant",Nn=m("option"),Nn.textContent="HEX dump",Vu=v(),Ul=m("div"),Ku=C("Publish topic"),Qu=m("br"),Zu=v(),sl=m("input"),Ju=v(),Ye&&Ye.c(),ys=v(),Ve&&Ve.c(),$s=v(),Ke&&Ke.c(),Ts=v(),Wt=m("div"),Vi=m("strong"),Vi.textContent="User interface",Xu=v(),In=m("a"),Z(En.$$.fragment),xu=v(),Jn=m("input"),er=v(),Xn=m("div");for(let D=0;DSave',Ms=v(),Z(Hl.$$.fragment),Ds=v(),Z(jl.$$.fragment),As=v(),Z(Wl.$$.fragment),Ns=v(),Z(Gl.$$.fragment),u(i,"class","text-sm"),u(r,"href",$t("General-configuration")),u(r,"target","_blank"),u(r,"class","float-right"),u(f,"type","hidden"),u(f,"name","g"),f.value="true",u(k,"name","gh"),u(k,"type","text"),u(k,"class","in-f w-full"),u(k,"pattern","[A-Za-z0-9-]+"),u(A,"name","gt"),u(A,"class","in-l w-full"),t[3].g.t===void 0&&Be(()=>t[13].call(A)),u(d,"class","flex"),u(_,"class","my-1"),u(U,"type","hidden"),u(U,"name","p"),U.value="true",X.__value="10YNO-1--------2",X.value=X.__value,z.__value="10YNO-2--------T",z.value=z.__value,ne.__value="10YNO-3--------J",ne.value=ne.__value,te.__value="10YNO-4--------9",te.value=te.__value,De.__value="10Y1001A1001A48H",De.value=De.__value,u(W,"label","Norway"),Ie.__value="10Y1001A1001A44P",Ie.value=Ie.__value,Ee.__value="10Y1001A1001A45N",Ee.value=Ee.__value,Le.__value="10Y1001A1001A46L",Le.value=Le.__value,Re.__value="10Y1001A1001A47J",Re.value=Re.__value,u(_e,"label","Sweden"),be.__value="10YDK-1--------W",be.value=be.__value,fe.__value="10YDK-2--------M",fe.value=fe.__value,u(Se,"label","Denmark"),ae.__value="10YAT-APG------L",ae.value=ae.__value,ce.__value="10YBE----------2",ce.value=ce.__value,ue.__value="10YCZ-CEPS-----N",ue.value=ue.__value,J.__value="10Y1001A1001A39I",J.value=J.__value,se.__value="10YFI-1--------U",se.value=se.__value,Pe.__value="10YFR-RTE------C",Pe.value=Pe.__value,ee.__value="10Y1001A1001A83F",ee.value=ee.__value,oe.__value="10YGB----------A",oe.value=oe.__value,Ue.__value="10YLV-1001A00074",Ue.value=Ue.__value,Me.__value="10YLT-1001A0008Q",Me.value=Me.__value,de.__value="10YNL----------L",de.value=de.__value,ve.__value="10YPL-AREA-----S",ve.value=ve.__value,le.__value="10YCH-SWISSGRIDZ",le.value=le.__value,u(q,"name","pr"),u(q,"class","in-s"),t[3].p.r===void 0&&Be(()=>t[14].call(q)),u(L,"class","my-1"),u(Tt,"name","pc"),u(Tt,"class","in-f w-full"),t[3].p.c===void 0&&Be(()=>t[15].call(Tt)),u(Ae,"class","w-1/2"),u(tt,"name","pm"),u(tt,"type","number"),u(tt,"min","0.001"),u(tt,"max","1000"),u(tt,"step","0.001"),u(tt,"class","in-l tr w-full"),u(Qt,"class","w-1/2"),u(re,"class","flex"),u(qe,"class","my-1"),u(pt,"type","checkbox"),u(pt,"name","pe"),pt.__value="true",pt.value=pt.__value,u(pt,"class","rounded mb-1"),u(Zt,"class","my-1"),rl.__value=0,rl.value=rl.__value,al.__value=1,al.value=al.__value,fl.__value=2,fl.value=fl.__value,u(_t,"name","gs"),u(_t,"class","in-s"),t[3].g.s===void 0&&Be(()=>t[19].call(_t)),u(Jt,"class","my-1"),u(n,"class","cnt"),u(Cl,"class","text-sm"),u(Sl,"href",$t("Meter-configuration")),u(Sl,"target","_blank"),u(Sl,"class","float-right"),u(Pl,"type","hidden"),u(Pl,"name","m"),Pl.value="true",_l.__value=0,_l.value=_l.__value,_l.disabled=Pi=t[3].m.b!=0,u(qt,"name","mb"),u(qt,"class","in-f"),t[3].m.b===void 0&&Be(()=>t[22].call(qt)),dl.__value=0,dl.value=dl.__value,dl.disabled=Mi=t[3].m.b!=0,Jl.__value=2,Jl.value=Jl.__value,Xl.__value=3,Xl.value=Xl.__value,xl.__value=10,xl.value=xl.__value,en.__value=11,en.value=en.__value,u(xe,"name","mp"),u(xe,"class","in-l"),xe.disabled=Di=t[3].m.b==0,t[3].m.p===void 0&&Be(()=>t[23].call(xe)),u(St,"name","mi"),St.__value="true",St.value=St.__value,u(St,"type","checkbox"),u(St,"class","rounded mb-1"),u(Yn,"class","mt-2 ml-3 whitespace-nowrap"),u(pl,"class","flex"),u(Zl,"class","my-1"),tn.__value=2,tn.value=tn.__value,ln.__value=1,ln.value=ln.__value,u(Ut,"name","md"),u(Ut,"class","in-s"),t[3].m.d===void 0&&Be(()=>t[25].call(Ut)),u(Ml,"class","my-1"),u(Pt,"name","mf"),u(Pt,"type","number"),u(Pt,"min","5"),u(Pt,"max","65535"),u(Pt,"class","in-f tr w-full"),u(Ai,"class","in-post"),u(sn,"class","flex"),u(Dl,"class","mx-1"),u(Mt,"name","mr"),u(Mt,"type","number"),u(Mt,"min","0"),u(Mt,"max","65535"),u(Mt,"class","in-f tr w-full"),u(Ni,"class","in-post"),u(on,"class","flex"),u(Al,"class","mx-1"),u(nn,"class","my-1 flex"),u(hs,"class","my-1"),u(Dt,"type","checkbox"),u(Dt,"name","me"),Dt.__value="true",Dt.value=Dt.__value,u(Dt,"class","rounded mb-1"),u(Nl,"class","my-1"),u(At,"type","checkbox"),u(At,"name","mm"),At.__value="true",At.value=At.__value,u(At,"class","rounded mb-1"),u(ge,"class","cnt"),u(Ri,"class","text-sm"),u(un,"href",$t("WiFi-configuration")),u(un,"target","_blank"),u(un,"class","float-right"),u(Vn,"type","hidden"),u(Vn,"name","w"),Vn.value="true",u(Xt,"name","ws"),u(Xt,"type","text"),u(Xt,"class","in-s"),u(Il,"class","my-1"),u(xt,"name","wp"),u(xt,"type","password"),u(xt,"class","in-s"),u(El,"class","my-1"),fn.__value=255,fn.value=fn.__value,cn.__value=0,cn.value=cn.__value,mn.__value=1,mn.value=mn.__value,pn.__value=2,pn.value=pn.__value,u(bt,"name","wz"),u(bt,"class","in-s"),t[3].w.z===void 0&&Be(()=>t[38].call(bt)),u(Rl,"class","w-1/2"),u(kt,"name","ww"),u(kt,"type","number"),u(kt,"min","0"),u(kt,"max","20.5"),u(kt,"step","0.5"),u(kt,"class","in-f tr w-full"),u(Fi,"class","in-post"),u(_n,"class","flex"),u(Fl,"class","ml-2 w-1/2"),u(an,"class","my-1 flex"),u(Nt,"type","checkbox"),u(Nt,"name","wa"),Nt.__value="true",Nt.value=Nt.__value,u(Nt,"class","rounded mb-1"),u(Li,"class","my-3"),u(Xe,"class","cnt"),u(qi,"class","text-sm"),u(dn,"href",$t("Network-configuration")),u(dn,"target","_blank"),u(dn,"class","float-right"),hn.__value="dhcp",hn.value=hn.__value,gn.__value="static",gn.value=gn.__value,u(Ht,"name","nm"),u(Ht,"class","in-f"),t[3].n.m===void 0&&Be(()=>t[41].call(Ht)),u(dt,"name","ni"),u(dt,"type","text"),u(dt,"class","in-m w-full"),dt.disabled=Ui=t[3].n.m=="dhcp",dt.required=Hi=t[3].n.m=="static",u(vt,"name","ns"),u(vt,"class","in-l"),vt.disabled=ji=t[3].n.m=="dhcp",vt.required=Wi=t[3].n.m=="static",t[3].n.s===void 0&&Be(()=>t[43].call(vt)),u(vl,"class","flex"),u(Ll,"class","my-1"),u(It,"name","nd"),It.__value="true",It.value=It.__value,u(It,"type","checkbox"),u(It,"class","rounded mb-1"),u(Gi,"class","my-1"),u(Kn,"type","hidden"),u(Kn,"name","ntp"),Kn.value="true",u(Et,"name","ntpd"),Et.__value="true",Et.value=Et.__value,u(Et,"type","checkbox"),u(Et,"class","rounded mb-1"),u(Qn,"class","ml-4"),u(el,"name","ntph"),u(el,"type","text"),u(el,"class","in-s"),u(zi,"class","flex"),u(hl,"class","my-1"),u(Je,"class","cnt"),u(Yi,"class","text-sm"),u(kn,"href",$t("MQTT-configuration")),u(kn,"target","_blank"),u(kn,"class","float-right"),u(Zn,"type","hidden"),u(Zn,"name","q"),Zn.value="true",u(tl,"name","qh"),u(tl,"type","text"),u(tl,"class","in-f w-3/4"),u(Rt,"name","qp"),u(Rt,"type","number"),u(Rt,"min","1024"),u(Rt,"max","65535"),u(Rt,"class","in-l tr w-1/4"),u(yn,"class","flex"),u(jt,"class","my-1"),u(ll,"name","qu"),u(ll,"type","text"),u(ll,"class","in-s"),u(Ol,"class","my-1"),u(nl,"name","qa"),u(nl,"type","password"),u(nl,"class","in-s"),u(ql,"class","my-1"),u(il,"name","qc"),u(il,"type","text"),u(il,"class","in-f w-full"),Sn.__value=0,Sn.value=Sn.__value,Pn.__value=1,Pn.value=Pn.__value,Mn.__value=2,Mn.value=Mn.__value,Dn.__value=3,Dn.value=Dn.__value,An.__value=4,An.value=An.__value,Nn.__value=255,Nn.value=Nn.__value,u(lt,"name","qm"),u(lt,"class","in-l"),t[3].q.m===void 0&&Be(()=>t[56].call(lt)),u($n,"class","my-1 flex"),u(sl,"name","qb"),u(sl,"type","text"),u(sl,"class","in-s"),u(Ul,"class","my-1"),u(We,"class","cnt"),u(Vi,"class","text-sm"),u(In,"href",$t("User-interface")),u(In,"target","_blank"),u(In,"class","float-right"),u(Jn,"type","hidden"),u(Jn,"name","u"),Jn.value="true",u(Xn,"class","flex flex-wrap"),u(Wt,"class","cnt"),u(Ki,"class","text-sm"),u(Rn,"href","https://amsleser.no/blog/post/24-telnet-debug"),u(Rn,"target","_blank"),u(Rn,"class","float-right"),u(xn,"type","hidden"),u(xn,"name","d"),xn.value="true",u(Ft,"type","checkbox"),u(Ft,"name","ds"),Ft.__value="true",Ft.value=Ft.__value,u(Ft,"class","rounded mb-1"),u(Qi,"class","mt-3"),u(ht,"class","cnt"),u(l,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2"),u(Ln,"type","button"),u(Ln,"class","py-2 px-4 rounded bg-red-500 text-white ml-2"),u(On,"type","button"),u(On,"class","py-2 px-4 rounded bg-yellow-500 text-white"),u(Ji,"class","text-center"),u(Xi,"class","text-right"),u(gl,"class","grid grid-cols-3"),u(e,"autocomplete","off")},m(D,x){y(D,e,x),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),K(a,r,null),s(n,c),s(n,f),s(n,p),s(n,_),s(_,d),s(d,g),s(g,h),s(g,b),s(g,$),s(g,k),Y(k,t[3].g.h),s(d,T),s(d,P),s(P,E),s(P,S),s(P,N),s(P,A),K(R,A,null),Fe(A,t[3].g.t),s(n,H),s(n,U),s(n,F),s(n,L),s(L,G),s(L,j),s(L,O),s(L,q),s(q,W),s(W,X),s(W,z),s(W,ne),s(W,te),s(W,De),s(q,_e),s(_e,Ie),s(_e,Ee),s(_e,Le),s(_e,Re),s(q,Se),s(Se,be),s(Se,fe),s(q,ae),s(q,ce),s(q,ue),s(q,J),s(q,se),s(q,Pe),s(q,ee),s(q,oe),s(q,Ue),s(q,Me),s(q,de),s(q,ve),s(q,le),Fe(q,t[3].p.r),s(n,he),s(n,qe),s(qe,re),s(re,Ae),s(Ae,fi),s(Ae,ci),s(Ae,mi),s(Ae,Tt);for(let mt=0;mt<4;mt+=1)xi[mt].m(Tt,null);Fe(Tt,t[3].p.c),s(re,pi),s(re,Qt),s(Qt,_i),s(Qt,di),s(Qt,vi),s(Qt,tt),Y(tt,t[3].p.m),s(n,hi),s(n,Zt),s(Zt,Ql),s(Ql,pt),pt.checked=t[3].p.e,s(Ql,gi),s(Zt,bi),nt&&nt.m(Zt,null),s(n,ki),s(n,Jt),s(Jt,wi),s(Jt,yi),s(Jt,$i),s(Jt,_t),s(_t,rl),s(_t,al),s(_t,fl),Fe(_t,t[3].g.s),s(n,Ci),it&&it.m(n,null),s(l,Ti),s(l,ge),s(ge,Cl),s(ge,Tl),s(ge,Sl),K(cl,Sl,null),s(ge,ml),s(ge,Pl),s(ge,Si),s(ge,Zl),s(Zl,vs),s(Zl,co),s(Zl,pl),s(pl,qt),s(qt,_l),s(_l,mo);for(let mt=0;mt<7;mt+=1)es[mt].m(qt,null);Fe(qt,t[3].m.b),s(pl,po),s(pl,xe),s(xe,dl),s(dl,_o),s(xe,Jl),s(xe,Xl),s(xe,xl),s(xe,en),Fe(xe,t[3].m.p),s(pl,vo),s(pl,Yn),s(Yn,St),St.checked=t[3].m.i,s(Yn,ho),s(ge,go),s(ge,Ml),s(Ml,bo),s(Ml,ko),s(Ml,wo),s(Ml,Ut),s(Ut,tn),s(Ut,ln),Fe(Ut,t[3].m.d),s(ge,yo),s(ge,nn),s(nn,Dl),s(Dl,$o),s(Dl,Co),s(Dl,To),s(Dl,sn),s(sn,Pt),Y(Pt,t[3].m.f),s(sn,So),s(sn,Ai),s(nn,Po),s(nn,Al),s(Al,Mo),s(Al,Do),s(Al,Ao),s(Al,on),s(on,Mt),Y(Mt,t[3].m.r),s(on,No),s(on,Ni),s(ge,Io),s(ge,hs),s(ge,Eo),s(ge,Nl),s(Nl,Ii),s(Ii,Dt),Dt.checked=t[3].m.e.e,s(Ii,Ro),s(Nl,Fo),st&&st.m(Nl,null),s(ge,Lo),ot&&ot.m(ge,null),s(ge,gs),s(ge,Ei),s(Ei,At),At.checked=t[3].m.m.e,s(Ei,Oo),s(ge,qo),ut&&ut.m(ge,null),s(l,Uo),s(l,Xe),s(Xe,Ri),s(Xe,Ho),s(Xe,un),K(rn,un,null),s(Xe,jo),s(Xe,Vn),s(Xe,Wo),s(Xe,Il),s(Il,Go),s(Il,Bo),s(Il,zo),s(Il,Xt),Y(Xt,t[3].w.s),s(Xe,Yo),s(Xe,El),s(El,Vo),s(El,Ko),s(El,Qo),s(El,xt),Y(xt,t[3].w.p),s(Xe,Zo),s(Xe,an),s(an,Rl),s(Rl,Jo),s(Rl,Xo),s(Rl,xo),s(Rl,bt),s(bt,fn),s(bt,cn),s(bt,mn),s(bt,pn),Fe(bt,t[3].w.z),s(an,eu),s(an,Fl),s(Fl,tu),s(Fl,lu),s(Fl,nu),s(Fl,_n),s(_n,kt),Y(kt,t[3].w.w),s(_n,iu),s(_n,Fi),s(Xe,su),s(Xe,Li),s(Li,Oi),s(Oi,Nt),Nt.checked=t[3].w.a,s(Oi,ou),s(l,uu),s(l,Je),s(Je,qi),s(Je,ru),s(Je,dn),K(vn,dn,null),s(Je,au),s(Je,Ll),s(Ll,fu),s(Ll,cu),s(Ll,mu),s(Ll,vl),s(vl,Ht),s(Ht,hn),s(Ht,gn),Fe(Ht,t[3].n.m),s(vl,pu),s(vl,dt),Y(dt,t[3].n.i),s(vl,_u),s(vl,vt),K(bn,vt,null),Fe(vt,t[3].n.s),s(Je,du),rt&&rt.m(Je,null),s(Je,bs),s(Je,Gi),s(Gi,Bi),s(Bi,It),It.checked=t[3].n.d,s(Bi,vu),s(Je,hu),s(Je,Kn),s(Je,gu),s(Je,hl),s(hl,bu),s(hl,Qn),s(Qn,Et),Et.checked=t[3].n.h,s(Qn,ku),s(hl,wu),s(hl,yu),s(hl,zi),s(zi,el),Y(el,t[3].n.n1),s(l,$u),s(l,We),s(We,Yi),s(We,Cu),s(We,kn),K(wn,kn,null),s(We,Tu),s(We,Zn),s(We,Su),s(We,jt),s(jt,Pu),at&&at.m(jt,null),s(jt,ks),s(jt,Mu),s(jt,Du),s(jt,yn),s(yn,tl),Y(tl,t[3].q.h),s(yn,Au),s(yn,Rt),Y(Rt,t[3].q.p),s(We,Nu),ze&&ze.m(We,null),s(We,ws),s(We,Ol),s(Ol,Iu),s(Ol,Eu),s(Ol,Ru),s(Ol,ll),Y(ll,t[3].q.u),s(We,Fu),s(We,ql),s(ql,Lu),s(ql,Ou),s(ql,qu),s(ql,nl),Y(nl,t[3].q.a),s(We,Uu),s(We,$n),s($n,Cn),s(Cn,Hu),s(Cn,ju),s(Cn,Wu),s(Cn,il),Y(il,t[3].q.c),s($n,Gu),s($n,Tn),s(Tn,Bu),s(Tn,zu),s(Tn,Yu),s(Tn,lt),s(lt,Sn),s(lt,Pn),s(lt,Mn),s(lt,Dn),s(lt,An),s(lt,Nn),Fe(lt,t[3].q.m),s(We,Vu),s(We,Ul),s(Ul,Ku),s(Ul,Qu),s(Ul,Zu),s(Ul,sl),Y(sl,t[3].q.b),s(l,Ju),Ye&&Ye.m(l,null),s(l,ys),Ve&&Ve.m(l,null),s(l,$s),Ke&&Ke.m(l,null),s(l,Ts),s(l,Wt),s(Wt,Vi),s(Wt,Xu),s(Wt,In),K(En,In,null),s(Wt,xu),s(Wt,Jn),s(Wt,er),s(Wt,Xn);for(let mt=0;mt0?it?it.p(D,x):(it=Ia(D),it.c(),it.m(n,null)):it&&(it.d(1),it=null),(!Lt||x[0]&8&&Pi!==(Pi=D[3].m.b!=0))&&(_l.disabled=Pi),x[0]&8&&Fe(qt,D[3].m.b),(!Lt||x[0]&8&&Mi!==(Mi=D[3].m.b!=0))&&(dl.disabled=Mi),(!Lt||x[0]&8&&Di!==(Di=D[3].m.b==0))&&(xe.disabled=Di),x[0]&8&&Fe(xe,D[3].m.p),x[0]&8&&(St.checked=D[3].m.i),x[0]&8&&Fe(Ut,D[3].m.d),x[0]&8&&me(Pt.value)!==D[3].m.f&&Y(Pt,D[3].m.f),x[0]&8&&me(Mt.value)!==D[3].m.r&&Y(Mt,D[3].m.r),x[0]&8&&(Dt.checked=D[3].m.e.e),D[3].m.e.e?st?st.p(D,x):(st=Ea(D),st.c(),st.m(Nl,null)):st&&(st.d(1),st=null),D[3].m.e.e?ot?ot.p(D,x):(ot=Ra(D),ot.c(),ot.m(ge,gs)):ot&&(ot.d(1),ot=null),x[0]&8&&(At.checked=D[3].m.m.e),D[3].m.m.e?ut?ut.p(D,x):(ut=Fa(D),ut.c(),ut.m(ge,null)):ut&&(ut.d(1),ut=null),x[0]&8&&Xt.value!==D[3].w.s&&Y(Xt,D[3].w.s),x[0]&8&&xt.value!==D[3].w.p&&Y(xt,D[3].w.p),x[0]&8&&Fe(bt,D[3].w.z),x[0]&8&&me(kt.value)!==D[3].w.w&&Y(kt,D[3].w.w),x[0]&8&&(Nt.checked=D[3].w.a),x[0]&8&&Fe(Ht,D[3].n.m),(!Lt||x[0]&8&&Ui!==(Ui=D[3].n.m=="dhcp"))&&(dt.disabled=Ui),(!Lt||x[0]&8&&Hi!==(Hi=D[3].n.m=="static"))&&(dt.required=Hi),x[0]&8&&dt.value!==D[3].n.i&&Y(dt,D[3].n.i),(!Lt||x[0]&8&&ji!==(ji=D[3].n.m=="dhcp"))&&(vt.disabled=ji),(!Lt||x[0]&8&&Wi!==(Wi=D[3].n.m=="static"))&&(vt.required=Wi),x[0]&8&&Fe(vt,D[3].n.s),D[3].n.m=="static"?rt?rt.p(D,x):(rt=La(D),rt.c(),rt.m(Je,bs)):rt&&(rt.d(1),rt=null),x[0]&8&&(It.checked=D[3].n.d),x[0]&8&&(Et.checked=D[3].n.h),x[0]&8&&el.value!==D[3].n.n1&&Y(el,D[3].n.n1),D[0].chip!="esp8266"?at?at.p(D,x):(at=Oa(D),at.c(),at.m(jt,ks)):at&&(at.d(1),at=null),x[0]&8&&tl.value!==D[3].q.h&&Y(tl,D[3].q.h),x[0]&8&&me(Rt.value)!==D[3].q.p&&Y(Rt,D[3].q.p),D[3].q.s.e?ze?(ze.p(D,x),x[0]&8&&M(ze,1)):(ze=qa(D),ze.c(),M(ze,1),ze.m(We,ws)):ze&&(Ce(),I(ze,1,1,()=>{ze=null}),Te()),x[0]&8&&ll.value!==D[3].q.u&&Y(ll,D[3].q.u),x[0]&8&&nl.value!==D[3].q.a&&Y(nl,D[3].q.a),x[0]&8&&il.value!==D[3].q.c&&Y(il,D[3].q.c),x[0]&8&&Fe(lt,D[3].q.m),x[0]&8&&sl.value!==D[3].q.b&&Y(sl,D[3].q.b),D[3].q.m==3?Ye?(Ye.p(D,x),x[0]&8&&M(Ye,1)):(Ye=Ua(D),Ye.c(),M(Ye,1),Ye.m(l,ys)):Ye&&(Ce(),I(Ye,1,1,()=>{Ye=null}),Te()),D[3].q.m==4?Ve?(Ve.p(D,x),x[0]&8&&M(Ve,1)):(Ve=Ha(D),Ve.c(),M(Ve,1),Ve.m(l,$s)):Ve&&(Ce(),I(Ve,1,1,()=>{Ve=null}),Te()),x[0]&8&&(Cs=D[3].p.r.startsWith("10YNO")||D[3].p.r=="10Y1001A1001A48H"),Cs?Ke?(Ke.p(D,x),x[0]&8&&M(Ke,1)):(Ke=ja(D),Ke.c(),M(Ke,1),Ke.m(l,Ts)):Ke&&(Ce(),I(Ke,1,1,()=>{Ke=null}),Te()),x[0]&136){qn=D[7];let wt;for(wt=0;wt20||D[0].chip=="esp8266"?Qe?(Qe.p(D,x),x[0]&1&&M(Qe,1)):(Qe=Ba(D),Qe.c(),M(Qe,1),Qe.m(l,Ss)):Qe&&(Ce(),I(Qe,1,1,()=>{Qe=null}),Te()),x[0]&8&&(Ft.checked=D[3].d.s),D[3].d.s?ct?ct.p(D,x):(ct=Za(D),ct.c(),ct.m(ht,null)):ct&&(ct.d(1),ct=null);const mt={};x[0]&2&&(mt.active=D[1]),Hl.$set(mt);const cr={};x[0]&4&&(cr.active=D[2]),jl.$set(cr);const mr={};x[0]&16&&(mr.active=D[4]),Wl.$set(mr);const pr={};x[0]&32&&(pr.active=D[5]),Gl.$set(pr)},i(D){Lt||(M(a.$$.fragment,D),M(R.$$.fragment,D),M(cl.$$.fragment,D),M(rn.$$.fragment,D),M(vn.$$.fragment,D),M(bn.$$.fragment,D),M(wn.$$.fragment,D),M(ze),M(Ye),M(Ve),M(Ke),M(En.$$.fragment,D),M(Qe),M(Fn.$$.fragment,D),M(Hl.$$.fragment,D),M(jl.$$.fragment,D),M(Wl.$$.fragment,D),M(Gl.$$.fragment,D),Lt=!0)},o(D){I(a.$$.fragment,D),I(R.$$.fragment,D),I(cl.$$.fragment,D),I(rn.$$.fragment,D),I(vn.$$.fragment,D),I(bn.$$.fragment,D),I(wn.$$.fragment,D),I(ze),I(Ye),I(Ve),I(Ke),I(En.$$.fragment,D),I(Qe),I(Fn.$$.fragment,D),I(Hl.$$.fragment,D),I(jl.$$.fragment,D),I(Wl.$$.fragment,D),I(Gl.$$.fragment,D),Lt=!1},d(D){D&&w(e),Q(a),Q(R),Vt(xi,D),nt&&nt.d(),it&&it.d(),Q(cl),Vt(es,D),st&&st.d(),ot&&ot.d(),ut&&ut.d(),Q(rn),Q(vn),Q(bn),rt&&rt.d(),Q(wn),at&&at.d(),ze&&ze.d(),Ye&&Ye.d(),Ve&&Ve.d(),Ke&&Ke.d(),Q(En),Vt(ft,D),Qe&&Qe.d(),Q(Fn),ct&&ct.d(),D&&w(Ms),Q(Hl,D),D&&w(Ds),Q(jl,D),D&&w(As),Q(Wl,D),D&&w(Ns),Q(Gl,D),Is=!1,Ge(fr)}}}async function wp(){await(await fetch("/reboot",{method:"POST"})).json()}function yp(t,e,l){let{sysinfo:n={}}=e,i=[{name:"Import gauge",key:"i"},{name:"Export gauge",key:"e"},{name:"Voltage",key:"v"},{name:"Amperage",key:"a"},{name:"Reactive",key:"r"},{name:"Realtime",key:"c"},{name:"Peaks",key:"t"},{name:"Price",key:"p"},{name:"Day plot",key:"d"},{name:"Month plot",key:"m"},{name:"Temperature plot",key:"s"}],o=!0,r=!1,a={g:{t:"",h:"",s:0,u:"",p:""},m:{b:2400,p:11,i:!1,d:0,f:0,r:0,e:{e:!1,k:"",a:""},m:{e:!1,w:!1,v:!1,a:!1,c:!1}},w:{s:"",p:"",w:0,z:255,a:!0},n:{m:"",i:"",s:"",g:"",d1:"",d2:"",d:!1,n1:"",n2:"",h:!1},q:{h:"",p:1883,u:"",a:"",b:"",s:{e:!1,c:!1,r:!0,k:!1}},o:{e:"",c:"",u1:"",u2:"",u3:""},t:{t:[0,0,0,0,0,0,0,0,0,0],h:1},p:{e:!1,t:"",r:"",c:"",m:1},d:{s:!1,t:!1,l:5},u:{i:0,e:0,v:0,a:0,r:0,c:0,t:0,p:0,d:0,m:0,s:0},i:{h:null,a:null,l:{p:null,i:!1},r:{r:null,g:null,b:null,i:!1},t:{d:null,a:null},v:{p:null,d:{v:null,g:null},o:null,m:null,b:null}},h:{t:"",h:"",n:""}};cc.subscribe(ge=>{ge.version&&(l(3,a=ge),l(1,o=!1))}),Xm();let c=!1,f=!1;async function p(){if(confirm("Are you sure you want to factory reset the device?")){l(4,c=!0);const ge=new URLSearchParams;ge.append("perform","true");let Tl=await(await fetch("/reset",{method:"POST",body:ge})).json();l(4,c=!1),l(5,f=Tl.success)}}async function _(ge){l(2,r=!0);const Cl=new FormData(ge.target),Tl=new URLSearchParams;for(let ml of Cl){const[Pl,Si]=ml;Tl.append(Pl,Si)}let cl=await(await fetch("/save",{method:"POST",body:Tl})).json();Ct.update(ml=>(ml.booting=cl.reboot,ml.ui=a.u,ml)),l(2,r=!1),jn("/")}const d=function(){confirm("Are you sure you want to reboot the device?")&&(Ct.update(ge=>(ge.booting=!0,ge)),wp())},g=function(){a.q.s.e?a.q.p==1883&&l(3,a.q.p=8883,a):a.q.p==8883&&l(3,a.q.p=1883,a)};let h=44;function b(){a.g.h=this.value,l(3,a)}function $(){a.g.t=et(this),l(3,a)}function k(){a.p.r=et(this),l(3,a)}function T(){a.p.c=et(this),l(3,a)}function P(){a.p.m=me(this.value),l(3,a)}function E(){a.p.e=this.checked,l(3,a)}function S(){a.p.t=this.value,l(3,a)}function N(){a.g.s=et(this),l(3,a)}function A(){a.g.u=this.value,l(3,a)}function R(){a.g.p=this.value,l(3,a)}function H(){a.m.b=et(this),l(3,a)}function U(){a.m.p=et(this),l(3,a)}function F(){a.m.i=this.checked,l(3,a)}function L(){a.m.d=et(this),l(3,a)}function G(){a.m.f=me(this.value),l(3,a)}function j(){a.m.r=me(this.value),l(3,a)}function O(){a.m.e.e=this.checked,l(3,a)}function q(){a.m.e.k=this.value,l(3,a)}function W(){a.m.e.a=this.value,l(3,a)}function X(){a.m.m.e=this.checked,l(3,a)}function z(){a.m.m.w=me(this.value),l(3,a)}function ne(){a.m.m.v=me(this.value),l(3,a)}function te(){a.m.m.a=me(this.value),l(3,a)}function De(){a.m.m.c=me(this.value),l(3,a)}function _e(){a.w.s=this.value,l(3,a)}function Ie(){a.w.p=this.value,l(3,a)}function Ee(){a.w.z=et(this),l(3,a)}function Le(){a.w.w=me(this.value),l(3,a)}function Re(){a.w.a=this.checked,l(3,a)}function Se(){a.n.m=et(this),l(3,a)}function be(){a.n.i=this.value,l(3,a)}function fe(){a.n.s=et(this),l(3,a)}function ae(){a.n.g=this.value,l(3,a)}function ce(){a.n.d1=this.value,l(3,a)}function ue(){a.n.d2=this.value,l(3,a)}function J(){a.n.d=this.checked,l(3,a)}function se(){a.n.h=this.checked,l(3,a)}function Pe(){a.n.n1=this.value,l(3,a)}function ee(){a.q.s.e=this.checked,l(3,a)}function oe(){a.q.h=this.value,l(3,a)}function Ue(){a.q.p=me(this.value),l(3,a)}function Me(){a.q.u=this.value,l(3,a)}function de(){a.q.a=this.value,l(3,a)}function ve(){a.q.c=this.value,l(3,a)}function le(){a.q.m=et(this),l(3,a)}function he(){a.q.b=this.value,l(3,a)}function qe(){a.o.e=this.value,l(3,a)}function re(){a.o.c=this.value,l(3,a)}function Ae(){a.o.u1=this.value,l(3,a)}function fi(){a.o.u2=this.value,l(3,a)}function ci(){a.o.u3=this.value,l(3,a)}function mi(){a.h.t=this.value,l(3,a)}function Tt(){a.h.h=this.value,l(3,a)}function pi(){a.h.n=this.value,l(3,a)}function Qt(ge){a.t.t[ge]=me(this.value),l(3,a)}function _i(){a.t.h=me(this.value),l(3,a)}function di(ge){a.u[ge.key]=et(this),l(3,a)}function vi(){a.i.h=et(this),l(3,a)}function tt(){a.i.a=me(this.value),l(3,a)}function hi(){a.i.l.i=this.checked,l(3,a)}function Zt(){a.i.l.p=me(this.value),l(3,a)}function Ql(){a.i.r.i=this.checked,l(3,a)}function pt(){a.i.r.r=me(this.value),l(3,a)}function gi(){a.i.r.g=me(this.value),l(3,a)}function bi(){a.i.r.b=me(this.value),l(3,a)}function ki(){a.i.t.d=me(this.value),l(3,a)}function Jt(){a.i.t.a=me(this.value),l(3,a)}function wi(){a.i.v.p=me(this.value),l(3,a)}function yi(){a.i.v.d.v=me(this.value),l(3,a)}function $i(){a.i.v.d.g=me(this.value),l(3,a)}function _t(){a.i.v.o=me(this.value),l(3,a)}function rl(){a.i.v.m=me(this.value),l(3,a)}function al(){a.i.v.b=me(this.value),l(3,a)}function fl(){a.d.s=this.checked,l(3,a)}function Ci(){a.d.t=this.checked,l(3,a)}function Ti(){a.d.l=et(this),l(3,a)}return t.$$set=ge=>{"sysinfo"in ge&&l(0,n=ge.sysinfo)},t.$$.update=()=>{t.$$.dirty[0]&1&&l(6,h=n.chip=="esp8266"?16:n.chip=="esp32s2"?44:39)},[n,o,r,a,c,f,h,i,p,_,d,g,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G,j,O,q,W,X,z,ne,te,De,_e,Ie,Ee,Le,Re,Se,be,fe,ae,ce,ue,J,se,Pe,ee,oe,Ue,Me,de,ve,le,he,qe,re,Ae,fi,ci,mi,Tt,pi,Qt,_i,di,vi,tt,hi,Zt,Ql,pt,gi,bi,ki,Jt,wi,yi,$i,_t,rl,al,fl,Ci,Ti]}class $p extends $e{constructor(e){super(),ye(this,e,yp,kp,we,{sysinfo:0},null,[-1,-1,-1,-1])}}function Xa(t,e,l){const n=t.slice();return n[20]=e[l],n}function Cp(t){let e=pe(t[1].chip,t[1].board)+"",l;return{c(){l=C(e)},m(n,i){y(n,l,i)},p(n,i){i&2&&e!==(e=pe(n[1].chip,n[1].board)+"")&&B(l,e)},d(n){n&&w(l)}}}function xa(t){let e,l,n=t[1].apmac+"",i,o,r,a,c,f,p,_,d,g=Nr(t[1])+"",h,b,$=t[1].boot_reason+"",k,T,P;const E=[Sp,Tp],S=[];function N(A,R){return A[0].u>0?0:1}return c=N(t),f=S[c]=E[c](t),{c(){e=m("div"),l=C("AP MAC: "),i=C(n),o=v(),r=m("div"),a=C(`Last boot: + `),f.c(),p=v(),_=m("div"),d=C("Reason: "),h=C(g),b=C(" ("),k=C($),T=C(")"),u(e,"class","my-2"),u(r,"class","my-2"),u(_,"class","my-2")},m(A,R){y(A,e,R),s(e,l),s(e,i),y(A,o,R),y(A,r,R),s(r,a),S[c].m(r,null),y(A,p,R),y(A,_,R),s(_,d),s(_,h),s(_,b),s(_,k),s(_,T),P=!0},p(A,R){(!P||R&2)&&n!==(n=A[1].apmac+"")&&B(i,n);let H=c;c=N(A),c===H?S[c].p(A,R):(Ce(),I(S[H],1,1,()=>{S[H]=null}),Te(),f=S[c],f?f.p(A,R):(f=S[c]=E[c](A),f.c()),M(f,1),f.m(r,null)),(!P||R&2)&&g!==(g=Nr(A[1])+"")&&B(h,g),(!P||R&2)&&$!==($=A[1].boot_reason+"")&&B(k,$)},i(A){P||(M(f),P=!0)},o(A){I(f),P=!1},d(A){A&&w(e),A&&w(o),A&&w(r),S[c].d(),A&&w(p),A&&w(_)}}}function Tp(t){let e;return{c(){e=C("-")},m(l,n){y(l,e,n)},p:ie,i:ie,o:ie,d(l){l&&w(e)}}}function Sp(t){let e,l;return e=new rc({props:{timestamp:new Date(new Date().getTime()-t[0].u*1e3),fullTimeColor:""}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.timestamp=new Date(new Date().getTime()-n[0].u*1e3)),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function Pp(t){let e;return{c(){e=m("span"),e.textContent="Update consents",u(e,"class","btn-pri-sm")},m(l,n){y(l,e,n)},p:ie,d(l){l&&w(e)}}}function ef(t){let e,l,n,i,o,r=ms(t[1].meter.mfg)+"",a,c,f,p,_=t[1].meter.model+"",d,g,h,b,$=t[1].meter.id+"",k;return{c(){e=m("div"),l=m("strong"),l.textContent="Meter",n=v(),i=m("div"),o=C("Manufacturer: "),a=C(r),c=v(),f=m("div"),p=C("Model: "),d=C(_),g=v(),h=m("div"),b=C("ID: "),k=C($),u(l,"class","text-sm"),u(i,"class","my-2"),u(f,"class","my-2"),u(h,"class","my-2"),u(e,"class","cnt")},m(T,P){y(T,e,P),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(e,c),s(e,f),s(f,p),s(f,d),s(e,g),s(e,h),s(h,b),s(h,k)},p(T,P){P&2&&r!==(r=ms(T[1].meter.mfg)+"")&&B(a,r),P&2&&_!==(_=T[1].meter.model+"")&&B(d,_),P&2&&$!==($=T[1].meter.id+"")&&B(k,$)},d(T){T&&w(e)}}}function tf(t){let e,l,n,i,o,r=t[1].net.ip+"",a,c,f,p,_=t[1].net.mask+"",d,g,h,b,$=t[1].net.gw+"",k,T,P,E,S=t[1].net.dns1+"",N,A,R=t[1].net.dns2&&lf(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Network",n=v(),i=m("div"),o=C("IP: "),a=C(r),c=v(),f=m("div"),p=C("Mask: "),d=C(_),g=v(),h=m("div"),b=C("Gateway: "),k=C($),T=v(),P=m("div"),E=C("DNS: "),N=C(S),A=v(),R&&R.c(),u(l,"class","text-sm"),u(i,"class","my-2"),u(f,"class","my-2"),u(h,"class","my-2"),u(P,"class","my-2"),u(e,"class","cnt")},m(H,U){y(H,e,U),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(e,c),s(e,f),s(f,p),s(f,d),s(e,g),s(e,h),s(h,b),s(h,k),s(e,T),s(e,P),s(P,E),s(P,N),s(P,A),R&&R.m(P,null)},p(H,U){U&2&&r!==(r=H[1].net.ip+"")&&B(a,r),U&2&&_!==(_=H[1].net.mask+"")&&B(d,_),U&2&&$!==($=H[1].net.gw+"")&&B(k,$),U&2&&S!==(S=H[1].net.dns1+"")&&B(N,S),H[1].net.dns2?R?R.p(H,U):(R=lf(H),R.c(),R.m(P,null)):R&&(R.d(1),R=null)},d(H){H&&w(e),R&&R.d()}}}function lf(t){let e,l=t[1].net.dns2+"",n;return{c(){e=C("/ "),n=C(l)},m(i,o){y(i,e,o),y(i,n,o)},p(i,o){o&2&&l!==(l=i[1].net.dns2+"")&&B(n,l)},d(i){i&&w(e),i&&w(n)}}}function nf(t){let e,l,n,i=t[2].tag_name+"",o,r,a,c,f,p,_=(t[1].security==0||t[0].a)&&t[1].fwconsent===1&&t[2]&&t[2].tag_name&&sf(t),d=t[1].fwconsent===2&&of();return{c(){e=m("div"),l=C(`Latest version: + `),n=m("a"),o=C(i),a=v(),_&&_.c(),c=v(),d&&d.c(),f=je(),u(n,"href",r=t[2].html_url),u(n,"class","ml-2 text-blue-600 hover:text-blue-800"),u(n,"target","_blank"),u(n,"rel","noreferrer"),u(e,"class","my-2 flex")},m(g,h){y(g,e,h),s(e,l),s(e,n),s(n,o),s(e,a),_&&_.m(e,null),y(g,c,h),d&&d.m(g,h),y(g,f,h),p=!0},p(g,h){(!p||h&4)&&i!==(i=g[2].tag_name+"")&&B(o,i),(!p||h&4&&r!==(r=g[2].html_url))&&u(n,"href",r),(g[1].security==0||g[0].a)&&g[1].fwconsent===1&&g[2]&&g[2].tag_name?_?(_.p(g,h),h&7&&M(_,1)):(_=sf(g),_.c(),M(_,1),_.m(e,null)):_&&(Ce(),I(_,1,1,()=>{_=null}),Te()),g[1].fwconsent===2?d||(d=of(),d.c(),d.m(f.parentNode,f)):d&&(d.d(1),d=null)},i(g){p||(M(_),p=!0)},o(g){I(_),p=!1},d(g){g&&w(e),_&&_.d(),g&&w(c),d&&d.d(g),g&&w(f)}}}function sf(t){let e,l,n,i,o,r;return n=new ac({}),{c(){e=m("div"),l=m("button"),Z(n.$$.fragment),u(e,"class","flex-none ml-2 text-green-500"),u(e,"title","Install this version")},m(a,c){y(a,e,c),s(e,l),K(n,l,null),i=!0,o||(r=V(l,"click",t[10]),o=!0)},p:ie,i(a){i||(M(n.$$.fragment,a),i=!0)},o(a){I(n.$$.fragment,a),i=!1},d(a){a&&w(e),Q(n),o=!1,r()}}}function of(t){let e;return{c(){e=m("div"),e.innerHTML='
You have disabled one-click firmware upgrade, link to self-upgrade is disabled
',u(e,"class","my-2")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function uf(t){let e,l=ps(pe(t[1].chip,t[1].board))+"",n;return{c(){e=m("div"),n=C(l),u(e,"class","bd-red")},m(i,o){y(i,e,o),s(e,n)},p(i,o){o&2&&l!==(l=ps(pe(i[1].chip,i[1].board))+"")&&B(n,l)},d(i){i&&w(e)}}}function rf(t){let e,l,n,i,o,r;function a(p,_){return p[4].length==0?Dp:Mp}let c=a(t),f=c(t);return{c(){e=m("div"),l=m("form"),n=m("input"),i=v(),f.c(),Cf(n,"display","none"),u(n,"name","file"),u(n,"type","file"),u(n,"accept",".bin"),u(l,"action","/firmware"),u(l,"enctype","multipart/form-data"),u(l,"method","post"),u(l,"autocomplete","off"),u(e,"class","my-2 flex")},m(p,_){y(p,e,_),s(e,l),s(l,n),t[12](n),s(l,i),f.m(l,null),o||(r=[V(n,"change",t[13]),V(l,"submit",t[15])],o=!0)},p(p,_){c===(c=a(p))&&f?f.p(p,_):(f.d(1),f=c(p),f&&(f.c(),f.m(l,null)))},d(p){p&&w(e),t[12](null),f.d(),o=!1,Ge(r)}}}function Mp(t){let e=t[4][0].name+"",l,n,i;return{c(){l=C(e),n=v(),i=m("button"),i.textContent="Upload",u(i,"type","submit"),u(i,"class","btn-pri-sm float-right")},m(o,r){y(o,l,r),y(o,n,r),y(o,i,r)},p(o,r){r&16&&e!==(e=o[4][0].name+"")&&B(l,e)},d(o){o&&w(l),o&&w(n),o&&w(i)}}}function Dp(t){let e,l,n;return{c(){e=m("button"),e.textContent="Select firmware file for upgrade",u(e,"type","button"),u(e,"class","btn-pri-sm float-right")},m(i,o){y(i,e,o),l||(n=V(e,"click",t[14]),l=!0)},p:ie,d(i){i&&w(e),l=!1,n()}}}function af(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b=t[9],$=[];for(let S=0;S Include Secrets
(SSID, PSK, passwords and tokens)',c=v(),k&&k.c(),f=v(),p=m("form"),_=m("input"),d=v(),E.c(),u(l,"class","text-sm"),u(a,"class","my-1 mx-3 col-span-2"),u(o,"class","grid grid-cols-2"),u(i,"method","get"),u(i,"action","/configfile.cfg"),u(i,"autocomplete","off"),Cf(_,"display","none"),u(_,"name","file"),u(_,"type","file"),u(_,"accept",".cfg"),u(p,"action","/configfile"),u(p,"enctype","multipart/form-data"),u(p,"method","post"),u(p,"autocomplete","off"),u(e,"class","cnt")},m(S,N){y(S,e,N),s(e,l),s(e,n),s(e,i),s(i,o);for(let A=0;A<$.length;A+=1)$[A].m(o,null);s(o,r),s(o,a),s(i,c),k&&k.m(i,null),s(e,f),s(e,p),s(p,_),t[16](_),s(p,d),E.m(p,null),g||(h=[V(_,"change",t[17]),V(p,"submit",t[19])],g=!0)},p(S,N){if(N&512){b=S[9];let A;for(A=0;A{fe=null}),Te());const Me={};oe&8388608&&(Me.$$scope={dirty:oe,ctx:ee}),S.$set(Me),ee[1].meter?ae?ae.p(ee,oe):(ae=ef(ee),ae.c(),ae.m(e,H)):ae&&(ae.d(1),ae=null),ee[1].net?ce?ce.p(ee,oe):(ce=tf(ee),ce.c(),ce.m(e,U)):ce&&(ce.d(1),ce=null),(!Re||oe&2)&&q!==(q=ee[1].version+"")&&B(W,q),ee[2]?ue?(ue.p(ee,oe),oe&4&&M(ue,1)):(ue=nf(ee),ue.c(),M(ue,1),ue.m(F,z)):ue&&(Ce(),I(ue,1,1,()=>{ue=null}),Te()),oe&3&&(ne=(ee[1].security==0||ee[0].a)&&Wn(ee[1].board)),ne?J?J.p(ee,oe):(J=uf(ee),J.c(),J.m(F,te)):J&&(J.d(1),J=null),ee[1].security==0||ee[0].a?se?se.p(ee,oe):(se=rf(ee),se.c(),se.m(F,null)):se&&(se.d(1),se=null),ee[1].security==0||ee[0].a?Pe?Pe.p(ee,oe):(Pe=af(ee),Pe.c(),Pe.m(e,null)):Pe&&(Pe.d(1),Pe=null);const de={};oe&32&&(de.active=ee[5]),Ie.$set(de);const ve={};oe&256&&(ve.active=ee[8]),Le.$set(ve)},i(ee){Re||(M(d.$$.fragment,ee),M(fe),M(S.$$.fragment,ee),M(ue),M(Ie.$$.fragment,ee),M(Le.$$.fragment,ee),Re=!0)},o(ee){I(d.$$.fragment,ee),I(fe),I(S.$$.fragment,ee),I(ue),I(Ie.$$.fragment,ee),I(Le.$$.fragment,ee),Re=!1},d(ee){ee&&w(e),Q(d),fe&&fe.d(),Q(S),ae&&ae.d(),ce&&ce.d(),ue&&ue.d(),J&&J.d(),se&&se.d(),Pe&&Pe.d(),ee&&w(_e),Q(Ie,ee),ee&&w(Ee),Q(Le,ee),Se=!1,be()}}}async function Ep(){await(await fetch("/reboot",{method:"POST"})).json()}function Rp(t,e,l){let{data:n}=e,{sysinfo:i}=e,o=[{name:"WiFi",key:"iw"},{name:"MQTT",key:"im"},{name:"Web",key:"ie"},{name:"Meter",key:"it"},{name:"Thresholds",key:"ih"},{name:"GPIO",key:"ig"},{name:"Domoticz",key:"id"},{name:"NTP",key:"in"},{name:"Price API",key:"is"}],r={};ao.subscribe(A=>{l(2,r=uc(i.version,A)),r||l(2,r=A[0])});function a(){confirm("Do you want to upgrade this device to "+r.tag_name+"?")&&(i.board!=2&&i.board!=4&&i.board!=7||confirm(ps(pe(i.chip,i.board))))&&(Ct.update(A=>(A.upgrading=!0,A)),oc())}const c=function(){confirm("Are you sure you want to reboot the device?")&&(Ct.update(A=>(A.booting=!0,A)),Ep())};let f,p=[],_=!1,d,g=[],h=!1;oo();function b(A){fs[A?"unshift":"push"](()=>{f=A,l(3,f)})}function $(){p=this.files,l(4,p)}const k=()=>{f.click()},T=()=>l(5,_=!0);function P(A){fs[A?"unshift":"push"](()=>{d=A,l(6,d)})}function E(){g=this.files,l(7,g)}const S=()=>{d.click()},N=()=>l(8,h=!0);return t.$$set=A=>{"data"in A&&l(0,n=A.data),"sysinfo"in A&&l(1,i=A.sysinfo)},[n,i,r,f,p,_,d,g,h,o,a,c,b,$,k,T,P,E,S,N]}class Fp extends $e{constructor(e){super(),ye(this,e,Rp,Ip,we,{data:0,sysinfo:1})}}function mf(t){let e,l,n=pe(t[0],7)+"",i,o,r=pe(t[0],5)+"",a,c,f=pe(t[0],4)+"",p,_,d=pe(t[0],3)+"",g,h,b,$,k=pe(t[0],2)+"",T,P,E=pe(t[0],1)+"",S,N,A=pe(t[0],0)+"",R,H,U,F,L=pe(t[0],101)+"",G,j,O=pe(t[0],100)+"",q;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),c=m("option"),p=C(f),_=m("option"),g=C(d),h=v(),b=m("optgroup"),$=m("option"),T=C(k),P=m("option"),S=C(E),N=m("option"),R=C(A),H=v(),U=m("optgroup"),F=m("option"),G=C(L),j=m("option"),q=C(O),l.__value=7,l.value=l.__value,o.__value=5,o.value=o.__value,c.__value=4,c.value=c.__value,_.__value=3,_.value=_.__value,u(e,"label","amsleser.no"),$.__value=2,$.value=$.__value,P.__value=1,P.value=P.__value,N.__value=0,N.value=N.__value,u(b,"label","Custom hardware"),F.__value=101,F.value=F.__value,j.__value=100,j.value=j.__value,u(U,"label","Generic hardware")},m(W,X){y(W,e,X),s(e,l),s(l,i),s(e,o),s(o,a),s(e,c),s(c,p),s(e,_),s(_,g),y(W,h,X),y(W,b,X),s(b,$),s($,T),s(b,P),s(P,S),s(b,N),s(N,R),y(W,H,X),y(W,U,X),s(U,F),s(F,G),s(U,j),s(j,q)},p(W,X){X&1&&n!==(n=pe(W[0],7)+"")&&B(i,n),X&1&&r!==(r=pe(W[0],5)+"")&&B(a,r),X&1&&f!==(f=pe(W[0],4)+"")&&B(p,f),X&1&&d!==(d=pe(W[0],3)+"")&&B(g,d),X&1&&k!==(k=pe(W[0],2)+"")&&B(T,k),X&1&&E!==(E=pe(W[0],1)+"")&&B(S,E),X&1&&A!==(A=pe(W[0],0)+"")&&B(R,A),X&1&&L!==(L=pe(W[0],101)+"")&&B(G,L),X&1&&O!==(O=pe(W[0],100)+"")&&B(q,O)},d(W){W&&w(e),W&&w(h),W&&w(b),W&&w(H),W&&w(U)}}}function pf(t){let e,l,n=pe(t[0],201)+"",i,o,r=pe(t[0],202)+"",a,c,f=pe(t[0],203)+"",p,_,d=pe(t[0],200)+"",g;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),c=m("option"),p=C(f),_=m("option"),g=C(d),l.__value=201,l.value=l.__value,o.__value=202,o.value=o.__value,c.__value=203,c.value=c.__value,_.__value=200,_.value=_.__value,u(e,"label","Generic hardware")},m(h,b){y(h,e,b),s(e,l),s(l,i),s(e,o),s(o,a),s(e,c),s(c,p),s(e,_),s(_,g)},p(h,b){b&1&&n!==(n=pe(h[0],201)+"")&&B(i,n),b&1&&r!==(r=pe(h[0],202)+"")&&B(a,r),b&1&&f!==(f=pe(h[0],203)+"")&&B(p,f),b&1&&d!==(d=pe(h[0],200)+"")&&B(g,d)},d(h){h&&w(e)}}}function _f(t){let e,l,n=pe(t[0],7)+"",i,o,r=pe(t[0],6)+"",a,c,f=pe(t[0],5)+"",p,_,d,g,h=pe(t[0],51)+"",b,$,k=pe(t[0],50)+"",T;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),c=m("option"),p=C(f),_=v(),d=m("optgroup"),g=m("option"),b=C(h),$=m("option"),T=C(k),l.__value=7,l.value=l.__value,o.__value=6,o.value=o.__value,c.__value=5,c.value=c.__value,u(e,"label","amsleser.no"),g.__value=51,g.value=g.__value,$.__value=50,$.value=$.__value,u(d,"label","Generic hardware")},m(P,E){y(P,e,E),s(e,l),s(l,i),s(e,o),s(o,a),s(e,c),s(c,p),y(P,_,E),y(P,d,E),s(d,g),s(g,b),s(d,$),s($,T)},p(P,E){E&1&&n!==(n=pe(P[0],7)+"")&&B(i,n),E&1&&r!==(r=pe(P[0],6)+"")&&B(a,r),E&1&&f!==(f=pe(P[0],5)+"")&&B(p,f),E&1&&h!==(h=pe(P[0],51)+"")&&B(b,h),E&1&&k!==(k=pe(P[0],50)+"")&&B(T,k)},d(P){P&&w(e),P&&w(_),P&&w(d)}}}function df(t){let e,l,n=pe(t[0],71)+"",i,o,r=pe(t[0],70)+"",a;return{c(){e=m("optgroup"),l=m("option"),i=C(n),o=m("option"),a=C(r),l.__value=71,l.value=l.__value,o.__value=70,o.value=o.__value,u(e,"label","Generic hardware")},m(c,f){y(c,e,f),s(e,l),s(l,i),s(e,o),s(o,a)},p(c,f){f&1&&n!==(n=pe(c[0],71)+"")&&B(i,n),f&1&&r!==(r=pe(c[0],70)+"")&&B(a,r)},d(c){c&&w(e)}}}function vf(t){let e,l,n=pe(t[0],200)+"",i;return{c(){e=m("optgroup"),l=m("option"),i=C(n),l.__value=200,l.value=l.__value,u(e,"label","Generic hardware")},m(o,r){y(o,e,r),s(e,l),s(l,i)},p(o,r){r&1&&n!==(n=pe(o[0],200)+"")&&B(i,n)},d(o){o&&w(e)}}}function Lp(t){let e,l,n,i,o,r,a,c=t[0]=="esp8266"&&mf(t),f=t[0]=="esp32"&&pf(t),p=t[0]=="esp32s2"&&_f(t),_=t[0]=="esp32c3"&&df(t),d=t[0]=="esp32solo"&&vf(t);return{c(){e=m("option"),l=v(),c&&c.c(),n=v(),f&&f.c(),i=v(),p&&p.c(),o=v(),_&&_.c(),r=v(),d&&d.c(),a=je(),e.__value=-1,e.value=e.__value},m(g,h){y(g,e,h),y(g,l,h),c&&c.m(g,h),y(g,n,h),f&&f.m(g,h),y(g,i,h),p&&p.m(g,h),y(g,o,h),_&&_.m(g,h),y(g,r,h),d&&d.m(g,h),y(g,a,h)},p(g,[h]){g[0]=="esp8266"?c?c.p(g,h):(c=mf(g),c.c(),c.m(n.parentNode,n)):c&&(c.d(1),c=null),g[0]=="esp32"?f?f.p(g,h):(f=pf(g),f.c(),f.m(i.parentNode,i)):f&&(f.d(1),f=null),g[0]=="esp32s2"?p?p.p(g,h):(p=_f(g),p.c(),p.m(o.parentNode,o)):p&&(p.d(1),p=null),g[0]=="esp32c3"?_?_.p(g,h):(_=df(g),_.c(),_.m(r.parentNode,r)):_&&(_.d(1),_=null),g[0]=="esp32solo"?d?d.p(g,h):(d=vf(g),d.c(),d.m(a.parentNode,a)):d&&(d.d(1),d=null)},i:ie,o:ie,d(g){g&&w(e),g&&w(l),c&&c.d(g),g&&w(n),f&&f.d(g),g&&w(i),p&&p.d(g),g&&w(o),_&&_.d(g),g&&w(r),d&&d.d(g),g&&w(a)}}}function Op(t,e,l){let{chip:n}=e;return t.$$set=i=>{"chip"in i&&l(0,n=i.chip)},[n]}class qp extends $e{constructor(e){super(),ye(this,e,Op,Lp,we,{chip:0})}}function hf(t){let e;return{c(){e=m("div"),e.textContent="WARNING: Changing this configuration will affect basic configuration of your device. Only make changes here if instructed by vendor",u(e,"class","bd-red")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function gf(t){let e,l,n,i,o,r,a;return r=new mc({props:{chip:t[0].chip}}),{c(){e=m("div"),l=C("HAN GPIO"),n=m("br"),i=v(),o=m("select"),Z(r.$$.fragment),u(o,"name","vh"),u(o,"class","in-s"),u(e,"class","my-3")},m(c,f){y(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),K(r,o,null),a=!0},p(c,f){const p={};f&1&&(p.chip=c[0].chip),r.$set(p)},i(c){a||(M(r.$$.fragment,c),a=!0)},o(c){I(r.$$.fragment,c),a=!1},d(c){c&&w(e),Q(r)}}}function Up(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G,j=t[0].usrcfg&&hf();h=new qp({props:{chip:t[0].chip}});let O=t[0].board&&t[0].board>20&&gf(t);return U=new gt({props:{active:t[1],message:"Saving device configuration"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=v(),r=m("strong"),r.textContent="Initial configuration",a=v(),j&&j.c(),c=v(),f=m("div"),p=C("Board type"),_=m("br"),d=v(),g=m("select"),Z(h.$$.fragment),b=v(),O&&O.c(),$=v(),k=m("div"),T=m("label"),P=m("input"),E=C(" Clear all other configuration"),S=v(),N=m("div"),N.innerHTML='',A=v(),R=m("span"),R.textContent="\xA0",H=v(),Z(U.$$.fragment),u(i,"type","hidden"),u(i,"name","v"),i.value="true",u(r,"class","text-sm"),u(g,"name","vb"),u(g,"class","in-s"),t[0].board===void 0&&Be(()=>t[4].call(g)),u(f,"class","my-3"),u(P,"type","checkbox"),u(P,"name","vr"),P.__value="true",P.value=P.__value,u(P,"class","rounded mb-1"),u(k,"class","my-3"),u(N,"class","my-3"),u(R,"class","clear-both"),u(n,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(q,W){y(q,e,W),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),j&&j.m(n,null),s(n,c),s(n,f),s(f,p),s(f,_),s(f,d),s(f,g),K(h,g,null),Fe(g,t[0].board),s(n,b),O&&O.m(n,null),s(n,$),s(n,k),s(k,T),s(T,P),P.checked=t[2],s(T,E),s(n,S),s(n,N),s(n,A),s(n,R),y(q,H,W),K(U,q,W),F=!0,L||(G=[V(g,"change",t[4]),V(P,"change",t[5]),V(n,"submit",_s(t[3]))],L=!0)},p(q,[W]){q[0].usrcfg?j||(j=hf(),j.c(),j.m(n,c)):j&&(j.d(1),j=null);const X={};W&1&&(X.chip=q[0].chip),h.$set(X),W&1&&Fe(g,q[0].board),q[0].board&&q[0].board>20?O?(O.p(q,W),W&1&&M(O,1)):(O=gf(q),O.c(),M(O,1),O.m(n,$)):O&&(Ce(),I(O,1,1,()=>{O=null}),Te()),W&4&&(P.checked=q[2]);const z={};W&2&&(z.active=q[1]),U.$set(z)},i(q){F||(M(h.$$.fragment,q),M(O),M(U.$$.fragment,q),F=!0)},o(q){I(h.$$.fragment,q),I(O),I(U.$$.fragment,q),F=!1},d(q){q&&w(e),j&&j.d(),Q(h),O&&O.d(),q&&w(H),Q(U,q),L=!1,Ge(G)}}}function Hp(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(f){l(1,i=!0);const p=new FormData(f.target),_=new URLSearchParams;for(let h of p){const[b,$]=h;_.append(b,$)}let g=await(await fetch("/save",{method:"POST",body:_})).json();l(1,i=!1),Ct.update(h=>(h.vndcfg=g.success,h.booting=g.reboot,h)),jn(n.usrcfg?"/":"/setup")}let r=!1;function a(){n.board=et(this),l(0,n)}function c(){r=this.checked,l(2,r),l(0,n)}return t.$$set=f=>{"sysinfo"in f&&l(0,n=f.sysinfo)},t.$$.update=()=>{t.$$.dirty&1&&l(2,r=!n.usrcfg)},[n,i,r,o,a,c]}class jp extends $e{constructor(e){super(),ye(this,e,Hp,Up,we,{sysinfo:0})}}function bf(t){let e,l,n,i,o,r,a,c;return a=new pc({}),{c(){e=m("br"),l=v(),n=m("div"),i=m("input"),o=v(),r=m("select"),Z(a.$$.fragment),u(i,"name","si"),u(i,"type","text"),u(i,"class","in-f w-full"),i.required=t[1],u(r,"name","su"),u(r,"class","in-l"),r.required=t[1],u(n,"class","flex")},m(f,p){y(f,e,p),y(f,l,p),y(f,n,p),s(n,i),s(n,o),s(n,r),K(a,r,null),c=!0},p(f,p){(!c||p&2)&&(i.required=f[1]),(!c||p&2)&&(r.required=f[1])},i(f){c||(M(a.$$.fragment,f),c=!0)},o(f){I(a.$$.fragment,f),c=!1},d(f){f&&w(e),f&&w(l),f&&w(n),Q(a)}}}function kf(t){let e;return{c(){e=m("div"),e.innerHTML=`
Gateway
DNS
-
`,u(e,"class","my-3 flex")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function Up(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W=t[1]&&vf(t),G=t[1]&&hf();return H=new gt({props:{active:t[2],message:"Saving your configuration to the device"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=v(),r=m("strong"),r.textContent="Setup",a=v(),f=m("div"),f.innerHTML=`SSID
- `,c=v(),p=m("div"),p.innerHTML=`PSK
+
`,u(e,"class","my-3 flex")},m(l,n){y(l,e,n)},d(l){l&&w(e)}}}function Wp(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G=t[1]&&bf(t),j=t[1]&&kf();return H=new gt({props:{active:t[2],message:"Saving your configuration to the device"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=v(),r=m("strong"),r.textContent="Setup",a=v(),c=m("div"),c.innerHTML=`SSID
+ `,f=v(),p=m("div"),p.innerHTML=`PSK
`,_=v(),d=m("div"),g=C(`Hostname - `),h=m("input"),b=v(),$=m("div"),k=m("label"),T=m("input"),M=C(" Static IP"),E=v(),W&&W.c(),S=v(),G&&G.c(),I=v(),A=m("div"),A.innerHTML='',R=v(),Q(H.$$.fragment),u(i,"type","hidden"),u(i,"name","s"),i.value="true",u(r,"class","text-sm"),u(f,"class","my-3"),u(p,"class","my-3"),u(h,"name","sh"),u(h,"type","text"),u(h,"class","in-s"),u(h,"maxlength","32"),u(h,"pattern","[a-z0-9_-]+"),u(h,"placeholder","Optional, ex.: ams-reader"),u(h,"autocomplete","off"),u(T,"type","checkbox"),u(T,"name","sm"),T.__value="static",T.value=T.__value,u(T,"class","rounded mb-1"),u($,"class","my-3"),u(A,"class","my-3"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(q,O){y(q,e,O),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),s(n,f),s(n,c),s(n,p),s(n,_),s(n,d),s(d,g),s(d,h),Z(h,t[0].hostname),s(n,b),s(n,$),s($,k),s(k,T),T.checked=t[1],s(k,M),s($,E),W&&W.m($,null),s(n,S),G&&G.m(n,null),s(n,I),s(n,A),y(q,R,O),Y(H,q,O),j=!0,F||(L=[K(h,"input",t[4]),K(T,"change",t[5]),K(n,"submit",cs(t[3]))],F=!0)},p(q,[O]){O&1&&h.value!==q[0].hostname&&Z(h,q[0].hostname),O&2&&(T.checked=q[1]),q[1]?W?(W.p(q,O),O&2&&P(W,1)):(W=vf(q),W.c(),P(W,1),W.m($,null)):W&&(Se(),N(W,1,1,()=>{W=null}),Pe()),q[1]?G||(G=hf(),G.c(),G.m(n,I)):G&&(G.d(1),G=null);const U={};O&4&&(U.active=q[2]),H.$set(U)},i(q){j||(P(W),P(H.$$.fragment,q),j=!0)},o(q){N(W),N(H.$$.fragment,q),j=!1},d(q){q&&w(e),W&&W.d(),G&&G.d(),q&&w(R),V(H,q),F=!1,Be(L)}}}function Hp(t,e,l){let{sysinfo:n={}}=e,i=!1,o=!1,r=0;function a(){var _="";r++;var d=function(){setTimeout(a,1e3)};if(n.net.ip&&r%3==0){if(!n.net.ip){d();return}_="http://"+n.net.ip}else n.hostname&&r%3==1?_="http://"+n.hostname:n.hostname&&r%3==2?_="http://"+n.hostname+".local":_="";console&&console.log("Trying url "+_),yt.update(h=>(h.trying=_,h));var g=new XMLHttpRequest;g.timeout=5e3,g.addEventListener("abort",d),g.addEventListener("error",d),g.addEventListener("timeout",d),g.addEventListener("load",function(h){window.location.href=_||"/"}),g.open("GET",_+"/is-alive",!0),g.send()}async function f(_){l(2,o=!0);const d=new FormData(_.target),g=new URLSearchParams;for(let $ of d){const[k,T]=$;g.append(k,T)}let b=await(await fetch("/save",{method:"POST",body:g})).json();l(2,o=!1),yt.update($=>($.hostname=d.get("sh"),$.usrcfg=b.success,$.booting=b.reboot,i&&($.net.ip=d.get("si"),$.net.mask=d.get("su"),$.net.gw=d.get("sg"),$.net.dns1=d.get("sd")),setTimeout(a,5e3),$))}function c(){n.hostname=this.value,l(0,n)}function p(){i=this.checked,l(1,i)}return t.$$set=_=>{"sysinfo"in _&&l(0,n=_.sysinfo)},[n,i,o,f,c,p]}class jp extends ye{constructor(e){super(),we(this,e,Hp,Up,ke,{sysinfo:0})}}function Wp(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k;return h=new gt({props:{active:t[2],message:"Uploading file, please wait"}}),{c(){e=m("div"),l=m("div"),n=m("strong"),i=C("Upload "),o=C(t[1]),r=v(),a=m("p"),a.textContent="Select a suitable file and click upload",f=v(),c=m("form"),p=m("input"),_=v(),d=m("div"),d.innerHTML='',g=v(),Q(h.$$.fragment),u(a,"class","mb-4"),u(p,"name","file"),u(p,"type","file"),u(d,"class","w-full text-right mt-4"),u(c,"action",t[0]),u(c,"enctype","multipart/form-data"),u(c,"method","post"),u(c,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2")},m(T,M){y(T,e,M),s(e,l),s(l,n),s(n,i),s(n,o),s(l,r),s(l,a),s(l,f),s(l,c),s(c,p),s(c,_),s(c,d),y(T,g,M),Y(h,T,M),b=!0,$||(k=K(c,"submit",t[3]),$=!0)},p(T,[M]){(!b||M&2)&&B(o,T[1]),(!b||M&1)&&u(c,"action",T[0]);const E={};M&4&&(E.active=T[2]),h.$set(E)},i(T){b||(P(h.$$.fragment,T),b=!0)},o(T){N(h.$$.fragment,T),b=!1},d(T){T&&w(e),T&&w(g),V(h,T),$=!1,k()}}}function Gp(t,e,l){let{action:n}=e,{title:i}=e,o=!1;const r=()=>l(2,o=!0);return t.$$set=a=>{"action"in a&&l(0,n=a.action),"title"in a&&l(1,i=a.title)},[n,i,o,r]}class oo extends ye{constructor(e){super(),we(this,e,Gp,Wp,ke,{action:0,title:1})}}function Bp(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M,E,S,I,A,R,H,j,F,L,W,G,q;return L=new gt({props:{active:t[1],message:"Saving preferences"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("div"),i.textContent="Various permissions we need to do stuff:",o=v(),r=m("hr"),a=v(),f=m("div"),c=C("Enable one-click upgrade? (implies data collection)"),p=m("br"),_=v(),d=m("a"),g=C("Read more"),h=m("br"),b=v(),$=m("label"),k=m("input"),M=C(" Yes"),E=m("label"),S=m("input"),A=C(" No"),R=m("br"),H=v(),j=m("div"),j.innerHTML='',F=v(),Q(L.$$.fragment),u(d,"href",Lt("Data-collection-on-one-click-firmware-upgrade")),u(d,"target","_blank"),u(d,"class","text-blue-600 hover:text-blue-800"),u(k,"type","radio"),u(k,"name","sf"),k.value=1,k.checked=T=t[0].fwconsent===1,u(k,"class","rounded m-2"),k.required=!0,u(S,"type","radio"),u(S,"name","sf"),S.value=2,S.checked=I=t[0].fwconsent===2,u(S,"class","rounded m-2"),S.required=!0,u(f,"class","my-3"),u(j,"class","my-3"),u(n,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-3 lg:grid-cols-2")},m(O,U){y(O,e,U),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),s(n,f),s(f,c),s(f,p),s(f,_),s(f,d),s(d,g),s(f,h),s(f,b),s(f,$),s($,k),s($,M),s(f,E),s(E,S),s(E,A),s(f,R),s(n,H),s(n,j),y(O,F,U),Y(L,O,U),W=!0,G||(q=K(n,"submit",cs(t[2])),G=!0)},p(O,[U]){(!W||U&1&&T!==(T=O[0].fwconsent===1))&&(k.checked=T),(!W||U&1&&I!==(I=O[0].fwconsent===2))&&(S.checked=I);const X={};U&2&&(X.active=O[1]),L.$set(X)},i(O){W||(P(L.$$.fragment,O),W=!0)},o(O){N(L.$$.fragment,O),W=!1},d(O){O&&w(e),O&&w(F),V(L,O),G=!1,q()}}}function zp(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(r){l(1,i=!0);const a=new FormData(r.target),f=new URLSearchParams;for(let _ of a){const[d,g]=_;f.append(d,g)}let p=await(await fetch("/save",{method:"POST",body:f})).json();l(1,i=!1),yt.update(_=>(_.fwconsent=a.sf===!0?1:a.sf===!1?2:0,_.booting=p.reboot,_)),Un("/")}return t.$$set=r=>{"sysinfo"in r&&l(0,n=r.sysinfo)},[n,i,o]}class Yp extends ye{constructor(e){super(),we(this,e,zp,Bp,ke,{sysinfo:0})}}function Vp(t){let e,l;return e=new Km({props:{data:t[1],sysinfo:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.data=n[1]),i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Kp(t){let e,l;return e=new kp({props:{sysinfo:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Qp(t){let e,l;return e=new Ip({props:{sysinfo:t[0],data:t[1]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),i&2&&(o.data=n[1]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Zp(t){let e,l;return e=new oo({props:{title:"CA",action:"/mqtt-ca"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p:ie,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Jp(t){let e,l;return e=new oo({props:{title:"certificate",action:"/mqtt-cert"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p:ie,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function Xp(t){let e,l;return e=new oo({props:{title:"private key",action:"/mqtt-key"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p:ie,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function xp(t){let e,l;return e=new Yp({props:{sysinfo:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function e0(t){let e,l;return e=new jp({props:{sysinfo:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function t0(t){let e,l;return e=new qp({props:{sysinfo:t[0]}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function l0(t){let e,l,n,i,o,r,a,f,c,p,_,d,g,h,b,$,k,T,M,E;return e=new rm({props:{data:t[1]}}),n=new ol({props:{path:"/",$$slots:{default:[Vp]},$$scope:{ctx:t}}}),o=new ol({props:{path:"/configuration",$$slots:{default:[Kp]},$$scope:{ctx:t}}}),a=new ol({props:{path:"/status",$$slots:{default:[Qp]},$$scope:{ctx:t}}}),c=new ol({props:{path:"/mqtt-ca",$$slots:{default:[Zp]},$$scope:{ctx:t}}}),_=new ol({props:{path:"/mqtt-cert",$$slots:{default:[Jp]},$$scope:{ctx:t}}}),g=new ol({props:{path:"/mqtt-key",$$slots:{default:[Xp]},$$scope:{ctx:t}}}),b=new ol({props:{path:"/consent",$$slots:{default:[xp]},$$scope:{ctx:t}}}),k=new ol({props:{path:"/setup",$$slots:{default:[e0]},$$scope:{ctx:t}}}),M=new ol({props:{path:"/vendor",$$slots:{default:[t0]},$$scope:{ctx:t}}}),{c(){Q(e.$$.fragment),l=v(),Q(n.$$.fragment),i=v(),Q(o.$$.fragment),r=v(),Q(a.$$.fragment),f=v(),Q(c.$$.fragment),p=v(),Q(_.$$.fragment),d=v(),Q(g.$$.fragment),h=v(),Q(b.$$.fragment),$=v(),Q(k.$$.fragment),T=v(),Q(M.$$.fragment)},m(S,I){Y(e,S,I),y(S,l,I),Y(n,S,I),y(S,i,I),Y(o,S,I),y(S,r,I),Y(a,S,I),y(S,f,I),Y(c,S,I),y(S,p,I),Y(_,S,I),y(S,d,I),Y(g,S,I),y(S,h,I),Y(b,S,I),y(S,$,I),Y(k,S,I),y(S,T,I),Y(M,S,I),E=!0},p(S,I){const A={};I&2&&(A.data=S[1]),e.$set(A);const R={};I&7&&(R.$$scope={dirty:I,ctx:S}),n.$set(R);const H={};I&5&&(H.$$scope={dirty:I,ctx:S}),o.$set(H);const j={};I&7&&(j.$$scope={dirty:I,ctx:S}),a.$set(j);const F={};I&4&&(F.$$scope={dirty:I,ctx:S}),c.$set(F);const L={};I&4&&(L.$$scope={dirty:I,ctx:S}),_.$set(L);const W={};I&4&&(W.$$scope={dirty:I,ctx:S}),g.$set(W);const G={};I&5&&(G.$$scope={dirty:I,ctx:S}),b.$set(G);const q={};I&5&&(q.$$scope={dirty:I,ctx:S}),k.$set(q);const O={};I&5&&(O.$$scope={dirty:I,ctx:S}),M.$set(O)},i(S){E||(P(e.$$.fragment,S),P(n.$$.fragment,S),P(o.$$.fragment,S),P(a.$$.fragment,S),P(c.$$.fragment,S),P(_.$$.fragment,S),P(g.$$.fragment,S),P(b.$$.fragment,S),P(k.$$.fragment,S),P(M.$$.fragment,S),E=!0)},o(S){N(e.$$.fragment,S),N(n.$$.fragment,S),N(o.$$.fragment,S),N(a.$$.fragment,S),N(c.$$.fragment,S),N(_.$$.fragment,S),N(g.$$.fragment,S),N(b.$$.fragment,S),N(k.$$.fragment,S),N(M.$$.fragment,S),E=!1},d(S){V(e,S),S&&w(l),V(n,S),S&&w(i),V(o,S),S&&w(r),V(a,S),S&&w(f),V(c,S),S&&w(p),V(_,S),S&&w(d),V(g,S),S&&w(h),V(b,S),S&&w($),V(k,S),S&&w(T),V(M,S)}}}function n0(t){let e,l,n,i;const o=[o0,s0],r=[];function a(f,c){return f[0].trying?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=We()},m(f,c){r[e].m(f,c),y(f,n,c),i=!0},p(f,c){let p=e;e=a(f),e===p?r[e].p(f,c):(Se(),N(r[p],1,1,()=>{r[p]=null}),Pe(),l=r[e],l?l.p(f,c):(l=r[e]=o[e](f),l.c()),P(l,1),l.m(n.parentNode,n))},i(f){i||(P(l),i=!0)},o(f){N(l),i=!1},d(f){r[e].d(f),f&&w(n)}}}function i0(t){let e,l;return e=new gt({props:{active:"true",message:"Device is upgrading, please wait"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p:ie,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function s0(t){let e,l;return e=new gt({props:{active:"true",message:"Device is booting, please wait"}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p:ie,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function o0(t){let e,l;return e=new gt({props:{active:"true",message:"Device is booting, please wait. Trying to reach it on "+t[0].trying}}),{c(){Q(e.$$.fragment)},m(n,i){Y(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.message="Device is booting, please wait. Trying to reach it on "+n[0].trying),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){N(e.$$.fragment,n),l=!1},d(n){V(e,n)}}}function u0(t){let e,l,n,i,o,r;l=new Bf({props:{$$slots:{default:[l0]},$$scope:{ctx:t}}});const a=[i0,n0],f=[];function c(p,_){return p[0].upgrading?0:p[0].booting?1:-1}return~(i=c(t))&&(o=f[i]=a[i](t)),{c(){e=m("div"),Q(l.$$.fragment),n=v(),o&&o.c(),u(e,"class","container mx-auto m-3")},m(p,_){y(p,e,_),Y(l,e,null),s(e,n),~i&&f[i].m(e,null),r=!0},p(p,[_]){const d={};_&7&&(d.$$scope={dirty:_,ctx:p}),l.$set(d);let g=i;i=c(p),i===g?~i&&f[i].p(p,_):(o&&(Se(),N(f[g],1,1,()=>{f[g]=null}),Pe()),~i?(o=f[i],o?o.p(p,_):(o=f[i]=a[i](p),o.c()),P(o,1),o.m(e,null)):o=null)},i(p){r||(P(l.$$.fragment,p),P(o),r=!0)},o(p){N(l.$$.fragment,p),N(o),r=!1},d(p){p&&w(e),V(l),~i&&f[i].d()}}}function r0(t,e,l){let n={};yt.subscribe(o=>{l(0,n=o),n.vndcfg===!1?Un("/vendor"):n.usrcfg===!1?Un("/setup"):n.fwconsent===0&&Un("/consent")}),lo();let i={};return D1.subscribe(o=>{l(1,i=o)}),[n,i]}class a0 extends ye{constructor(e){super(),we(this,e,r0,u0,ke,{})}}new a0({target:document.getElementById("app")}); + `),h=m("input"),b=v(),$=m("div"),k=m("label"),T=m("input"),P=C(" Static IP"),E=v(),G&&G.c(),S=v(),j&&j.c(),N=v(),A=m("div"),A.innerHTML='',R=v(),Z(H.$$.fragment),u(i,"type","hidden"),u(i,"name","s"),i.value="true",u(r,"class","text-sm"),u(c,"class","my-3"),u(p,"class","my-3"),u(h,"name","sh"),u(h,"type","text"),u(h,"class","in-s"),u(h,"maxlength","32"),u(h,"pattern","[a-z0-9_-]+"),u(h,"placeholder","Optional, ex.: ams-reader"),u(h,"autocomplete","off"),u(T,"type","checkbox"),u(T,"name","sm"),T.__value="static",T.value=T.__value,u(T,"class","rounded mb-1"),u($,"class","my-3"),u(A,"class","my-3"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(O,q){y(O,e,q),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),s(n,c),s(n,f),s(n,p),s(n,_),s(n,d),s(d,g),s(d,h),Y(h,t[0].hostname),s(n,b),s(n,$),s($,k),s(k,T),T.checked=t[1],s(k,P),s($,E),G&&G.m($,null),s(n,S),j&&j.m(n,null),s(n,N),s(n,A),y(O,R,q),K(H,O,q),U=!0,F||(L=[V(h,"input",t[4]),V(T,"change",t[5]),V(n,"submit",_s(t[3]))],F=!0)},p(O,[q]){q&1&&h.value!==O[0].hostname&&Y(h,O[0].hostname),q&2&&(T.checked=O[1]),O[1]?G?(G.p(O,q),q&2&&M(G,1)):(G=bf(O),G.c(),M(G,1),G.m($,null)):G&&(Ce(),I(G,1,1,()=>{G=null}),Te()),O[1]?j||(j=kf(),j.c(),j.m(n,N)):j&&(j.d(1),j=null);const W={};q&4&&(W.active=O[2]),H.$set(W)},i(O){U||(M(G),M(H.$$.fragment,O),U=!0)},o(O){I(G),I(H.$$.fragment,O),U=!1},d(O){O&&w(e),G&&G.d(),j&&j.d(),O&&w(R),Q(H,O),F=!1,Ge(L)}}}function Gp(t,e,l){let{sysinfo:n={}}=e,i=!1,o=!1,r=0;function a(){var _="";r++;var d=function(){setTimeout(a,1e3)};if(n.net.ip&&r%3==0){if(!n.net.ip){d();return}_="http://"+n.net.ip}else n.hostname&&r%3==1?_="http://"+n.hostname:n.hostname&&r%3==2?_="http://"+n.hostname+".local":_="";console&&console.log("Trying url "+_),Ct.update(h=>(h.trying=_,h));var g=new XMLHttpRequest;g.timeout=5e3,g.addEventListener("abort",d),g.addEventListener("error",d),g.addEventListener("timeout",d),g.addEventListener("load",function(h){window.location.href=_||"/"}),g.open("GET",_+"/is-alive",!0),g.send()}async function c(_){l(2,o=!0);const d=new FormData(_.target),g=new URLSearchParams;for(let $ of d){const[k,T]=$;g.append(k,T)}let b=await(await fetch("/save",{method:"POST",body:g})).json();l(2,o=!1),Ct.update($=>($.hostname=d.get("sh"),$.usrcfg=b.success,$.booting=b.reboot,i&&($.net.ip=d.get("si"),$.net.mask=d.get("su"),$.net.gw=d.get("sg"),$.net.dns1=d.get("sd")),setTimeout(a,5e3),$))}function f(){n.hostname=this.value,l(0,n)}function p(){i=this.checked,l(1,i)}return t.$$set=_=>{"sysinfo"in _&&l(0,n=_.sysinfo)},[n,i,o,c,f,p]}class Bp extends $e{constructor(e){super(),ye(this,e,Gp,Wp,we,{sysinfo:0})}}function zp(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k;return h=new gt({props:{active:t[2],message:"Uploading file, please wait"}}),{c(){e=m("div"),l=m("div"),n=m("strong"),i=C("Upload "),o=C(t[1]),r=v(),a=m("p"),a.textContent="Select a suitable file and click upload",c=v(),f=m("form"),p=m("input"),_=v(),d=m("div"),d.innerHTML='',g=v(),Z(h.$$.fragment),u(a,"class","mb-4"),u(p,"name","file"),u(p,"type","file"),u(d,"class","w-full text-right mt-4"),u(f,"action",t[0]),u(f,"enctype","multipart/form-data"),u(f,"method","post"),u(f,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2")},m(T,P){y(T,e,P),s(e,l),s(l,n),s(n,i),s(n,o),s(l,r),s(l,a),s(l,c),s(l,f),s(f,p),s(f,_),s(f,d),y(T,g,P),K(h,T,P),b=!0,$||(k=V(f,"submit",t[3]),$=!0)},p(T,[P]){(!b||P&2)&&B(o,T[1]),(!b||P&1)&&u(f,"action",T[0]);const E={};P&4&&(E.active=T[2]),h.$set(E)},i(T){b||(M(h.$$.fragment,T),b=!0)},o(T){I(h.$$.fragment,T),b=!1},d(T){T&&w(e),T&&w(g),Q(h,T),$=!1,k()}}}function Yp(t,e,l){let{action:n}=e,{title:i}=e,o=!1;const r=()=>l(2,o=!0);return t.$$set=a=>{"action"in a&&l(0,n=a.action),"title"in a&&l(1,i=a.title)},[n,i,o,r]}class fo extends $e{constructor(e){super(),ye(this,e,Yp,zp,we,{action:0,title:1})}}function Vp(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E,S,N,A,R,H,U,F,L,G,j,O;return L=new gt({props:{active:t[1],message:"Saving preferences"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("div"),i.textContent="Various permissions we need to do stuff:",o=v(),r=m("hr"),a=v(),c=m("div"),f=C("Enable one-click upgrade? (implies data collection)"),p=m("br"),_=v(),d=m("a"),g=C("Read more"),h=m("br"),b=v(),$=m("label"),k=m("input"),P=C(" Yes"),E=m("label"),S=m("input"),A=C(" No"),R=m("br"),H=v(),U=m("div"),U.innerHTML='',F=v(),Z(L.$$.fragment),u(d,"href",$t("Data-collection-on-one-click-firmware-upgrade")),u(d,"target","_blank"),u(d,"class","text-blue-600 hover:text-blue-800"),u(k,"type","radio"),u(k,"name","sf"),k.value=1,k.checked=T=t[0].fwconsent===1,u(k,"class","rounded m-2"),k.required=!0,u(S,"type","radio"),u(S,"name","sf"),S.value=2,S.checked=N=t[0].fwconsent===2,u(S,"class","rounded m-2"),S.required=!0,u(c,"class","my-3"),u(U,"class","my-3"),u(n,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-3 lg:grid-cols-2")},m(q,W){y(q,e,W),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),s(n,c),s(c,f),s(c,p),s(c,_),s(c,d),s(d,g),s(c,h),s(c,b),s(c,$),s($,k),s($,P),s(c,E),s(E,S),s(E,A),s(c,R),s(n,H),s(n,U),y(q,F,W),K(L,q,W),G=!0,j||(O=V(n,"submit",_s(t[2])),j=!0)},p(q,[W]){(!G||W&1&&T!==(T=q[0].fwconsent===1))&&(k.checked=T),(!G||W&1&&N!==(N=q[0].fwconsent===2))&&(S.checked=N);const X={};W&2&&(X.active=q[1]),L.$set(X)},i(q){G||(M(L.$$.fragment,q),G=!0)},o(q){I(L.$$.fragment,q),G=!1},d(q){q&&w(e),q&&w(F),Q(L,q),j=!1,O()}}}function Kp(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(r){l(1,i=!0);const a=new FormData(r.target),c=new URLSearchParams;for(let _ of a){const[d,g]=_;c.append(d,g)}let p=await(await fetch("/save",{method:"POST",body:c})).json();l(1,i=!1),Ct.update(_=>(_.fwconsent=a.sf===!0?1:a.sf===!1?2:0,_.booting=p.reboot,_)),jn("/")}return t.$$set=r=>{"sysinfo"in r&&l(0,n=r.sysinfo)},[n,i,o]}class Qp extends $e{constructor(e){super(),ye(this,e,Kp,Vp,we,{sysinfo:0})}}function Zp(t){let e,l;return e=new Jm({props:{data:t[1],sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.data=n[1]),i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function Jp(t){let e,l;return e=new $p({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function Xp(t){let e,l;return e=new Fp({props:{sysinfo:t[0],data:t[1]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),i&2&&(o.data=n[1]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function xp(t){let e,l;return e=new fo({props:{title:"CA",action:"/mqtt-ca"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p:ie,i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function e0(t){let e,l;return e=new fo({props:{title:"certificate",action:"/mqtt-cert"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p:ie,i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function t0(t){let e,l;return e=new fo({props:{title:"private key",action:"/mqtt-key"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p:ie,i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function l0(t){let e,l;return e=new Qp({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function n0(t){let e,l;return e=new Bp({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function i0(t){let e,l;return e=new jp({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function s0(t){let e,l,n,i,o,r,a,c,f,p,_,d,g,h,b,$,k,T,P,E;return e=new cm({props:{data:t[1]}}),n=new ol({props:{path:"/",$$slots:{default:[Zp]},$$scope:{ctx:t}}}),o=new ol({props:{path:"/configuration",$$slots:{default:[Jp]},$$scope:{ctx:t}}}),a=new ol({props:{path:"/status",$$slots:{default:[Xp]},$$scope:{ctx:t}}}),f=new ol({props:{path:"/mqtt-ca",$$slots:{default:[xp]},$$scope:{ctx:t}}}),_=new ol({props:{path:"/mqtt-cert",$$slots:{default:[e0]},$$scope:{ctx:t}}}),g=new ol({props:{path:"/mqtt-key",$$slots:{default:[t0]},$$scope:{ctx:t}}}),b=new ol({props:{path:"/consent",$$slots:{default:[l0]},$$scope:{ctx:t}}}),k=new ol({props:{path:"/setup",$$slots:{default:[n0]},$$scope:{ctx:t}}}),P=new ol({props:{path:"/vendor",$$slots:{default:[i0]},$$scope:{ctx:t}}}),{c(){Z(e.$$.fragment),l=v(),Z(n.$$.fragment),i=v(),Z(o.$$.fragment),r=v(),Z(a.$$.fragment),c=v(),Z(f.$$.fragment),p=v(),Z(_.$$.fragment),d=v(),Z(g.$$.fragment),h=v(),Z(b.$$.fragment),$=v(),Z(k.$$.fragment),T=v(),Z(P.$$.fragment)},m(S,N){K(e,S,N),y(S,l,N),K(n,S,N),y(S,i,N),K(o,S,N),y(S,r,N),K(a,S,N),y(S,c,N),K(f,S,N),y(S,p,N),K(_,S,N),y(S,d,N),K(g,S,N),y(S,h,N),K(b,S,N),y(S,$,N),K(k,S,N),y(S,T,N),K(P,S,N),E=!0},p(S,N){const A={};N&2&&(A.data=S[1]),e.$set(A);const R={};N&7&&(R.$$scope={dirty:N,ctx:S}),n.$set(R);const H={};N&5&&(H.$$scope={dirty:N,ctx:S}),o.$set(H);const U={};N&7&&(U.$$scope={dirty:N,ctx:S}),a.$set(U);const F={};N&4&&(F.$$scope={dirty:N,ctx:S}),f.$set(F);const L={};N&4&&(L.$$scope={dirty:N,ctx:S}),_.$set(L);const G={};N&4&&(G.$$scope={dirty:N,ctx:S}),g.$set(G);const j={};N&5&&(j.$$scope={dirty:N,ctx:S}),b.$set(j);const O={};N&5&&(O.$$scope={dirty:N,ctx:S}),k.$set(O);const q={};N&5&&(q.$$scope={dirty:N,ctx:S}),P.$set(q)},i(S){E||(M(e.$$.fragment,S),M(n.$$.fragment,S),M(o.$$.fragment,S),M(a.$$.fragment,S),M(f.$$.fragment,S),M(_.$$.fragment,S),M(g.$$.fragment,S),M(b.$$.fragment,S),M(k.$$.fragment,S),M(P.$$.fragment,S),E=!0)},o(S){I(e.$$.fragment,S),I(n.$$.fragment,S),I(o.$$.fragment,S),I(a.$$.fragment,S),I(f.$$.fragment,S),I(_.$$.fragment,S),I(g.$$.fragment,S),I(b.$$.fragment,S),I(k.$$.fragment,S),I(P.$$.fragment,S),E=!1},d(S){Q(e,S),S&&w(l),Q(n,S),S&&w(i),Q(o,S),S&&w(r),Q(a,S),S&&w(c),Q(f,S),S&&w(p),Q(_,S),S&&w(d),Q(g,S),S&&w(h),Q(b,S),S&&w($),Q(k,S),S&&w(T),Q(P,S)}}}function o0(t){let e,l,n,i;const o=[a0,r0],r=[];function a(c,f){return c[0].trying?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=je()},m(c,f){r[e].m(c,f),y(c,n,f),i=!0},p(c,f){let p=e;e=a(c),e===p?r[e].p(c,f):(Ce(),I(r[p],1,1,()=>{r[p]=null}),Te(),l=r[e],l?l.p(c,f):(l=r[e]=o[e](c),l.c()),M(l,1),l.m(n.parentNode,n))},i(c){i||(M(l),i=!0)},o(c){I(l),i=!1},d(c){r[e].d(c),c&&w(n)}}}function u0(t){let e,l;return e=new gt({props:{active:"true",message:"Device is upgrading, please wait"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p:ie,i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function r0(t){let e,l;return e=new gt({props:{active:"true",message:"Device is booting, please wait"}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p:ie,i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function a0(t){let e,l;return e=new gt({props:{active:"true",message:"Device is booting, please wait. Trying to reach it on "+t[0].trying}}),{c(){Z(e.$$.fragment)},m(n,i){K(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.message="Device is booting, please wait. Trying to reach it on "+n[0].trying),e.$set(o)},i(n){l||(M(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){Q(e,n)}}}function f0(t){let e,l,n,i,o,r;l=new Vf({props:{$$slots:{default:[s0]},$$scope:{ctx:t}}});const a=[u0,o0],c=[];function f(p,_){return p[0].upgrading?0:p[0].booting?1:-1}return~(i=f(t))&&(o=c[i]=a[i](t)),{c(){e=m("div"),Z(l.$$.fragment),n=v(),o&&o.c(),u(e,"class","container mx-auto m-3")},m(p,_){y(p,e,_),K(l,e,null),s(e,n),~i&&c[i].m(e,null),r=!0},p(p,[_]){const d={};_&7&&(d.$$scope={dirty:_,ctx:p}),l.$set(d);let g=i;i=f(p),i===g?~i&&c[i].p(p,_):(o&&(Ce(),I(c[g],1,1,()=>{c[g]=null}),Te()),~i?(o=c[i],o?o.p(p,_):(o=c[i]=a[i](p),o.c()),M(o,1),o.m(e,null)):o=null)},i(p){r||(M(l.$$.fragment,p),M(o),r=!0)},o(p){I(l.$$.fragment,p),I(o),r=!1},d(p){p&&w(e),Q(l),~i&&c[i].d()}}}function c0(t,e,l){let n={};Ct.subscribe(o=>{l(0,n=o),n.vndcfg===!1?jn("/vendor"):n.usrcfg===!1?jn("/setup"):n.fwconsent===0&&jn("/consent")}),oo();let i={};return I1.subscribe(o=>{l(1,i=o)}),[n,i]}class m0 extends $e{constructor(e){super(),ye(this,e,c0,f0,we,{})}}new m0({target:document.getElementById("app")}); diff --git a/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte b/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte index 121b2082..1f57d7e0 100644 --- a/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte +++ b/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte @@ -93,6 +93,9 @@ r: { r: null, g: null, b: null, i: false }, t: { d: null, a: null }, v: { p: null, d: { v: null, g: null }, o: null, m: null, b: null } + }, + h: { + t: '', h: '', n: '' } }; configurationStore.subscribe(update => { @@ -531,6 +534,25 @@ {/if} + {#if configuration.q.m == 4} +
+ Home-Assistant + + +
+ Discovery topic
+ +
+
+ Hostname for URL
+ +
+
+ Name tag
+ +
+
+ {/if} {#if configuration.p.r.startsWith("10YNO") || configuration.p.r == '10Y1001A1001A48H'}
Tariff thresholds diff --git a/lib/SvelteUi/app/src/lib/Helpers.js b/lib/SvelteUi/app/src/lib/Helpers.js index 3c6e0e15..01b6ea01 100644 --- a/lib/SvelteUi/app/src/lib/Helpers.js +++ b/lib/SvelteUi/app/src/lib/Helpers.js @@ -86,7 +86,7 @@ export function boardtype(c, b) { case 0: return "Custom hardware by Roar Fredriksen"; case 1: - return "Kamstrup module by Egil Opsahl" + return "Kamstrup module by Egil Opsahl"; case 3: return "Pow-K (UART0)"; case 4: diff --git a/lib/SvelteUi/json/conf_domoticz.json b/lib/SvelteUi/json/conf_domoticz.json index 3c11d996..b6528ec9 100644 --- a/lib/SvelteUi/json/conf_domoticz.json +++ b/lib/SvelteUi/json/conf_domoticz.json @@ -4,4 +4,4 @@ "u1" : %d, "u2" : %d, "u3" : %d -} +}, diff --git a/lib/SvelteUi/json/conf_ha.json b/lib/SvelteUi/json/conf_ha.json new file mode 100644 index 00000000..9ca02761 --- /dev/null +++ b/lib/SvelteUi/json/conf_ha.json @@ -0,0 +1,5 @@ +"h": { + "t" : "%s", + "h" : "%s", + "n" : "%s" +} diff --git a/lib/SvelteUi/src/AmsWebServer.cpp b/lib/SvelteUi/src/AmsWebServer.cpp index ad202d91..d29f0974 100644 --- a/lib/SvelteUi/src/AmsWebServer.cpp +++ b/lib/SvelteUi/src/AmsWebServer.cpp @@ -27,6 +27,7 @@ #include "html/conf_debug_json.h" #include "html/conf_gpio_json.h" #include "html/conf_domoticz_json.h" +#include "html/conf_ha_json.h" #include "html/conf_ui_json.h" #include "html/firmware_html.h" @@ -800,6 +801,8 @@ void AmsWebServer::configurationJson() { config->getDomoticzConfig(domo); UiConfig ui; config->getUiConfig(ui); + HomeAssistantConfig haconf; + config->getHomeAssistantConfig(haconf); bool qsc = false; bool qsr = false; @@ -949,6 +952,12 @@ void AmsWebServer::configurationJson() { domo.vl3idx ); server.sendContent(buf); + snprintf_P(buf, BufferSize, CONF_HA_JSON, + haconf.discoveryTopic, + haconf.discoveryHostname, + haconf.discoveryNameTag + ); + server.sendContent(buf); server.sendContent("}"); } @@ -1278,6 +1287,15 @@ void AmsWebServer::handleSave() { config->setDomoticzConfig(domo); } + if(server.hasArg(F("h")) && server.arg(F("h")) == F("true")) { + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received Home-Assistant config")); + HomeAssistantConfig haconf; + config->getHomeAssistantConfig(haconf); + strcpy(haconf.discoveryTopic, server.arg(F("ht")).c_str()); + strcpy(haconf.discoveryHostname, server.arg(F("hh")).c_str()); + strcpy(haconf.discoveryNameTag, server.arg(F("hn")).c_str()); + config->setHomeAssistantConfig(haconf); + } if(server.hasArg(F("g")) && server.arg(F("g")) == F("true")) { if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received web config")); diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index ed1339c7..d8ad199a 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -1361,7 +1361,11 @@ void MQTT_connect() { mqttHandler = new DomoticzMqttHandler(mqtt, (char*) commonBuffer, domo); break; case 4: - mqttHandler = new HomeAssistantMqttHandler(mqtt, (char*) commonBuffer, mqttConfig.clientId, mqttConfig.publishTopic, &hw); + HomeAssistantConfig haconf; + SystemConfig sys; + config.getHomeAssistantConfig(haconf); + config.getSystemConfig(sys); + mqttHandler = new HomeAssistantMqttHandler(mqtt, (char*) commonBuffer, mqttConfig.clientId, mqttConfig.publishTopic, sys.boardType, haconf, &hw); break; }