"use strict";(self.webpackChunkhacs_frontend=self.webpackChunkhacs_frontend||[]).push([[5867],{85867:function(e,t,r){var i=r(22858).A,n=r(33994).A;r.a(e,function(){var e=i(n().mark((function e(i,s){var a,o,u,d,c,l,h,v,f,k,p,_,w,b,y,A,m,x,g,M,P;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,r.r(t),a=r(33994),o=r(22858),u=r(64599),d=r(35806),c=r(71008),l=r(62193),h=r(2816),v=r(27927),f=r(14562),k=r(19867),p=r(81027),r.n(p),_=r(26098),r.n(_),w=r(66360),b=r(29818),y=r(56357),A=r(4501),m=r(46530),x=r(50880),!(g=i([A])).then){e.next=30;break}return e.next=26,g;case 26:e.t1=e.sent,e.t0=(0,e.t1)(),e.next=31;break;case 30:e.t0=g;case 31:A=e.t0[0],(0,v.A)([(0,b.EM)("flow-preview-generic")],(function(e,t){var r,i=function(t){function r(){var t;(0,c.A)(this,r);for(var i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];return t=(0,l.A)(this,r,[].concat(n)),e(t),t}return(0,h.A)(r,t),(0,d.A)(r)}(t);return{F:i,d:[{kind:"field",decorators:[(0,b.MZ)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,b.MZ)()],key:"flowType",value:void 0},{kind:"field",key:"handler",value:void 0},{kind:"field",decorators:[(0,b.MZ)()],key:"domain",value:void 0},{kind:"field",decorators:[(0,b.MZ)()],key:"stepId",value:void 0},{kind:"field",decorators:[(0,b.MZ)()],key:"flowId",value:void 0},{kind:"field",decorators:[(0,b.MZ)()],key:"stepData",value:void 0},{kind:"field",decorators:[(0,b.wk)()],key:"_preview",value:void 0},{kind:"field",decorators:[(0,b.wk)()],key:"_error",value:void 0},{kind:"field",key:"_unsub",value:void 0},{kind:"method",key:"disconnectedCallback",value:function(){(0,f.A)((0,k.A)(i.prototype),"disconnectedCallback",this).call(this),this._unsub&&(this._unsub.then((function(e){return e()})),this._unsub=void 0)}},{kind:"method",key:"willUpdate",value:function(e){e.has("stepData")&&this._debouncedSubscribePreview()}},{kind:"method",key:"render",value:function(){return this._error?(0,w.qy)(M||(M=(0,u.A)(['<ha-alert alert-type="error">',"</ha-alert>"])),this._error):(0,w.qy)(P||(P=(0,u.A)(['<entity-preview-row .hass="','" .stateObj="','"></entity-preview-row>'])),this.hass,this._preview)}},{kind:"field",key:"_setPreview",value:function(){var e=this;return function(t){var r=(new Date).toISOString();e._preview=Object.assign({entity_id:"".concat(e.stepId,".___flow_preview___"),last_changed:r,last_updated:r,context:{id:"",parent_id:null,user_id:null}},t)}}},{kind:"field",key:"_debouncedSubscribePreview",value:function(){var e=this;return(0,m.s)((function(){e._subscribePreview()}),250)}},{kind:"method",key:"_subscribePreview",value:(r=(0,o.A)((0,a.A)().mark((function e(){return(0,a.A)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._unsub){e.next=6;break}return e.next=3,this._unsub;case 3:e.t0=e.sent,(0,e.t0)(),this._unsub=void 0;case 6:if("repair_flow"!==this.flowType){e.next=8;break}return e.abrupt("return");case 8:try{this._unsub=(0,y.Q)(this.hass,this.domain,this.flowId,this.flowType,this.stepData,this._setPreview),(0,x.r)(this,"set-flow-errors",{errors:{}})}catch(t){"string"==typeof t.message?this._error=t.message:(this._error=void 0,(0,x.r)(this,"set-flow-errors",t.message)),this._unsub=void 0,this._preview=void 0}case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})}]}}),w.WF),s(),e.next=39;break;case 36:e.prev=36,e.t2=e.catch(0),s(e.t2);case 39:case"end":return e.stop()}}),e,null,[[0,36]])})));return function(t,r){return e.apply(this,arguments)}}())}}]);
//# sourceMappingURL=5867.ca9XWz6SiHs.js.map