'use strict';

var React = require('react');
var FormField = require('./FormField-cjs.js');
require('classnames');
require('./tslib.es6-cjs.js');
require('react-hook-form');
require('@jobber/hooks');
require('framer-motion');
require('@jobber/design');
require('./Button-cjs.js');

function InputPassword(props) {
    const { hasVisibility = false } = props;
    const [visible, setVisibility] = React.useState(false);
    return (React.createElement(FormField.FormField, Object.assign({}, props, (hasVisibility && {
        suffix: {
            ariaLabel: visible ? "Hide password" : "Show password",
            icon: visible ? "eye" : "eyeCrossed",
            onClick: () => setVisibility(!visible),
        },
    }), { type: visible ? "text" : "password", onChange: handleChange })));
    function handleChange(newValue) {
        props.onChange && props.onChange(newValue);
    }
}

exports.InputPassword = InputPassword;
