"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MultiInputDateField = MultiInputDateField;
exports.default = void 0;
var _DateInput = _interopRequireDefault(require("./DateInput"));
var _defaultDateFormatter = _interopRequireDefault(require("./defaultDateFormatter"));
var _cleanFieldProps = _interopRequireDefault(require("../utilities/cleanFieldProps"));
var _classnames = _interopRequireDefault(require("classnames"));
var _describeField = _interopRequireDefault(require("../utilities/describeField"));
var _useId = _interopRequireDefault(require("../utilities/useId"));
var _Label = require("../Label");
var _i18n = require("../i18n");
var _useLabelProps = require("../Label/useLabelProps");
var _useHint = require("../Hint/useHint");
var _useInlineError = require("../InlineError/useInlineError");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
 * For information about how and when to use this component,
 * [refer to its full documentation page](https://design.cms.gov/components/date-field/multi-input-date-field/).
 */
function MultiInputDateField(props) {
  const id = (0, _useId.default)('date-field--', props.id);
  const {
    errorId,
    topError,
    bottomError,
    invalid
  } = (0, _useInlineError.useInlineError)({
    ...props,
    id
  });
  const {
    hintId,
    hintElement
  } = (0, _useHint.useHint)({
    hint: (0, _i18n.t)('dateField.hint'),
    ...props,
    id
  });
  const labelProps = (0, _useLabelProps.useLabelProps)({
    label: (0, _i18n.t)('dateField.label'),
    ...props,
    id
  });
  const fieldProps = {
    dayName: 'day',
    monthName: 'month',
    yearName: 'year',
    dateFormatter: _defaultDateFormatter.default,
    ...(0, _cleanFieldProps.default)(props),
    id,
    language: (0, _i18n.getLanguage)()
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
    "aria-invalid": invalid,
    "aria-describedby": (0, _describeField.default)({
      ...props,
      hintId,
      errorId
    }),
    className: (0, _classnames.default)('ds-c-fieldset', props.className),
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Label.Label, {
      component: "legend",
      ...labelProps
    }), hintElement, topError, /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateInput.default, {
      ...fieldProps
    }), bottomError]
  });
}
var _default = exports.default = MultiInputDateField;