"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["94332"],{55287:function(e,i,t){t.a(e,async function(e,a){try{t.r(i),t.d(i,{SideBarView:function(){return f}});t(18111),t(7588),t(3362),t(62953);var o=t(40445),n=t(96196),d=t(77845),s=t(1087),l=t(52667),r=t(82360),c=e([l]);l=(c.then?(await c)():c)[0];let h,v,p,u=e=>e;const m="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z",g="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z",b="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z";class f extends n.WF{connectedCallback(){super.connectedCallback(),this._mql=window.matchMedia("(min-width: 760px)"),this._mqlListenerRef=this._createCards.bind(this),this._mql.addListener(this._mqlListenerRef)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._mql)||void 0===e||e.removeListener(this._mqlListenerRef),this._mqlListenerRef=void 0,this._mql=void 0}setConfig(e){this._config=e}willUpdate(e){var i,a,o;if(super.willUpdate(e),null!==(i=this.lovelace)&&void 0!==i&&i.editMode&&t.e("59127").then(t.bind(t,70410)),e.has("cards")&&this._createCards(),!e.has("lovelace")&&!e.has("_config"))return;const n=e.get("lovelace");(!e.has("cards")&&(null==n?void 0:n.config)!==(null===(a=this.lovelace)||void 0===a?void 0:a.config)||n&&(null==n?void 0:n.editMode)!==(null===(o=this.lovelace)||void 0===o?void 0:o.editMode))&&this._createCards()}render(){var e,i;return(0,n.qy)(h||(h=u` <hui-view-badges .hass="${0}" .badges="${0}" .lovelace="${0}" .viewIndex="${0}" show-add-label></hui-view-badges> <div class="container ${0}"></div> ${0} `),this.hass,this.badges,this.lovelace,this.index,null!==(e=this.lovelace)&&void 0!==e&&e.editMode?"edit-mode":"",null!==(i=this.lovelace)&&void 0!==i&&i.editMode?(0,n.qy)(v||(v=u` <ha-fab .label="${0}" extended @click="${0}"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-fab> `),this.hass.localize("ui.panel.lovelace.editor.edit_card.add"),this._addCard,b):"")}_addCard(){(0,s.r)(this,"ll-create-card")}_createCards(){var e;const i=document.createElement("div");let t;if(i.id="main",null!==(e=this._mql)&&void 0!==e&&e.matches?(t=document.createElement("div"),t.id="sidebar"):t=i,this.hasUpdated){const e=this.renderRoot.querySelector("#main"),a=this.renderRoot.querySelector("#sidebar"),o=this.renderRoot.querySelector(".container");e&&o.removeChild(e),a&&o.removeChild(a),o.appendChild(i),o.appendChild(t)}else this.updateComplete.then(()=>{const e=this.renderRoot.querySelector(".container");e.appendChild(i),e.appendChild(t)});this.cards.forEach((e,a)=>{var o,n,d;const s=null===(o=this._config)||void 0===o||null===(o=o.cards)||void 0===o?void 0:o[a];let l;if(this.isStrategy||null===(n=this.lovelace)||void 0===n||!n.editMode)e.preview=!1,l=e;else{var c;l=document.createElement("hui-card-options"),l.hass=this.hass,l.lovelace=this.lovelace,l.path=[this.index,a],e.preview=!0;const i=document.createElement("ha-icon-button");i.slot="buttons";const t=document.createElement("ha-svg-icon");t.path="sidebar"!==(null==s||null===(c=s.view_layout)||void 0===c?void 0:c.position)?g:m,i.appendChild(t),i.addEventListener("click",()=>{var e;this.lovelace.saveConfig((0,r.bn)(this.lovelace.config,[this.index,a],Object.assign(Object.assign({},s),{},{view_layout:{position:"sidebar"!==(null==s||null===(e=s.view_layout)||void 0===e?void 0:e.position)?"sidebar":"main"}})))}),l.appendChild(i),l.appendChild(e)}"sidebar"!==(null==s||null===(d=s.view_layout)||void 0===d?void 0:d.position)?i.appendChild(l):t.appendChild(l)})}constructor(...e){super(...e),this.isStrategy=!1,this.cards=[],this.badges=[]}}f.styles=(0,n.AH)(p||(p=u`:host{display:block;padding-top:4px}hui-view-badges{display:block;margin:4px 8px 4px 8px;font-size:var(--ha-font-size-s)}.container{display:flex;justify-content:center;margin-left:4px;margin-right:4px}.container.edit-mode{margin-bottom:72px}#main{max-width:1620px;flex-grow:2}#sidebar{flex-grow:1;flex-shrink:0;max-width:380px}.container>div{min-width:0;box-sizing:border-box}.container>div>:not([hidden]){display:block;margin:var(--masonry-view-card-margin,4px 4px 8px)}@media (max-width:500px){.container>div>*{margin-left:0;margin-right:0}}ha-fab{position:fixed;right:calc(16px + var(--safe-area-inset-right));bottom:calc(16px + var(--safe-area-inset-bottom));inset-inline-end:calc(16px + var(--safe-area-inset-right));inset-inline-start:initial;z-index:1}`)),(0,o.Cg)([(0,d.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,o.Cg)([(0,d.MZ)({attribute:!1})],f.prototype,"lovelace",void 0),(0,o.Cg)([(0,d.MZ)({type:Number})],f.prototype,"index",void 0),(0,o.Cg)([(0,d.MZ)({attribute:!1})],f.prototype,"isStrategy",void 0),(0,o.Cg)([(0,d.MZ)({attribute:!1})],f.prototype,"cards",void 0),(0,o.Cg)([(0,d.MZ)({attribute:!1})],f.prototype,"badges",void 0),(0,o.Cg)([(0,d.wk)()],f.prototype,"_config",void 0),f=(0,o.Cg)([(0,d.EM)("hui-sidebar-view")],f),a()}catch(h){a(h)}})}}]);
//# sourceMappingURL=94332.b92dddc0d3367526.js.map