"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["87764"],{5023:function(t,i,e){e.r(i),e.d(i,{HuiToggleGroupCard:function(){return d}});e(16280),e(18111),e(22489),e(61701);var o=e(40445),n=e(96196),s=e(77845),r=e(29485),a=e(78870),c=e(71727),l=e(47129),h=e(27120),g=(e(76776),e(22573),e(80933),e(32248),e(88360));let _,u,f=t=>t;class d extends n.WF{setConfig(t){var i;if(null===(i=t.entities)||void 0===i||!i.length)throw new Error("Entities are required");this._config=t}getCardSize(){var t;return null!==(t=this._config)&&void 0!==t&&t.vertical?2:1}getGridOptions(){var t;let i=1,e=6;return null!==(t=this._config)&&void 0!==t&&t.vertical&&(i++,e=3),{columns:6,rows:i,min_columns:e,min_rows:i}}_getOnEntities(){return this.hass&&this._config?this._config.entities.map(t=>this.hass.states[t]).filter(t=>void 0!==t&&(0,l.a)(t)):[]}_computeColor(){if(!this._config||!this.hass)return;const t=this._getOnEntities();return 0!==t.length?this._config.color?(0,a.MP)(this._config.color):(0,h.Se)(t[0]):void 0}_computeLabel(){if(!this.hass||!this._config)return"";const t=this._getOnEntities().length,i=this._config.entities.length;return 0===t?this.hass.localize("ui.card.toggle-group.all_off"):t===i?this.hass.localize("ui.card.toggle-group.all_on"):this.hass.localize("ui.card.toggle-group.some_on",{on_count:t,total_count:i})}_handleTap(){if(!this.hass||!this._config)return;const t=this._getOnEntities(),i=(0,c.m)(this._config.entities[0]);let e;e="cover"===i?t.length>0?"close_cover":"open_cover":t.length>0?"turn_off":"turn_on",this.hass.callService(i,e,{entity_id:this._config.entities}),(0,g.j)(this,"light")}render(){if(!this._config||!this.hass)return n.s6;const t={"--tile-color":this._computeColor()},i=this._computeLabel(),e=this._config.title||i,o=this._config.title?i:void 0;return(0,n.qy)(_||(_=f` <ha-card style="${0}"> <ha-tile-container .vertical="${0}"> <ha-tile-icon slot="icon" icon="mdi:power" .interactive="${0}" @action="${0}"></ha-tile-icon> <ha-tile-info slot="info" .primary="${0}" .secondary="${0}"></ha-tile-info> </ha-tile-container> </ha-card> `),(0,r.W)(t),Boolean(this._config.vertical),!0,this._handleTap,e,o)}}d.styles=(0,n.AH)(u||(u=f`:host{--tile-color:var(--state-inactive-color)}ha-card{background:0 0;backdrop-filter:none;-webkit-backdrop-filter:none;border:none;box-shadow:none;height:100%}ha-tile-icon{--tile-icon-color:var(--tile-color)}`)),(0,o.Cg)([(0,s.MZ)({attribute:!1})],d.prototype,"hass",void 0),(0,o.Cg)([(0,s.wk)()],d.prototype,"_config",void 0),d=(0,o.Cg)([(0,s.EM)("hui-toggle-group-card")],d)}}]);
//# sourceMappingURL=87764.e89454673ccad679.js.map