"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["79927"],{7466:function(e,t,s){s.a(e,async function(e,a){try{s.r(t),s.d(t,{CloudForgotPasswordCard:function(){return P}});s(3362),s(62953);var i=s(40445),r=s(96196),o=s(77845),n=s(1087),l=s(89300),d=s(38962),h=(s(76776),s(75709),s(14503)),c=s(71117),u=s(79007),p=e([l,d]);[l,d]=p.then?(await p)():p;let y,g,_,m,w=e=>e;class P extends r.WF{render(){return this.cardLess?this._renderContent():(0,r.qy)(y||(y=w` <ha-card outlined .header="${0}"> ${0} </ha-card> `),this.localize(`ui.panel.${this.translationKeyPanel}.subtitle`),this._renderContent())}_renderContent(){var e;return(0,r.qy)(g||(g=w` <div class="card-content"> <p> ${0} </p> ${0} <ha-textfield autofocus id="email" label="${0}" .value="${0}" type="email" required .disabled="${0}" @keydown="${0}" .validationMessage="${0}"></ha-textfield> </div> <div class="card-actions"> <ha-progress-button @click="${0}" .progress="${0}"> ${0} </ha-progress-button> </div> `),this.localize(`ui.panel.${this.translationKeyPanel}.instructions`),this._error?(0,r.qy)(_||(_=w`<ha-alert alert-type="error">${0}</ha-alert>`),this._error):r.s6,this.localize(`ui.panel.${this.translationKeyPanel}.email`),null!==(e=this.email)&&void 0!==e?e:"",this._inProgress,this._keyDown,this.localize(`ui.panel.${this.translationKeyPanel}.email_error_msg`),this._handleEmailPasswordReset,this._inProgress,this.localize(`ui.panel.${this.translationKeyPanel}.send_reset_email`))}_keyDown(e){"Enter"===e.key&&this._handleEmailPasswordReset()}async _handleEmailPasswordReset(){const e=this.emailField,t=e.value;e.reportValidity()?(this._inProgress=!0,this._resetPassword(t)):e.focus()}static get styles(){return[h.RF,(0,r.AH)(m||(m=w`ha-card{max-width:600px;margin:0 auto;margin-top:24px}h1{margin:0}ha-textfield{width:100%}.card-actions{display:flex;justify-content:flex-end;align-items:center}`))]}constructor(...e){super(...e),this.translationKeyPanel="config.cloud.forgot_password",this.cardLess=!1,this._inProgress=!1,this._resetPassword=async e=>{this._inProgress=!0;try{this.hass?await(0,c.Ut)(this.hass,e):await(0,u.zN)(e),(0,n.r)(this,"cloud-email-changed",{value:e}),this._inProgress=!1,(0,n.r)(this,"cloud-done",{flashMessage:this.localize(`ui.panel.${this.translationKeyPanel}.check_your_email`)})}catch(t){this._inProgress=!1;"usernotfound"===(t&&t.body&&t.body.code)&&e!==e.toLowerCase()?await this._resetPassword(e.toLowerCase()):this._error=t&&t.body&&t.body.message?t.body.message:"Unknown error"}}}}(0,i.Cg)([(0,o.MZ)({attribute:!1})],P.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],P.prototype,"localize",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"translation-key-panel"})],P.prototype,"translationKeyPanel",void 0),(0,i.Cg)([(0,o.MZ)()],P.prototype,"email",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,attribute:"card-less"})],P.prototype,"cardLess",void 0),(0,i.Cg)([(0,o.wk)()],P.prototype,"_inProgress",void 0),(0,i.Cg)([(0,o.wk)()],P.prototype,"_error",void 0),(0,i.Cg)([(0,o.P)("#email",!0)],P.prototype,"emailField",void 0),P=(0,i.Cg)([(0,o.EM)("cloud-forgot-password-card")],P),a()}catch(y){a(y)}})}}]);
//# sourceMappingURL=79927.01105911fbfdfb2a.js.map