const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/AsYouTypeFormatter.util.js
var require_AsYouTypeFormatter_util = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/AsYouTypeFormatter.util.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.closeNonPairedParens = closeNonPairedParens;
	exports.countOccurences = countOccurences;
	exports.cutAndStripNonPairedParens = cutAndStripNonPairedParens;
	exports.populateTemplateWithDigits = populateTemplateWithDigits;
	exports.repeat = repeat;
	exports.stripNonPairedParens = stripNonPairedParens;
	function _createForOfIteratorHelperLoose(o, allowArrayLike) {
		var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
		if (it) return (it = it.call(o)).next.bind(it);
		if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
			if (it) o = it;
			var i = 0;
			return function() {
				if (i >= o.length) return { done: true };
				return {
					done: false,
					value: o[i++]
				};
			};
		}
		throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
	}
	function _unsupportedIterableToArray(o, minLen) {
		if (!o) return;
		if (typeof o === "string") return _arrayLikeToArray(o, minLen);
		var n = Object.prototype.toString.call(o).slice(8, -1);
		if (n === "Object" && o.constructor) n = o.constructor.name;
		if (n === "Map" || n === "Set") return Array.from(o);
		if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
	}
	function _arrayLikeToArray(arr, len) {
		if (len == null || len > arr.length) len = arr.length;
		for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
		return arr2;
	}
	var DIGIT_PLACEHOLDER = "x";
	exports.DIGIT_PLACEHOLDER = DIGIT_PLACEHOLDER;
	var DIGIT_PLACEHOLDER_MATCHER = new RegExp(DIGIT_PLACEHOLDER);
	function countOccurences(symbol, string) {
		var count = 0;
		for (var _iterator = _createForOfIteratorHelperLoose(string.split("")), _step; !(_step = _iterator()).done;) if (_step.value === symbol) count++;
		return count;
	}
	function repeat(string, times) {
		if (times < 1) return "";
		var result = "";
		while (times > 1) {
			if (times & 1) result += string;
			times >>= 1;
			string += string;
		}
		return result + string;
	}
	function cutAndStripNonPairedParens(string, cutBeforeIndex) {
		if (string[cutBeforeIndex] === ")") cutBeforeIndex++;
		return stripNonPairedParens(string.slice(0, cutBeforeIndex));
	}
	function closeNonPairedParens(template, cut_before) {
		var retained_template = template.slice(0, cut_before);
		var dangling_braces = countOccurences("(", retained_template) - countOccurences(")", retained_template);
		while (dangling_braces > 0 && cut_before < template.length) {
			if (template[cut_before] === ")") dangling_braces--;
			cut_before++;
		}
		return template.slice(0, cut_before);
	}
	function stripNonPairedParens(string) {
		var dangling_braces = [];
		var i = 0;
		while (i < string.length) {
			if (string[i] === "(") dangling_braces.push(i);
			else if (string[i] === ")") dangling_braces.pop();
			i++;
		}
		var start = 0;
		var cleared_string = "";
		dangling_braces.push(string.length);
		for (var _i = 0, _dangling_braces = dangling_braces; _i < _dangling_braces.length; _i++) {
			var index = _dangling_braces[_i];
			cleared_string += string.slice(start, index);
			start = index + 1;
		}
		return cleared_string;
	}
	function populateTemplateWithDigits(template, position, digits) {
		for (var _iterator2 = _createForOfIteratorHelperLoose(digits.split("")), _step2; !(_step2 = _iterator2()).done;) {
			var digit = _step2.value;
			if (template.slice(position + 1).search(DIGIT_PLACEHOLDER_MATCHER) < 0) return;
			position = template.search(DIGIT_PLACEHOLDER_MATCHER);
			template = template.replace(DIGIT_PLACEHOLDER_MATCHER, digit);
		}
		return [template, position];
	}
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_AsYouTypeFormatter_util();
  }
});