const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.js');
const require_parseDigits$1 = require('./helpers/parseDigits.js');
const require_checkNumberLength$1 = require('./helpers/checkNumberLength.js');
const require_formatNationalNumberUsingFormat$1 = require('./helpers/formatNationalNumberUsingFormat.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/AsYouTypeFormatter.complete.js
var require_AsYouTypeFormatter_complete = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/AsYouTypeFormatter.complete.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.canFormatCompleteNumber = canFormatCompleteNumber;
	exports["default"] = formatCompleteNumber;
	var _checkNumberLength = _interopRequireDefault(require_checkNumberLength$1.require_checkNumberLength());
	var _parseDigits = _interopRequireDefault(require_parseDigits$1.require_parseDigits());
	var _formatNationalNumberUsingFormat = _interopRequireDefault(require_formatNationalNumberUsingFormat$1.require_formatNationalNumberUsingFormat());
	function _interopRequireDefault(obj) {
		return obj && obj.__esModule ? obj : { "default": obj };
	}
	function formatCompleteNumber(state, format, _ref) {
		var metadata = _ref.metadata, shouldTryNationalPrefixFormattingRule = _ref.shouldTryNationalPrefixFormattingRule, getSeparatorAfterNationalPrefix = _ref.getSeparatorAfterNationalPrefix;
		if (new RegExp("^(?:".concat(format.pattern(), ")$")).test(state.nationalSignificantNumber)) return formatNationalNumberWithAndWithoutNationalPrefixFormattingRule(state, format, {
			metadata,
			shouldTryNationalPrefixFormattingRule,
			getSeparatorAfterNationalPrefix
		});
	}
	function canFormatCompleteNumber(nationalSignificantNumber, metadata) {
		return (0, _checkNumberLength["default"])(nationalSignificantNumber, metadata) === "IS_POSSIBLE";
	}
	function formatNationalNumberWithAndWithoutNationalPrefixFormattingRule(state, format, _ref2) {
		var metadata = _ref2.metadata, shouldTryNationalPrefixFormattingRule = _ref2.shouldTryNationalPrefixFormattingRule, getSeparatorAfterNationalPrefix = _ref2.getSeparatorAfterNationalPrefix;
		state.nationalSignificantNumber;
		state.international;
		state.nationalPrefix;
		state.carrierCode;
		if (shouldTryNationalPrefixFormattingRule(format)) {
			var formattedNumber = formatNationalNumber(state, format, {
				useNationalPrefixFormattingRule: true,
				getSeparatorAfterNationalPrefix,
				metadata
			});
			if (formattedNumber) return formattedNumber;
		}
		return formatNationalNumber(state, format, {
			useNationalPrefixFormattingRule: false,
			getSeparatorAfterNationalPrefix,
			metadata
		});
	}
	function formatNationalNumber(state, format, _ref3) {
		var metadata = _ref3.metadata, useNationalPrefixFormattingRule = _ref3.useNationalPrefixFormattingRule, getSeparatorAfterNationalPrefix = _ref3.getSeparatorAfterNationalPrefix;
		var formattedNationalNumber = (0, _formatNationalNumberUsingFormat["default"])(state.nationalSignificantNumber, format, {
			carrierCode: state.carrierCode,
			useInternationalFormat: state.international,
			withNationalPrefix: useNationalPrefixFormattingRule,
			metadata
		});
		if (!useNationalPrefixFormattingRule) {
			if (state.nationalPrefix) formattedNationalNumber = state.nationalPrefix + getSeparatorAfterNationalPrefix(format) + formattedNationalNumber;
			else if (state.complexPrefixBeforeNationalSignificantNumber) formattedNationalNumber = state.complexPrefixBeforeNationalSignificantNumber + " " + formattedNationalNumber;
		}
		if (isValidFormattedNationalNumber(formattedNationalNumber, state)) return formattedNationalNumber;
	}
	function isValidFormattedNationalNumber(formattedNationalNumber, state) {
		return (0, _parseDigits["default"])(formattedNationalNumber) === state.getNationalDigits();
	}
}) });

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