"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
require("clsx");
const styles = require("../../utils/styles.cjs");
const index = require("../Typography/index.cjs");
const TextInput$1 = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/TextInput/TextInput.cjs");
const getSize = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/core/utils/get-size/get-size.cjs");
const TextInput = React.forwardRef((props, ref) => {
  const {
    leftLabel,
    leftLabelProps,
    leftAddon,
    rightAddon,
    leftAddonProps,
    rightAddonProps,
    leftSection,
    rightLabel,
    rightLabelProps,
    rightSection,
    ...rest
  } = props;
  const withLeftAddon = !!(leftLabel || leftAddon);
  const withRightAddon = !!(rightLabel || rightAddon);
  return /* @__PURE__ */ jsxRuntime.jsx(
    TextInput$1.TextInput,
    {
      ...rest,
      styles: styles.mergeStylesList([
        (theme) => {
          if (!withLeftAddon && !withRightAddon) {
            return {};
          }
          const sectionBaseStyles = {
            position: "initial",
            width: "fit-content",
            border: `1px solid ${theme.colors.carbon[4]}`,
            backgroundColor: theme.colors.carbon[2],
            paddingLeft: 12,
            paddingRight: 12,
            "& > .mantine-Text-root": {
              fontSize: getSize.getFontSize(props.size ?? "md")
            }
          };
          const wrapperBaseStyles = {
            "--input-padding-inline-start": "var(--input-padding)"
          };
          return {
            wrapper: {
              display: "flex",
              // see https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/core/src/components/Input/Input.module.css#L70C4-L70C33I
              // correct input left padding
              "&[data-with-left-section]": withLeftAddon ? wrapperBaseStyles : void 0,
              "&[data-with-right-section]": withRightAddon ? wrapperBaseStyles : void 0
            },
            section: {
              '&[data-position="left"]': withLeftAddon ? {
                ...sectionBaseStyles,
                borderRightWidth: 0,
                borderTopLeftRadius: theme.defaultRadius,
                borderBottomLeftRadius: theme.defaultRadius
              } : void 0,
              '&[data-position="right"]': withRightAddon ? {
                ...sectionBaseStyles,
                borderLeftWidth: 0,
                borderTopRightRadius: theme.defaultRadius,
                borderBottomRightRadius: theme.defaultRadius
              } : void 0
            },
            input: {
              flex: 1,
              ...withLeftAddon ? {
                borderTopLeftRadius: 0,
                borderBottomLeftRadius: 0
              } : void 0,
              ...withRightAddon ? {
                borderTopRightRadius: 0,
                borderBottomRightRadius: 0
              } : void 0
            }
          };
        },
        props.styles
      ]),
      leftSection: !!withLeftAddon ? /* @__PURE__ */ jsxRuntime.jsx(index.Typography, { variant: "label-lg", ...leftLabelProps || leftAddonProps, children: leftLabel || leftAddon }) : leftSection,
      rightSection: !!withRightAddon ? /* @__PURE__ */ jsxRuntime.jsx(index.Typography, { variant: "label-lg", ...rightLabelProps || rightAddonProps, children: rightLabel || rightAddon }) : rightSection,
      ref
    }
  );
});
exports.TextInput = TextInput;
