'use strict';

var React = require('react');
var jsxRuntime = require('react/jsx-runtime');

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

exports.FieldLabelIdContextProvider = FieldLabelIdContextProvider;
exports.InputDescribedByProvider = InputDescribedByProvider;
exports.InputIdContextProvider = InputIdContextProvider;
exports.InputInvalidProvider = InputInvalidProvider;
exports.useInputAttributes = useInputAttributes;
exports.withInputAttributes = withInputAttributes;
//# sourceMappingURL=contexts.js.map
