/*! For license information please see eclBmlI9.js.LICENSE.txt */
export const id=6414;export const ids=[6414];export const modules={3604:(t,e,i)=>{var s=i(5461),n=i(9534),o=i(8597),a=i(6513),r=i(196),h=i(1497),l=i(8678);let d=class extends h.L{};d.styles=[l.R],d=(0,a.Cg)([(0,r.EM)("mwc-checkbox")],d);var c=i(9760),m=i(6175);class p extends m.J{constructor(){super(...arguments),this.left=!1,this.graphic="control"}render(){const t={"mdc-deprecated-list-item__graphic":this.left,"mdc-deprecated-list-item__meta":!this.left},e=this.renderText(),i=this.graphic&&"control"!==this.graphic&&!this.left?this.renderGraphic():o.qy``,s=this.hasMeta&&this.left?this.renderMeta():o.qy``,n=this.renderRipple();return o.qy`
      ${n}
      ${i}
      ${this.left?"":e}
      <span class=${(0,c.H)(t)}>
        <mwc-checkbox
            reducedTouchTarget
            tabindex=${this.tabindex}
            .checked=${this.selected}
            ?disabled=${this.disabled}
            @change=${this.onChange}>
        </mwc-checkbox>
      </span>
      ${this.left?e:""}
      ${s}`}async onChange(t){const e=t.target;this.selected===e.checked||(this._skipPropRequest=!0,this.selected=e.checked,await this.updateComplete,this._skipPropRequest=!1)}}(0,a.Cg)([(0,r.P)("slot")],p.prototype,"slotElement",void 0),(0,a.Cg)([(0,r.P)("mwc-checkbox")],p.prototype,"checkboxElement",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],p.prototype,"left",void 0),(0,a.Cg)([(0,r.MZ)({type:String,reflect:!0})],p.prototype,"graphic",void 0);const u=o.AH`:host(:not([twoline])){height:56px}:host(:not([left])) .mdc-deprecated-list-item__meta{height:40px;width:40px}`;var g=i(5592),f=i(3167);(0,s.A)([(0,r.EM)("ha-check-list-item")],(function(t,e){class i extends e{constructor(...e){super(...e),t(this)}}return{F:i,d:[{kind:"method",key:"onChange",value:async function(t){(0,n.A)(i,"onChange",this,3)([t]),(0,f.r)(this,t.type)}},{kind:"field",static:!0,key:"styles",value(){return[g.R,u,o.AH`
      :host {
        --mdc-theme-secondary: var(--primary-color);
      }

      :host([graphic="avatar"]) .mdc-deprecated-list-item__graphic,
      :host([graphic="medium"]) .mdc-deprecated-list-item__graphic,
      :host([graphic="large"]) .mdc-deprecated-list-item__graphic,
      :host([graphic="control"]) .mdc-deprecated-list-item__graphic {
        margin-inline-end: var(--mdc-list-item-graphic-margin, 16px);
        margin-inline-start: 0px;
        direction: var(--direction);
      }
      .mdc-deprecated-list-item__meta {
        flex-shrink: 0;
        direction: var(--direction);
        margin-inline-start: auto;
        margin-inline-end: 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);
      }
    `]}}]}}),p)},6414:(t,e,i)=>{var s=i(5461),n=i(4078),o=i(3358),a=i(5031);const r=new WeakMap;let h=0;const l=new Map,d=new WeakSet,c=()=>new Promise((t=>requestAnimationFrame(t))),m=(t,e)=>{const i=t-e;return 0===i?void 0:i},p=(t,e)=>{const i=t/e;return 1===i?void 0:i},u={left:(t,e)=>{const i=m(t,e);return{value:i,transform:null==i||isNaN(i)?void 0:`translateX(${i}px)`}},top:(t,e)=>{const i=m(t,e);return{value:i,transform:null==i||isNaN(i)?void 0:`translateY(${i}px)`}},width:(t,e)=>{let i;0===e&&(e=1,i={width:"1px"});const s=p(t,e);return{value:s,overrideFrom:i,transform:null==s||isNaN(s)?void 0:`scaleX(${s})`}},height:(t,e)=>{let i;0===e&&(e=1,i={height:"1px"});const s=p(t,e);return{value:s,overrideFrom:i,transform:null==s||isNaN(s)?void 0:`scaleY(${s})`}}},g={duration:333,easing:"ease-in-out"},f=["left","top","width","height","opacity","color","background"],v=new WeakMap;class _ extends a.Kq{constructor(t){if(super(t),this.t=!1,this.i=null,this.o=null,this.h=!0,this.shouldLog=!1,t.type===o.OA.CHILD)throw Error("The `animate` directive must be used in attribute position.");this.createFinished()}createFinished(){this.resolveFinished?.(),this.finished=new Promise((t=>{this.l=t}))}async resolveFinished(){this.l?.(),this.l=void 0}render(t){return n.s6}getController(){return r.get(this.u)}isDisabled(){return this.options.disabled||this.getController()?.disabled}update(t,[e]){const i=void 0===this.u;return i&&(this.u=t.options?.host,this.u.addController(this),this.u.updateComplete.then((t=>this.t=!0)),this.element=t.element,v.set(this.element,this)),this.optionsOrCallback=e,(i||"function"!=typeof e)&&this.p(e),this.render(e)}p(t){t=t??{};const e=this.getController();void 0!==e&&((t={...e.defaultOptions,...t}).keyframeOptions={...e.defaultOptions.keyframeOptions,...t.keyframeOptions}),t.properties??=f,this.options=t}m(){const t={},e=this.element.getBoundingClientRect(),i=getComputedStyle(this.element);return this.options.properties.forEach((s=>{const n=e[s]??(u[s]?void 0:i[s]),o=Number(n);t[s]=isNaN(o)?n+"":o})),t}v(){let t,e=!0;return this.options.guard&&(t=this.options.guard(),e=((t,e)=>{if(Array.isArray(t)){if(Array.isArray(e)&&e.length===t.length&&t.every(((t,i)=>t===e[i])))return!1}else if(e===t)return!1;return!0})(t,this._)),this.h=this.t&&!this.isDisabled()&&!this.isAnimating()&&e&&this.element.isConnected,this.h&&(this._=Array.isArray(t)?Array.from(t):t),this.h}hostUpdate(){"function"==typeof this.optionsOrCallback&&this.p(this.optionsOrCallback()),this.v()&&(this.A=this.m(),this.i=this.i??this.element.parentNode,this.o=this.element.nextSibling)}async hostUpdated(){if(!this.h||!this.element.isConnected||this.options.skipInitial&&!this.isHostRendered)return;let t;this.prepare(),await c;const e=this.O(),i=this.j(this.options.keyframeOptions,e),s=this.m();if(void 0!==this.A){const{from:i,to:n}=this.N(this.A,s,e);this.log("measured",[this.A,s,i,n]),t=this.calculateKeyframes(i,n)}else{const i=l.get(this.options.inId);if(i){l.delete(this.options.inId);const{from:n,to:o}=this.N(i,s,e);t=this.calculateKeyframes(n,o),t=this.options.in?[{...this.options.in[0],...t[0]},...this.options.in.slice(1),t[1]]:t,h++,t.forEach((t=>t.zIndex=h))}else this.options.in&&(t=[...this.options.in,{}])}this.animate(t,i)}resetStyles(){void 0!==this.P&&(this.element.setAttribute("style",this.P??""),this.P=void 0)}commitStyles(){this.P=this.element.getAttribute("style"),this.webAnimation?.commitStyles(),this.webAnimation?.cancel()}reconnected(){}async disconnected(){if(!this.h)return;if(void 0!==this.options.id&&l.set(this.options.id,this.A),void 0===this.options.out)return;if(this.prepare(),await c(),this.i?.isConnected){const t=this.o&&this.o.parentNode===this.i?this.o:null;if(this.i.insertBefore(this.element,t),this.options.stabilizeOut){const t=this.m();this.log("stabilizing out");const e=this.A.left-t.left,i=this.A.top-t.top;!("static"===getComputedStyle(this.element).position)||0===e&&0===i||(this.element.style.position="relative"),0!==e&&(this.element.style.left=e+"px"),0!==i&&(this.element.style.top=i+"px")}}const t=this.j(this.options.keyframeOptions);await this.animate(this.options.out,t),this.element.remove()}prepare(){this.createFinished()}start(){this.options.onStart?.(this)}didFinish(t){t&&this.options.onComplete?.(this),this.A=void 0,this.animatingProperties=void 0,this.frames=void 0,this.resolveFinished()}O(){const t=[];for(let e=this.element.parentNode;e;e=e?.parentNode){const i=v.get(e);i&&!i.isDisabled()&&i&&t.push(i)}return t}get isHostRendered(){const t=d.has(this.u);return t||this.u.updateComplete.then((()=>{d.add(this.u)})),t}j(t,e=this.O()){const i={...g};return e.forEach((t=>Object.assign(i,t.options.keyframeOptions))),Object.assign(i,t),i}N(t,e,i){t={...t},e={...e};const s=i.map((t=>t.animatingProperties)).filter((t=>void 0!==t));let n=1,o=1;return s.length>0&&(s.forEach((t=>{t.width&&(n/=t.width),t.height&&(o/=t.height)})),void 0!==t.left&&void 0!==e.left&&(t.left=n*t.left,e.left=n*e.left),void 0!==t.top&&void 0!==e.top&&(t.top=o*t.top,e.top=o*e.top)),{from:t,to:e}}calculateKeyframes(t,e,i=!1){const s={},n={};let o=!1;const a={};for(const r in e){const i=t[r],h=e[r];if(r in u){const t=u[r];if(void 0===i||void 0===h)continue;const e=t(i,h);void 0!==e.transform&&(a[r]=e.value,o=!0,s.transform=`${s.transform??""} ${e.transform}`,void 0!==e.overrideFrom&&Object.assign(s,e.overrideFrom))}else i!==h&&void 0!==i&&void 0!==h&&(o=!0,s[r]=i,n[r]=h)}return s.transformOrigin=n.transformOrigin=i?"center center":"top left",this.animatingProperties=a,o?[s,n]:void 0}async animate(t,e=this.options.keyframeOptions){this.start(),this.frames=t;let i=!1;if(!this.isAnimating()&&!this.isDisabled()&&(this.options.onFrames&&(this.frames=t=this.options.onFrames(this),this.log("modified frames",t)),void 0!==t)){this.log("animate",[t,e]),i=!0,this.webAnimation=this.element.animate(t,e);const s=this.getController();s?.add(this);try{await this.webAnimation.finished}catch(t){}s?.remove(this)}return this.didFinish(i),i}isAnimating(){return"running"===this.webAnimation?.playState||this.webAnimation?.pending}log(t,e){this.shouldLog&&!this.isDisabled()&&console.log(t,this.options.id,e)}}const y=(0,o.u$)(_),k=["top","right","bottom","left"];class b extends a.Kq{constructor(t){if(super(t),t.type!==o.OA.ELEMENT)throw Error("The `position` directive must be used in attribute position.")}render(t,e){return n.s6}update(t,[e,i]){return void 0===this.u&&(this.u=t.options?.host,this.u.addController(this)),this.S=t.element,this.C=e,this.F=i??["left","top","width","height"],this.render(e,i)}hostUpdated(){this.$()}$(){const t="function"==typeof this.C?this.C():this.C?.value,e=t.offsetParent;if(void 0===t||!e)return;const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();this.F?.forEach((t=>{const e=k.includes(t)?i[t]-s[t]:i[t];this.S.style[t]=e+"px"}))}}(0,o.u$)(b);i(9805),i(3981);var x=i(8597),w=i(196),$=i(6580),A=i(3167),C=i(7222),I=i(3728),M=i(2462),q=i(1447),F=i(3799);i(6494),i(3604),i(3279),i(8762),i(2714),i(9222);(0,s.A)([(0,w.EM)("ha-tip")],(function(t,e){return{F:class extends e{constructor(...e){super(...e),t(this)}},d:[{kind:"field",decorators:[(0,w.MZ)({attribute:!1})],key:"hass",value:void 0},{kind:"method",key:"render",value:function(){return this.hass?x.qy`
      <ha-svg-icon .path=${"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"}></ha-svg-icon>
      <span class="prefix"
        >${this.hass.localize("ui.panel.config.tips.tip")}</span
      >
      <span class="text"><slot></slot></span>
    `:x.s6}},{kind:"field",static:!0,key:"styles",value(){return x.AH`
    :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: 500;
    }
  `}}]}}),x.WF);i(5193),i(8068);(0,s.A)([(0,w.EM)("ha-media-upload-button")],(function(t,e){return{F:class extends e{constructor(...e){super(...e),t(this)}},d:[{kind:"field",decorators:[(0,w.MZ)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,w.MZ)({attribute:!1})],key:"currentItem",value:void 0},{kind:"field",decorators:[(0,w.wk)()],key:"_uploading",value(){return 0}},{kind:"method",key:"render",value:function(){return this.currentItem&&(0,M.Jz)(this.currentItem.media_content_id||"")?x.qy`
      <mwc-button
        .label=${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")}
        .disabled=${this._uploading>0}
        @click=${this._startUpload}
      >
        ${this._uploading>0?x.qy`
              <ha-circular-progress
                size="small"
                indeterminate
                area-label="Uploading"
                slot="icon"
              ></ha-circular-progress>
            `:x.qy` <ha-svg-icon .path=${"M9,16V10H5L12,3L19,10H15V16H9M5,20V18H19V20H5Z"} slot="icon"></ha-svg-icon> `}
      </mwc-button>
    `:x.s6}},{kind:"method",key:"_startUpload",value:async function(){if(this._uploading>0)return;const t=document.createElement("input");t.type="file",t.accept="audio/*,video/*,image/*",t.multiple=!0,t.addEventListener("change",(async()=>{(0,A.r)(this,"uploading");const e=t.files;document.body.removeChild(t);const i=this.currentItem.media_content_id;for(let t=0;t<e.length;t++){this._uploading=e.length-t;try{await(0,M.VA)(this.hass,i,e[t])}catch(s){(0,q.K$)(this,{text:this.hass.localize("ui.components.media-browser.file_management.upload_failed",{reason:s.message||s})});break}}this._uploading=0,(0,A.r)(this,"media-refresh")}),{once:!0}),t.style.display="none",document.body.append(t),t.click()}},{kind:"field",static:!0,key:"styles",value(){return x.AH`
    mwc-button {
      /* We use icon + text to show disabled state */
      --mdc-button-disabled-ink-color: --mdc-theme-primary;
    }

    ha-svg-icon[slot="icon"],
    ha-circular-progress[slot="icon"] {
      vertical-align: middle;
    }

    ha-svg-icon[slot="icon"] {
      margin-inline-start: 0px;
      margin-inline-end: 8px;
      direction: var(--direction);
    }
  `}}]}}),x.WF);var H=i(2872);const L="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";(0,s.A)([(0,w.EM)("dialog-media-manage")],(function(t,e){return{F:class extends e{constructor(...e){super(...e),t(this)}},d:[{kind:"field",decorators:[(0,w.MZ)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,w.wk)()],key:"_currentItem",value:void 0},{kind:"field",decorators:[(0,w.wk)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,w.wk)()],key:"_uploading",value(){return!1}},{kind:"field",decorators:[(0,w.wk)()],key:"_deleting",value(){return!1}},{kind:"field",decorators:[(0,w.wk)()],key:"_selected",value(){return new Set}},{kind:"field",key:"_filesChanged",value(){return!1}},{kind:"method",key:"showDialog",value:function(t){this._params=t,this._refreshMedia()}},{kind:"method",key:"closeDialog",value:function(){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,A.r)(this,"dialog-closed",{dialog:this.localName})}},{kind:"method",key:"render",value:function(){if(!this._params)return x.s6;const t=this._currentItem?.children?.filter((t=>!t.can_expand))||[];let e=0;return x.qy`
      <ha-dialog
        open
        scrimClickAction
        escapeKeyAction
        hideActions
        flexContent
        .heading=${this._params.currentItem.title}
        @closed=${this.closeDialog}
      >
        <ha-dialog-header slot="heading">
          ${0===this._selected.size?x.qy`
                <span slot="title">
                  ${this.hass.localize("ui.components.media-browser.file_management.title")}
                </span>

                <ha-media-upload-button
                  .disabled=${this._deleting}
                  .hass=${this.hass}
                  .currentItem=${this._params.currentItem}
                  @uploading=${this._startUploading}
                  @media-refresh=${this._doneUploading}
                  slot="actionItems"
                ></ha-media-upload-button>
                ${this._uploading?"":x.qy`
                      <ha-icon-button
                        .label=${this.hass.localize("ui.dialogs.generic.close")}
                        .path=${L}
                        dialogAction="close"
                        slot="navigationIcon"
                        dir=${(0,C.Vc)(this.hass)}
                      ></ha-icon-button>
                    `}
              `:x.qy`
                <ha-button
                  class="danger"
                  slot="title"
                  .disabled=${this._deleting}
                  .label=${this.hass.localize("ui.components.media-browser.file_management."+(this._deleting?"deleting":"delete"),{count:this._selected.size})}
                  @click=${this._handleDelete}
                >
                  <ha-svg-icon .path=${"M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"} slot="icon"></ha-svg-icon>
                </ha-button>

                ${this._deleting?"":x.qy`
                      <ha-button
                        slot="actionItems"
                        .label=${"Deselect all"}
                        @click=${this._handleDeselectAll}
                      >
                        <ha-svg-icon
                          .path=${L}
                          slot="icon"
                        ></ha-svg-icon>
                      </ha-button>
                    `}
              `}
        </ha-dialog-header>
        ${this._currentItem?t.length?x.qy`
                <mwc-list multi @selected=${this._handleSelected}>
                  ${(0,$.u)(t,(t=>t.media_content_id),(t=>{const i=x.qy`
                        <ha-svg-icon
                          slot="graphic"
                          .path=${I.EC["directory"===t.media_class&&t.children_media_class||t.media_class].icon}
                        ></ha-svg-icon>
                      `;return x.qy`
                        <ha-check-list-item
                          ${y({id:t.media_content_id,skipInitial:!0})}
                          graphic="icon"
                          .disabled=${this._uploading||this._deleting}
                          .selected=${this._selected.has(e++)}
                          .item=${t}
                        >
                          ${i} ${t.title}
                        </ha-check-list-item>
                      `}))}
                </mwc-list>
              `:x.qy`<div class="no-items">
                <p>
                  ${this.hass.localize("ui.components.media-browser.file_management.no_items")}
                </p>
                ${this._currentItem?.children?.length?x.qy`<span class="folders"
                      >${this.hass.localize("ui.components.media-browser.file_management.folders_not_supported")}</span
                    >`:""}
              </div>`:x.qy`
              <div class="refresh">
                <ha-circular-progress indeterminate></ha-circular-progress>
              </div>
            `}
        ${(0,H.x)(this.hass,"hassio")?x.qy`<ha-tip .hass=${this.hass}>
              ${this.hass.localize("ui.components.media-browser.file_management.tip_media_storage",{storage:x.qy`<a
                    href="/config/storage"
                    @click=${this.closeDialog}
                  >
                    ${this.hass.localize("ui.components.media-browser.file_management.tip_storage_panel").toLowerCase()}
                  </a>`})}
            </ha-tip>`:x.s6}
      </ha-dialog>
    `}},{kind:"method",key:"_handleSelected",value:function(t){this._selected=t.detail.index}},{kind:"method",key:"_startUploading",value:function(){this._uploading=!0,this._filesChanged=!0}},{kind:"method",key:"_doneUploading",value:function(){this._uploading=!1,this._refreshMedia()}},{kind:"method",key:"_handleDeselectAll",value:function(){this._selected.size&&(this._selected=new Set)}},{kind:"method",key:"_handleDelete",value:async function(){if(!(await(0,q.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 t=[];let e=0;this._currentItem.children.forEach((i=>{i.can_expand||this._selected.has(e++)&&t.push(i)}));try{await Promise.all(t.map((async t=>{await(0,M.WI)(this.hass,t.media_content_id),this._currentItem={...this._currentItem,children:this._currentItem.children.filter((e=>e!==t))}})))}finally{this._deleting=!1,this._selected=new Set}}},{kind:"method",key:"_refreshMedia",value:async function(){this._selected=new Set,this._currentItem=void 0,this._currentItem=await(0,M.Fn)(this.hass,this._params.currentItem.media_content_id)}},{kind:"get",static:!0,key:"styles",value:function(){return[F.nA,x.AH`
        ha-dialog {
          --dialog-z-index: 9;
          --dialog-content-padding: 0;
        }

        @media (min-width: 800px) {
          ha-dialog {
            --mdc-dialog-max-width: 800px;
            --dialog-surface-position: fixed;
            --dialog-surface-top: 40px;
            --mdc-dialog-max-height: calc(100vh - 72px);
          }
        }

        ha-dialog-header ha-media-upload-button,
        ha-dialog-header ha-button {
          --mdc-theme-primary: var(--primary-text-color);
          margin: 6px;
          display: block;
        }

        .danger {
          --mdc-theme-primary: var(--error-color);
        }

        ha-svg-icon[slot="icon"] {
          vertical-align: middle;
        }

        ha-tip {
          margin: 16px;
        }

        ha-svg-icon[slot="icon"] {
          margin-inline-start: 0px !important;
          margin-inline-end: 8px !important;
          direction: var(--direction);
        }

        .refresh {
          display: flex;
          height: 200px;
          justify-content: center;
          align-items: center;
        }

        .no-items {
          text-align: center;
          padding: 16px;
        }
        .folders {
          color: var(--secondary-text-color);
          font-style: italic;
        }
      `]}}]}}),x.WF)}};
//# sourceMappingURL=eclBmlI9.js.map