export const id=1848;export const ids=[1848];export const modules={3350:(e,i,t)=>{t.d(i,{S:()=>l});var o=t(5461),s=t(8597),a=t(196);t(9222);const l=e=>{switch(e.level){case 0:return"M11,10H13V16H11V10M22,12H19V20H5V12H2L12,3L22,12M15,10A2,2 0 0,0 13,8H11A2,2 0 0,0 9,10V16A2,2 0 0,0 11,18H13A2,2 0 0,0 15,16V10Z";case 1:return"M12,3L2,12H5V20H19V12H22L12,3M10,8H14V18H12V10H10V8Z";case 2:return"M12,3L2,12H5V20H19V12H22L12,3M9,8H13A2,2 0 0,1 15,10V12A2,2 0 0,1 13,14H11V16H15V18H9V14A2,2 0 0,1 11,12H13V10H9V8Z";case 3:return"M12,3L22,12H19V20H5V12H2L12,3M15,11.5V10C15,8.89 14.1,8 13,8H9V10H13V12H11V14H13V16H9V18H13A2,2 0 0,0 15,16V14.5A1.5,1.5 0 0,0 13.5,13A1.5,1.5 0 0,0 15,11.5Z";case-1:return"M12,3L2,12H5V20H19V12H22L12,3M11,15H7V13H11V15M15,18H13V10H11V8H15V18Z"}return"M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"};(0,o.A)([(0,a.EM)("ha-floor-icon")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[(0,a.MZ)({attribute:!1})],key:"floor",value:void 0},{kind:"field",decorators:[(0,a.MZ)()],key:"icon",value:void 0},{kind:"method",key:"render",value:function(){if(this.floor.icon)return s.qy`<ha-icon .icon=${this.floor.icon}></ha-icon>`;const e=l(this.floor);return s.qy`<ha-svg-icon .path=${e}></ha-svg-icon>`}}]}}),s.WF)},1848:(e,i,t)=>{var o=t(5461),s=t(8597),a=t(196),l=t(9760),r=t(5081),d=t(3167),n=t(9263),c=t(8848),h=t(3473),u=t(1378),f=t(3018),_=t(1447),v=t(5845);const m=()=>Promise.all([t.e(7385),t.e(8662)]).then(t.bind(t,8662));t(6442),t(3350),t(6396),t(9484);const k="___ADD_NEW___",y="___NO_FLOORS___",p="___ADD_NEW_SUGGESTION___",g=e=>s.qy`<ha-list-item
    graphic="icon"
    class=${(0,l.H)({"add-new":e.floor_id===k})}
  >
    <ha-floor-icon slot="graphic" .floor=${e}></ha-floor-icon>
    ${e.name}
  </ha-list-item>`;(0,o.A)([(0,a.EM)("ha-floor-picker")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[(0,a.MZ)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,a.MZ)()],key:"label",value:void 0},{kind:"field",decorators:[(0,a.MZ)()],key:"value",value:void 0},{kind:"field",decorators:[(0,a.MZ)()],key:"helper",value:void 0},{kind:"field",decorators:[(0,a.MZ)()],key:"placeholder",value:void 0},{kind:"field",decorators:[(0,a.MZ)({type:Boolean,attribute:"no-add"})],key:"noAdd",value(){return!1}},{kind:"field",decorators:[(0,a.MZ)({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[(0,a.MZ)({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[(0,a.MZ)({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[(0,a.MZ)({type:Array,attribute:"exclude-floor"})],key:"excludeFloors",value:void 0},{kind:"field",decorators:[(0,a.MZ)({attribute:!1})],key:"deviceFilter",value:void 0},{kind:"field",decorators:[(0,a.MZ)({attribute:!1})],key:"entityFilter",value:void 0},{kind:"field",decorators:[(0,a.MZ)({type:Boolean})],key:"disabled",value(){return!1}},{kind:"field",decorators:[(0,a.MZ)({type:Boolean})],key:"required",value(){return!1}},{kind:"field",decorators:[(0,a.wk)()],key:"_opened",value:void 0},{kind:"field",decorators:[(0,a.wk)()],key:"_floors",value:void 0},{kind:"field",decorators:[(0,a.P)("ha-combo-box",!0)],key:"comboBox",value:void 0},{kind:"field",key:"_suggestion",value:void 0},{kind:"field",key:"_init",value(){return!1}},{kind:"method",key:"open",value:async function(){await this.updateComplete,await(this.comboBox?.open())}},{kind:"method",key:"focus",value:async function(){await this.updateComplete,await(this.comboBox?.focus())}},{kind:"method",key:"hassSubscribe",value:function(){return[(0,f.eg)(this.hass.connection,(e=>{this._floors=e}))]}},{kind:"field",key:"_getFloors",value(){return(0,r.A)(((e,i,t,o,s,a,l,r,d,c,h)=>{let _,v,m={};(s||a||l||r||d)&&(m=(0,u.g2)(o),_=t,v=o.filter((e=>e.area_id)),s&&(_=_.filter((e=>{const i=m[e.id];return!(!i||!i.length)&&m[e.id].some((e=>s.includes((0,n.m)(e.entity_id))))})),v=v.filter((e=>s.includes((0,n.m)(e.entity_id))))),a&&(_=_.filter((e=>{const i=m[e.id];return!i||!i.length||o.every((e=>!a.includes((0,n.m)(e.entity_id))))})),v=v.filter((e=>!a.includes((0,n.m)(e.entity_id))))),l&&(_=_.filter((e=>{const i=m[e.id];return!(!i||!i.length)&&m[e.id].some((e=>{const i=this.hass.states[e.entity_id];return!!i&&(i.attributes.device_class&&l.includes(i.attributes.device_class))}))})),v=v.filter((e=>{const i=this.hass.states[e.entity_id];return i.attributes.device_class&&l.includes(i.attributes.device_class)}))),r&&(_=_.filter((e=>r(e)))),d&&(_=_.filter((e=>{const i=m[e.id];return!(!i||!i.length)&&m[e.id].some((e=>{const i=this.hass.states[e.entity_id];return!!i&&d(i)}))})),v=v.filter((e=>{const i=this.hass.states[e.entity_id];return!!i&&d(i)}))));let p,g=e;if(_&&(p=_.filter((e=>e.area_id)).map((e=>e.area_id))),v&&(p=(p??[]).concat(v.filter((e=>e.area_id)).map((e=>e.area_id)))),p){const e=(0,f._o)(i);g=g.filter((i=>e[i.floor_id]?.some((e=>p.includes(e.area_id)))))}return h&&(g=g.filter((e=>!h.includes(e.floor_id)))),g.length||(g=[{floor_id:y,name:this.hass.localize("ui.components.floor-picker.no_floors"),icon:null,level:null,aliases:[],created_at:0,modified_at:0}]),c?g:[...g,{floor_id:k,name:this.hass.localize("ui.components.floor-picker.add_new"),icon:"mdi:plus",level:null,aliases:[],created_at:0,modified_at:0}]}))}},{kind:"method",key:"updated",value:function(e){if(!this._init&&this.hass&&this._floors||this._init&&e.has("_opened")&&this._opened){this._init=!0;const e=this._getFloors(this._floors,Object.values(this.hass.areas),Object.values(this.hass.devices),Object.values(this.hass.entities),this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.noAdd,this.excludeFloors).map((e=>({...e,strings:[e.floor_id,e.name,...e.aliases]})));this.comboBox.items=e,this.comboBox.filteredItems=e}}},{kind:"method",key:"render",value:function(){return s.qy`
      <ha-combo-box
        .hass=${this.hass}
        .helper=${this.helper}
        item-value-path="floor_id"
        item-id-path="floor_id"
        item-label-path="name"
        .value=${this._value}
        .disabled=${this.disabled}
        .required=${this.required}
        .label=${void 0===this.label&&this.hass?this.hass.localize("ui.components.floor-picker.floor"):this.label}
        .placeholder=${this.placeholder?this._floors?.find((e=>e.floor_id===this.placeholder))?.name:void 0}
        .renderer=${g}
        @filter-changed=${this._filterChanged}
        @opened-changed=${this._openedChanged}
        @value-changed=${this._floorChanged}
      >
      </ha-combo-box>
    `}},{kind:"method",key:"_filterChanged",value:function(e){const i=e.target,t=e.detail.value;if(!t)return void(this.comboBox.filteredItems=this.comboBox.items);const o=(0,c.H)(t,i.items?.filter((e=>![y,k].includes(e.label_id)))||[]);0===o.length?this.noAdd?this.comboBox.filteredItems=[{floor_id:y,name:this.hass.localize("ui.components.floor-picker.no_match"),icon:null,level:null,aliases:[],created_at:0,modified_at:0}]:(this._suggestion=t,this.comboBox.filteredItems=[{floor_id:p,name:this.hass.localize("ui.components.floor-picker.add_new_sugestion",{name:this._suggestion}),icon:"mdi:plus",level:null,aliases:[],created_at:0,modified_at:0}]):this.comboBox.filteredItems=o}},{kind:"get",key:"_value",value:function(){return this.value||""}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_floorChanged",value:function(e){e.stopPropagation();let i=e.detail.value;if(i===y)return i="",void this.comboBox.setInputValue("");var t,o;[p,k].includes(i)?(e.target.value=this._value,this.hass.loadFragmentTranslation("config"),t=this,o={suggestedName:i===p?this._suggestion:"",createEntry:async(e,i)=>{try{const t=await(0,f.KD)(this.hass,e);i.forEach((e=>{(0,h.gs)(this.hass,e,{floor_id:t.floor_id})}));const o=[...this._floors,t];this.comboBox.filteredItems=this._getFloors(o,Object.values(this.hass.areas),Object.values(this.hass.devices),Object.values(this.hass.entities),this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.noAdd,this.excludeFloors),await this.updateComplete,await this.comboBox.updateComplete,this._setValue(t.floor_id)}catch(t){(0,_.K$)(this,{title:this.hass.localize("ui.components.floor-picker.failed_create_floor"),text:t.message})}}},(0,d.r)(t,"show-dialog",{dialogTag:"dialog-floor-registry-detail",dialogImport:m,dialogParams:o}),this._suggestion=void 0,this.comboBox.setInputValue("")):i!==this._value&&this._setValue(i)}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{(0,d.r)(this,"value-changed",{value:e}),(0,d.r)(this,"change")}),0)}}]}}),(0,v.E)(s.WF))},3018:(e,i,t)=>{t.d(i,{KD:()=>n,_o:()=>c,eg:()=>d});var o=t(4856),s=t(6412),a=t(1355);t(9812);const l=e=>e.sendMessagePromise({type:"config/floor_registry/list"}).then((e=>e.sort(((e,i)=>e.level!==i.level?(e.level??9999)-(i.level??9999):(0,s.x)(e.name,i.name))))),r=(e,i)=>e.subscribeEvents((0,a.s)((()=>l(e).then((e=>i.setState(e,!0)))),500,!0),"floor_registry_updated"),d=(e,i)=>(0,o.N)("_floorRegistry",l,r,e,i),n=(e,i)=>e.callWS({type:"config/floor_registry/create",...i}),c=e=>{const i={};for(const t of e)t.floor_id&&(t.floor_id in i||(i[t.floor_id]=[]),i[t.floor_id].push(t));return i}}};
//# sourceMappingURL=NO-UUZ0K.js.map