import { createContext, useContext } from 'react';
import { jsx } from 'react/jsx-runtime';

const FieldLabelIdContext = /*#__PURE__*/createContext(undefined);
const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
const InputIdContext = /*#__PURE__*/createContext(undefined);
const InputIdContextProvider = InputIdContext.Provider;
const InputDescribedByContext = /*#__PURE__*/createContext(undefined);
const InputDescribedByProvider = InputDescribedByContext.Provider;
const InputInvalidContext = /*#__PURE__*/createContext(undefined);
const InputInvalidProvider = InputInvalidContext.Provider;
function useInputAttributes({
  nonLabelable
} = {}) {
  const labelId = useContext(FieldLabelIdContext);
  return {
    id: useContext(InputIdContext),
    'aria-labelledby': nonLabelable ? labelId : undefined,
    'aria-describedby': useContext(InputDescribedByContext),
    'aria-invalid': useContext(InputInvalidContext)
  };
}
function withInputAttributes(Component, args) {
  function ComponentWithInputAttributes(props) {
    return /*#__PURE__*/jsx(Component, {
      inputAttributes: useInputAttributes(args),
      ...props
    });
  }
  ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
  return ComponentWithInputAttributes;
}

export { FieldLabelIdContextProvider, InputDescribedByProvider, InputIdContextProvider, InputInvalidProvider, useInputAttributes, withInputAttributes };
//# sourceMappingURL=contexts.mjs.map
