"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var NumberInput_exports = {};
__export(NumberInput_exports, {
  default: () => NumberInput_default
});
module.exports = __toCommonJS(NumberInput_exports);
var import_react = __toESM(require("react"));
var import_BaseInput = __toESM(require("../BaseInput"));
var import_Flex = __toESM(require("../../layout/Flex"));
var import_Text = __toESM(require("../../asorted/Text"));
var import_styled_components = __toESM(require("styled-components"));
const MaxButton = import_styled_components.default.button`
  color: ${(p) => p.active ? p.theme.colors.neutral.c00 : p.theme.colors.neutral.c70};
  background-color: ${(p) => p.active ? p.theme.colors.neutral.c100 : p.theme.colors.neutral.c00};
  border-radius: 100px;
  border-width: 0;
  height: 31px;
  padding-left: 13px;
  padding-right: 13px;
  cursor: pointer;

  &:disabled {
    color: ${(p) => p.theme.colors.neutral.c50};
    background-color: ${(p) => p.active ? p.theme.colors.neutral.c30 : "transparent"};
    cursor: unset;
  }
`;
function serialize(value) {
  return value ? "" + value : "";
}
function deserialize(value) {
  try {
    return parseFloat(value);
  } catch (error) {
    return void 0;
  }
}
function NumberInput({
  value,
  onPercentClick,
  max,
  disabled,
  ...inputProps
}, ref) {
  return /* @__PURE__ */ import_react.default.createElement(
    import_BaseInput.default,
    {
      ref,
      serialize,
      deserialize,
      ...inputProps,
      type: "number",
      value,
      max,
      disabled,
      renderRight: /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { alignItems: "center", justifyContent: "center", py: "3px", mr: "8px" }, [0.25, 0.5, 0.75, 1].map((percent) => /* @__PURE__ */ import_react.default.createElement(
        MaxButton,
        {
          key: percent,
          onClick: () => onPercentClick(percent),
          active: !!value && !!max && Number(value) === percent * Number(max),
          disabled
        },
        /* @__PURE__ */ import_react.default.createElement(import_Text.default, { variant: "tiny", color: "inherit" }, percent * 100, "%")
      )))
    }
  );
}
var NumberInput_default = import_react.default.forwardRef(NumberInput);
//# sourceMappingURL=index.js.map
