"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1414],{33164:function(e,t,r){r.d(t,{A:function(){return u}});var a=r(20641);const n=["src","alt","width","height"];function i(e,t,r,i,s,h){return h.iconUrl?((0,a.uX)(),(0,a.CE)("img",{key:0,src:h.iconUrl,alt:r.weather?.summary,width:r.size,height:r.size,class:"weather-icon"},null,8,n)):(0,a.Q3)("",!0)}var s={name:"WeatherIcon",props:{weather:{type:Object,required:!0},iconColor:{type:String,default:"dark"},size:{type:Number,default:75}},computed:{iconUrl(){return this.weather?.image?this.weather.image:this.weather?.icon?`/icons/openweathermap/${this.iconColor||"dark"}/${this.weather.icon}.png`:null}}},h=r(66262);const o=(0,h.A)(s,[["render",i],["__scopeId","data-v-445fc8f0"]]);var u=o},1414:function(e,t,r){r.r(t),r.d(t,{default:function(){return g}});var a=r(20641),n=r(90033);const i={class:"weather"},s={key:1},h={key:1,class:"temperature"},o=["textContent"];function u(e,t,r,u,l,c){const w=(0,a.g2)("Loading"),d=(0,a.g2)("WeatherIcon");return(0,a.uX)(),(0,a.CE)("div",i,[e.loading?((0,a.uX)(),(0,a.Wv)(w,{key:0})):((0,a.uX)(),(0,a.CE)("h1",s,[c._showIcon&&e.weather?((0,a.uX)(),(0,a.Wv)(d,{key:0,weather:e.weather,"icon-color":r.iconColor,size:1.5*r.iconSize,class:"owm-icon"},null,8,["weather","icon-color","size"])):(0,a.Q3)("",!0),c._showTemperature&&e.weather?((0,a.uX)(),(0,a.CE)("span",h,(0,n.v_)(Math.round(parseFloat(e.weather.temperature))+"°"),1)):(0,a.Q3)("",!0)])),c._showSummary&&e.weather&&e.weather.summary?((0,a.uX)(),(0,a.CE)("div",{key:2,class:"summary",textContent:(0,n.v_)(e.weather.summary)},null,8,o)):(0,a.Q3)("",!0)])}r(74423);var l=r(91387),c=r(81350),w=r(33164),d={name:"Weather",mixins:[l.A],components:{Loading:c.A,WeatherIcon:w.A},props:{iconSize:{type:Number,required:!1,default:50},iconColor:{type:String,required:!1},showIcon:{required:!1,default:!0},showSummary:{required:!1,default:!0},showTemperature:{required:!1,default:!0},refreshSeconds:{type:Number,required:!1,default:900}},data:function(){return{weather:void 0,weatherPlugin:void 0,loading:!1,weatherPlugins:["weather.openweathermap","weather.buienradar"]}},computed:{_showSummary(){return this.parseBoolean(this.showSummary)},_showIcon(){return this.parseBoolean(this.showIcon)},_showTemperature(){return this.parseBoolean(this.showTemperature)}},methods:{async refresh(){this.loading=!0;try{const e=await this.request(`${this.weatherPlugin}.get_current_weather`);this.onWeatherChange(e)}finally{this.loading=!1}},onWeatherChange(e){this.weather&&e&&this.weatherPlugins.includes(e.plugin_name)||(this.weather={}),this.weather={...this.weather,...e}},initWeatherPlugin(){for(const e of this.weatherPlugins)if(this.$root.config[e]){this.weatherPlugin=e,console.debug(`Initialized weather UI - plugin: ${e}`);break}this.weatherPlugin||console.warn(`No weather plugins configured. Compatible plugins: ${this.weatherPlugins}`)}},mounted:function(){this.initWeatherPlugin(),this.refresh(),this.subscribe(this.onWeatherChange,null,"platypush.message.event.weather.NewWeatherConditionEvent"),setInterval(this.refresh,parseInt((1e3*this.refreshSeconds).toFixed(0)))}},p=r(66262);const m=(0,p.A)(d,[["render",u],["__scopeId","data-v-4f5b2f9b"]]);var g=m}}]);
//# sourceMappingURL=1414.31a60972.js.map