"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/hooks/useNumberInput/utils/fixedDecimalValue.ts
function fixedDecimalValue(value, decimalSeparator, fixedDecimalLength) {
  if (decimalSeparator.length !== 1) {
    throw new Error("decimalSeparator must be a single character.");
  }
  const decimalIndex = value.indexOf(decimalSeparator);
  if (fixedDecimalLength === void 0) {
    return value;
  }
  if (decimalIndex === -1) {
    const paddedDecimals = "0".repeat(fixedDecimalLength);
    return `${value}${decimalSeparator}${paddedDecimals}`;
  }
  const integerPart = value.substring(0, decimalIndex);
  let decimalPart = value.substring(decimalIndex + 1);
  if (decimalPart === "") {
    decimalPart = "0".repeat(fixedDecimalLength);
    return `${integerPart}${decimalSeparator}${decimalPart}`;
  }
  const currentDecimalLength = decimalPart.length;
  if (currentDecimalLength < fixedDecimalLength) {
    const paddingLength = fixedDecimalLength - currentDecimalLength;
    const paddedDecimal = decimalPart + "0".repeat(paddingLength);
    return `${integerPart}${decimalSeparator}${paddedDecimal}`;
  } else if (currentDecimalLength > fixedDecimalLength) {
    const trimmedDecimal = decimalPart.substring(0, fixedDecimalLength);
    return `${integerPart}${decimalSeparator}${trimmedDecimal}`;
  } else {
    return value;
  }
}



exports.fixedDecimalValue = fixedDecimalValue;
