const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.js');
const require_checkNumberLength$1 = require('./checkNumberLength.js');
const require_matchesEntirely$1 = require('./matchesEntirely.js');
const require_extractNationalNumberFromPossiblyIncompleteNumber$1 = require('./extractNationalNumberFromPossiblyIncompleteNumber.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractNationalNumber.js
var require_extractNationalNumber = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractNationalNumber.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports["default"] = extractNationalNumber;
	var _extractNationalNumberFromPossiblyIncompleteNumber = _interopRequireDefault(require_extractNationalNumberFromPossiblyIncompleteNumber$1.require_extractNationalNumberFromPossiblyIncompleteNumber());
	var _matchesEntirely = _interopRequireDefault(require_matchesEntirely$1.require_matchesEntirely());
	var _checkNumberLength = _interopRequireDefault(require_checkNumberLength$1.require_checkNumberLength());
	function _interopRequireDefault(obj) {
		return obj && obj.__esModule ? obj : { "default": obj };
	}
	/**
	* Strips national prefix and carrier code from a complete phone number.
	* The difference from the non-"FromCompleteNumber" function is that
	* it won't extract national prefix if the resultant number is too short
	* to be a complete number for the selected phone numbering plan.
	* @param  {string} number — Complete phone number digits.
	* @param  {Metadata} metadata — Metadata with a phone numbering plan selected.
	* @return {object} `{ nationalNumber: string, carrierCode: string? }`.
	*/
	function extractNationalNumber(number, metadata) {
		var _extractNationalNumbe = (0, _extractNationalNumberFromPossiblyIncompleteNumber["default"])(number, metadata), carrierCode = _extractNationalNumbe.carrierCode, nationalNumber = _extractNationalNumbe.nationalNumber;
		if (nationalNumber !== number) {
			if (!shouldHaveExtractedNationalPrefix(number, nationalNumber, metadata)) return { nationalNumber: number };
			if (metadata.possibleLengths()) {
				if (!isPossibleIncompleteNationalNumber(nationalNumber, metadata)) return { nationalNumber: number };
			}
		}
		return {
			nationalNumber,
			carrierCode
		};
	}
	function shouldHaveExtractedNationalPrefix(nationalNumberBefore, nationalNumberAfter, metadata) {
		if ((0, _matchesEntirely["default"])(nationalNumberBefore, metadata.nationalNumberPattern()) && !(0, _matchesEntirely["default"])(nationalNumberAfter, metadata.nationalNumberPattern())) return false;
		return true;
	}
	function isPossibleIncompleteNationalNumber(nationalNumber, metadata) {
		switch ((0, _checkNumberLength["default"])(nationalNumber, metadata)) {
			case "TOO_SHORT":
			case "INVALID_LENGTH": return false;
			default: return true;
		}
	}
}) });

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