"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.validateTimeInput = exports.validateStopwatchTime = exports.validateNumberInput = exports.isValidUrl = void 0;
var _currencyUtils = require("./currencyUtils");
var validateStopwatchTime = exports.validateStopwatchTime = function validateStopwatchTime(value) {
  return /^([0-9]{0,2})?(((:([0-5][0-9])?)|(:[0-5]?))|(\.[0-9]{0,2})|(,[0-9]{0,2}))?$/g.test(value);
};
var validateTimeInput = exports.validateTimeInput = function validateTimeInput(value, withLeadingZero) {
  if (withLeadingZero) {
    return /^(([0-9][0-9]?|[1-9][0-9]{2,8})?(([:,.][0-5][0-9]?)|([:,.][0-5]?)|(\.[0-9]{1,2})|(,[0-9]{1,2}))?)$/.test(value);
  } else {
    return /^(([1-9][0-9]*|0)?(([:,.][0-5][0-9]?)|([:,.][0-5]?)|(\.[0-9]{1,2})|(,[0-9]{1,2}))?)$/.test(value);
  }
};
var validateNumberInput = exports.validateNumberInput = function validateNumberInput(value, disableMacros, decimalSeparator, decimalLength) {
  var limit = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 12;
  if (value.startsWith("00")) {
    return false;
  }
  var numericInput = disableMacros ? value : value.replace(/([0-9.]+)([kmbtKMBT])/, function (_, num, unit) {
    return (parseFloat(num) * _currencyUtils.currencyMultiplier[unit.toLowerCase()]).toString();
  });
  var regexString = "^(-?\\d{0,".concat(limit, "}(?:\\").concat(decimalSeparator, "\\d{0,").concat(decimalLength, "})?)?$");
  return new RegExp(regexString).test(numericInput);
};
var isValidUrl = exports.isValidUrl = function isValidUrl(string) {
  try {
    new URL(string);
    return true;
  } catch (_) {
    return false;
  }
};
//# sourceMappingURL=validation.js.map