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AC,cAAc,CAAC,CAAC,CAAC,SAAS,GAAI,CACjD,CACT,CAAC;IAEF,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAE,OAAgB,EAAE,EAAE;QAC9D,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACxC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CACpB,IAAC,gBAAgB,oBACZ,KAAK,IACT,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,GAAG,EAAC,MAAM,EACV,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,EACxC,KAAK,EAAE,KAAK,CAAC,OAAO,CACnB,YAAY,EACZ,GAAG,CACH,uBAEK,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAE,QAAQ,IACX,CACnB,CAAC,CAAC,CAAC,CACH,IAAC,SAAS,oBACL,KAAK,IACT,GAAG,EAAC,MAAM,EACV,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,EACxC,KAAK,EAAE,KAAK,CAAC,OAAO,CACnB,YAAY,EACZ,GAAG,CACH,EACD,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,uBAEpB,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAE,QAAQ,IAClB,CACZ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC","sourcesContent":["import { createICacheMiddleware } from '@dojo/framework/core/middleware/icache';\nimport { create, tsx } from '@dojo/framework/core/vdom';\nimport Icon from '../icon';\nimport ConstrainedInput, { ConstrainedInputProperties } from '../constrained-input';\nimport theme from '../middleware/theme';\nimport * as css from '../theme/default/password-input.m.css';\nimport * as textInputCss from '../theme/default/text-input.m.css';\nimport TextInput, { TextInputChildren } from '../text-input';\nimport { ValidationRules } from '../middleware/validation';\n\nexport type Omit<T, E> = Pick<T, Exclude<keyof T, E>>;\n\nexport interface PasswordInputProperties\n\textends Omit<ConstrainedInputProperties, 'type' | 'rules'> {\n\trules?: ValidationRules;\n}\n\nexport interface PasswordInputState {\n\tshowPassword: boolean;\n\tvalid: { valid?: boolean; message?: string } | undefined;\n}\n\nconst factory = create({\n\ticache: createICacheMiddleware<PasswordInputState>(),\n\ttheme\n})\n\t.properties<PasswordInputProperties>()\n\t.children<TextInputChildren | undefined>();\n\nexport const PasswordInput = factory(function PasswordInput({\n\tmiddleware: { theme, icache },\n\tproperties,\n\tchildren\n}) {\n\tconst props = properties();\n\tconst showPassword = icache.getOrSet('showPassword', false);\n\tconst classes = theme.classes(css);\n\n\tconst trailing = (\n\t\t<button\n\t\t\tonclick={(e) => {\n\t\t\t\te.stopPropagation();\n\t\t\t\ticache.set('showPassword', !showPassword);\n\t\t\t}}\n\t\t\tclasses={classes.toggleButton}\n\t\t\ttype=\"button\"\n\t\t>\n\t\t\t<Icon type={showPassword ? 'eyeSlashIcon' : 'eyeIcon'} />\n\t\t</button>\n\t);\n\n\tconst handleValidation = (valid?: boolean, message?: string) => {\n\t\ticache.set('valid', { valid, message });\n\t\tprops.onValidate && props.onValidate(valid);\n\t};\n\n\treturn props.rules ? (\n\t\t<ConstrainedInput\n\t\t\t{...props}\n\t\t\trules={props.rules}\n\t\t\tkey=\"root\"\n\t\t\ttype={showPassword ? 'text' : 'password'}\n\t\t\ttheme={theme.compose(\n\t\t\t\ttextInputCss,\n\t\t\t\tcss\n\t\t\t)}\n\t\t>\n\t\t\t{{ ...children()[0], trailing }}\n\t\t</ConstrainedInput>\n\t) : (\n\t\t<TextInput\n\t\t\t{...props}\n\t\t\tkey=\"root\"\n\t\t\ttype={showPassword ? 'text' : 'password'}\n\t\t\ttheme={theme.compose(\n\t\t\t\ttextInputCss,\n\t\t\t\tcss\n\t\t\t)}\n\t\t\tonValidate={handleValidation}\n\t\t\tvalid={icache.get('valid')}\n\t\t>\n\t\t\t{{ ...children()[0], trailing }}\n\t\t</TextInput>\n\t);\n});\n\nexport default PasswordInput;\n"]}