iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
37 lines • 28.3 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[80957],{30716:function(e,t,a){a(3362),a(62953);var i=a(40445),o=a(72274),r=a(34875),s=a(7731),l=a(5124),n=a(67576),d=a(1087);const h=e=>e.preventDefault();var c=a(57237);a(9503);let p,g,u=e=>e;class m extends o.h{async onChange(e){e.stopPropagation(),super.onChange(e),(0,d.r)(this,e.type)}render(){const e=this.renderText(),t=this.graphic&&"control"!==this.graphic&&!this.left?this.renderGraphic():l.s6,a=this.hasMeta&&this.left?this.renderMeta():l.s6,i=this.renderRipple();return(0,l.qy)(p||(p=u` ${0} ${0} ${0} <ha-checkbox tabindex="${0}" .checked="${0}" .indeterminate="${0}" ?disabled="${0}" ="${0}" ="${0}" class="${0}"> </ha-checkbox> ${0} ${0}`),i,t,this.left?"":e,this.separateCheckboxClick?this.tabindex:-1,this.selected,this.indeterminate,this.disabled||this.checkboxDisabled,this.onChange,this.separateCheckboxClick?c.d:h,this.left?"left":"",this.left?e:"",a)}constructor(...e){super(...e),this.checkboxDisabled=!1,this.indeterminate=!1,this.separateCheckboxClick=!1}}m.styles=[s.R,r.R,(0,l.AH)(g||(g=u`:host{--mdc-theme-secondary:var(--primary-color)}:host([graphic=avatar]) .mdc-deprecated-list-item__graphic,:host([graphic=control]) .mdc-deprecated-list-item__graphic,:host([graphic=large]) .mdc-deprecated-list-item__graphic,:host([graphic=medium]) .mdc-deprecated-list-item__graphic{margin-inline-end:var(--mdc-list-item-graphic-margin,16px);margin-inline-start:0px;direction:var(--direction)}ha-checkbox{flex-shrink:0;direction:var(--direction);margin-inline-start:auto;margin-inline-end:0;height:100%;justify-content:center}ha-checkbox.left{margin-inline-start:0}.mdc-deprecated-list-item__graphic{margin-top:var(--check-list-item-graphic-margin-top)}:host([graphic=icon]) .mdc-deprecated-list-item__graphic{margin-inline-start:0;margin-inline-end:var(--mdc-list-item-graphic-margin,32px)}`))],(0,i.Cg)([(0,n.MZ)({type:Boolean,attribute:"checkbox-disabled"})],m.prototype,"checkboxDisabled",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean})],m.prototype,"indeterminate",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean,attribute:"separate-checkbox-click"})],m.prototype,"separateCheckboxClick",void 0),m=(0,i.Cg)([(0,n.EM)("ha-check-list-item")],m)},9503:function(e,t,a){var i=a(40445),o=a(97577),r=a(5124),s=a(67576);let l,n=e=>e;class d extends o.A{get value(){var e;return null!==(e=this._value)&&void 0!==e?e:null}set value(e){this._value=e}static get styles(){return[o.A.styles,(0,r.AH)(l||(l=n`:host{--wa-form-control-toggle-size:var(--ha-checkbox-size, 20px);--wa-form-control-border-color:var(
--ha-checkbox-border-color,
var(--ha-color-border-neutral-normal)
);--wa-form-control-background-color:var(
--ha-checkbox-background-color,
var(--wa-form-control-background-color)
);--checked-icon-color:var(
--ha-checkbox-checked-icon-color,
var(--wa-color-brand-on-loud)
);--wa-form-control-activated-color:var(
--ha-checkbox-checked-background-color,
var(--ha-color-fill-primary-loud-resting)
);-webkit-tap-highlight-color:transparent;--checked-icon-scale:var(--ha-checkbox-checked-icon-scale, 0.9);--wa-form-control-required-content:var(
--ha-checkbox-required-marker,
var(--ha-input-required-marker, "*")
);--wa-form-control-required-content-offset:var(
--ha-checkbox-required-marker-offset,
0.1rem
)}[part~=base]{align-items:center;gap:var(--ha-space-2)}[part~=control]{border-radius:var(--ha-checkbox-border-radius,var(--ha-border-radius-sm));border-width:var(--ha-checkbox-border-width,var(--ha-border-width-md));margin-inline-end:0}[part~=label]{line-height:1}#hint{font-size:var(--ha-font-size-xs);color:var(--ha-color-text-secondary)}label:has(input:not(:disabled)):hover{--wa-form-control-border-color:var(
--ha-checkbox-border-color-hover,
var(--ha-checkbox-border-color, var(--ha-color-border-neutral-loud))
)}label:has(input:not(:disabled)):hover [part~=control]{background-color:var(--ha-checkbox-background-color-hover,var(--ha-color-form-background-hover))}label:has(input:checked:not(:disabled)):hover [part~=control],label:has(input:indeterminate:not(:disabled)):hover [part~=control]{background-color:var(--ha-checkbox-checked-background-color-hover,var(--ha-color-fill-primary-loud-hover));border-color:var(--ha-checkbox-checked-background-color-hover,var(--ha-color-fill-primary-loud-hover))}`))]}}d=(0,i.Cg)([(0,s.EM)("ha-checkbox")],d)},93444:function(e,t,a){var i=a(40445),o=a(5124),r=a(67576);let s,l,n=e=>e;class d extends o.WF{render(){return(0,o.qy)(s||(s=n` <footer> <slot name="secondaryAction"></slot> <slot name="primaryAction"></slot> </footer> `))}static get styles(){return[(0,o.AH)(l||(l=n`footer{display:flex;gap:var(--ha-space-3);justify-content:flex-end;align-items:center;width:100%}`))]}}d=(0,i.Cg)([(0,r.EM)("ha-dialog-footer")],d)},76538:function(e,t,a){a(62953);var i=a(40445),o=a(5124),r=a(67576);let s,l,n,d,h,c,p=e=>e;class g extends o.WF{render(){const e=(0,o.qy)(s||(s=p`<div class="header-title"> <slot name="title"></slot> </div>`)),t=(0,o.qy)(l||(l=p`<div class="header-subtitle"> <slot name="subtitle"></slot> </div>`));return(0,o.qy)(n||(n=p` <header class="header"> <div class="header-bar"> <section class="header-navigation-icon"> <slot name="navigationIcon"></slot> </section> <section class="header-content"> ${0} </section> <section class="header-action-items"> <slot name="actionItems"></slot> </section> </div> <slot></slot> </header> `),"above"===this.subtitlePosition?(0,o.qy)(d||(d=p`${0}${0}`),t,e):(0,o.qy)(h||(h=p`${0}${0}`),e,t))}static get styles(){return[(0,o.AH)(c||(c=p`: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))} 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,i.Cg)([(0,r.MZ)({type:String,attribute:"subtitle-position"})],g.prototype,"subtitlePosition",void 0),(0,i.Cg)([(0,r.MZ)({type:Boolean,reflect:!0,attribute:"show-border"})],g.prototype,"showBorder",void 0),g=(0,i.Cg)([(0,r.EM)("ha-dialog-header")],g)},72554:function(e,t,a){a.a(e,async function(e,t){try{a(3362),a(62953),a(49255);var i=a(40445),o=a(93900),r=a(35211),s=a(5124),l=a(67576),n=a(63672),d=a(1087),h=a(64481),c=a(22792),p=a(59992),g=a(14503),u=a(22348),m=(a(76538),a(26300)),v=e([o,m,p]);[o,m,p]=v.then?(await v)():v;let f,b,_,w,y,x,k,C=e=>e;const $="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 A 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(){var e,t,a;return(0,s.qy)(f||(f=C` <wa-dialog .open="${0}" .lightDismiss="${0}" without-header aria-labelledby="${0}" aria-describedby="${0}" ="${0}" -hide="${0}" -show="${0}" -after-show="${0}" -after-hide="${0}"> ${0} <div class="content-wrapper"> <div class="body ha-scrollbar" ="${0}"> <slot></slot> </div> ${0} </div> <slot name="footer" slot="footer"></slot> </wa-dialog> `),this._open,!this.preventScrimClose,(0,n.J)(this.ariaLabelledBy||(void 0!==this.headerTitle?"ha-dialog-title":void 0)),(0,n.J)(this.ariaDescribedBy),this._handleKeyDown,this._handleHide,this._handleShow,this._handleAfterShow,this._handleAfterHide,this.withoutHeader?s.s6:(0,s.qy)(b||(b=C`<slot name="header"> <ha-dialog-header .subtitlePosition="${0}" .showBorder="${0}"> <slot name="headerNavigationIcon" slot="navigationIcon"> <ha-icon-button data-dialog="close" .label="${0}" .path="${0}"></ha-icon-button> </slot> ${0} ${0} <slot name="headerActionItems" slot="actionItems"></slot> </ha-dialog-header> </slot>`),this.headerSubtitlePosition,this._bodyScrolled,null!==(e=null===(t=this._i18n)||void 0===t||null===(a=t.localize)||void 0===a?void 0:a.call(t,"ui.common.close"))&&void 0!==e?e:"Close",$,void 0!==this.headerTitle?(0,s.qy)(_||(_=C`<span slot="title" class="title" id="ha-dialog-title"> ${0} </span>`),this.headerTitle):(0,s.qy)(w||(w=C`<slot name="headerTitle" slot="title"></slot>`)),void 0!==this.headerSubtitle?(0,s.qy)(y||(y=C`<span slot="subtitle">${0}</span>`),this.headerSubtitle):(0,s.qy)(x||(x=C`<slot name="headerSubtitle" slot="subtitle"></slot>`))),this._handleBodyScroll,this.renderScrollableFades())}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){var t;const a=(null===(t=e.detail)||void 0===t?void 0:t.source)===e.target.dialog;this.preventScrimClose&&this._escapePressed&&a&&e.preventDefault(),this._escapePressed=!1}static get styles(){return[...super.styles,g.dp,(0,s.AH)(k||(k=C`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))} (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)} 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,d.r)(this,"opened"),await this.updateComplete,requestAnimationFrame(()=>{var e,t;if(null!==(e=this._hassConfig)&&void 0!==e&&e.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}})))}null===(t=this.querySelector("[autofocus]"))||void 0===t||t.focus()}))},this._handleAfterShow=e=>{e.eventPhase===Event.AT_TARGET&&(0,d.r)(this,"after-show")},this._handleAfterHide=e=>{e.eventPhase===Event.AT_TARGET&&(this._open=!1,this._setFullscreen(!1),(0,d.r)(this,"closed"))}}}(0,i.Cg)([(0,l.MZ)({attribute:"aria-labelledby"})],A.prototype,"ariaLabelledBy",void 0),(0,i.Cg)([(0,l.MZ)({attribute:"aria-describedby"})],A.prototype,"ariaDescribedBy",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,reflect:!0})],A.prototype,"open",void 0),(0,i.Cg)([(0,l.MZ)({reflect:!0})],A.prototype,"type",void 0),(0,i.Cg)([(0,l.MZ)({type:String,reflect:!0,attribute:"width"})],A.prototype,"width",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,reflect:!0,attribute:"prevent-scrim-close"})],A.prototype,"preventScrimClose",void 0),(0,i.Cg)([(0,l.MZ)({attribute:"header-title"})],A.prototype,"headerTitle",void 0),(0,i.Cg)([(0,l.MZ)({attribute:"header-subtitle"})],A.prototype,"headerSubtitle",void 0),(0,i.Cg)([(0,l.MZ)({type:String,attribute:"header-subtitle-position"})],A.prototype,"headerSubtitlePosition",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,reflect:!0,attribute:"flexcontent"})],A.prototype,"flexContent",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,attribute:"without-header"})],A.prototype,"withoutHeader",void 0),(0,i.Cg)([(0,l.wk)()],A.prototype,"_open",void 0),(0,i.Cg)([(0,l.P)(".body")],A.prototype,"bodyContainer",void 0),(0,i.Cg)([(0,l.wk)(),(0,r.Fg)({context:c.D5,subscribe:!0})],A.prototype,"_i18n",void 0),(0,i.Cg)([(0,l.wk)(),(0,r.Fg)({context:c.WF,subscribe:!0})],A.prototype,"_hassConfig",void 0),(0,i.Cg)([(0,l.wk)()],A.prototype,"_bodyScrolled",void 0),(0,i.Cg)([(0,l.Ls)({passive:!0})],A.prototype,"_handleBodyScroll",null),A=(0,i.Cg)([(0,l.EM)("ha-dialog")],A),t()}catch(f){t(f)}})},67505:function(e,t,a){var i=a(40445),o=a(5124),r=a(67576),s=a(93421);a(67094);let l,n,d=e=>e;class h extends o.WF{render(){return this._localize?(0,o.qy)(l||(l=d` <ha-svg-icon .path="${0}"></ha-svg-icon> <span class="prefix">${0}</span> <span class="text"><slot></slot></span> `),"M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z",this._localize("ui.panel.config.tips.tip")):o.s6}}h.styles=(0,o.AH)(n||(n=d`:host{display:block;text-align:center}.text{direction:var(--direction);margin-left:2px;margin-inline-start:2px;margin-inline-end:initial;color:var(--secondary-text-color)}.prefix{font-weight:var(--ha-font-weight-medium)}`)),(0,i.Cg)([(0,r.wk)(),(0,s.IW)()],h.prototype,"_localize",void 0),h=(0,i.Cg)([(0,r.EM)("ha-tip")],h)},71084:function(e,t,a){a.a(e,async function(e,i){try{a.r(t);a(44114),a(18111),a(22489),a(7588),a(3362),a(17642),a(58004),a(33853),a(45876),a(32475),a(15024),a(31698),a(62953);var o=a(40445),r=a(7364),s=a(5124),l=a(67576),n=a(75751),d=a(36312),h=a(1087),c=a(3129),p=a(53072),g=a(17022),u=a(65063),m=a(18350),v=(a(30716),a(72554)),f=(a(93444),a(76538),a(26300)),b=(a(8630),a(65829)),_=(a(67094),a(67505),a(45098)),w=a(62176),y=e([m,v,f,b,_,w]);[m,v,f,b,_,w]=y.then?(await y)():y;let x,k,C,$,A,M,S,z,L,H,q,I,E,Z=e=>e;const V="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z",D="M19,19H5V5H15V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V11H19M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z",F="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",P="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z";class T extends s.WF{showDialog(e){this._params=e,this._refreshMedia(),this._open=!0}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._filesChanged&&this._params.onClose&&this._params.onClose(),this._params=void 0,this._currentItem=void 0,this._uploading=!1,this._deleting=!1,this._filesChanged=!1,(0,h.r)(this,"dialog-closed",{dialog:this.localName})}willUpdate(){var e;this._filteredChildren=(null===(e=this._currentItem)||void 0===e||null===(e=e.children)||void 0===e?void 0:e.filter(e=>!e.can_expand))||[],0===this._filteredChildren.length&&0!==this._selected.size&&(this._selected=new Set)}render(){var e,t,a;if(!this._params)return s.s6;let i=0;return(0,s.qy)(x||(x=Z` <ha-dialog .open="${0}" ?prevent-scrim-close="${0}" ="${0}"> <ha-dialog-header slot="header"> ${0} <h1 class="title" slot="title" id="dialog-box-title"> ${0} </h1> ${0} </ha-dialog-header> ${0} ${0} </ha-dialog> `),this._open,this._uploading||this._deleting,this._dialogClosed,this._uploading||this._deleting?s.s6:(0,s.qy)(k||(k=Z`<slot name="headerNavigationIcon" slot="navigationIcon"> <ha-icon-button data-dialog="close" .label="${0}" .path="${0}"></ha-icon-button></slot>`),null!==(e=null===(t=this.hass)||void 0===t?void 0:t.localize("ui.common.close"))&&void 0!==e?e:"Close",F),this.hass.localize("ui.components.media-browser.file_management.title"),0===this._selected.size?(0,s.qy)(C||(C=Z`<ha-media-upload-button .hass="${0}" .currentItem="${0}" ="${0}" -refresh="${0}" slot="actionItems"></ha-media-upload-button>`),this.hass,this._params.currentItem,this._startUploading,this._doneUploading):(0,s.qy)($||($=Z`<ha-button variant="danger" slot="actionItems" .disabled="${0}" ="${0}"> <ha-svg-icon .path="${0}" slot="start"></ha-svg-icon> ${0} </ha-button>`),this._deleting,this._handleDelete,P,this.hass.localize("ui.components.media-browser.file_management."+(this._deleting?"deleting":"delete"),{count:this._selected.size})),this._currentItem?this._filteredChildren.length?(0,s.qy)(z||(z=Z` <div class="buttons" slot="footer"> <ha-button appearance="filled" ="${0}" .disabled="${0}"> <ha-svg-icon .path="${0}" slot="start"></ha-svg-icon> ${0} </ha-button> <ha-button appearance="filled" ="${0}" .disabled="${0}"> <ha-svg-icon .path="${0}" slot="start"></ha-svg-icon> ${0} </ha-button> </div> <ha-list multi ="${0}"> ${0} </ha-list> `),this._handleDeselectAll,0===this._selected.size,V,this.hass.localize("ui.components.media-browser.file_management.deselect_all"),this._handleSelectAll,this._selected.size===this._filteredChildren.length,D,this.hass.localize("ui.components.media-browser.file_management.select_all"),this._handleSelected,(0,n.u)(this._filteredChildren,e=>e.media_content_id,e=>{const t=(0,s.qy)(L||(L=Z` <ha-svg-icon slot="graphic" .path="${0}"></ha-svg-icon> `),p.EC["directory"===e.media_class&&e.children_media_class||e.media_class].icon);return(0,s.qy)(H||(H=Z` <ha-check-list-item ${0} graphic="icon" .disabled="${0}" .selected="${0}" .item="${0}"> ${0} ${0} </ha-check-list-item> `),(0,r.i0)({id:e.media_content_id,skipInitial:!0}),this._uploading||this._deleting,this._selected.has(i++),e,t,e.title)})):(0,s.qy)(M||(M=Z`<div class="no-items"> <p> ${0} </p> ${0} </div>`),this.hass.localize("ui.components.media-browser.file_management.no_items"),null!==(a=this._currentItem)&&void 0!==a&&null!==(a=a.children)&&void 0!==a&&a.length?(0,s.qy)(S||(S=Z`<span class="folders">${0}</span>`),this.hass.localize("ui.components.media-browser.file_management.folders_not_supported")):""):(0,s.qy)(A||(A=Z` <div class="refresh"> <ha-spinner></ha-spinner> </div> `)),(0,d.x)(this.hass.config,"hassio")?(0,s.qy)(q||(q=Z`<ha-tip> ${0} </ha-tip>`),this.hass.localize("ui.components.media-browser.file_management.tip_media_storage",{storage:(0,s.qy)(I||(I=Z`<a href="/config/storage" ="${0}"> ${0}</a>`),this.closeDialog,this.hass.localize("ui.components.media-browser.file_management.tip_storage_panel"))})):s.s6)}_handleSelected(e){this._selected=e.detail.index}_startUploading(){this._uploading=!0,this._filesChanged=!0}_doneUploading(){this._uploading=!1,this._refreshMedia()}_handleDeselectAll(){this._selected.size&&(this._selected=new Set)}_handleSelectAll(){this._selected=new Set([...Array(this._filteredChildren.length).keys()])}async _handleDelete(){if(!(await(0,u.dk)(this,{text:this.hass.localize("ui.components.media-browser.file_management.confirm_delete",{count:this._selected.size}),warning:!0})))return;this._filesChanged=!0,this._deleting=!0;const e=[];let t=0;this._currentItem.children.forEach(a=>{a.can_expand||this._selected.has(t++)&&e.push(a)});try{await Promise.all(e.map(async e=>{if((0,g.Jz)(e.media_content_id))await(0,g.WI)(this.hass,e.media_content_id);else if((0,g.iY)(e.media_content_id)){const t=(0,c.pD)(e.media_content_id);t&&await(0,c.vS)(this.hass,t)}this._currentItem=Object.assign(Object.assign({},this._currentItem),{},{children:this._currentItem.children.filter(t=>t!==e)})}))}finally{this._deleting=!1,this._selected=new Set}}async _refreshMedia(){this._selected=new Set,this._currentItem=void 0,this._currentItem=await(0,g.Fn)(this.hass,this._params.currentItem.media_content_id)}static get styles(){return[(0,s.AH)(E||(E=Z`ha-dialog{--dialog-content-padding:0}ha-dialog-header ha-button,ha-dialog-header ha-media-upload-button{--mdc-theme-primary:var(--primary-text-color);margin:6px;display:block}ha-tip{margin:16px}.refresh{display:flex;height:200px;justify-content:center;align-items:center}.buttons{display:flex;justify-content:center;width:100%}.no-items{text-align:center;padding:16px}.folders{color:var(--secondary-text-color);font-style:italic}.title{font:inherit;font-size:inherit;margin:inherit}`))]}constructor(...e){super(...e),this._uploading=!1,this._deleting=!1,this._selected=new Set,this._open=!1,this._filteredChildren=[],this._filesChanged=!1}}(0,o.Cg)([(0,l.MZ)({attribute:!1})],T.prototype,"hass",void 0),(0,o.Cg)([(0,l.wk)()],T.prototype,"_currentItem",void 0),(0,o.Cg)([(0,l.wk)()],T.prototype,"_params",void 0),(0,o.Cg)([(0,l.wk)()],T.prototype,"_uploading",void 0),(0,o.Cg)([(0,l.wk)()],T.prototype,"_deleting",void 0),(0,o.Cg)([(0,l.wk)()],T.prototype,"_selected",void 0),(0,o.Cg)([(0,l.wk)()],T.prototype,"_open",void 0),(0,o.Cg)([(0,l.wk)()],T.prototype,"_filteredChildren",void 0),T=(0,o.Cg)([(0,l.EM)("dialog-media-manage")],T),i()}catch(x){i(x)}})},62176:function(e,t,a){a.a(e,async function(e,t){try{a(3362),a(62953);var i=a(40445),o=a(5124),r=a(67576),s=a(1087),l=a(17022),n=a(65063),d=a(18350),h=(a(67094),e([d]));d=(h.then?(await h)():h)[0];let c,p=e=>e;const g="M9,16V10H5L12,3L19,10H15V16H9M5,20V18H19V20H5Z";class u extends o.WF{render(){return this.currentItem&&(0,l.Jz)(this.currentItem.media_content_id||"")?(0,o.qy)(c||(c=p` <ha-button .disabled="${0}" ="${0}" .loading="${0}"> <ha-svg-icon .path="${0}" slot="start"></ha-svg-icon> ${0} </ha-button> `),this._uploading>0,this._startUpload,this._uploading>0,g,this._uploading>0?this.hass.localize("ui.components.media-browser.file_management.uploading",{count:this._uploading}):this.hass.localize("ui.components.media-browser.file_management.add_media")):o.s6}async _startUpload(){if(this._uploading>0)return;const e=document.createElement("input");e.type="file",e.accept="audio/*,video/*,image/*",e.multiple=!0,e.addEventListener("change",async()=>{(0,s.r)(this,"uploading");const t=e.files;document.body.removeChild(e);const a=this.currentItem.media_content_id;for(let e=0;e<t.length;e++){this._uploading=t.length-e;try{await(0,l.VA)(this.hass,a,t[e])}catch(i){(0,n.showAlertDialog)(this,{text:this.hass.localize("ui.components.media-browser.file_management.upload_failed",{reason:i.message||i})});break}}this._uploading=0,(0,s.r)(this,"media-refresh")},{once:!0}),e.style.display="none",document.body.append(e),e.click()}constructor(...e){super(...e),this._uploading=0}}(0,i.Cg)([(0,r.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,i.Cg)([(0,r.MZ)({attribute:!1})],u.prototype,"currentItem",void 0),(0,i.Cg)([(0,r.wk)()],u.prototype,"_uploading",void 0),u=(0,i.Cg)([(0,r.EM)("ha-media-upload-button")],u),t()}catch(c){t(c)}})},3129:function(e,t,a){a.d(t,{AP:function(){return o},M5:function(){return d},Q0:function(){return s},mF:function(){return l},pD:function(){return r},vS:function(){return n}});a(16280),a(3362);const i="/api/image/serve/",o="media-source://image_upload",r=e=>{let t;if(e.startsWith(i)){t=e.substring(17);const a=t.indexOf("/");a>=0&&(t=t.substring(0,a))}else e.startsWith(o)&&(t=e.substring(o.length+1));return t},s=(e,t,a=!1)=>{if(!a&&!t)throw new Error("Size must be provided if original is false");return a?`/api/image/serve/${e}/original`:`/api/image/serve/${e}/${t}x${t}`},l=async(e,t)=>{const a=new FormData;a.append("file",t);const i=await e.fetchWithAuth("/api/image/upload",{method:"POST",body:a});if(413===i.status)throw new Error(`Uploaded image is too large (${t.name})`);if(200!==i.status)throw new Error("Unknown error");return i.json()},n=(e,t)=>e.callWS({type:"image/delete",image_id:t}),d=async(e,t)=>{const a=await fetch(e.hassUrl(t));if(!a.ok)throw new Error(`Failed to fetch image: ${a.statusText?a.statusText:a.status}`);return a.blob()}}}]);