UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

16 lines 23.9 kB
export const __rspack_esm_id=6660;export const __rspack_esm_ids=[6660];export const __webpack_modules__={64481(e,a,t){t.d(a,{D:()=>o,J:()=>s});t(64979);let r=!1;try{r="true"===window.localStorage.getItem("disableViewTransition")}catch{}const o=e=>{r=e},i=e=>{if(!(e=>(e instanceof DOMException||e instanceof Error)&&"AbortError"===e.name)(e))throw e},s=e=>{if(!document.startViewTransition||r)return e(!1),Promise.resolve();let a=!1;try{const t=document.startViewTransition(()=>{a=!0,e(!0)});return t.ready.catch(i),t.finished.catch(i)}catch(t){return console.warn("View transition failed, falling back to direct execution.",t),a?Promise.reject(t):(e(!1),Promise.resolve())}}},93444(e,a,t){var r=t(62826),o=t(5124),i=t(22441);class s extends o.WF{render(){return o.qy` <footer> <slot name="secondaryAction"></slot> <slot name="primaryAction"></slot> </footer> `}static get styles(){return[o.AH`footer{display:flex;gap:var(--ha-space-3);justify-content:flex-end;align-items:center;width:100%}`]}}s=(0,r.Cg)([(0,i.EM)("ha-dialog-footer")],s)},76538(e,a,t){var r=t(62826),o=t(5124),i=t(22441);class s extends o.WF{render(){const e=o.qy`<div class="header-title"> <slot name="title"></slot> </div>`,a=o.qy`<div class="header-subtitle"> <slot name="subtitle"></slot> </div>`;return o.qy` <header class="header"> <div class="header-bar"> <section class="header-navigation-icon"> <slot name="navigationIcon"></slot> </section> <section class="header-content"> ${"above"===this.subtitlePosition?o.qy`${a}${e}`:o.qy`${e}${a}`} </section> <section class="header-action-items"> <slot name="actionItems"></slot> </section> </div> <slot></slot> </header> `}static get styles(){return[o.AH`:host{display:block}:host([show-border]){border-bottom:1px solid var(--mdc-dialog-scroll-divider-color,rgba(0,0,0,.12))}.header-bar{display:flex;flex-direction:row;align-items:center;padding:0 var(--ha-space-1);box-sizing:border-box}.header-content{flex:1;padding:10px var(--ha-space-1);display:flex;flex-direction:column;justify-content:center;min-height:var(--ha-space-12);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.header-title{height:var(--ha-dialog-header-title-height,calc(var(--ha-font-size-xl) + var(--ha-space-1)));font-size:var(--ha-font-size-xl);line-height:var(--ha-line-height-condensed);font-weight:var(--ha-font-weight-medium);color:var(--ha-dialog-header-title-color,var(--primary-text-color))}.header-subtitle{font-size:var(--ha-font-size-m);line-height:var(--ha-line-height-normal);color:var(--ha-dialog-header-subtitle-color,var(--secondary-text-color))}@media all and (min-width:450px) and (min-height:500px){.header-bar{padding:0 var(--ha-space-2)}}.header-navigation-icon{flex:none;min-width:var(--ha-space-2);height:100%;display:flex;flex-direction:row}.header-action-items{flex:none;min-width:var(--ha-space-2);height:100%;display:flex;flex-direction:row}`]}constructor(...e){super(...e),this.subtitlePosition="below",this.showBorder=!1}}(0,r.Cg)([(0,i.MZ)({type:String,attribute:"subtitle-position"})],s.prototype,"subtitlePosition",void 0),(0,r.Cg)([(0,i.MZ)({type:Boolean,reflect:!0,attribute:"show-border"})],s.prototype,"showBorder",void 0),s=(0,r.Cg)([(0,i.EM)("ha-dialog-header")],s)},72554(e,a,t){t.a(e,async function(e,a){try{var r=t(62826),o=t(93900),i=t(35211),s=t(5124),l=t(22441),d=t(63672),n=t(1087),h=t(64481),c=t(22792),p=t(59992),g=t(14503),u=t(22348),v=(t(76538),t(26300)),f=e([o,v]);[o,v]=f.then?(await f)():f;const m="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";class b extends((0,p.V)(s.WF)){connectedCallback(){super.connectedCallback(),this.addEventListener("dialog-set-fullscreen",this._handleFullscreenChanged)}get scrollableElement(){return this.bodyContainer}updated(e){super.updated(e),e.has("open")&&(this._open=this.open)}render(){return s.qy` <wa-dialog .open="${this._open}" .lightDismiss="${!this.preventScrimClose}" without-header aria-labelledby="${(0,d.J)(this.ariaLabelledBy||(void 0!==this.headerTitle?"ha-dialog-title":void 0))}" aria-describedby="${(0,d.J)(this.ariaDescribedBy)}" @keydown="${this._handleKeyDown}" @wa-hide="${this._handleHide}" @wa-show="${this._handleShow}" @wa-after-show="${this._handleAfterShow}" @wa-after-hide="${this._handleAfterHide}"> ${this.withoutHeader?s.s6:s.qy`<slot name="header"> <ha-dialog-header .subtitlePosition="${this.headerSubtitlePosition}" .showBorder="${this._bodyScrolled}"> <slot name="headerNavigationIcon" slot="navigationIcon"> <ha-icon-button data-dialog="close" .label="${this._i18n?.localize?.("ui.common.close")??"Close"}" .path="${m}"></ha-icon-button> </slot> ${void 0!==this.headerTitle?s.qy`<span slot="title" class="title" id="ha-dialog-title"> ${this.headerTitle} </span>`:s.qy`<slot name="headerTitle" slot="title"></slot>`} ${void 0!==this.headerSubtitle?s.qy`<span slot="subtitle">${this.headerSubtitle}</span>`:s.qy`<slot name="headerSubtitle" slot="subtitle"></slot>`} <slot name="headerActionItems" slot="actionItems"></slot> </ha-dialog-header> </slot>`} <div class="content-wrapper"> <div class="body ha-scrollbar" @scroll="${this._handleBodyScroll}"> <slot></slot> </div> ${this.renderScrollableFades()} </div> <slot name="footer" slot="footer"></slot> </wa-dialog> `}disconnectedCallback(){this.removeEventListener("dialog-set-fullscreen",this._handleFullscreenChanged),this._setFullscreen(!1),super.disconnectedCallback(),this._open=!1}_handleFullscreenChanged(e){this._open?(0,h.J)(()=>{this._setFullscreen(e.detail)}):this._setFullscreen(e.detail)}_setFullscreen(e){this.toggleAttribute("fullscreen",e)}_handleBodyScroll(e){this._bodyScrolled=e.target.scrollTop>0}_handleKeyDown(e){"Escape"===e.key&&(this._escapePressed=!0,this.preventScrimClose&&e.preventDefault(),e.stopPropagation(),e.currentTarget.open=!1)}_handleHide(e){const a=e.detail?.source===e.target.dialog;this.preventScrimClose&&this._escapePressed&&a&&e.preventDefault(),this._escapePressed=!1}static get styles(){return[...super.styles,g.dp,s.AH`wa-dialog{--full-width:var( --ha-dialog-width-full, min(95vw, var(--safe-width)) );--width:min(var(--ha-dialog-width-md, 580px), var(--full-width));--spacing:var(--dialog-content-padding, var(--ha-space-6));--show-duration:var(--ha-dialog-show-duration, 200ms);--hide-duration:var(--ha-dialog-hide-duration, 200ms);--wa-color-surface-raised:var( --ha-dialog-surface-background, var(--card-background-color, var(--ha-color-surface-default)) );--wa-panel-border-radius:var( --ha-dialog-border-radius, var(--ha-border-radius-3xl) );max-width:var(--ha-dialog-max-width,var(--safe-width))}@media (prefers-reduced-motion:reduce){wa-dialog{--show-duration:0ms;--hide-duration:0ms}}:host([width=small]) wa-dialog{--width:min(var(--ha-dialog-width-sm, 320px), var(--full-width))}:host([width=large]) wa-dialog{--width:min(var(--ha-dialog-width-lg, 1024px), var(--full-width))}:host([fullscreen]) wa-dialog,:host([width=full]) wa-dialog{--width:var(--full-width)}:host([fullscreen]) wa-dialog::part(dialog){min-height:var(--safe-height);max-height:var(--safe-height);margin-top:0;transform:none}:host([fullscreen]) .content-wrapper{overflow:hidden}:host([fullscreen]) .body{overflow:hidden;padding:0}wa-dialog::part(dialog){-webkit-backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);box-shadow:var(--dialog-box-shadow,var(--wa-shadow-l));color:var(--primary-text-color);min-width:var(--width,var(--full-width));max-width:var(--width,var(--full-width));max-height:var(--ha-dialog-max-height,calc(var(--safe-height) - var(--ha-space-20)));min-height:var(--ha-dialog-min-height);margin-top:var(--dialog-surface-margin-top,auto);transform:translate(calc(var(--safe-area-offset-left,0px) - var(--safe-area-offset-right,0px)),calc(var(--safe-area-offset-top,0px) - var(--safe-area-offset-bottom,0px)));display:flex;flex-direction:column;overflow:hidden}wa-dialog::part(dialog)::backdrop{-webkit-backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));background-color:var(--mdc-dialog-scrim-color,none)}@media all and (max-width:450px),all and (max-height:500px){:host([type=standard]){--ha-dialog-border-radius:0}:host([type=standard]) wa-dialog{--full-width:var(--ha-dialog-width-full, 100vw);--width:var(--full-width)}:host([type=standard]) wa-dialog::part(dialog){min-height:var(--ha-dialog-min-height,100vh);min-height:var(--ha-dialog-min-height,100dvh);max-height:var(--ha-dialog-max-height,100vh);max-height:var(--ha-dialog-max-height,100dvh);margin-top:0;margin-bottom:0;padding-top:var(--safe-area-inset-top);padding-bottom:var(--safe-area-inset-bottom);padding-left:var(--safe-area-inset-left);padding-right:var(--safe-area-inset-right);transform:none}}.header-title-container{display:flex;align-items:center}.header-title{margin:0;margin-bottom:0;color:var(--ha-dialog-header-title-color,var(--primary-text-color));font-size:var( --ha-dialog-header-title-font-size, var(--ha-font-size-2xl) );line-height:var( --ha-dialog-header-title-line-height, var(--ha-line-height-condensed) );font-weight:var(--ha-dialog-header-title-font-weight,var(--ha-font-weight-normal));overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-right:var(--ha-space-3)}wa-dialog::part(body){padding:0;display:flex;flex-direction:column;max-width:100%;overflow:hidden}.content-wrapper{position:relative;flex:1;display:flex;flex-direction:column;min-height:0}.body{position:var(--dialog-content-position,relative);padding:var(--dialog-content-padding,0 var(--ha-space-6) var(--ha-space-6) var(--ha-space-6));overflow:auto;flex-grow:1}:host([flexcontent]) .body{max-width:100%;flex:1;display:flex;flex-direction:column}wa-dialog::part(footer){padding:0}::slotted([slot=footer]){display:flex;padding:var(--ha-space-3) var(--ha-space-4) var(--ha-space-4) var(--ha-space-4);gap:var(--ha-space-3);justify-content:flex-end;align-items:center;width:100%}`]}constructor(...e){super(...e),this.open=!1,this.type="standard",this.width="medium",this.preventScrimClose=!1,this.headerSubtitlePosition="below",this.flexContent=!1,this.withoutHeader=!1,this._open=!1,this._bodyScrolled=!1,this._escapePressed=!1,this._handleShow=async e=>{e.eventPhase===Event.AT_TARGET&&(this._open=!0,(0,n.r)(this,"opened"),await this.updateComplete,requestAnimationFrame(()=>{if(this._hassConfig?.auth.external&&(0,u.V)(this._hassConfig.auth.external)){const e=this.querySelector("[autofocus]");return void(null!==e&&(e.id||(e.id="ha-dialog-autofocus"),this._hassConfig.auth.external.fireMessage({type:"focus_element",payload:{element_id:e.id}})))}this.querySelector("[autofocus]")?.focus()}))},this._handleAfterShow=e=>{e.eventPhase===Event.AT_TARGET&&(0,n.r)(this,"after-show")},this._handleAfterHide=e=>{e.eventPhase===Event.AT_TARGET&&(this._open=!1,this._setFullscreen(!1),(0,n.r)(this,"closed"))}}}(0,r.Cg)([(0,l.MZ)({attribute:"aria-labelledby"})],b.prototype,"ariaLabelledBy",void 0),(0,r.Cg)([(0,l.MZ)({attribute:"aria-describedby"})],b.prototype,"ariaDescribedBy",void 0),(0,r.Cg)([(0,l.MZ)({type:Boolean,reflect:!0})],b.prototype,"open",void 0),(0,r.Cg)([(0,l.MZ)({reflect:!0})],b.prototype,"type",void 0),(0,r.Cg)([(0,l.MZ)({type:String,reflect:!0,attribute:"width"})],b.prototype,"width",void 0),(0,r.Cg)([(0,l.MZ)({type:Boolean,reflect:!0,attribute:"prevent-scrim-close"})],b.prototype,"preventScrimClose",void 0),(0,r.Cg)([(0,l.MZ)({attribute:"header-title"})],b.prototype,"headerTitle",void 0),(0,r.Cg)([(0,l.MZ)({attribute:"header-subtitle"})],b.prototype,"headerSubtitle",void 0),(0,r.Cg)([(0,l.MZ)({type:String,attribute:"header-subtitle-position"})],b.prototype,"headerSubtitlePosition",void 0),(0,r.Cg)([(0,l.MZ)({type:Boolean,reflect:!0,attribute:"flexcontent"})],b.prototype,"flexContent",void 0),(0,r.Cg)([(0,l.MZ)({type:Boolean,attribute:"without-header"})],b.prototype,"withoutHeader",void 0),(0,r.Cg)([(0,l.wk)()],b.prototype,"_open",void 0),(0,r.Cg)([(0,l.P)(".body")],b.prototype,"bodyContainer",void 0),(0,r.Cg)([(0,l.wk)(),(0,i.Fg)({context:c.D5,subscribe:!0})],b.prototype,"_i18n",void 0),(0,r.Cg)([(0,l.wk)(),(0,i.Fg)({context:c.WF,subscribe:!0})],b.prototype,"_hassConfig",void 0),(0,r.Cg)([(0,l.wk)()],b.prototype,"_bodyScrolled",void 0),(0,r.Cg)([(0,l.Ls)({passive:!0})],b.prototype,"_handleBodyScroll",null),b=(0,r.Cg)([(0,l.EM)("ha-dialog")],b),a()}catch(e){a(e)}})},2846(e,a,t){t.d(a,{G:()=>n,J:()=>d});var r=t(62826),o=t(58168),i=t(82553),s=t(5124),l=t(22441);t(54276);const d=[i.R,s.AH`:host{--ha-icon-display:block;--md-sys-color-primary:var(--primary-text-color);--md-sys-color-secondary:var(--secondary-text-color);--md-sys-color-surface:var(--card-background-color);--md-sys-color-on-surface:var(--primary-text-color);--md-sys-color-on-surface-variant:var(--secondary-text-color)}md-item{overflow:var(--md-item-overflow,hidden);align-items:var(--md-item-align-items,center);gap:var(--ha-md-list-item-gap,16px)}`];class n extends o.n{renderRipple(){return"text"===this.type?s.s6:s.qy`<ha-ripple part="ripple" for="item" ?disabled="${this.disabled&&"link"!==this.type}"></ha-ripple>`}}n.styles=d,n=(0,r.Cg)([(0,l.EM)("ha-md-list-item")],n)},17308(e,a,t){var r=t(62826),o=t(49838),i=t(11245),s=t(5124),l=t(22441);class d extends o.B{}d.styles=[i.R,s.AH`:host{--md-sys-color-surface:var(--card-background-color)}`],d=(0,r.Cg)([(0,l.EM)("ha-md-list")],d)},59992(e,a,t){t.d(a,{V:()=>d});var r=t(62826),o=t(88696),i=t(5124),s=t(6412),l=t(22441);const d=e=>{class a extends e{get scrollableElement(){return a.DEFAULT_SCROLLABLE_ELEMENT}firstUpdated(e){super.firstUpdated?.(e),this.scrollableElement&&this._updateScrollableState(this.scrollableElement),this._attachScrollableElement()}updated(e){super.updated?.(e),this._attachScrollableElement()}disconnectedCallback(){this._detachScrollableElement(),this._contentScrolled=!1,this._contentScrollable=!1,super.disconnectedCallback()}renderScrollableFades(e=!1){return i.qy` <div class="${(0,s.H)({"fade-top":!0,rounded:e,visible:this._contentScrolled})}"></div> <div class="${(0,s.H)({"fade-bottom":!0,rounded:e,visible:this._contentScrollable})}"></div> `}static get styles(){const e=Object.getPrototypeOf(this);var a;return[...void 0===(a=e?.styles??[])?[]:Array.isArray(a)?a:[a],i.AH`.fade-bottom,.fade-top{position:absolute;left:0;right:0;height:var(--ha-space-2);pointer-events:none;transition:opacity 180ms ease-in-out;border-radius:var(--ha-border-radius-square);opacity:0;background:linear-gradient(to bottom,var(--ha-color-shadow-scrollable-fade),transparent)}.fade-top{top:0}.fade-bottom{bottom:0;transform:rotate(180deg)}.fade-bottom.visible,.fade-top.visible{opacity:1}.fade-bottom.rounded,.fade-top.rounded{border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg));border-bottom-left-radius:var(--ha-border-radius-square);border-bottom-right-radius:var(--ha-border-radius-square)}.fade-top.rounded{border-top-left-radius:var(--ha-border-radius-square);border-top-right-radius:var(--ha-border-radius-square)}.fade-bottom.rounded{border-bottom-left-radius:var(--ha-border-radius-square);border-bottom-right-radius:var(--ha-border-radius-square)}`]}_attachScrollableElement(){const e=this.scrollableElement;e!==this._scrollTarget&&(this._detachScrollableElement(),e&&(this._scrollTarget=e,e.addEventListener("scroll",this._onScroll,{passive:!0}),this._resize.observe(e),this._updateScrollableState(e)))}_detachScrollableElement(){this._scrollTarget&&(this._scrollTarget.removeEventListener("scroll",this._onScroll),this._resize.unobserve?.(this._scrollTarget),this._scrollTarget=void 0)}_updateScrollableState(e){const a=parseFloat(getComputedStyle(e).getPropertyValue("--safe-area-inset-bottom"))||0,{scrollHeight:t=0,clientHeight:r=0,scrollTop:o=0}=e;this._contentScrollable=t-r>o+a+this.scrollFadeSafeAreaPadding}constructor(...e){super(...e),this._contentScrolled=!1,this._contentScrollable=!1,this._onScroll=e=>{const a=e.currentTarget;this._contentScrolled=(a.scrollTop??0)>this.scrollFadeThreshold,this._updateScrollableState(a)},this._resize=new o.P(this,{target:null,callback:e=>{const a=e[0]?.target;a&&this._updateScrollableState(a)}}),this.scrollFadeSafeAreaPadding=4,this.scrollFadeThreshold=4}}return a.DEFAULT_SCROLLABLE_ELEMENT=null,(0,r.Cg)([(0,l.wk)()],a.prototype,"_contentScrolled",void 0),(0,r.Cg)([(0,l.wk)()],a.prototype,"_contentScrollable",void 0),a}},54607(e,a,t){t.a(e,async function(e,r){try{t.r(a);t(44114),t(18111),t(22489),t(61701);var o=t(62826),i=t(5124),s=t(22441),l=t(75751),d=t(66639),n=t(1087),h=t(18350),c=(t(93444),t(18198),t(47680),t(17308),t(2846),t(85938),t(67094),t(72554)),p=t(2514),g=t(32250),u=t(14503),v=t(81619),f=e([h,c]);[h,c]=f.then?(await f)():f;const m="M21 11H3V9H21V11M21 13H3V15H21V13Z",b="M20 2H4C2.9 2 2 2.9 2 4V20C2 21.11 2.9 22 4 22H20C21.11 22 22 21.11 22 20V4C22 2.9 21.11 2 20 2M4 6L6 4H10.9L4 10.9V6M4 13.7L13.7 4H18.6L4 18.6V13.7M20 18L18 20H13.1L20 13.1V18M20 10.3L10.3 20H5.4L20 5.4V10.3Z",y="__unassigned__";class _ extends i.WF{async showDialog(e){this._open=!0,this._computeHierarchy()}_computeHierarchy(){this._hierarchy=(0,d.cs)(Object.values(this.hass.floors),Object.values(this.hass.areas))}closeDialog(){this._saving=!1,this._open=!1}_dialogClosed(){this._open=!1,this._hierarchy=void 0,this._saving=!1,(0,n.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._hierarchy)return i.s6;const e=this._hierarchy.floors.length>0,a=this.hass.localize(e?"ui.panel.config.areas.dialog.reorder_floors_areas_title":"ui.panel.config.areas.dialog.reorder_areas_title");return i.qy` <ha-dialog .open="${this._open}" header-title="${a}" @closed="${this._dialogClosed}"> <div class="content"> <ha-sortable handle-selector=".floor-handle" draggable-selector=".floor" @item-moved="${this._floorMoved}" invert-swap> <div class="floors"> ${(0,l.u)(this._hierarchy.floors,e=>e.id,e=>this._renderFloor(e))} </div> </ha-sortable> ${this._renderUnassignedAreas()} </div> <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" @click="${this.closeDialog}" appearance="plain"> ${this.hass.localize("ui.common.cancel")} </ha-button> <ha-button slot="primaryAction" @click="${this._save}" .disabled="${this._saving}"> ${this.hass.localize("ui.common.save")} </ha-button> </ha-dialog-footer> </ha-dialog> `}_renderFloor(e){const a=this.hass.floors[e.id];return a?i.qy` <div class="floor"> <div class="floor-header"> <ha-floor-icon .floor="${a}"></ha-floor-icon> <span class="floor-name">${a.name}</span> <ha-svg-icon class="floor-handle" .path="${m}"></ha-svg-icon> </div> <ha-sortable handle-selector=".area-handle" draggable-selector="ha-md-list-item" @item-moved="${this._areaMoved}" @item-added="${this._areaAdded}" group="areas" .floor="${e.id}"> <ha-md-list> ${e.areas.length>0?e.areas.map(e=>this._renderArea(e)):i.qy`<p class="empty"> ${this.hass.localize("ui.panel.config.areas.dialog.empty_floor")} </p>`} </ha-md-list> </ha-sortable> </div> `:i.s6}_renderUnassignedAreas(){const e=this._hierarchy.floors.length>0;return i.qy` <div class="floor unassigned"> ${e?i.qy`<div class="floor-header"> <span class="floor-name"> ${this.hass.localize("ui.panel.config.areas.dialog.other_areas")} </span> </div>`:i.s6} <ha-sortable handle-selector=".area-handle" draggable-selector="ha-md-list-item" @item-moved="${this._areaMoved}" @item-added="${this._areaAdded}" group="areas" .floor="${y}"> <ha-md-list> ${this._hierarchy.areas.length>0?this._hierarchy.areas.map(e=>this._renderArea(e)):i.qy`<p class="empty"> ${this.hass.localize("ui.panel.config.areas.dialog.empty_unassigned")} </p>`} </ha-md-list> </ha-sortable> </div> `}_renderArea(e){const a=this.hass.areas[e];return a?i.qy` <ha-md-list-item .sortableData="${a}"> ${a.icon?i.qy`<ha-icon slot="start" .icon="${a.icon}"></ha-icon>`:i.qy`<ha-svg-icon slot="start" .path="${b}"></ha-svg-icon>`} <span slot="headline">${a.name}</span> <ha-svg-icon class="area-handle" slot="end" .path="${m}"></ha-svg-icon> </ha-md-list-item> `:i.s6}_floorMoved(e){if(e.stopPropagation(),!this._hierarchy)return;const{oldIndex:a,newIndex:t}=e.detail,r=[...this._hierarchy.floors],[o]=r.splice(a,1);r.splice(t,0,o),this._hierarchy={...this._hierarchy,floors:r}}_areaMoved(e){if(e.stopPropagation(),!this._hierarchy)return;const{floor:a}=e.currentTarget,{oldIndex:t,newIndex:r}=e.detail,o=a===y?null:a;if(null===o){const e=[...this._hierarchy.areas],[a]=e.splice(t,1);e.splice(r,0,a),this._hierarchy={...this._hierarchy,areas:e}}else this._hierarchy={...this._hierarchy,floors:this._hierarchy.floors.map(e=>{if(e.id===o){const a=[...e.areas],[o]=a.splice(t,1);return a.splice(r,0,o),{...e,areas:a}}return e})}}_areaAdded(e){if(e.stopPropagation(),!this._hierarchy)return;const{floor:a}=e.currentTarget,{data:t,index:r}=e.detail,o=a===y?null:a,i=this._hierarchy.areas.filter(e=>e!==t.area_id);null===o&&i.splice(r,0,t.area_id),this._hierarchy={...this._hierarchy,floors:this._hierarchy.floors.map(e=>{if(e.id===o){const a=[...e.areas];return a.splice(r,0,t.area_id),{...e,areas:a}}return{...e,areas:e.areas.filter(e=>e!==t.area_id)}}),areas:i}}_computeFloorChanges(){if(!this._hierarchy)return[];const e=[];for(const a of this._hierarchy.floors)for(const t of a.areas){const r=this.hass.areas[t]?.floor_id??null;a.id!==r&&e.push({areaId:t,floorId:a.id})}for(const a of this._hierarchy.areas){null!==(this.hass.areas[a]?.floor_id??null)&&e.push({areaId:a,floorId:null})}return e}async _save(){if(this._hierarchy&&!this._saving){this._saving=!0;try{const e=(0,d.Xz)(this._hierarchy),a=(0,d.Vu)(this._hierarchy),t=this._computeFloorChanges().map(({areaId:e,floorId:a})=>(0,p.gs)(this.hass,e,{floor_id:a}));await Promise.all(t),await(0,p.WT)(this.hass,e),await(0,g.Rj)(this.hass,a),this.closeDialog()}catch(e){(0,v.P)(this,{message:e.message||this.hass.localize("ui.panel.config.areas.dialog.reorder_failed")}),this._saving=!1}}}static get styles(){return[u.RF,u.nA,i.AH`ha-dialog{max-height:90%;--dialog-content-padding:var(--ha-space-2) var(--ha-space-6)}@media all and (max-width:580px),all and (max-height:500px){ha-dialog{min-width:100%;min-height:100%}}.floors{display:flex;flex-direction:column;gap:16px}.floor{border:1px solid var(--divider-color);border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg));overflow:hidden}.floor.unassigned{margin-top:16px}.floor-header{display:flex;align-items:center;padding:12px 16px;background-color:var(--secondary-background-color);gap:12px}.floor-name{flex:1;font-weight:var(--ha-font-weight-medium)}.floor-handle{cursor:grab;color:var(--secondary-text-color)}ha-md-list{padding:0;--md-list-item-leading-space:16px;--md-list-item-trailing-space:16px;display:flex;flex-direction:column}ha-md-list-item{--md-list-item-one-line-container-height:48px;--md-list-item-container-shape:0}ha-md-list-item.sortable-ghost{border-radius:calc(var(--ha-card-border-radius,var(--ha-border-radius-lg)) - 1px);box-shadow:inset 0 0 0 2px var(--primary-color)}.area-handle{cursor:grab;color:var(--secondary-text-color)}.empty{text-align:center;color:var(--secondary-text-color);font-style:italic;margin:0;padding:12px 16px;order:1}ha-md-list:has(ha-md-list-item) .empty{display:none}.content{padding-top:16px;padding-bottom:16px}`]}constructor(...e){super(...e),this._open=!1,this._saving=!1}}(0,o.Cg)([(0,s.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,o.Cg)([(0,s.wk)()],_.prototype,"_open",void 0),(0,o.Cg)([(0,s.wk)()],_.prototype,"_hierarchy",void 0),(0,o.Cg)([(0,s.wk)()],_.prototype,"_saving",void 0),_=(0,o.Cg)([(0,s.EM)("dialog-areas-floors-order")],_),r()}catch(e){r(e)}})},22348(e,a,t){t.d(a,{V:()=>o});var r=t(37177);const o=e=>!!e&&r.n},37177(e,a,t){t.d(a,{n:()=>r});const r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}};