import { jsxs, jsx } from 'react/jsx-runtime';
import { Y as YearlessDateInputWithPicker } from './YearlessDateInputWithPicker-DyytWt0x.js';
import { useRef, useId, isValidElement } from 'react';
import { F as FieldLabel } from './FieldLabel-DZWu5dMp.js';
import { w as warnDeprecatedErrorUsage } from './utils-CM48ODEJ.js';
import { t as textFieldStyles } from './TextField.module-MRVo1X9H.js';
import { c as cx } from './index-De1g9FRV.js';
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-CB_zHDbW.js';
import { c as childrenToString } from './childrenToString-Bz9MqbHb.js';
import { useTrackingId } from './useTrackingId.js';
import { w as warnOnce } from './warnOnce-Y9PRHcU4.js';
import { s as stripInlineMarkdown } from './stripInlineMarkdown-BWbMy7r_.js';
import { H as Helper } from './Helper-DtDeaYTn.js';

const DateFieldYearless = (props) => {
  const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
  const {
    value,
    defaultValue,
    minDate,
    maxDate,
    unavailable,
    required,
    disablePicker = false,
    mode = "mm/dd",
    error,
    errorAriaLive: _errorAriaLive,
    label,
    moreInfo,
    size,
    disabled,
    loading,
    labelProps,
    warning,
    description,
    id: idProp,
    style,
    disableHint = false,
    hideLabel = false,
    onFocus,
    onBlur,
    className,
    onChange,
    ...restProps
  } = componentProps;
  const inputRef = useRef(null);
  const { aiMark, ...labelPropsWithoutAiMark } = labelProps || {};
  const data = {
    label: childrenToString(props.label),
    labelProps: labelPropsWithoutAiMark,
    description: childrenToString(props.description)
  };
  const trackingId = useTrackingId({
    name: "DateFieldYearless",
    data,
    hasOverride: !!props["data-tracking-id"]
  });
  const labelUid = useId();
  const id = idProp ?? labelUid;
  const helperUid = useId();
  const moreInfoUid = useId();
  warnDeprecatedErrorUsage("DateFieldYearless", error);
  if (label === void 0) {
    warnOnce(
      "DateFieldYearless: label will be required in v4.0.0. Use hideLabel to visually hide the label."
    );
  } else if (typeof label !== "string") {
    warnOnce(
      "DateFieldYearless: Passing ReactNode to label is deprecated. Use a plain string with inline markdown instead."
    );
  }
  const errorMessages = typeof error === "boolean" || error === void 0 ? void 0 : error;
  const styleCombined = { ...style, ...layoutStyles };
  const ariaDescribedBy = [helperUid, moreInfo && moreInfoUid].filter(Boolean).join(" ");
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: cx(textFieldStyles["textfield"], className),
      "data-anv": "datefield-yearless",
      style: styleCombined,
      children: [
        label && !hideLabel && /* @__PURE__ */ jsx(
          FieldLabel,
          {
            moreInfo,
            moreInfoId: moreInfo ? moreInfoUid : void 0,
            required,
            htmlFor: id,
            ...labelProps,
            children: label
          }
        ),
        /* @__PURE__ */ jsx(
          YearlessDateInputWithPicker,
          {
            ...restProps,
            ref: inputRef,
            mode,
            required,
            minDate,
            maxDate,
            unavailable,
            disablePicker,
            size,
            error: !!error,
            disabled,
            loading,
            id,
            "data-tracking-id": trackingId,
            "aria-describedby": ariaDescribedBy,
            "aria-invalid": error ? !!error : void 0,
            "aria-label": (
              // TODO(v4.0.0): remove typeof check — label will always be string
              hideLabel && typeof label === "string" ? stripInlineMarkdown(label) : label ? void 0 : "Select a date"
            ),
            value,
            defaultValue,
            onChange,
            onFocus,
            onBlur
          }
        ),
        errorMessages || warning || description || !disableHint && mode ? /* @__PURE__ */ jsx(
          Helper,
          {
            id: helperUid,
            hint: disableHint ? void 0 : `Format: ${mode}`,
            showCounter: false,
            error: typeof errorMessages === "string" || Array.isArray(errorMessages) ? errorMessages : void 0,
            warning,
            errorMessage: isValidElement(errorMessages) ? errorMessages : void 0,
            description
          }
        ) : null
      ]
    }
  );
};
DateFieldYearless.displayName = "DateFieldYearless";

export { DateFieldYearless as D };
//# sourceMappingURL=DateFieldYearless-DHNVc7Sd.js.map
