'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { confirmPassword } from 'payload/shared';
import React from 'react';
import { useField } from '../../forms/useField/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { FieldError } from '../FieldError/index.js';
import { FieldLabel } from '../FieldLabel/index.js';
import { fieldBaseClass } from '../shared/index.js';
import './index.scss';
export const ConfirmPasswordField = (props)=>{
    const { disabled: disabledFromProps, path = 'confirm-password' } = props;
    const { t } = useTranslation();
    const { disabled, setValue, showError, value } = useField({
        path,
        validate: (value, options)=>{
            return confirmPassword(value, {
                name: 'confirm-password',
                type: 'text',
                required: true,
                ...options
            });
        }
    });
    return /*#__PURE__*/ _jsxDEV("div", {
        className: [
            fieldBaseClass,
            'confirm-password',
            showError && 'error'
        ].filter(Boolean).join(' '),
        children: [
            /*#__PURE__*/ _jsxDEV(FieldLabel, {
                htmlFor: "field-confirm-password",
                label: t('authentication:confirmPassword'),
                required: true
            }, void 0, false, {
                fileName: "src/fields/ConfirmPassword/index.tsx",
                lineNumber: 40,
                columnNumber: 7
            }, this),
            /*#__PURE__*/ _jsxDEV("div", {
                className: `${fieldBaseClass}__wrap`,
                children: [
                    /*#__PURE__*/ _jsxDEV(FieldError, {
                        path: path
                    }, void 0, false, {
                        fileName: "src/fields/ConfirmPassword/index.tsx",
                        lineNumber: 46,
                        columnNumber: 9
                    }, this),
                    /*#__PURE__*/ _jsxDEV("input", {
                        "aria-label": t('authentication:confirmPassword'),
                        autoComplete: "off",
                        disabled: !!(disabled || disabledFromProps),
                        id: "field-confirm-password",
                        name: "confirm-password",
                        onChange: setValue,
                        type: "password",
                        value: value || ''
                    }, void 0, false, {
                        fileName: "src/fields/ConfirmPassword/index.tsx",
                        lineNumber: 47,
                        columnNumber: 9
                    }, this)
                ]
            }, void 0, true, {
                fileName: "src/fields/ConfirmPassword/index.tsx",
                lineNumber: 45,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/fields/ConfirmPassword/index.tsx",
        lineNumber: 35,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map