"use strict";var Z=Object.create;var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var se=Object.getPrototypeOf;var te=Object.prototype.hasOwnProperty;var I=(t,e)=>l(t,"name",{value:e,configurable:true});var oe=(t,e)=>{for(var s in e)l(t,s,{get:e[s],enumerable:true})};var x=(t,e,s,o)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let r of ee(e))if(!te.call(t,r)&&r!==s)l(t,r,{get:()=>e[r],enumerable:!(o=v(e,r))||o.enumerable})}return t};var n=(t,e,s)=>(s=t!=null?Z(se(t)):{},x(e||!t||!t.__esModule?l(s,"default",{value:t,enumerable:true}):s,t));var re=t=>x(l({},"__esModule",{value:true}),t);var T=(t,e,s,o)=>{var r=o>1?void 0:o?v(e,s):e;for(var i=t.length-1,p;i>=0;i--)if(p=t[i])r=(o?p(e,s,r):p(r))||r;if(o&&r)l(e,s,r);return r};var ie={};oe(ie,{default:()=>ne});module.exports=re(ie);var a=require("react/jsx-runtime");var f=require("@mdi/js");var c=n(require("classnames"));var d=require("lodash");var C=require("mobx-react");var u=require("react");var h=require("react-intl");var M=n(require("react-jss"));var S=require("../../../jsUtils");var N=n(require("../error"));var L=n(require("../icon"));var F=n(require("../label"));var K=n(require("../wrapper"));var H=require("./scorePassword");var R=n(require("./styles"));const ae=(0,h.defineMessages)({passwordToggle:{id:"settings.app.form.passwordToggle",defaultMessage:"Password toggle"}});let m=class extends u.Component{inputElement=(0,u.createRef)();constructor(e){super(e);this.state={passwordScore:0,showPassword:false}}componentDidMount(){const{focus:e=false,data:s={}}=this.props;if(this.inputElement?.current){if(e){this.inputElement.current.focus()}for(const o of Object.keys(s)){this.inputElement.current.dataset[o]=s[o]}}}onChange(e){const{scorePassword:s,onChange:o=d.noop}=this.props;o(e);if(s){this.setState({passwordScore:(0,H.scorePasswordFunc)(e.target.value)})}}onInputKeyPress(e){if((0,S.isEnterKeyPress)(e.key)){const{onEnterKey:s=d.noop}=this.props;s()}}render(){const{classes:e,className:s,error:o,id:r,inputClassName:i,label:p,prefix:g,suffix:w,value:k,name:O,placeholder:W,spellCheck:$,min:j,max:D,step:q,required:z,noMargin:A,onBlur:B=d.noop,onFocus:_=d.noop,scorePassword:U=false,showLabel:y=true,showPasswordToggle:G=false,type:b="text",disabled:E=false,readOnly:J,intl:Q}=this.props;const{showPassword:V,passwordScore:P}=this.state;const X=b==="password"&&V?"text":b;return(0,a.jsxs)(K.default,{className:s,identifier:"franz-input",noMargin:A,children:[p&&y&&(0,a.jsx)(F.default,{title:p,showLabel:y,htmlFor:r,className:e.label,isRequired:z}),(0,a.jsxs)("div",{className:(0,c.default)({[`${i}`]:i,[`${e.wrapper}`]:true,[`${e.disabled}`]:E,[`${e.hasError}`]:o}),children:[g&&(0,a.jsx)("span",{className:e.prefix,children:g}),(0,a.jsx)("input",{id:r,type:X,name:O,value:k,placeholder:W,spellCheck:$,className:e.input,ref:this.inputElement,onChange:this.onChange.bind(this),onFocus:_,onBlur:B,disabled:E,onKeyUp:this.onInputKeyPress.bind(this),min:j,max:D,step:q,readOnly:J}),w&&(0,a.jsx)("span",{className:e.suffix,children:w}),G&&(0,a.jsx)("button",{type:"button",className:(0,c.default)({"franz-form__input-modifier":true}),onClick:()=>this.setState(Y=>({showPassword:!Y.showPassword})),tabIndex:-1,"aria-label":Q.formatMessage(ae.passwordToggle),children:(0,a.jsx)(L.default,{icon:this.state.showPassword?f.mdiEye:f.mdiEyeOff})})]}),U&&(0,a.jsx)("div",{className:(0,c.default)({[`${e.passwordScore}`]:true,[`${e.hasError}`]:o}),children:(0,a.jsx)("meter",{value:P<5?5:P,low:30,high:75,optimum:100,max:100})}),o&&(0,a.jsx)(N.default,{message:o})]})}};I(m,"Input");m=T([C.observer],m);var ne=(0,h.injectIntl)((0,M.default)(R.default,{injectTheme:true})(m));
