const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.js');
const require_metadata$1 = require('../metadata.js');
const require_getCountryCallingCode$1 = require('../getCountryCallingCode.js');
const require_checkNumberLength$1 = require('./checkNumberLength.js');
const require_matchesEntirely$1 = require('./matchesEntirely.js');
const require_extractNationalNumber$1 = require('./extractNationalNumber.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js
var require_extractCountryCallingCodeFromInternationalNumberWithoutPlusSign = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports["default"] = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign;
	var _metadata = _interopRequireDefault(require_metadata$1.require_metadata());
	var _matchesEntirely = _interopRequireDefault(require_matchesEntirely$1.require_matchesEntirely());
	var _extractNationalNumber = _interopRequireDefault(require_extractNationalNumber$1.require_extractNationalNumber());
	var _checkNumberLength = _interopRequireDefault(require_checkNumberLength$1.require_checkNumberLength());
	var _getCountryCallingCode = _interopRequireDefault(require_getCountryCallingCode$1.require_getCountryCallingCode());
	function _interopRequireDefault(obj) {
		return obj && obj.__esModule ? obj : { "default": obj };
	}
	/**
	* Sometimes some people incorrectly input international phone numbers
	* without the leading `+`. This function corrects such input.
	* @param  {string} number — Phone number digits.
	* @param  {string?} country
	* @param  {string?} callingCode
	* @param  {object} metadata
	* @return {object} `{ countryCallingCode: string?, number: string }`.
	*/
	function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
		var countryCallingCode = country ? (0, _getCountryCallingCode["default"])(country, metadata) : callingCode;
		if (number.indexOf(countryCallingCode) === 0) {
			metadata = new _metadata["default"](metadata);
			metadata.selectNumberingPlan(country, callingCode);
			var possibleShorterNumber = number.slice(countryCallingCode.length);
			var possibleShorterNationalNumber = (0, _extractNationalNumber["default"])(possibleShorterNumber, metadata).nationalNumber;
			var nationalNumber = (0, _extractNationalNumber["default"])(number, metadata).nationalNumber;
			if (!(0, _matchesEntirely["default"])(nationalNumber, metadata.nationalNumberPattern()) && (0, _matchesEntirely["default"])(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || (0, _checkNumberLength["default"])(nationalNumber, metadata) === "TOO_LONG") return {
				countryCallingCode,
				number: possibleShorterNumber
			};
		}
		return { number };
	}
}) });

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