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

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js
var require_extractNationalNumberFromPossiblyIncompleteNumber = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports["default"] = extractNationalNumberFromPossiblyIncompleteNumber;
	/**
	* Strips any national prefix (such as 0, 1) present in a
	* (possibly incomplete) number provided.
	* "Carrier codes" are only used  in Colombia and Brazil,
	* and only when dialing within those countries from a mobile phone to a fixed line number.
	* Sometimes it won't actually strip national prefix
	* and will instead prepend some digits to the `number`:
	* for example, when number `2345678` is passed with `VI` country selected,
	* it will return `{ number: "3402345678" }`, because `340` area code is prepended.
	* @param {string} number — National number digits.
	* @param {object} metadata — Metadata with country selected.
	* @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`. Even if a national prefix was extracted, it's not necessarily present in the returned object, so don't rely on its presence in the returned object in order to find out whether a national prefix has been extracted or not.
	*/
	function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
		if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
			var prefixPattern = /* @__PURE__ */ new RegExp("^(?:" + metadata.numberingPlan.nationalPrefixForParsing() + ")");
			var prefixMatch = prefixPattern.exec(number);
			if (prefixMatch) {
				var nationalNumber;
				var carrierCode;
				var capturedGroupsCount = prefixMatch.length - 1;
				var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
				if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
					nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule());
					if (capturedGroupsCount > 1) carrierCode = prefixMatch[1];
				} else {
					var prefixBeforeNationalNumber = prefixMatch[0];
					nationalNumber = number.slice(prefixBeforeNationalNumber.length);
					if (hasCapturedGroups) carrierCode = prefixMatch[1];
				}
				var nationalPrefix;
				if (hasCapturedGroups) {
					var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
					if (number.slice(0, possiblePositionOfTheFirstCapturedGroup) === metadata.numberingPlan.nationalPrefix()) nationalPrefix = metadata.numberingPlan.nationalPrefix();
				} else nationalPrefix = prefixMatch[0];
				return {
					nationalNumber,
					nationalPrefix,
					carrierCode
				};
			}
		}
		return { nationalNumber: number };
	}
}) });

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