-
Notifications
You must be signed in to change notification settings - Fork 13
/
bundle.js
2 lines (2 loc) · 19.4 KB
/
bundle.js
1
2
!function(){"use strict";var e=new Date,t=new Date;function n(r,o,a,u){function c(e){return r(e=0===arguments.length?new Date:new Date(+e)),e}return c.floor=function(e){return r(e=new Date(+e)),e},c.ceil=function(e){return r(e=new Date(e-1)),o(e,1),r(e),e},c.round=function(e){var t=c(e),n=c.ceil(e);return e-t<n-e?t:n},c.offset=function(e,t){return o(e=new Date(+e),null==t?1:Math.floor(t)),e},c.range=function(e,t,n){var a,u=[];if(e=c.ceil(e),n=null==n?1:Math.floor(n),!(e<t&&n>0))return u;do{u.push(a=new Date(+e)),o(e,n),r(e)}while(a<e&&e<t);return u},c.filter=function(e){return n((function(t){if(t>=t)for(;r(t),!e(t);)t.setTime(t-1)}),(function(t,n){if(t>=t)if(n<0)for(;++n<=0;)for(;o(t,-1),!e(t););else for(;--n>=0;)for(;o(t,1),!e(t););}))},a&&(c.count=function(n,o){return e.setTime(+n),t.setTime(+o),r(e),r(t),Math.floor(a(e,t))},c.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?c.filter(u?function(t){return u(t)%e==0}:function(t){return c.count(0,t)%e==0}):c:null}),c}const r=6e4,o=864e5,a=6048e5;var u=n((e=>e.setHours(0,0,0,0)),((e,t)=>e.setDate(e.getDate()+t)),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*r)/o),(e=>e.getDate()-1)),c=u;function i(e){return n((function(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+7*t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*r)/a}))}u.range;var s=i(0),l=i(1),g=i(2),f=i(3),d=i(4),m=i(5),h=i(6);s.range,l.range,g.range,f.range,d.range,m.range,h.range;var w=n((function(e){e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,t){e.setFullYear(e.getFullYear()+t)}),(function(e,t){return t.getFullYear()-e.getFullYear()}),(function(e){return e.getFullYear()}));w.every=function(e){return isFinite(e=Math.floor(e))&&e>0?n((function(t){t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n*e)})):null};var y=w;w.range;var v=n((function(e){e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t-e)/o}),(function(e){return e.getUTCDate()-1})),T=v;function p(e){return n((function(t){t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+7*t)}),(function(e,t){return(t-e)/a}))}v.range;var C=p(0),U=p(1),D=p(2),M=p(3),S=p(4),b=p(5),I=p(6);C.range,U.range,D.range,M.range,S.range,b.range,I.range;var _=n((function(e){e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)}),(function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()}),(function(e){return e.getUTCFullYear()}));_.every=function(e){return isFinite(e=Math.floor(e))&&e>0?n((function(t){t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null};var A=_;function E(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function L(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function x(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}_.range;var F,Y,H,O={"-":"",_:" ",0:"0"},$=/^\s*\d+/,k=/^%/,G=/[\\^$*+?|[\]().{}]/g;function R(e,t,n){var r=e<0?"-":"",o=(r?-e:e)+"",a=o.length;return r+(a<n?new Array(n-a+1).join(t)+o:o)}function N(e){return e.replace(G,"\\$&")}function B(e){return new RegExp("^(?:"+e.map(N).join("|")+")","i")}function j(e){return new Map(e.map(((e,t)=>[e.toLowerCase(),t])))}function W(e,t,n){var r=$.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function Z(e,t,n){var r=$.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function P(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function V(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function q(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function z(e,t,n){var r=$.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function J(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Q(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function X(e,t,n){var r=$.exec(t.slice(n,n+1));return r?(e.q=3*r[0]-3,n+r[0].length):-1}function K(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function ee(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function te(e,t,n){var r=$.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function ne(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function re(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function oe(e,t,n){var r=$.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function ae(e,t,n){var r=$.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function ue(e,t,n){var r=$.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ce(e,t,n){var r=k.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function ie(e,t,n){var r=$.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function se(e,t,n){var r=$.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function le(e,t){return R(e.getDate(),t,2)}function ge(e,t){return R(e.getHours(),t,2)}function fe(e,t){return R(e.getHours()%12||12,t,2)}function de(e,t){return R(1+c.count(y(e),e),t,3)}function me(e,t){return R(e.getMilliseconds(),t,3)}function he(e,t){return me(e,t)+"000"}function we(e,t){return R(e.getMonth()+1,t,2)}function ye(e,t){return R(e.getMinutes(),t,2)}function ve(e,t){return R(e.getSeconds(),t,2)}function Te(e){var t=e.getDay();return 0===t?7:t}function pe(e,t){return R(s.count(y(e)-1,e),t,2)}function Ce(e){var t=e.getDay();return t>=4||0===t?d(e):d.ceil(e)}function Ue(e,t){return e=Ce(e),R(d.count(y(e),e)+(4===y(e).getDay()),t,2)}function De(e){return e.getDay()}function Me(e,t){return R(l.count(y(e)-1,e),t,2)}function Se(e,t){return R(e.getFullYear()%100,t,2)}function be(e,t){return R((e=Ce(e)).getFullYear()%100,t,2)}function Ie(e,t){return R(e.getFullYear()%1e4,t,4)}function _e(e,t){var n=e.getDay();return R((e=n>=4||0===n?d(e):d.ceil(e)).getFullYear()%1e4,t,4)}function Ae(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+R(t/60|0,"0",2)+R(t%60,"0",2)}function Ee(e,t){return R(e.getUTCDate(),t,2)}function Le(e,t){return R(e.getUTCHours(),t,2)}function xe(e,t){return R(e.getUTCHours()%12||12,t,2)}function Fe(e,t){return R(1+T.count(A(e),e),t,3)}function Ye(e,t){return R(e.getUTCMilliseconds(),t,3)}function He(e,t){return Ye(e,t)+"000"}function Oe(e,t){return R(e.getUTCMonth()+1,t,2)}function $e(e,t){return R(e.getUTCMinutes(),t,2)}function ke(e,t){return R(e.getUTCSeconds(),t,2)}function Ge(e){var t=e.getUTCDay();return 0===t?7:t}function Re(e,t){return R(C.count(A(e)-1,e),t,2)}function Ne(e){var t=e.getUTCDay();return t>=4||0===t?S(e):S.ceil(e)}function Be(e,t){return e=Ne(e),R(S.count(A(e),e)+(4===A(e).getUTCDay()),t,2)}function je(e){return e.getUTCDay()}function We(e,t){return R(U.count(A(e)-1,e),t,2)}function Ze(e,t){return R(e.getUTCFullYear()%100,t,2)}function Pe(e,t){return R((e=Ne(e)).getUTCFullYear()%100,t,2)}function Ve(e,t){return R(e.getUTCFullYear()%1e4,t,4)}function qe(e,t){var n=e.getUTCDay();return R((e=n>=4||0===n?S(e):S.ceil(e)).getUTCFullYear()%1e4,t,4)}function ze(){return"+0000"}function Je(){return"%"}function Qe(e){return+e}function Xe(e){return Math.floor(+e/1e3)}F=function(e){var t=e.dateTime,n=e.date,r=e.time,o=e.periods,a=e.days,u=e.shortDays,i=e.months,s=e.shortMonths,g=B(o),f=j(o),d=B(a),m=j(a),h=B(u),w=j(u),y=B(i),v=j(i),p=B(s),C=j(s),D={a:function(e){return u[e.getDay()]},A:function(e){return a[e.getDay()]},b:function(e){return s[e.getMonth()]},B:function(e){return i[e.getMonth()]},c:null,d:le,e:le,f:he,g:be,G:_e,H:ge,I:fe,j:de,L:me,m:we,M:ye,p:function(e){return o[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:Qe,s:Xe,S:ve,u:Te,U:pe,V:Ue,w:De,W:Me,x:null,X:null,y:Se,Y:Ie,Z:Ae,"%":Je},M={a:function(e){return u[e.getUTCDay()]},A:function(e){return a[e.getUTCDay()]},b:function(e){return s[e.getUTCMonth()]},B:function(e){return i[e.getUTCMonth()]},c:null,d:Ee,e:Ee,f:He,g:Pe,G:qe,H:Le,I:xe,j:Fe,L:Ye,m:Oe,M:$e,p:function(e){return o[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:Qe,s:Xe,S:ke,u:Ge,U:Re,V:Be,w:je,W:We,x:null,X:null,y:Ze,Y:Ve,Z:ze,"%":Je},S={a:function(e,t,n){var r=h.exec(t.slice(n));return r?(e.w=w.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(e,t,n){var r=p.exec(t.slice(n));return r?(e.m=C.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(e,t,n){var r=y.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(e,n,r){return _(e,t,n,r)},d:ee,e:ee,f:ue,g:J,G:z,H:ne,I:ne,j:te,L:ae,m:K,M:re,p:function(e,t,n){var r=g.exec(t.slice(n));return r?(e.p=f.get(r[0].toLowerCase()),n+r[0].length):-1},q:X,Q:ie,s:se,S:oe,u:Z,U:P,V:V,w:W,W:q,x:function(e,t,r){return _(e,n,t,r)},X:function(e,t,n){return _(e,r,t,n)},y:J,Y:z,Z:Q,"%":ce};function b(e,t){return function(n){var r,o,a,u=[],c=-1,i=0,s=e.length;for(n instanceof Date||(n=new Date(+n));++c<s;)37===e.charCodeAt(c)&&(u.push(e.slice(i,c)),null!=(o=O[r=e.charAt(++c)])?r=e.charAt(++c):o="e"===r?" ":"0",(a=t[r])&&(r=a(n,o)),u.push(r),i=c+1);return u.push(e.slice(i,c)),u.join("")}}function I(e,t){return function(n){var r,o,a=x(1900,void 0,1);if(_(a,e,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(t&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(o=(r=L(x(a.y,0,1))).getUTCDay(),r=o>4||0===o?U.ceil(r):U(r),r=T.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(o=(r=E(x(a.y,0,1))).getDay(),r=o>4||0===o?l.ceil(r):l(r),r=c.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),o="Z"in a?L(x(a.y,0,1)).getUTCDay():E(x(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(o+5)%7:a.w+7*a.U-(o+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,L(a)):E(a)}}function _(e,t,n,r){for(var o,a,u=0,c=t.length,i=n.length;u<c;){if(r>=i)return-1;if(37===(o=t.charCodeAt(u++))){if(o=t.charAt(u++),!(a=S[o in O?t.charAt(u++):o])||(r=a(e,n,r))<0)return-1}else if(o!=n.charCodeAt(r++))return-1}return r}return D.x=b(n,D),D.X=b(r,D),D.c=b(t,D),M.x=b(n,M),M.X=b(r,M),M.c=b(t,M),{format:function(e){var t=b(e+="",D);return t.toString=function(){return e},t},parse:function(e){var t=I(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=b(e+="",M);return t.toString=function(){return e},t},utcParse:function(e){var t=I(e+="",!0);return t.toString=function(){return e},t}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),F.format,F.parse,Y=F.utcFormat,H=F.utcParse;const Ke="https://epic.gsfc.nasa.gov/",et="https://rammb-slider.cira.colostate.edu/data/",tt="https://epic.gsfc.nasa.gov",nt=tt+"/enhanced",rt="INFRARED_FULL",ot="D531106",at="EPIC",ut="EPIC_ENHANCED",ct="GOES_16",it="GOES_16_NATURAL",st="GOES_18",lt="GOES_18_NATURAL",gt="GOES_19",ft="GOES_19_NATURAL",dt="METEOSAT",mt="METEOSAT_IODC",ht="HIMAWARI_9",wt=550,yt=[1,4,8,16,20],vt=678,Tt=[1,2,4,8,16],pt=2048,Ct="imageData",Ut="cachedDate",Dt="cachedImageType",Mt=window.browser&&!!browser.storage,St={animated:!1,imageType:ot};function bt(e,t){let n=e+"";for(;n.length<t;)n="0"+n;return n}function It(e){return Mt?e:`https://slider-proxy.domoritz.workers.dev/?${encodeURIComponent(e)}`}async function _t(e){const t={GOES_16:"goes-16",GOES_16_NATURAL:"goes-16",GOES_18:"goes-17",GOES_18_NATURAL:"goes-17",GOES_19:"goes-19",GOES_19_NATURAL:"goes-19",HIMAWARI_9:"himawari"}[e],n=await fetch(It(`${et}json/${t}/full_disk/geocolor/latest_times.json`)),r=await n.json();return H("%Y%m%d%H%M%S")(r.timestamps_int[0])}function At(e,t){const n=document.getElementById("output").clientHeight*window.devicePixelRatio/e;for(let e=0;e<t.length;e++){const r=t[e];if(r>n)return{blocks:r,level:e}}const r=t.length-1;return{blocks:t[r],level:r}}let Et=null,Lt=null;function xt(e){document.getElementById("time").innerHTML=null===e?"":`<abbr title="${e}">${function(e){const t=Math.floor(((new Date).getTime()-e.getTime())/1e3);let n=Math.floor(t/31536e3);return n>1?n+" years":(n=Math.floor(t/2592e3),n>1?n+" months":(n=Math.floor(t/86400),n>1?n+" days":(n=Math.floor(t/3600),n>1?n+" hours":(n=Math.floor(t/60),n>1?n+" minutes":Math.floor(t)+" seconds"))))}(e)}</abbr> ago`}function Ft(e,t){xt(e),Et=e,function(e){switch(document.body.classList.remove("himawari"),document.body.classList.remove("dscovr"),document.body.classList.remove("goes"),document.body.classList.remove("goes16"),document.body.classList.remove("meteosat"),e){case rt:case ot:case ht:document.body.classList.add("himawari");break;case at:case ut:document.body.classList.add("dscovr");break;case ct:case it:case st:case lt:case gt:case ft:document.body.classList.add("goes");break;case dt:case mt:document.body.classList.add("meteosat");break;default:console.warn("Unknown image type",e)}}(t),Lt=t}function Yt(e,t,n=.95){const r=document.getElementById("output").toDataURL("image/jpeg",n);try{localStorage.setItem(Ct,r)}catch{if(n>.5)return n-=.05,console.warn(`Couldn't store image. Trying again with lower image quality of ${n}`),Yt(e,t,n)}localStorage.setItem(Ut,e.toString()),localStorage.setItem(Dt,t)}function Ht(e,t){if(Et&&e.getTime()===Et.getTime()&&Lt===t)return;const n=!localStorage.getItem(Ut);n&&Ft(e,t);const r=function(e){const t="https://himawari8-dl.nict.go.jp/himawari8/img/"+(e.type||ot),n=e.date,r=e.blocks,o=`${t}/${r}d/550/${Y("%Y/%m/%d/%H%M%S")(n)}`,a=[];for(let e=0;e<r;e++)for(let t=0;t<r;t++){const n=`${o}_${t}_${e}.png`;a.push({url:n,x:t,y:e})}return{blocks:r,date:n,tiles:a}}({blocks:At(wt,yt).blocks,date:e,type:t}),o=r.blocks*wt,a=n?document.getElementById("output"):document.createElement("canvas"),u=a.getContext("2d");u.canvas.width=o,u.canvas.height=o,Promise.all(r.tiles.map((e=>function(e){return new Promise((t=>{const n=new Image;n.setAttribute("crossOrigin","anonymous"),n.onload=()=>{u.drawImage(n,e.x*wt,e.y*wt,wt,wt),t()},n.src=e.url}))}(e)))).catch((e=>{throw e})).then((()=>{if(!n){const e=document.getElementById("output").getContext("2d");e.canvas.width=o,e.canvas.height=o,e.drawImage(a,0,0)}Ft(e,t),Yt(e,t)}))}function Ot(e,t){if(Et&&e.getTime()===Et.getTime()&&Lt===t)return;const n=!localStorage.getItem(Ut);n&&Ft(e,t);const r=function(e){const t=e.date,n=e.blocks,r=e.level,o={GOES_16:"geocolor",GOES_16_NATURAL:"natural_color",GOES_18:"geocolor",GOES_18_NATURAL:"natural_color",GOES_19:"geocolor",GOES_19_NATURAL:"natural_color",HIMAWARI_9:"geocolor"}[e.type],a={GOES_16:"goes-16",GOES_16_NATURAL:"goes-16",GOES_18:"goes-17",GOES_18_NATURAL:"goes-17",GOES_19:"goes-19",GOES_19_NATURAL:"goes-19",HIMAWARI_9:"himawari"}[e.type],u=Y("%Y/%m/%d")(e.date),c=Y("%Y%m%d%H%M%S")(e.date),i=`${et}imagery/${u}/${a}---full_disk/${o}/${c}/`,s=[];for(let e=0;e<n;e++)for(let t=0;t<n;t++){const n=`${i}${bt(r,2)}/${bt(e,3)}_${bt(t,3)}.png`;s.push({url:n,x:t,y:e})}return{blocks:n,date:t,tiles:s}}({date:e,type:t,...At(vt,Tt)}),o=r.blocks*vt,a=n?document.getElementById("output"):document.createElement("canvas"),u=a.getContext("2d");u.canvas.width=o,u.canvas.height=o,Promise.all(r.tiles.map((e=>function(e){return new Promise((t=>{const n=new Image;n.setAttribute("crossOrigin","anonymous"),n.onload=()=>{u.drawImage(n,e.x*vt,e.y*vt,vt,vt),t()},n.src=It(e.url)}))}(e)))).catch((e=>{throw e})).then((()=>{if(!n){const e=document.getElementById("output").getContext("2d");e.canvas.width=o,e.canvas.height=o,e.drawImage(a,0,0)}Ft(e,t),Yt(e,t)}))}async function $t(){if(navigator.onLine)if(Mt){document.title="New Tab";const{imageType:e}=await browser.storage.sync.get(St);switch(e){case at:case ut:!function(e,t){if(Et&&e.date.getTime()===Et.getTime()&&Lt===t)return;const n=!localStorage.getItem(Ut);n&&Ft(e.date,t);const r=n?document.getElementById("output"):document.createElement("canvas"),o=r.getContext("2d");o.canvas.width=pt,o.canvas.height=pt;const a=new Image;a.setAttribute("crossOrigin","anonymous"),a.onload=()=>{if(o.drawImage(a,0,0),!n){const e=document.getElementById("output").getContext("2d");e.canvas.width=pt,e.canvas.height=pt,e.drawImage(r,0,0)}Ft(e.date,t),Yt(e.date,t)};const u=t===ut?"enhanced":"natural",c=bt(e.date.getMonth()+1,2),i=bt(e.date.getDate(),2);a.src=`${Ke}archive/${u}/${e.date.getFullYear()}/${c}/${i}/png/${e.image}.png`}(await async function(e){const t=await fetch(`${Ke}api/${e===ut?"enhanced":"natural"}`),n=await t.json();if(0===n.length)return null;const r=n[n.length-1];return{date:H("%Y-%m-%d %H:%M:%S")(r.date),image:r.image}}(e),e);break;case ct:case it:case st:case lt:case gt:case ft:Ot(await _t(e),e);break;case dt:case mt:!function(e,t){if(Et&&e.date.getTime()===Et.getTime()&&Lt===t)return;const n=!localStorage.getItem(Ut);n&&Ft(e.date,t);const r=n?document.getElementById("output"):document.createElement("canvas"),o=r.getContext("2d");o.canvas.width=3712,o.canvas.height=3630;const a=new Image;a.setAttribute("crossOrigin","anonymous"),a.onload=()=>{if(o.drawImage(a,0,0),!n){const e=document.getElementById("output").getContext("2d");e.canvas.width=3712,e.canvas.height=3630,e.drawImage(r,0,0)}Ft(e.date,t),Yt(e.date,t)},a.src=e.image}(await async function(e){const t=await fetch("https://meteosat-url.appspot.com/msg"+(e===mt?"iodc":"")),n=await t.json();return{date:H("%Y-%m-%d %H:%M:%S")(n.date),image:n.url}}(e),e);break;case rt:case ot:Ht(await async function(e){const t=await fetch("https://himawari-8.appspot.com/latest"+(e===rt?"?infrared=true":"")),n=(await t.json()).date;return H("%Y-%m-%d %H:%M:%S")(n)}(e),e);break;default:Ot(await _t(e),e)}}else Ot(await _t(ht),ht)}function kt(){localStorage.getItem(Ut)&&function(){const e=document.getElementById("output").getContext("2d"),t=new Date(localStorage.getItem(Ut)),n=new Image;n.onload=()=>{e.canvas.width=n.width,e.canvas.height=n.height,e.drawImage(n,0,0),Ft(t,localStorage.getItem(Dt))},n.src=localStorage.getItem(Ct)}(),$t()}window.setInterval($t,6e4),window.addEventListener("online",$t),Mt?browser.storage.sync.get(St).then((e=>{e.animated?document.body.classList.add("animated"):document.body.classList.remove("animated"),kt()})):kt(),window.setInterval((()=>{Et&&xt(Et)}),1e4),Mt&&(browser.storage.onChanged.addListener($t),document.body.classList.add("extension"),document.getElementById("go-to-options").addEventListener("click",(()=>{browser.runtime.openOptionsPage()}))),document.getElementById("explore").addEventListener("click",(()=>{switch(Lt){case at:window.open(tt,"_self");break;case ut:window.open(nt,"_self");break;case ct:case it:case st:case lt:case gt:case ft:case ht:window.open("https://rammb-slider.cira.colostate.edu/","_self");break;case rt:case ot:window.open("https://himawari8.nict.go.jp/himawari8-image.htm?sI=D531106","_self");break;case dt:case mt:window.open("https://eumetview.eumetsat.int/static-images/","_self");break;default:window.alert("No explorer found.")}}))}();
//# sourceMappingURL=bundle.js.map