"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["85030"],{67013:function(t,i,e){e.d(i,{e:function(){return n}});const n=t=>`/api/image_proxy/${t.entity_id}?token=${t.attributes.access_token}&state=${t.state}`},17022:function(t,i,e){e.d(i,{A1:function(){return n},CY:function(){return o},Fn:function(){return s},Jz:function(){return r},St:function(){return c},VA:function(){return _},WI:function(){return d},iY:function(){return h},xw:function(){return a}});e(16280),e(3362);const n=(t,i)=>t.callWS({type:"media_source/resolve_media",media_content_id:i}),s=(t,i)=>t.callWS({type:"media_source/browse_media",media_content_id:i}),a="__MANUAL_ENTRY__",o=t=>t.startsWith(a),c=t=>t.startsWith("media-source://"),r=t=>t.startsWith("media-source://media_source"),h=t=>t.startsWith("media-source://image_upload"),_=async(t,i,e)=>{const n=new FormData;n.append("media_content_id",i),n.append("file",e);const s=await t.fetchWithAuth("/api/media_source/local_source/upload",{method:"POST",body:n});if(413===s.status)throw new Error(`Uploaded file is too large (${e.name})`);if(200!==s.status)throw new Error("Unknown error");return s.json()},d=async(t,i)=>t.callWS({type:"media_source/local_source/remove",media_content_id:i})},30789:function(t,i,e){e.a(t,async function(t,n){try{e.r(i),e.d(i,{HuiPictureCard:function(){return C}});e(16280),e(3362),e(62953);var s=e(40445),a=e(96196),o=e(77845),c=e(94333),r=e(32288),h=e(42372),_=e(71727),d=(e(76776),e(67013)),u=e(19037),g=e(37544),f=e(97176),l=e(784),m=e(85979),p=e(17022),y=t([m]);m=(y.then?(await y)():y)[0];let v,w,b,k=t=>t;class C extends a.WF{static async getConfigElement(){return await e.e("87367").then(e.bind(e,75930)),document.createElement("hui-picture-card-editor")}static getStubConfig(){return{type:"picture",image:"https://demo.home-assistant.io/stub_config/t-shirt-promo.png"}}getCardSize(){return 5}setConfig(t){if(!t||!t.image&&!t.image_entity)throw new Error("Image required");this._config=Object.assign({tap_action:{action:"more-info"}},t)}shouldUpdate(t){if(!this._config||(0,l.xP)(this,t)||t.has("_resolvedImage"))return!0;if(this._config.image_entity&&t.has("hass")){const i=t.get("hass");if(!i||i.states[this._config.image_entity]!==this.hass.states[this._config.image_entity])return!0}return!1}willUpdate(t){var i,e,n;if(super.willUpdate(t),!this._config||!this.hass)return;const s=t.has("hass")&&void 0===t.get("hass"),a=t.has("_config")&&(null===(i=t.get("_config"))||void 0===i?void 0:i.image)!==(null===(e=this._config)||void 0===e?void 0:e.image),o="object"==typeof(null===(n=this._config)||void 0===n?void 0:n.image)&&this._config.image.media_content_id||this._config.image;(s||a)&&"string"==typeof o&&(0,p.St)(o)?(this._resolvedImage=void 0,(0,p.A1)(this.hass,o).then(t=>{this._resolvedImage=t.url})):a&&(this._resolvedImage=o)}updated(t){if(super.updated(t),!this._config||!this.hass)return;const i=t.get("hass"),e=t.get("_config");i&&e&&i.themes===this.hass.themes&&e.theme===this._config.theme||(0,h.Q)(this,this.hass.themes,this._config.theme)}render(){var t;if(!this._config||!this.hass)return a.s6;let i;if(this._config.image_entity&&(i=this.hass.states[this._config.image_entity],!i))return(0,a.qy)(v||(v=k`<hui-warning .hass="${0}"> ${0} </hui-warning>`),this.hass,(0,m.j)(this.hass,this._config.image_entity));let e=this._resolvedImage;if(this._config.image_entity){switch((0,_.m)(this._config.image_entity)){case"image":e=(0,d.e)(i);break;case"person":i.attributes.entity_picture&&(e=i.attributes.entity_picture)}}return void 0===e?a.s6:(0,a.qy)(w||(w=k` <ha-card @action="${0}" .actionHandler="${0}" tabindex="${0}" class="${0}"> <img alt="${0}" src="${0}"> </ha-card> `),this._handleAction,(0,u.T)({hasHold:(0,f.h)(this._config.hold_action),hasDoubleClick:(0,f.h)(this._config.double_tap_action)}),(0,r.J)((0,f.h)(this._config.tap_action)||this._config.image_entity?"0":void 0),(0,c.H)({clickable:Boolean(this._config.image_entity&&!this._config.tap_action||this._config.tap_action&&"none"!==this._config.tap_action.action||this._config.hold_action&&"none"!==this._config.hold_action.action||this._config.double_tap_action&&"none"!==this._config.double_tap_action.action)}),(0,r.J)(this._config.alt_text||(null===(t=i)||void 0===t?void 0:t.attributes.friendly_name)),this.hass.hassUrl(e))}_handleAction(t){(0,g.$)(this,this.hass,this._config,t.detail.action)}}C.styles=(0,a.AH)(b||(b=k`ha-card{overflow:hidden;height:100%}ha-card.clickable{cursor:pointer}img{display:block;width:100%}`)),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,s.Cg)([(0,o.wk)()],C.prototype,"_config",void 0),(0,s.Cg)([(0,o.wk)()],C.prototype,"_resolvedImage",void 0),C=(0,s.Cg)([(0,o.EM)("hui-picture-card")],C),n()}catch(v){n(v)}})}}]);
//# sourceMappingURL=85030.867971195b9f327b.js.map