iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
8 lines • 24.2 kB
JavaScript
export const __webpack_ids__=["36265"];export const __webpack_modules__={99426:function(e,t,i){i.r(t);var a=i(44249),s=i(57243),o=i(15093),n=i(35359),r=i(36522);i(23334),i(37583);const d={info:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",warning:"M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16",error:"M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z",success:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2,4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"};(0,a.Z)([(0,o.Mo)("ha-alert")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,o.Cb)()],key:"title",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({attribute:"alert-type"})],key:"alertType",value:()=>"info"},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"dismissable",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"narrow",value:()=>!1},{kind:"method",key:"render",value:function(){return s.dy` <div class="issue-type ${(0,n.$)({[this.alertType]:!0})}" role="alert"> <div class="icon ${this.title?"":"no-title"}"> <slot name="icon"> <ha-svg-icon .path="${d[this.alertType]}"></ha-svg-icon> </slot> </div> <div class="${(0,n.$)({content:!0,narrow:this.narrow})}"> <div class="main-content"> ${this.title?s.dy`<div class="title">${this.title}</div>`:s.Ld} <slot></slot> </div> <div class="action"> <slot name="action"> ${this.dismissable?s.dy`<ha-icon-button ="${this._dismissClicked}" label="Dismiss alert" .path="${"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"}"></ha-icon-button>`:s.Ld} </slot> </div> </div> </div> `}},{kind:"method",key:"_dismissClicked",value:function(){(0,r.B)(this,"alert-dismissed-clicked")}},{kind:"field",static:!0,key:"styles",value:()=>s.iv`.issue-type{position:relative;padding:8px;display:flex}.issue-type::after{position:absolute;top:0;right:0;bottom:0;left:0;opacity:.12;pointer-events:none;content:"";border-radius:4px}.icon{z-index:1}.icon.no-title{align-self:center}.content{display:flex;justify-content:space-between;align-items:center;width:100%;text-align:var(--float-start)}.content.narrow{flex-direction:column;align-items:flex-end}.action{z-index:1;width:min-content;--mdc-theme-primary:var(--primary-text-color)}.main-content{overflow-wrap:anywhere;word-break:break-word;margin-left:8px;margin-right:0;margin-inline-start:8px;margin-inline-end:0}.title{margin-top:2px;font-weight:700}.action ha-icon-button,.action mwc-button{--mdc-theme-primary:var(--primary-text-color);--mdc-icon-button-size:36px}.issue-type.info>.icon{color:var(--info-color)}.issue-type.info::after{background-color:var(--info-color)}.issue-type.warning>.icon{color:var(--warning-color)}.issue-type.warning::after{background-color:var(--warning-color)}.issue-type.error>.icon{color:var(--error-color)}.issue-type.error::after{background-color:var(--error-color)}.issue-type.success>.icon{color:var(--success-color)}.issue-type.success::after{background-color:var(--success-color)}:host ::slotted(ul){margin:0;padding-inline-start:20px}`}]}}),s.oi)},59826:function(e,t,i){var a=i(44249),s=i(31622),o=i(57243),n=i(15093),r=i(22344);(0,a.Z)([(0,n.Mo)("ha-button")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",static:!0,key:"styles",value:()=>[r.W,o.iv`::slotted([slot=icon]){margin-inline-start:0px;margin-inline-end:8px;direction:var(--direction);display:block}.mdc-button{height:var(--button-height,36px)}.trailing-icon{display:flex}.slot-container{overflow:var(--button-slot-container-overflow,visible)}:host([destructive]){--mdc-theme-primary:var(--error-color)}`]}]}}),s.Button)},55486:function(e,t,i){var a=i(44249),s=i(4918),o=i(6394),n=i(57243),r=i(15093),d=i(35359),l=i(36522);(0,a.Z)([(0,r.Mo)("ha-formfield")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"method",key:"render",value:function(){const e={"mdc-form-field--align-end":this.alignEnd,"mdc-form-field--space-between":this.spaceBetween,"mdc-form-field--nowrap":this.nowrap};return n.dy` <div class="mdc-form-field ${(0,d.$)(e)}"> <slot></slot> <label class="mdc-label" ="${this._labelClick}"> <slot name="label">${this.label}</slot> </label> </div>`}},{kind:"method",key:"_labelClick",value:function(){const e=this.input;if(e&&(e.focus(),!e.disabled))switch(e.tagName){case"HA-CHECKBOX":e.checked=!e.checked,(0,l.B)(e,"change");break;case"HA-RADIO":e.checked=!0,(0,l.B)(e,"change");break;default:e.click()}}},{kind:"field",static:!0,key:"styles",value:()=>[o.W,n.iv`:host(:not([alignEnd])) ::slotted(ha-switch){margin-right:10px;margin-inline-end:10px;margin-inline-start:inline}.mdc-form-field{align-items:var(--ha-formfield-align-items,center);gap:4px}.mdc-form-field>label{direction:var(--direction);margin-inline-start:0;margin-inline-end:auto;padding:0}:host([disabled]) label{color:var(--disabled-text-color)}`]}]}}),s.a)},34326:function(e,t,i){var a=i(44249),s=i(57243),o=i(15093);i(23334),i(83166);(0,a.Z)([(0,o.Mo)("ha-password-field")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"invalid",value:void 0},{kind:"field",decorators:[(0,o.Cb)({attribute:"error-message"})],key:"errorMessage",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"icon",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"iconTrailing",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)()],key:"autocomplete",value:void 0},{kind:"field",decorators:[(0,o.Cb)()],key:"autocorrect",value:void 0},{kind:"field",decorators:[(0,o.Cb)({attribute:"input-spellcheck"})],key:"inputSpellcheck",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"value",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"placeholder",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"label",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Number})],key:"minLength",value:()=>-1},{kind:"field",decorators:[(0,o.Cb)({type:Number})],key:"maxLength",value:()=>-1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean,reflect:!0})],key:"outlined",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"helper",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"validateOnInitialRender",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"validationMessage",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"autoValidate",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"pattern",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:Number})],key:"size",value:()=>null},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"helperPersistent",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"charCounter",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"endAligned",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"prefix",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"suffix",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:String})],key:"name",value:()=>""},{kind:"field",decorators:[(0,o.Cb)({type:String,attribute:"input-mode"})],key:"inputMode",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"readOnly",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({attribute:!1,type:String})],key:"autocapitalize",value:()=>""},{kind:"field",decorators:[(0,o.SB)()],key:"_unmaskedPassword",value:()=>!1},{kind:"field",decorators:[(0,o.IO)("ha-textfield")],key:"_textField",value:void 0},{kind:"method",key:"render",value:function(){return s.dy`<ha-textfield .invalid="${this.invalid}" .errorMessage="${this.errorMessage}" .icon="${this.icon}" .iconTrailing="${this.iconTrailing}" .autocomplete="${this.autocomplete}" .autocorrect="${this.autocorrect}" .inputSpellcheck="${this.inputSpellcheck}" .value="${this.value}" .placeholder="${this.placeholder}" .label="${this.label}" .disabled="${this.disabled}" .required="${this.required}" .minLength="${this.minLength}" .maxLength="${this.maxLength}" .outlined="${this.outlined}" .helper="${this.helper}" .validateOnInitialRender="${this.validateOnInitialRender}" .validationMessage="${this.validationMessage}" .autoValidate="${this.autoValidate}" .pattern="${this.pattern}" .size="${this.size}" .helperPersistent="${this.helperPersistent}" .charCounter="${this.charCounter}" .endAligned="${this.endAligned}" .prefix="${this.prefix}" .name="${this.name}" .inputMode="${this.inputMode}" .readOnly="${this.readOnly}" .autocapitalize="${this.autocapitalize}" .type="${this._unmaskedPassword?"text":"password"}" .suffix="${s.dy`<div style="width:24px"></div>`}" ="${this._handleInputEvent}" ="${this._handleChangeEvent}"></ha-textfield> <ha-icon-button .label="${this.hass?.localize(this._unmaskedPassword?"ui.components.selectors.text.hide_password":"ui.components.selectors.text.show_password")||(this._unmaskedPassword?"Hide password":"Show password")}" ="${this._toggleUnmaskedPassword}" .path="${this._unmaskedPassword?"M11.83,9L15,12.16C15,12.11 15,12.05 15,12A3,3 0 0,0 12,9C11.94,9 11.89,9 11.83,9M7.53,9.8L9.08,11.35C9.03,11.56 9,11.77 9,12A3,3 0 0,0 12,15C12.22,15 12.44,14.97 12.65,14.92L14.2,16.47C13.53,16.8 12.79,17 12,17A5,5 0 0,1 7,12C7,11.21 7.2,10.47 7.53,9.8M2,4.27L4.28,6.55L4.73,7C3.08,8.3 1.78,10 1,12C2.73,16.39 7,19.5 12,19.5C13.55,19.5 15.03,19.2 16.38,18.66L16.81,19.08L19.73,22L21,20.73L3.27,3M12,7A5,5 0 0,1 17,12C17,12.64 16.87,13.26 16.64,13.82L19.57,16.75C21.07,15.5 22.27,13.86 23,12C21.27,7.61 17,4.5 12,4.5C10.6,4.5 9.26,4.75 8,5.2L10.17,7.35C10.74,7.13 11.35,7 12,7Z":"M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z"}"></ha-icon-button>`}},{kind:"method",key:"focus",value:function(){this._textField.focus()}},{kind:"method",key:"checkValidity",value:function(){return this._textField.checkValidity()}},{kind:"method",key:"reportValidity",value:function(){return this._textField.reportValidity()}},{kind:"method",key:"setCustomValidity",value:function(e){return this._textField.setCustomValidity(e)}},{kind:"method",key:"layout",value:function(){return this._textField.layout()}},{kind:"method",key:"_toggleUnmaskedPassword",value:function(){this._unmaskedPassword=!this._unmaskedPassword}},{kind:"method",decorators:[(0,o.hO)({passive:!0})],key:"_handleInputEvent",value:function(e){this.value=e.target.value}},{kind:"method",decorators:[(0,o.hO)({passive:!0})],key:"_handleChangeEvent",value:function(e){this.value=e.target.value,this._reDispatchEvent(e)}},{kind:"method",key:"_reDispatchEvent",value:function(e){const t=new Event(e.type,e);this.dispatchEvent(t)}},{kind:"field",static:!0,key:"styles",value:()=>s.iv`:host{display:block;position:relative}ha-textfield{width:100%}ha-icon-button{position:absolute;top:8px;right:8px;inset-inline-start:initial;inset-inline-end:8px;--mdc-icon-button-size:40px;--mdc-icon-size:20px;color:var(--secondary-text-color);direction:var(--direction)}`}]}}),s.oi)},30509:function(e,t,i){var a=i(44249),s=i(57243),o=i(15093);(0,a.Z)([(0,o.Mo)("ha-settings-row")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,o.Cb)({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean,reflect:!0})],key:"slim",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean,attribute:"three-line"})],key:"threeLine",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean,attribute:"wrap-heading",reflect:!0})],key:"wrapHeading",value:()=>!1},{kind:"method",key:"render",value:function(){return s.dy` <div class="prefix-wrap"> <slot name="prefix"></slot> <div class="body" ?two-line="${!this.threeLine}" ?three-line="${this.threeLine}"> <slot name="heading"></slot> <div class="secondary"><slot name="description"></slot></div> </div> </div> <div class="content"><slot></slot></div> `}},{kind:"field",static:!0,key:"styles",value:()=>s.iv`:host{display:flex;padding:0 16px;align-content:normal;align-self:auto;align-items:center}.body{padding-top:8px;padding-bottom:8px;padding-left:0;padding-inline-start:0;padding-right:16px;padding-inline-end:16px;overflow:hidden;display:var(--layout-vertical_-_display,flex);flex-direction:var(--layout-vertical_-_flex-direction,column);justify-content:var(--layout-center-justified_-_justify-content,center);flex:var(--layout-flex_-_flex,1);flex-basis:var(--layout-flex_-_flex-basis,0.000000001px)}.body[three-line]{min-height:var(--paper-item-body-three-line-min-height,88px)}:host(:not([wrap-heading])) body>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.body>.secondary{display:block;padding-top:4px;font-family:var(
--mdc-typography-body2-font-family,
var(--mdc-typography-font-family, Roboto, sans-serif)
);-webkit-font-smoothing:antialiased;font-size:var(--mdc-typography-body2-font-size, .875rem);font-weight:var(--mdc-typography-body2-font-weight,400);line-height:normal;color:var(--secondary-text-color)}.body[two-line]{min-height:calc(var(--paper-item-body-two-line-min-height,72px) - 16px);flex:1}.content{display:contents}:host(:not([narrow])) .content{display:var(--settings-row-content-display,flex);justify-content:flex-end;flex:1;padding:16px 0}.content ::slotted(*){width:var(--settings-row-content-width)}:host([narrow]){align-items:normal;flex-direction:column;border-top:1px solid var(--divider-color);padding-bottom:8px}::slotted(ha-switch){padding:16px 0}.secondary{white-space:normal}.prefix-wrap{display:var(--settings-row-prefix-display)}:host([narrow]) .prefix-wrap{display:flex;align-items:center}:host([slim]),:host([slim]) .content,:host([slim]) ::slotted(ha-switch){padding:0}:host([slim]) .body{min-height:0}`}]}}),s.oi)},17170:function(e,t,i){i.a(e,(async function(e,a){try{i.r(t),i.d(t,{HaSpinner:()=>h});var s=i(44249),o=i(72621),n=i(97677),r=i(43580),d=i(57243),l=i(15093),c=e([n]);n=(c.then?(await c)():c)[0];let h=(0,s.Z)([(0,l.Mo)("ha-spinner")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,l.Cb)()],key:"size",value:void 0},{kind:"method",key:"updated",value:function(e){if((0,o.Z)(i,"updated",this,3)([e]),e.has("size"))switch(this.size){case"tiny":this.style.setProperty("--ha-spinner-size","16px");break;case"small":this.style.setProperty("--ha-spinner-size","28px");break;case"medium":this.style.setProperty("--ha-spinner-size","48px");break;case"large":this.style.setProperty("--ha-spinner-size","68px");break;case void 0:this.style.removeProperty("--ha-progress-ring-size")}}},{kind:"field",static:!0,key:"styles",value:()=>[r.Z,d.iv`:host{--indicator-color:var(
--ha-spinner-indicator-color,
var(--primary-color)
);--track-color:var(--ha-spinner-divider-color, var(--divider-color));--track-width:4px;--speed:3.5s;font-size:var(--ha-spinner-size, 48px)}`]}]}}),n.Z);a()}catch(e){a(e)}}))},1888:function(e,t,i){var a=i(44249),s=i(72621),o=i(62523),n=i(83835),r=i(57243),d=i(15093),l=i(13560);(0,a.Z)([(0,d.Mo)("ha-switch")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,d.Cb)({type:Boolean})],key:"haptic",value:()=>!1},{kind:"method",key:"firstUpdated",value:function(){(0,s.Z)(i,"firstUpdated",this,3)([]),this.addEventListener("change",(()=>{this.haptic&&(0,l.j)("light")}))}},{kind:"field",static:!0,key:"styles",value:()=>[n.W,r.iv`:host{--mdc-theme-secondary:var(--switch-checked-color)}.mdc-switch.mdc-switch--checked .mdc-switch__thumb{background-color:var(--switch-checked-button-color);border-color:var(--switch-checked-button-color)}.mdc-switch.mdc-switch--checked .mdc-switch__track{background-color:var(--switch-checked-track-color);border-color:var(--switch-checked-track-color)}.mdc-switch:not(.mdc-switch--checked) .mdc-switch__thumb{background-color:var(--switch-unchecked-button-color);border-color:var(--switch-unchecked-button-color)}.mdc-switch:not(.mdc-switch--checked) .mdc-switch__track{background-color:var(--switch-unchecked-track-color);border-color:var(--switch-unchecked-track-color)}`]}]}}),o.H)},43546:function(e,t,i){i.d(t,{Cp:()=>n,TZ:()=>r,W2:()=>o,YY:()=>l,iI:()=>s,j2:()=>d,oT:()=>a});i(9359),i(70104);const a=e=>e.map((e=>{if("string"!==e.type)return e;switch(e.name){case"username":return{...e,autocomplete:"username",autofocus:!0};case"password":return{...e,autocomplete:"current-password"};case"code":return{...e,autocomplete:"one-time-code",autofocus:!0};default:return e}})),s=(e,t)=>e.callWS({type:"auth/sign_path",path:t}),o=async(e,t,i,a)=>e.callWS({type:"config/auth_provider/homeassistant/create",user_id:t,username:i,password:a}),n=(e,t,i)=>e.callWS({type:"config/auth_provider/homeassistant/change_password",current_password:t,new_password:i}),r=(e,t,i)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_password",user_id:t,password:i}),d=(e,t,i)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_username",user_id:t,username:i}),l=(e,t,i)=>e.callWS({type:"auth/delete_all_refresh_tokens",token_type:t,delete_current_token:i})},78845:function(e,t,i){i.a(e,(async function(e,a){try{i.r(t),i.d(t,{DialogAddUser:()=>y});var s=i(44249),o=i(72621),n=i(57243),r=i(15093),d=(i(99426),i(59826),i(17170)),l=i(73729),c=(i(55486),i(23334),i(30509),i(1888),i(83166),i(43546)),h=i(4242),u=i(28008),p=(i(34326),e([d]));d=(p.then?(await p)():p)[0];let y=(0,s.Z)([(0,r.Mo)("dialog-add-user")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_loading",value:()=>!1},{kind:"field",decorators:[(0,r.SB)()],key:"_error",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_name",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_username",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_password",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_passwordConfirm",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_isAdmin",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_localOnly",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_allowChangeName",value:()=>!0},{kind:"method",key:"showDialog",value:function(e){this._params=e,this._name=this._params.name||"",this._username="",this._password="",this._passwordConfirm="",this._isAdmin=!1,this._localOnly=!1,this._error=void 0,this._loading=!1,this._params.name?(this._allowChangeName=!1,this._maybePopulateUsername()):this._allowChangeName=!0}},{kind:"method",key:"firstUpdated",value:function(e){(0,o.Z)(i,"firstUpdated",this,3)([e]),this.addEventListener("keypress",(e=>{"Enter"===e.key&&this._createUser(e)}))}},{kind:"method",key:"render",value:function(){return this._params?n.dy` <ha-dialog open ="${this._close}" scrimClickAction escapeKeyAction .heading="${(0,l.i)(this.hass,this.hass.localize("ui.panel.config.users.add_user.caption"))}"> <div> ${this._error?n.dy` <div class="error">${this._error}</div> `:""} ${this._allowChangeName?n.dy`<ha-textfield class="name" name="name" .label="${this.hass.localize("ui.panel.config.users.editor.name")}" .value="${this._name}" required .validationMessage="${this.hass.localize("ui.common.error_required")}" ="${this._handleValueChanged}" ="${this._maybePopulateUsername}" dialogInitialFocus></ha-textfield>`:""} <ha-textfield class="username" name="username" .label="${this.hass.localize("ui.panel.config.users.editor.username")}" .value="${this._username}" required ="${this._handleValueChanged}" .validationMessage="${this.hass.localize("ui.common.error_required")}" dialogInitialFocus></ha-textfield> <ha-password-field .label="${this.hass.localize("ui.panel.config.users.add_user.password")}" name="password" .value="${this._password}" required ="${this._handleValueChanged}" .validationMessage="${this.hass.localize("ui.common.error_required")}"></ha-password-field> <ha-password-field .label="${this.hass.localize("ui.panel.config.users.add_user.password_confirm")}" name="passwordConfirm" .value="${this._passwordConfirm}" ="${this._handleValueChanged}" required .invalid="${""!==this._password&&""!==this._passwordConfirm&&this._passwordConfirm!==this._password}" .errorMessage="${this.hass.localize("ui.panel.config.users.add_user.password_not_match")}"></ha-password-field> <ha-settings-row> <span slot="heading"> ${this.hass.localize("ui.panel.config.users.editor.local_access_only")} </span> <span slot="description"> ${this.hass.localize("ui.panel.config.users.editor.local_access_only_description")} </span> <ha-switch .checked="${this._localOnly}" ="${this._localOnlyChanged}"> </ha-switch> </ha-settings-row> <ha-settings-row> <span slot="heading"> ${this.hass.localize("ui.panel.config.users.editor.admin")} </span> <span slot="description"> ${this.hass.localize("ui.panel.config.users.editor.admin_description")} </span> <ha-switch .checked="${this._isAdmin}" ="${this._adminChanged}"> </ha-switch> </ha-settings-row> ${this._isAdmin?n.Ld:n.dy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.users.users_privileges_note")} </ha-alert> `} </div> ${this._loading?n.dy` <div slot="primaryAction" class="submit-spinner"> <ha-spinner></ha-spinner> </div> `:n.dy` <ha-button slot="primaryAction" .disabled="${!this._name||!this._username||!this._password||this._password!==this._passwordConfirm}" ="${this._createUser}"> ${this.hass.localize("ui.panel.config.users.add_user.create")} </ha-button> `} </ha-dialog> `:n.Ld}},{kind:"method",key:"_close",value:function(){this._params=void 0}},{kind:"method",key:"_maybePopulateUsername",value:function(){if(this._username||!this._name)return;const e=this._name.split(" ");e.length&&(this._username=e[0].toLowerCase())}},{kind:"method",key:"_handleValueChanged",value:function(e){this._error=void 0;const t=e.target;this[`_${t.name}`]=t.value}},{kind:"method",key:"_adminChanged",value:async function(e){const t=e.target;this._isAdmin=t.checked}},{kind:"method",key:"_localOnlyChanged",value:function(e){const t=e.target;this._localOnly=t.checked}},{kind:"method",key:"_createUser",value:async function(e){if(e.preventDefault(),!this._name||!this._username||!this._password)return;let t;this._loading=!0,this._error="";try{t=(await(0,h.r4)(this.hass,this._name,[this._isAdmin?h.Pb:h.CE],this._localOnly)).user}catch(e){return this._loading=!1,void(this._error=e.message)}try{await(0,c.W2)(this.hass,t.id,this._username,this._password)}catch(e){return await(0,h.h8)(this.hass,t.id),this._loading=!1,void(this._error=e.message)}t.username=this._username,t.credentials=[{type:"homeassistant"}],this._params.userAddedCallback(t),this._close()}},{kind:"get",static:!0,key:"styles",value:function(){return[u.yu,n.iv`ha-dialog{--mdc-dialog-max-width:500px;--dialog-z-index:10}.row{display:flex;padding:8px 0}ha-password-field,ha-textfield{display:block;margin-bottom:8px}ha-settings-row{padding:0}`]}}]}}),n.oi);a()}catch(e){a(e)}}))}};
//# sourceMappingURL=36265.1ab3b0c6c15e67a9.js.map