"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["65742"],{16349:function(t,a,e){e.a(t,async function(t,s){try{e.r(a);e(16280),e(3362),e(62953),e(3296),e(27208),e(48408),e(14603),e(47566),e(98721);var o=e(40445),n=e(96196),i=e(77845),c=e(80880),r=e(89300),d=e(13062),h=e(22675),l=e(30039),p=e(81619),w=t([r,d]);[r,d]=w.then?(await w)():w;let _,b,g=t=>t;class u extends n.WF{connectedCallback(){super.connectedCallback(),this._attached=!0}disconnectedCallback(){super.disconnectedCallback(),this._attached=!1}render(){return this._attached&&this.stateObj?(0,n.qy)(_||(_=g` <ha-camera-stream .hass="${0}" .stateObj="${0}" allow-exoplayer controls></ha-camera-stream> <div class="actions"> <ha-progress-button @click="${0}" .progress="${0}" .disabled="${0}" appearance="filled"> ${0} </ha-progress-button> </div> `),this.hass,this.stateObj,this._downloadSnapshot,this._waiting,this.stateObj.state===h.Hh,this.hass.localize("ui.dialogs.more_info_control.camera.download_snapshot")):n.s6}async _downloadSnapshot(t){const a=t.currentTarget;this._waiting=!0;try{const t=await this.hass.callApiRaw("GET",`camera_proxy/${this.stateObj.entity_id}`);if(!t)throw new Error("No response from API");const a="image/png"===t.headers.get("content-type")?"png":"jpg",e=(new Date).toLocaleString(),s=`snapshot_${(0,c.Y)(this.stateObj.entity_id)}_${e}.${a}`,o=await t.blob(),n=window.URL.createObjectURL(o);(0,l.R)(n,s)}catch(e){return this._waiting=!1,a.actionError(),void(0,p.P)(this,{message:this.hass.localize("ui.dialogs.more_info_control.camera.failed_to_download")})}this._waiting=!1,a.actionSuccess()}constructor(...t){super(...t),this._attached=!1,this._waiting=!1}}u.styles=(0,n.AH)(b||(b=g`:host{display:block}.actions{width:100%;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-end;box-sizing:border-box;padding:var(--ha-space-4);z-index:1;gap:var(--ha-space-2)}`)),(0,o.Cg)([(0,i.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,o.Cg)([(0,i.MZ)({attribute:!1})],u.prototype,"stateObj",void 0),(0,o.Cg)([(0,i.wk)()],u.prototype,"_attached",void 0),(0,o.Cg)([(0,i.wk)()],u.prototype,"_waiting",void 0),u=(0,o.Cg)([(0,i.EM)("more-info-camera")],u),s()}catch(_){s(_)}})},30039:function(t,a,e){e.d(a,{R:function(){return s}});const s=(t,a="")=>{const e=document.createElement("a");e.target="_blank",e.href=t,e.download=a,e.style.display="none",document.body.appendChild(e),e.dispatchEvent(new MouseEvent("click")),document.body.removeChild(e)}}}]);
//# sourceMappingURL=65742.9e9fd590b6a0d716.js.map