"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Label = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _useTheme = require("../theme/use-theme.js");
var _index = require("../typography/index.js");
var _index2 = require("../styles/index.js");
var _tokens = require("../styles/tokens.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const SIZE_FONT = {
  xs: _tokens.fontSize.xs,
  sm: _tokens.fontSize.sm,
  md: _tokens.fontSize.md
};

/**
 * Themed form label. A thin wrapper over Bloom's `Text` that applies the
 * label typography (medium weight, secondary color) and optionally renders a
 * required marker. On web it forwards `htmlFor` so a click focuses the
 * associated control.
 */
const LabelComponent = function Label({
  children,
  nativeID,
  htmlFor,
  required = false,
  disabled = false,
  size = 'sm',
  style,
  testID
}) {
  const theme = (0, _useTheme.useTheme)();
  const webProps = _reactNative.Platform.OS === 'web' ? {
    htmlFor: htmlFor ?? nativeID
  } : {};
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_index.Text, {
    ...webProps,
    nativeID: nativeID,
    testID: testID,
    style: [_index2.atoms.font_medium, _index2.atoms.mb_sm, {
      fontSize: SIZE_FONT[size],
      color: disabled ? theme.colors.textTertiary : theme.colors.textSecondary
    }, style],
    children: [children, required ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Text, {
      accessibilityLabel: "required",
      style: {
        color: theme.colors.negative
      },
      children: ' *'
    }) : null]
  });
};
const Label = exports.Label = /*#__PURE__*/(0, _react.memo)(LabelComponent);
Label.displayName = 'Label';
//# sourceMappingURL=Label.js.map