aboutsummaryrefslogtreecommitdiff
path: root/client/index.f6ed59e6.js
blob: d51d98f69eb3c4743c852a1555ed9df3e3317f2e (plain) (blame)
1
import{S as e,i as t,s as a,e as s,c as l,a as n,d as r,b as c,f as i,g as o,n as u,w as d,h,j as f,t as p,k as m,l as v,m as g,o as k,p as _,q as w,r as $,u as b,v as E,x as D,y,z as I,A as V,B as j,C as q,D as O,E as T,F as x,G as M,H as P,I as S,J as N,K as C}from"./client.0692ce05.js";function A(e){let t,a,d,h,f,p,m,v,g;return{c(){t=s("div"),a=s("div"),d=s("div"),h=s("div"),f=s("div"),p=s("div"),m=s("div"),v=s("div"),g=s("div"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"DIV",{class:!0}),n(a).forEach(r),d=l(s,"DIV",{class:!0}),n(d).forEach(r),h=l(s,"DIV",{class:!0}),n(h).forEach(r),f=l(s,"DIV",{class:!0}),n(f).forEach(r),p=l(s,"DIV",{class:!0}),n(p).forEach(r),m=l(s,"DIV",{class:!0}),n(m).forEach(r),v=l(s,"DIV",{class:!0}),n(v).forEach(r),g=l(s,"DIV",{class:!0}),n(g).forEach(r),s.forEach(r),this.h()},h(){c(a,"class","svelte-7k6qu0"),c(d,"class","svelte-7k6qu0"),c(h,"class","svelte-7k6qu0"),c(f,"class","svelte-7k6qu0"),c(p,"class","svelte-7k6qu0"),c(m,"class","svelte-7k6qu0"),c(v,"class","svelte-7k6qu0"),c(g,"class","svelte-7k6qu0"),c(t,"class","lds-roller svelte-7k6qu0")},m(e,s){i(e,t,s),o(t,a),o(t,d),o(t,h),o(t,f),o(t,p),o(t,m),o(t,v),o(t,g)},p:u,i:u,o:u,d(e){e&&r(t)}}}class B extends e{constructor(e){super(),t(this,e,null,A,a,{})}}const H=d("light");setInterval((function(){if("undefined"==typeof window)return;let e=window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";e!=h(H)&&H.set(e)}),1e3),H.subscribe((e=>{"undefined"!=typeof window&&("dark"==e?window.document.body.classList.add("dark"):window.document.body.classList.remove("dark"))}));const J={updated:!1,updating:!0},K=d(Object.assign(Object.assign({},J),{available:!1,longitude:null,latitude:null,city:null})),z=d(Object.assign(Object.assign({},J),{available:!1})),F=d(Object.assign({},J));function L(e,t=!1){let a=t?{}:{updated:new Date};e.update((e=>Object.assign(Object.assign(Object.assign({},e),a),{updating:t})))}function U(e){let t,a,u,d,h=e[0].city+"";return{c(){t=s("i"),a=f(),u=s("h1"),d=p(h),this.h()},l(e){t=l(e,"I",{class:!0}),n(t).forEach(r),a=m(e),u=l(e,"H1",{class:!0});var s=n(u);d=v(s,h),s.forEach(r),this.h()},h(){c(t,"class","symbol fas fa-map-marker-alt svelte-9kdo4s"),c(u,"class","svelte-9kdo4s")},m(e,s){i(e,t,s),i(e,a,s),i(e,u,s),o(u,d)},p(e,t){1&t&&h!==(h=e[0].city+"")&&g(d,h)},d(e){e&&r(t),e&&r(a),e&&r(u)}}}function Z(e){let t,a;function s(e,a){return 6&a&&(t=null),null==t&&(t=!!(Math.abs(e[1].updated-e[2].updated)>6e5)),t?Q:G}let l=s(e,-1),n=l(e);return{c(){n.c(),a=k()},l(e){n.l(e),a=k()},m(e,t){n.m(e,t),i(e,a,t)},p(e,t){l===(l=s(e,t))&&n?n.p(e,t):(n.d(1),n=l(e),n&&(n.c(),n.m(a.parentNode,a)))},d(e){n.d(e),e&&r(a)}}}function G(e){let t,a,c=e[1].updated.toLocaleString("no-NO",{dateStyle:"medium",timeStyle:"short"})+"";return{c(){t=s("p"),a=p(c)},l(e){t=l(e,"P",{});var s=n(t);a=v(s,c),s.forEach(r)},m(e,s){i(e,t,s),o(t,a)},p(e,t){2&t&&c!==(c=e[1].updated.toLocaleString("no-NO",{dateStyle:"medium",timeStyle:"short"})+"")&&g(a,c)},d(e){e&&r(t)}}}function Q(e){let t,a;return{c(){t=s("p"),a=p("There is more than 10 minutes difference between data updates")},l(e){t=l(e,"P",{});var s=n(t);a=v(s,"There is more than 10 minutes difference between data updates"),s.forEach(r)},m(e,s){i(e,t,s),o(t,a)},p:u,d(e){e&&r(t)}}}function R(e){let t,a,d,h,k,_,w,$,b,E,D,y,I=e[2].now.kp+"",V=e[2].now.kp_max+"",j=e[2].now.kp_min+"";return{c(){t=s("h2"),a=p("KP "),d=p(I),h=f(),k=s("p"),_=s("span"),w=p("↑ KP "),$=p(V),b=f(),E=s("span"),D=p("↓ KP "),y=p(j),this.h()},l(e){t=l(e,"H2",{class:!0});var s=n(t);a=v(s,"KP "),d=v(s,I),s.forEach(r),h=m(e),k=l(e,"P",{});var c=n(k);_=l(c,"SPAN",{classname:!0});var i=n(_);w=v(i,"↑ KP "),$=v(i,V),i.forEach(r),b=m(c),E=l(c,"SPAN",{classname:!0});var o=n(E);D=v(o,"↓ KP "),y=v(o,j),o.forEach(r),c.forEach(r),this.h()},h(){c(t,"class","svelte-9kdo4s"),c(_,"classname","pr-2"),c(E,"classname","pl-2")},m(e,s){i(e,t,s),o(t,a),o(t,d),i(e,h,s),i(e,k,s),o(k,_),o(_,w),o(_,$),o(k,b),o(k,E),o(E,D),o(E,y)},p(e,t){4&t&&I!==(I=e[2].now.kp+"")&&g(d,I),4&t&&V!==(V=e[2].now.kp_max+"")&&g($,V),4&t&&j!==(j=e[2].now.kp_min+"")&&g(y,j)},i:u,o:u,d(e){e&&r(t),e&&r(h),e&&r(k)}}}function W(e){let t,a;return t=new B({}),{c(){D(t.$$.fragment)},l(e){y(t.$$.fragment,e)},m(e,s){I(t,e,s),a=!0},p:u,i(e){a||(b(t.$$.fragment,e),a=!0)},o(e){w(t.$$.fragment,e),a=!1},d(e){V(t,e)}}}function X(e){let t,a,u,d,h,_,w,$,b,E,D,y,I,V,j,q=e[2].now.bz+"",O=e[2].now.bt+"",T=e[1].available&&Y(e);return{c(){t=s("div"),a=s("p"),u=p("BZ"),d=f(),h=s("p"),_=p(q),w=f(),$=s("div"),b=s("p"),E=p("BT"),D=f(),y=s("p"),I=p(O),V=f(),T&&T.c(),j=k(),this.h()},l(e){t=l(e,"DIV",{});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);u=v(c,"BZ"),c.forEach(r),d=m(s),h=l(s,"P",{class:!0});var i=n(h);_=v(i,q),i.forEach(r),s.forEach(r),w=m(e),$=l(e,"DIV",{});var o=n($);b=l(o,"P",{class:!0});var f=n(b);E=v(f,"BT"),f.forEach(r),D=m(o),y=l(o,"P",{class:!0});var p=n(y);I=v(p,O),p.forEach(r),o.forEach(r),V=m(e),T&&T.l(e),j=k(),this.h()},h(){c(a,"class","svelte-9kdo4s"),c(h,"class","svelte-9kdo4s"),c(b,"class","svelte-9kdo4s"),c(y,"class","svelte-9kdo4s")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(t,d),o(t,h),o(h,_),i(e,w,s),i(e,$,s),o($,b),o(b,E),o($,D),o($,y),o(y,I),i(e,V,s),T&&T.m(e,s),i(e,j,s)},p(e,t){4&t&&q!==(q=e[2].now.bz+"")&&g(_,q),4&t&&O!==(O=e[2].now.bt+"")&&g(I,O),e[1].available?T?T.p(e,t):(T=Y(e),T.c(),T.m(j.parentNode,j)):T&&(T.d(1),T=null)},d(e){e&&r(t),e&&r(w),e&&r($),e&&r(V),T&&T.d(e),e&&r(j)}}}function Y(e){let t,a,u,d,h,k,_,w,$,b,E,D,y,I,V,j=e[1].now.temp+"",q=e[1].now.clouds+"";return{c(){t=s("div"),a=s("p"),u=p("Temp"),d=f(),h=s("p"),k=p(j),_=p("°C"),w=f(),$=s("div"),b=s("p"),E=p("Clouds"),D=f(),y=s("p"),I=p(q),V=p("%"),this.h()},l(e){t=l(e,"DIV",{});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);u=v(c,"Temp"),c.forEach(r),d=m(s),h=l(s,"P",{class:!0});var i=n(h);k=v(i,j),_=v(i,"°C"),i.forEach(r),s.forEach(r),w=m(e),$=l(e,"DIV",{});var o=n($);b=l(o,"P",{class:!0});var f=n(b);E=v(f,"Clouds"),f.forEach(r),D=m(o),y=l(o,"P",{class:!0});var p=n(y);I=v(p,q),V=v(p,"%"),p.forEach(r),o.forEach(r),this.h()},h(){c(a,"class","svelte-9kdo4s"),c(h,"class","svelte-9kdo4s"),c(b,"class","svelte-9kdo4s"),c(y,"class","svelte-9kdo4s")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(t,d),o(t,h),o(h,k),o(h,_),i(e,w,s),i(e,$,s),o($,b),o(b,E),o($,D),o($,y),o(y,I),o(y,V)},p(e,t){2&t&&j!==(j=e[1].now.temp+"")&&g(k,j),2&t&&q!==(q=e[1].now.clouds+"")&&g(I,q)},d(e){e&&r(t),e&&r(w),e&&r($)}}}function ee(e){let t,a,u,d,h,p,v,g,k,E,D,y,I=!e[0].updating&&e[0].available&&!e[1].updating&&!e[2].updating&&U(e),V=!e[1].updating&&!e[2].updating&&Z(e);const j=[W,R],q=[];function O(e,t){return e[2].updating||e[1].updating?0:1}g=O(e),k=q[g]=j[g](e);let T=!e[2].updating&&!e[1].updating&&X(e);return{c(){t=s("div"),a=s("div"),u=s("div"),I&&I.c(),d=f(),h=s("div"),V&&V.c(),p=f(),v=s("div"),k.c(),E=f(),D=s("div"),T&&T.c(),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"DIV",{class:!0});var c=n(a);u=l(c,"DIV",{class:!0});var i=n(u);I&&I.l(i),i.forEach(r),d=m(c),h=l(c,"DIV",{class:!0});var o=n(h);V&&V.l(o),o.forEach(r),p=m(c),v=l(c,"DIV",{class:!0});var f=n(v);k.l(f),f.forEach(r),E=m(c),D=l(c,"DIV",{class:!0});var g=n(D);T&&T.l(g),g.forEach(r),c.forEach(r),s.forEach(r),this.h()},h(){c(u,"class","weatherCurrent-data-location svelte-9kdo4s"),c(h,"class","weatherCurrent-data-date"),c(v,"class","weatherCurrent-data-kp svelte-9kdo4s"),c(D,"class","current-details svelte-9kdo4s"),c(a,"class","weatherCurrent-data svelte-9kdo4s"),c(t,"class","weatherCurrent-wrapper svelte-9kdo4s")},m(e,s){i(e,t,s),o(t,a),o(a,u),I&&I.m(u,null),o(a,d),o(a,h),V&&V.m(h,null),o(a,p),o(a,v),q[g].m(v,null),o(a,E),o(a,D),T&&T.m(D,null),y=!0},p(e,[t]){e[0].updating||!e[0].available||e[1].updating||e[2].updating?I&&(I.d(1),I=null):I?I.p(e,t):(I=U(e),I.c(),I.m(u,null)),e[1].updating||e[2].updating?V&&(V.d(1),V=null):V?V.p(e,t):(V=Z(e),V.c(),V.m(h,null));let a=g;g=O(e),g===a?q[g].p(e,t):(_(),w(q[a],1,1,(()=>{q[a]=null})),$(),k=q[g],k?k.p(e,t):(k=q[g]=j[g](e),k.c()),b(k,1),k.m(v,null)),e[2].updating||e[1].updating?T&&(T.d(1),T=null):T?T.p(e,t):(T=X(e),T.c(),T.m(D,null))},i(e){y||(b(k),y=!0)},o(e){w(k),y=!1},d(e){e&&r(t),I&&I.d(),V&&V.d(),q[g].d(),T&&T.d()}}}function te(e,t,a){let s,l,n;return E(e,K,(e=>a(0,s=e))),E(e,z,(e=>a(1,l=e))),E(e,F,(e=>a(2,n=e))),[s,l,n]}!async function(){if("undefined"==typeof window)return;let e;L(K,!0);try{e=await async function(){return new Promise(((e,t)=>{"undefined"!=typeof navigator?navigator.geolocation.getCurrentPosition((t=>{e({longitude:t.coords.longitude,latitude:t.coords.latitude})}),(e=>{t(e)})):t(Error())}))}()}catch(e){return console.log(e),K.update((e=>Object.assign(Object.assign({},e),{available:!1,city:null,longitude:null,latitude:null}))),void L(K,!1)}let t=await fetch(`https://geocode.xyz/${e.latitude},${e.longitude}?geoit=json`),a=await t.json();K.update((t=>Object.assign(Object.assign(Object.assign({},t),{available:!0,city:a.city}),e))),L(K,!1)}(),K.subscribe((async function(e=null){if("undefined"==typeof window)return;if(null===e)return;if(e.updating)return;if(!e.available)return z.update((e=>Object.assign(Object.assign({},e),{available:!1}))),void L(z,!1);L(z,!0);let t=await fetch(`https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${e.latitude}&lon=${e.longitude}`),a=await t.json(),s={clouds:null,temp:null};try{s.clouds=a.properties.timeseries[0].data.instant.details.cloud_area_fraction,s.temp=a.properties.timeseries[0].data.instant.details.air_temperature,a.properties.timeseries=a.properties.timeseries.map((e=>Object.assign(Object.assign({},e),{time:new Date(e.time)})))}catch(e){}z.update((e=>Object.assign(Object.assign({},e),{yr_data_raw:a,now:s,available:!0}))),L(z,!1)})),async function(){if("undefined"==typeof window)return;L(F,!0);let e=await async function(){let e,t={now:{bz:"-",bt:"-",kp:"-",kp_min:"-",kp_max:"-"},usnoaa_data_raw:{solar_wind_mag_field:!1,noaa_planetary_k_index_forecast:!1,geospace_pred_est_kp_1_hour:!1,outlook_27_day:!1}},a=await fetch("https://services.swpc.noaa.gov/products/summary/solar-wind-mag-field.json");t.usnoaa_data_raw.solar_wind_mag_field=await a.json(),t.usnoaa_data_raw.solar_wind_mag_field.TimeStamp=new Date(t.usnoaa_data_raw.solar_wind_mag_field.TimeStamp+" UTC"),t.now.bz=t.usnoaa_data_raw.solar_wind_mag_field.Bz,t.now.bt=t.usnoaa_data_raw.solar_wind_mag_field.Bt,a=await fetch("https://services.swpc.noaa.gov/json/geospace/geospace_pred_est_kp_1_hour.json"),e=await a.json(),e=e.map((e=>Object.assign(Object.assign({},e),{model_prediction_time:new Date(e.model_prediction_time)}))),t.usnoaa_data_raw.geospace_pred_est_kp_1_hour=e,a=await fetch("https://services.swpc.noaa.gov/text/27-day-outlook.txt"),e=await a.text(),e=[...e.matchAll(/^(?<time>\d{4}\s.{3}\s\d{2})\s+(?<flux107>\d+)\s+(?<aindex>\d+)\s+(?<kindex>\d+)$/gm)],e=e.map((e=>Object.assign(Object.assign({},e.groups),{time:new Date(e.groups.time+" UTC")}))),t.usnoaa_data_raw.outlook_27_day=e,a=await fetch("https://services.swpc.noaa.gov/products/noaa-planetary-k-index-forecast.json"),t.usnoaa_data_raw.noaa_planetary_k_index_forecast=await a.json(),t.usnoaa_data_raw.noaa_planetary_k_index_forecast.shift();let s=new Date,l=new Date(0,0,0),n=1e3,r=0;return t.usnoaa_data_raw.noaa_planetary_k_index_forecast.forEach(((e,a)=>{e[1]>r&&(r=e[1]),e[1]<n&&(n=e[1]);let c=new Date(e[0]+" UTC");Math.abs(c.getTime()-s.getTime())<Math.abs(l.getTime()-s.getTime())&&(l=c,t.now.kp=e[1]),t.usnoaa_data_raw.noaa_planetary_k_index_forecast[a]={time:c,kp:e[1],observed:e[2]}})),t.now.kp_min=n.toString(),t.now.kp_max=r.toString(),console.log(t),t}();F.update((t=>Object.assign(Object.assign({},t),e))),L(F,!1)}();class ae extends e{constructor(e){super(),t(this,e,te,ee,a,{})}}function se(e){let t,a;const o=e[1].default,u=j(o,e,e[0],null);return{c(){t=s("div"),u&&u.c(),this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);u&&u.l(a),a.forEach(r),this.h()},h(){c(t,"class","chip svelte-1jb0ny7")},m(e,s){i(e,t,s),u&&u.m(t,null),a=!0},p(e,[t]){u&&u.p&&(!a||1&t)&&q(u,o,e,e[0],a?T(o,e[0],t,null):O(e[0]),null)},i(e){a||(b(u,e),a=!0)},o(e){w(u,e),a=!1},d(e){e&&r(t),u&&u.d(e)}}}function le(e,t,a){let{$$slots:s={},$$scope:l}=t;return e.$$set=e=>{"$$scope"in e&&a(0,l=e.$$scope)},[l,s]}class ne extends e{constructor(e){super(),t(this,e,le,se,a,{})}}function re(e){let t,a,d,h,k,_;return{c(){t=s("div"),a=s("div"),d=s("div"),h=f(),k=s("span"),_=p(e[1]),this.h()},l(s){t=l(s,"DIV",{class:!0,style:!0});var c=n(t);a=l(c,"DIV",{class:!0});var i=n(a);d=l(i,"DIV",{class:!0}),n(d).forEach(r),i.forEach(r),h=m(c),k=l(c,"SPAN",{class:!0});var o=n(k);_=v(o,e[1]),o.forEach(r),c.forEach(r),this.h()},h(){c(d,"class","bar svelte-1mo8cjf"),c(a,"class","bar-wrapper svelte-1mo8cjf"),c(k,"class","value svelte-1mo8cjf"),c(t,"class","wrapper svelte-1mo8cjf"),x(t,"--progress",100*e[0]+"%")},m(e,s){i(e,t,s),o(t,a),o(a,d),o(t,h),o(t,k),o(k,_)},p(e,[a]){2&a&&g(_,e[1]),1&a&&x(t,"--progress",100*e[0]+"%")},i:u,o:u,d(e){e&&r(t)}}}function ce(e,t,a){let{percentage:s}=t,{value:l}=t;return e.$$set=e=>{"percentage"in e&&a(0,s=e.percentage),"value"in e&&a(1,l=e.value)},[s,l]}class ie extends e{constructor(e){super(),t(this,e,ce,re,a,{percentage:0,value:1})}}function oe(e){let t,a,d,h,g,k,_,$,E,j,q,O,T;j=new ie({props:{percentage:e[0]/9,value:e[0]}});let x=e[5]&&function(e){let t,a,d,h,g,k,_,w,$,b,E,D,y=Math.round(e[3])+"",I=Math.round(e[4])+"";return{c(){t=s("div"),a=s("p"),d=s("i"),h=f(),g=p(y),k=p("°C"),_=f(),w=s("p"),$=s("i"),b=f(),E=p(I),D=p("%"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);d=l(c,"I",{class:!0}),n(d).forEach(r),h=m(c),g=v(c,y),k=v(c,"°C"),c.forEach(r),_=m(s),w=l(s,"P",{class:!0});var i=n(w);$=l(i,"I",{class:!0}),n($).forEach(r),b=m(i),E=v(i,I),D=v(i,"%"),i.forEach(r),s.forEach(r),this.h()},h(){c(d,"class","fas fa-thermometer-half svelte-m9qkku"),c(a,"class","svelte-m9qkku"),c($,"class","fas fa-cloud svelte-m9qkku"),c(w,"class","svelte-m9qkku"),c(t,"class","svelte-m9qkku")},m(e,s){i(e,t,s),o(t,a),o(a,d),o(a,h),o(a,g),o(a,k),o(t,_),o(t,w),o(w,$),o(w,b),o(w,E),o(w,D)},p:u,d(e){e&&r(t)}}}(e);return{c(){t=s("div"),a=s("div"),d=s("h3"),h=p(e[2]),g=f(),k=s("p"),_=p(e[1]),$=f(),E=s("div"),D(j.$$.fragment),q=f(),O=s("div"),x&&x.c(),this.h()},l(s){t=l(s,"DIV",{class:!0});var c=n(t);a=l(c,"DIV",{class:!0});var i=n(a);d=l(i,"H3",{class:!0});var o=n(d);h=v(o,e[2]),o.forEach(r),g=m(i),k=l(i,"P",{class:!0});var u=n(k);_=v(u,e[1]),u.forEach(r),i.forEach(r),$=m(c),E=l(c,"DIV",{class:!0});var f=n(E);y(j.$$.fragment,f),f.forEach(r),q=m(c),O=l(c,"DIV",{class:!0});var p=n(O);x&&x.l(p),p.forEach(r),c.forEach(r),this.h()},h(){c(d,"class","svelte-m9qkku"),c(k,"class","svelte-m9qkku"),c(a,"class","svelte-m9qkku"),c(E,"class","KP svelte-m9qkku"),c(O,"class","data svelte-m9qkku"),c(t,"class","prediction-details svelte-m9qkku")},m(e,s){i(e,t,s),o(t,a),o(a,d),o(d,h),o(a,g),o(a,k),o(k,_),o(t,$),o(t,E),I(j,E,null),o(t,q),o(t,O),x&&x.m(O,null),T=!0},p(e,[t]){e[5]&&x.p(e,t)},i(e){T||(b(j.$$.fragment,e),T=!0)},o(e){w(j.$$.fragment,e),T=!1},d(e){e&&r(t),V(j),x&&x.d()}}}function ue(e,t=2){let a=e;for(let s=0;s<t-e.length;s++)a="0"+a;return a}function de(e,t,a){let{prediction:s}=t;let l=s.kp,n=s.time.getDate()+". "+["January","February","March","April","May","June","July","August","September","October","November","December"][s.time.getMonth()],r=ue(s.time.getHours().toString())+":"+ue(s.time.getMinutes().toString()),c=s.temp,i=s.clouds,o=s.hasNOMETData;return e.$$set=e=>{"prediction"in e&&a(6,s=e.prediction)},[l,n,r,c,i,o,s]}class he extends e{constructor(e){super(),t(this,e,de,oe,a,{prediction:6})}}function fe(e,t,a){const s=e.slice();return s[5]=t[a],s[7]=a,s}function pe(e){let t,a;return t=new he({props:{prediction:e[5]}}),{c(){D(t.$$.fragment)},l(e){y(t.$$.fragment,e)},m(e,s){I(t,e,s),a=!0},p(e,a){const s={};1&a&&(s.prediction=e[5]),t.$set(s)},i(e){a||(b(t.$$.fragment,e),a=!0)},o(e){w(t.$$.fragment,e),a=!1},d(e){V(t,e)}}}function me(e){let t,a,o=e[0],u=[];for(let t=0;t<o.length;t+=1)u[t]=pe(fe(e,o,t));const d=e=>w(u[e],1,1,(()=>{u[e]=null}));return{c(){t=s("div");for(let e=0;e<u.length;e+=1)u[e].c();this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);for(let e=0;e<u.length;e+=1)u[e].l(a);a.forEach(r),this.h()},h(){c(t,"class","prediction-table svelte-1uc0m3l")},m(e,s){i(e,t,s);for(let e=0;e<u.length;e+=1)u[e].m(t,null);a=!0},p(e,[a]){if(1&a){let s;for(o=e[0],s=0;s<o.length;s+=1){const l=fe(e,o,s);u[s]?(u[s].p(l,a),b(u[s],1)):(u[s]=pe(l),u[s].c(),b(u[s],1),u[s].m(t,null))}for(_(),s=o.length;s<u.length;s+=1)d(s);$()}},i(e){if(!a){for(let e=0;e<o.length;e+=1)b(u[e]);a=!0}},o(e){u=u.filter(Boolean);for(let e=0;e<u.length;e+=1)w(u[e]);a=!1},d(e){e&&r(t),M(u,e)}}}function ve(e,t,a){let s,l,n;async function r(){if(l.updating||s.updating)return void a(0,n=null);let e=l.usnoaa_data_raw.geospace_pred_est_kp_1_hour.filter((e=>e.model_prediction_time>=new Date));a(0,n=e.map((e=>({time:e.model_prediction_time,kp:Math.round(e.k),temp:null,clouds:null,hasNOMETData:s.available})))),s.available&&n.forEach(((e,t)=>{let l,r,c=new Date(0,0,0),i=!0;s.yr_data_raw.properties.timeseries.forEach(((t,a)=>{let s=new Date(t.time);if(Math.abs(s.getTime()-e.time.getTime())<Math.abs(c.getTime()-e.time.getTime())){if(Math.abs(s.getTime()-e.time.getTime())>18e6)return void(i=!1);c=s,l=t.data.instant.details.air_temperature,r=t.data.instant.details.cloud_area_fraction}})),a(0,n[t]=Object.assign(Object.assign({},n[t]),{temp:l,clouds:r,hasNOMETData:i}),n)}))}return E(e,z,(e=>a(1,s=e))),E(e,F,(e=>a(2,l=e))),F.subscribe(r),z.subscribe(r),[n]}class ge extends e{constructor(e){super(),t(this,e,ve,me,a,{})}}function ke(e){let t,a,o;return a=new ne({props:{$$slots:{default:[_e]},$$scope:{ctx:e}}}),{c(){t=s("div"),D(a.$$.fragment),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);y(a.$$.fragment,s),s.forEach(r),this.h()},h(){c(t,"class","svelte-m9qkku")},m(e,s){i(e,t,s),I(a,t,null),o=!0},p(e,t){const s={};257&t&&(s.$$scope={dirty:t,ctx:e}),a.$set(s)},i(e){o||(b(a.$$.fragment,e),o=!0)},o(e){w(a.$$.fragment,e),o=!1},d(e){e&&r(t),V(a)}}}function _e(e){let t,a=e[0].observed+"";return{c(){t=p(a)},l(e){t=v(e,a)},m(e,a){i(e,t,a)},p(e,s){1&s&&a!==(a=e[0].observed+"")&&g(t,a)},d(e){e&&r(t)}}}function we(e){let t,a,d,h,g,k,E,j,q,O,T,x,M,P,S="predicted"!=e[0].observed&&ke(e);T=new ie({props:{percentage:e[1]/9,value:e[1]}});let N=e[6]&&function(e){let t,a,d,h,g,k,_,w,$,b,E,D,y=Math.round(e[4])+"",I=Math.round(e[5])+"";return{c(){t=s("div"),a=s("p"),d=s("i"),h=f(),g=p(y),k=p("°C"),_=f(),w=s("p"),$=s("i"),b=f(),E=p(I),D=p("%"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"P",{class:!0});var c=n(a);d=l(c,"I",{class:!0}),n(d).forEach(r),h=m(c),g=v(c,y),k=v(c,"°C"),c.forEach(r),_=m(s),w=l(s,"P",{class:!0});var i=n(w);$=l(i,"I",{class:!0}),n($).forEach(r),b=m(i),E=v(i,I),D=v(i,"%"),i.forEach(r),s.forEach(r),this.h()},h(){c(d,"class","fas fa-thermometer-half svelte-m9qkku"),c(a,"class","svelte-m9qkku"),c($,"class","fas fa-cloud svelte-m9qkku"),c(w,"class","svelte-m9qkku"),c(t,"class","svelte-m9qkku")},m(e,s){i(e,t,s),o(t,a),o(a,d),o(a,h),o(a,g),o(a,k),o(t,_),o(t,w),o(w,$),o(w,b),o(w,E),o(w,D)},p:u,d(e){e&&r(t)}}}(e);return{c(){t=s("div"),a=s("div"),d=s("h3"),h=p(e[3]),g=f(),k=s("p"),E=p(e[2]),j=f(),S&&S.c(),q=f(),O=s("div"),D(T.$$.fragment),x=f(),M=s("div"),N&&N.c(),this.h()},l(s){t=l(s,"DIV",{class:!0});var c=n(t);a=l(c,"DIV",{class:!0});var i=n(a);d=l(i,"H3",{class:!0});var o=n(d);h=v(o,e[3]),o.forEach(r),g=m(i),k=l(i,"P",{class:!0});var u=n(k);E=v(u,e[2]),u.forEach(r),i.forEach(r),j=m(c),S&&S.l(c),q=m(c),O=l(c,"DIV",{class:!0});var f=n(O);y(T.$$.fragment,f),f.forEach(r),x=m(c),M=l(c,"DIV",{class:!0});var p=n(M);N&&N.l(p),p.forEach(r),c.forEach(r),this.h()},h(){c(d,"class","svelte-m9qkku"),c(k,"class","svelte-m9qkku"),c(a,"class","svelte-m9qkku"),c(O,"class","KP svelte-m9qkku"),c(M,"class","data svelte-m9qkku"),c(t,"class","prediction-details svelte-m9qkku")},m(e,s){i(e,t,s),o(t,a),o(a,d),o(d,h),o(a,g),o(a,k),o(k,E),o(t,j),S&&S.m(t,null),o(t,q),o(t,O),I(T,O,null),o(t,x),o(t,M),N&&N.m(M,null),P=!0},p(e,[a]){"predicted"!=e[0].observed?S?(S.p(e,a),1&a&&b(S,1)):(S=ke(e),S.c(),b(S,1),S.m(t,q)):S&&(_(),w(S,1,1,(()=>{S=null})),$()),e[6]&&N.p(e,a)},i(e){P||(b(S),b(T.$$.fragment,e),P=!0)},o(e){w(S),w(T.$$.fragment,e),P=!1},d(e){e&&r(t),S&&S.d(),V(T),N&&N.d()}}}function $e(e,t=2){let a=e;for(let s=0;s<t-e.length;s++)a="0"+a;return a}function be(e,t,a){let{prediction:s}=t;let l=s.kp,n=s.time.getDate()+". "+["January","February","March","April","May","June","July","August","September","October","November","December"][s.time.getMonth()],r=$e(s.time.getHours().toString())+":"+$e(s.time.getMinutes().toString()),c=s.temp,i=s.clouds,o=s.hasNOMETData;return e.$$set=e=>{"prediction"in e&&a(0,s=e.prediction)},[s,l,n,r,c,i,o]}class Ee extends e{constructor(e){super(),t(this,e,be,we,a,{prediction:0})}}function De(e,t,a){const s=e.slice();return s[5]=t[a],s[7]=a,s}function ye(e){let t,a;return t=new Ee({props:{prediction:e[5]}}),{c(){D(t.$$.fragment)},l(e){y(t.$$.fragment,e)},m(e,s){I(t,e,s),a=!0},p(e,a){const s={};1&a&&(s.prediction=e[5]),t.$set(s)},i(e){a||(b(t.$$.fragment,e),a=!0)},o(e){w(t.$$.fragment,e),a=!1},d(e){V(t,e)}}}function Ie(e){let t,a,o=e[0],u=[];for(let t=0;t<o.length;t+=1)u[t]=ye(De(e,o,t));const d=e=>w(u[e],1,1,(()=>{u[e]=null}));return{c(){t=s("div");for(let e=0;e<u.length;e+=1)u[e].c();this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);for(let e=0;e<u.length;e+=1)u[e].l(a);a.forEach(r),this.h()},h(){c(t,"class","prediction-table svelte-1uc0m3l")},m(e,s){i(e,t,s);for(let e=0;e<u.length;e+=1)u[e].m(t,null);a=!0},p(e,[a]){if(1&a){let s;for(o=e[0],s=0;s<o.length;s+=1){const l=De(e,o,s);u[s]?(u[s].p(l,a),b(u[s],1)):(u[s]=ye(l),u[s].c(),b(u[s],1),u[s].m(t,null))}for(_(),s=o.length;s<u.length;s+=1)d(s);$()}},i(e){if(!a){for(let e=0;e<o.length;e+=1)b(u[e]);a=!0}},o(e){u=u.filter(Boolean);for(let e=0;e<u.length;e+=1)w(u[e]);a=!1},d(e){e&&r(t),M(u,e)}}}function Ve(e,t,a){let s,l,n;async function r(){if(l.updating||s.updating)return void a(0,n=null);let e=l.usnoaa_data_raw.noaa_planetary_k_index_forecast.filter((e=>"observed"!==e.observed));a(0,n=e.map((e=>({time:e.time,kp:e.kp,observed:e.observed,temp:null,clouds:null,hasNOMETData:s.available})))),s.available&&n.forEach(((e,t)=>{let l,r,c=new Date(0,0,0);s.yr_data_raw.properties.timeseries.forEach(((t,a)=>{let s=new Date(t.time);Math.abs(s.getTime()-e.time.getTime())<Math.abs(c.getTime()-e.time.getTime())&&(c=s,l=t.data.instant.details.air_temperature,r=t.data.instant.details.cloud_area_fraction)})),a(0,n[t]=Object.assign(Object.assign({},n[t]),{temp:l,clouds:r}),n)}))}return E(e,z,(e=>a(1,s=e))),E(e,F,(e=>a(2,l=e))),F.subscribe(r),z.subscribe(r),[n]}class je extends e{constructor(e){super(),t(this,e,Ve,Ie,a,{})}}function qe(e){let t,a,u,d,h,g,k,_,$,E;return k=new ie({props:{percentage:e[0]/9,value:e[0]}}),{c(){t=s("div"),a=s("div"),u=s("h3"),d=p(e[1]),h=f(),g=s("div"),D(k.$$.fragment),_=f(),$=s("div"),this.h()},l(s){t=l(s,"DIV",{class:!0});var c=n(t);a=l(c,"DIV",{class:!0});var i=n(a);u=l(i,"H3",{class:!0});var o=n(u);d=v(o,e[1]),o.forEach(r),i.forEach(r),h=m(c),g=l(c,"DIV",{class:!0});var f=n(g);y(k.$$.fragment,f),f.forEach(r),_=m(c),$=l(c,"DIV",{class:!0}),n($).forEach(r),c.forEach(r),this.h()},h(){c(u,"class","svelte-m9qkku"),c(a,"class","svelte-m9qkku"),c(g,"class","KP svelte-m9qkku"),c($,"class","data svelte-m9qkku"),c(t,"class","prediction-details svelte-m9qkku")},m(e,s){i(e,t,s),o(t,a),o(a,u),o(u,d),o(t,h),o(t,g),I(k,g,null),o(t,_),o(t,$),E=!0},p(e,[t]){},i(e){E||(b(k.$$.fragment,e),E=!0)},o(e){w(k.$$.fragment,e),E=!1},d(e){e&&r(t),V(k)}}}function Oe(e,t=2){let a=e;for(let s=0;s<t-e.length;s++)a="0"+a;return a}function Te(e,t,a){let{prediction:s}=t;let l=s.kp,n=s.time.getDate()+". "+["January","February","March","April","May","June","July","August","September","October","November","December"][s.time.getMonth()];Oe(s.time.getHours().toString()),Oe(s.time.getMinutes().toString());let r=s.temp,c=s.clouds;return e.$$set=e=>{"prediction"in e&&a(4,s=e.prediction)},[l,n,r,c,s]}class xe extends e{constructor(e){super(),t(this,e,Te,qe,a,{prediction:4})}}function Me(e,t,a){const s=e.slice();return s[5]=t[a],s[7]=a,s}function Pe(e){let t,a;return t=new xe({props:{prediction:e[5]}}),{c(){D(t.$$.fragment)},l(e){y(t.$$.fragment,e)},m(e,s){I(t,e,s),a=!0},p(e,a){const s={};1&a&&(s.prediction=e[5]),t.$set(s)},i(e){a||(b(t.$$.fragment,e),a=!0)},o(e){w(t.$$.fragment,e),a=!1},d(e){V(t,e)}}}function Se(e){let t,a,o=e[0],u=[];for(let t=0;t<o.length;t+=1)u[t]=Pe(Me(e,o,t));const d=e=>w(u[e],1,1,(()=>{u[e]=null}));return{c(){t=s("div");for(let e=0;e<u.length;e+=1)u[e].c();this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);for(let e=0;e<u.length;e+=1)u[e].l(a);a.forEach(r),this.h()},h(){c(t,"class","prediction-table svelte-1uc0m3l")},m(e,s){i(e,t,s);for(let e=0;e<u.length;e+=1)u[e].m(t,null);a=!0},p(e,[a]){if(1&a){let s;for(o=e[0],s=0;s<o.length;s+=1){const l=Me(e,o,s);u[s]?(u[s].p(l,a),b(u[s],1)):(u[s]=Pe(l),u[s].c(),b(u[s],1),u[s].m(t,null))}for(_(),s=o.length;s<u.length;s+=1)d(s);$()}},i(e){if(!a){for(let e=0;e<o.length;e+=1)b(u[e]);a=!0}},o(e){u=u.filter(Boolean);for(let e=0;e<u.length;e+=1)w(u[e]);a=!1},d(e){e&&r(t),M(u,e)}}}function Ne(e,t,a){let s,l,n;async function r(){if(l.updating||s.updating)return void a(0,n=null);let e=l.usnoaa_data_raw.outlook_27_day.filter((e=>e.time>=new Date));a(0,n=e.map((e=>({time:e.time,kp:e.kindex,temp:null,clouds:null,hasNOMETData:s.available})))),s.available&&n.forEach(((e,t)=>{let l,r,c=new Date(0,0,0),i=!0;s.yr_data_raw.properties.timeseries.forEach(((t,a)=>{let s=new Date(t.time);if(Math.abs(s.getTime()-e.time.getTime())<Math.abs(c.getTime()-e.time.getTime())){if(Math.abs(s.getTime()-e.time.getTime())>864e5)return void(i=!1);c=s,l=t.data.instant.details.air_temperature,r=t.data.instant.details.cloud_area_fraction}})),a(0,n[t]=Object.assign(Object.assign({},n[t]),{temp:l,clouds:r,hasNOMETData:i}),n)}))}return E(e,z,(e=>a(1,s=e))),E(e,F,(e=>a(2,l=e))),F.subscribe(r),z.subscribe(r),[n]}class Ce extends e{constructor(e){super(),t(this,e,Ne,Se,a,{})}}function Ae(e){let t,a,d,h,g;return{c(){t=s("div"),a=s("i"),d=f(),h=s("p"),g=p("No prediction data"),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"I",{class:!0}),n(a).forEach(r),d=m(s),h=l(s,"P",{});var c=n(h);g=v(c,"No prediction data"),c.forEach(r),s.forEach(r),this.h()},h(){c(a,"class","fas fa-7x fa-exclamation-triangle"),c(t,"class","no-data svelte-2wkoqk")},m(e,s){i(e,t,s),o(t,a),o(t,d),o(t,h),o(h,g)},p:u,i:u,o:u,d(e){e&&r(t)}}}function Be(e){let t,a,u,d,h,g,E,j,q,O,T,x,M,C,A,B,H,J,K;var z=e[0];return z&&(A=new z({})),{c(){t=s("div"),a=s("h2"),u=p("Forecast"),d=f(),h=s("div"),g=s("div"),E=p("hour"),j=f(),q=s("div"),O=p("3 day"),T=f(),x=s("div"),M=p("Long time"),C=f(),A&&D(A.$$.fragment),B=k(),this.h()},l(e){t=l(e,"DIV",{class:!0});var s=n(t);a=l(s,"H2",{class:!0});var c=n(a);u=v(c,"Forecast"),c.forEach(r),d=m(s),h=l(s,"DIV",{class:!0});var i=n(h);g=l(i,"DIV",{class:!0});var o=n(g);E=v(o,"hour"),o.forEach(r),j=m(i),q=l(i,"DIV",{class:!0});var f=n(q);O=v(f,"3 day"),f.forEach(r),T=m(i),x=l(i,"DIV",{class:!0});var p=n(x);M=v(p,"Long time"),p.forEach(r),i.forEach(r),s.forEach(r),C=m(e),A&&y(A.$$.fragment,e),B=k(),this.h()},h(){c(a,"class","svelte-2wkoqk"),c(g,"class","svelte-2wkoqk"),P(g,"selected",e[0]==ge),c(q,"class","svelte-2wkoqk"),P(q,"selected",e[0]==je),c(x,"class","svelte-2wkoqk"),P(x,"selected",e[0]==Ce),c(h,"class","version-picker svelte-2wkoqk"),c(t,"class","header svelte-2wkoqk")},m(s,l){i(s,t,l),o(t,a),o(a,u),o(t,d),o(t,h),o(h,g),o(g,E),o(h,j),o(h,q),o(q,O),o(h,T),o(h,x),o(x,M),i(s,C,l),A&&I(A,s,l),i(s,B,l),H=!0,J||(K=[S(g,"click",e[3]),S(q,"click",e[4]),S(x,"click",e[5])],J=!0)},p(e,t){if(1&t&&P(g,"selected",e[0]==ge),1&t&&P(q,"selected",e[0]==je),1&t&&P(x,"selected",e[0]==Ce),z!==(z=e[0])){if(A){_();const e=A;w(e.$$.fragment,1,0,(()=>{V(e,1)})),$()}z?(A=new z({}),D(A.$$.fragment),b(A.$$.fragment,1),I(A,B.parentNode,B)):A=null}},i(e){H||(A&&b(A.$$.fragment,e),H=!0)},o(e){A&&w(A.$$.fragment,e),H=!1},d(e){e&&r(t),e&&r(C),e&&r(B),A&&V(A,e),J=!1,N(K)}}}function He(e){let t,a,o,u;const d=[Be,Ae],h=[];function f(e,t){return e[1].updating||e[2].updating?1:0}return a=f(e),o=h[a]=d[a](e),{c(){t=s("div"),o.c(),this.h()},l(e){t=l(e,"DIV",{class:!0});var a=n(t);o.l(a),a.forEach(r),this.h()},h(){c(t,"class","drawer svelte-2wkoqk")},m(e,s){i(e,t,s),h[a].m(t,null),u=!0},p(e,[s]){let l=a;a=f(e),a===l?h[a].p(e,s):(_(),w(h[l],1,1,(()=>{h[l]=null})),$(),o=h[a],o?o.p(e,s):(o=h[a]=d[a](e),o.c()),b(o,1),o.m(t,null))},i(e){u||(b(o),u=!0)},o(e){w(o),u=!1},d(e){e&&r(t),h[a].d()}}}function Je(e,t,a){let s,l;E(e,z,(e=>a(1,s=e))),E(e,F,(e=>a(2,l=e)));let n=je;return[n,s,l,()=>a(0,n=ge),()=>a(0,n=je),()=>a(0,n=Ce)]}class Ke extends e{constructor(e){super(),t(this,e,Je,He,a,{})}}function ze(e){let t,a,d,h,p,v;return d=new ae({}),p=new Ke({}),{c(){t=f(),a=s("div"),D(d.$$.fragment),h=f(),D(p.$$.fragment),this.h()},l(e){C('[data-svelte="svelte-1q3846k"]',document.head).forEach(r),t=m(e),a=l(e,"DIV",{class:!0});var s=n(a);y(d.$$.fragment,s),h=m(s),y(p.$$.fragment,s),s.forEach(r),this.h()},h(){document.title="Aurora data",c(a,"class","homescreen svelte-pf4p6y")},m(e,s){i(e,t,s),i(e,a,s),I(d,a,null),o(a,h),I(p,a,null),v=!0},p:u,i(e){v||(b(d.$$.fragment,e),b(p.$$.fragment,e),v=!0)},o(e){w(d.$$.fragment,e),w(p.$$.fragment,e),v=!1},d(e){e&&r(t),e&&r(a),V(d),V(p)}}}class Fe extends e{constructor(e){super(),t(this,e,null,ze,a,{})}}export{Fe as default};