"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[5023],{96682:function(e,t,n){var i=n(5443),r="unavailable",a="unknown",s=[r,a,"off"];(0,i.g)(s);n.d(t,{HV:function(){return a},Hh:function(){return r},KF:function(){return"off"},ON:function(){return"on"}})},31202:function(e,t,n){var i=n(57567),r=n(25979),a=n(12463),s=n(16472),o=(n(28706),n(15697)),d=n(51209),u=n(90789),c=n(61051),f=(n(23418),n(23792),n(62062),n(44114),n(18111),n(61701),n(13579),n(36033),n(45367),n(92731),n(26099),n(16034),n(47764),n(62953),n(87160)),l=n(45602),v=n(13239),h=n(96682),y=function(e,t,n){var i,r=function(e,t,n){for(var i=[],r=0,a=Object.values(e);r<a.length;r++){var s,o=a[r];if("infrared"===(0,l.m)(o.entity_id)){var d=t[o.entity_id],u=null==d?void 0:d.attributes.device_class;if("emitter"===u||"receiver"===u){var c=d.state!==h.Hh,f=void 0;if(d.state!==h.Hh&&d.state!==h.HV){var y=new Date(d.state).getTime();isNaN(y)||(f=d.state)}i.push({entity_id:o.entity_id,device_id:null!==(s=o.device_id)&&void 0!==s?s:null,name:(0,v.aH)(d,e,n)||o.entity_id,type:u,online:c,last_used:f})}}}return i}(e,t,n),a=new Map,s=(0,c.A)(r);try{for(s.s();!(i=s.n()).done;){var o,d=i.value,u=null!==(o=d.device_id)&&void 0!==o?o:"entity:".concat(d.entity_id),y=a.get(u);y?y.push(d):a.set(u,[d])}}catch(_){s.e(_)}finally{s.f()}return Array.from(a.values(),function(e){var t,i,r=e.some(function(e){return"emitter"===e.type}),a=e.some(function(e){return"receiver"===e.type}),s=r&&a?"both":r?"emitter":"receiver",o=e.some(function(e){return e.online}),d=(0,c.A)(e);try{for(d.s();!(i=d.n()).done;){var u=i.value;u.last_used&&(!t||new Date(u.last_used).getTime()>new Date(t).getTime())&&(t=u.last_used)}}catch(_){d.e(_)}finally{d.f()}var l=e[0].device_id,v=l?n[l]:void 0,h=v&&(0,f.xn)(v)||e[0].name;return{id:null!=l?l:e[0].entity_id,device_id:l,name:h,type:s,online:o,last_used:t,entity_ids:e.map(function(e){return e.entity_id})}})},_=function(e){function t(){var e;(0,i.A)(this,t);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return(e=(0,s.A)(this,t,[].concat(a))).isWide=!1,e.narrow=!1,e.routerOptions={defaultPage:"dashboard",showLoading:!0,routes:{dashboard:{tag:"infrared-config-dashboard",load:function(){return Promise.all([n.e(51843),n.e(57927),n.e(5933),n.e(38552),n.e(61710),n.e(80152)]).then(n.bind(n,86899))}},devices:{tag:"infrared-devices-page",load:function(){return Promise.all([n.e(67202),n.e(51843),n.e(5933),n.e(98870),n.e(13049),n.e(82590),n.e(73142),n.e(54600),n.e(77086),n.e(70547),n.e(3786),n.e(57425),n.e(79337),n.e(15124)]).then(n.bind(n,46017))}}}},e._devices=(0,u.A)(function(e,t,n){return y(e,t,n)}),e}return(0,a.A)(t,e),(0,r.A)(t,[{key:"updatePageEl",value:function(e){e.route=this.routeTail,e.hass=this.hass,e.isWide=this.isWide,e.narrow=this.narrow,e.devices=this._devices(this.hass.entities,this.hass.states,this.hass.devices)}}])}(n(99061).a);(0,o.Cg)([(0,d.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,o.Cg)([(0,d.MZ)({attribute:"is-wide",type:Boolean})],_.prototype,"isWide",void 0),(0,o.Cg)([(0,d.MZ)({type:Boolean})],_.prototype,"narrow",void 0),_=(0,o.Cg)([(0,d.EM)("infrared-config-dashboard-router")],_)}}]);
//# sourceMappingURL=5023.ca3aae6ed6d8223b.js.map