const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.js');
const require_constants$1 = require('../constants.js');
const require_util$1 = require('./util.js');
const require_utf_8$1 = require('./utf-8.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/findNumbers/isValidCandidate.js
var require_isValidCandidate = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/findNumbers/isValidCandidate.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports["default"] = isValidCandidate;
	var _constants = require_constants$1.require_constants();
	var _util = require_util$1.require_util();
	var _utf = require_utf_8$1.require_utf_8();
	var OPENING_PARENS = "(\\[（［";
	var CLOSING_PARENS = ")\\]）］";
	var NON_PARENS = "[^".concat(OPENING_PARENS).concat(CLOSING_PARENS, "]");
	var LEAD_CLASS = "[".concat(OPENING_PARENS).concat(_constants.PLUS_CHARS, "]");
	exports.LEAD_CLASS = LEAD_CLASS;
	var LEAD_CLASS_LEADING = /* @__PURE__ */ new RegExp("^" + LEAD_CLASS);
	var BRACKET_PAIR_LIMIT = (0, _util.limit)(0, 3);
	/**
	* Pattern to check that brackets match. Opening brackets should be closed within a phone number.
	* This also checks that there is something inside the brackets. Having no brackets at all is also
	* fine.
	*
	* An opening bracket at the beginning may not be closed, but subsequent ones should be.  It's
	* also possible that the leading bracket was dropped, so we shouldn't be surprised if we see a
	* closing bracket first. We limit the sets of brackets in a phone number to four.
	*/
	var MATCHING_BRACKETS_ENTIRE = /* @__PURE__ */ new RegExp("^(?:[" + OPENING_PARENS + "])?(?:" + NON_PARENS + "+[" + CLOSING_PARENS + "])?" + NON_PARENS + "+(?:[" + OPENING_PARENS + "]" + NON_PARENS + "+[" + CLOSING_PARENS + "])" + BRACKET_PAIR_LIMIT + NON_PARENS + "*$");
	/**
	* Matches strings that look like publication pages. Example:
	* <pre>Computing Complete Answers to Queries in the Presence of Limited Access Patterns.
	* Chen Li. VLDB J. 12(3): 211-227 (2003).</pre>
	*
	* The string "211-227 (2003)" is not a telephone number.
	*/
	var PUB_PAGES = /\d{1,5}-+\d{1,5}\s{0,4}\(\d{1,4}/;
	function isValidCandidate(candidate, offset, text, leniency) {
		if (!MATCHING_BRACKETS_ENTIRE.test(candidate) || PUB_PAGES.test(candidate)) return;
		if (leniency !== "POSSIBLE") {
			if (offset > 0 && !LEAD_CLASS_LEADING.test(candidate)) {
				var previousChar = text[offset - 1];
				if ((0, _utf.isInvalidPunctuationSymbol)(previousChar) || (0, _utf.isLatinLetter)(previousChar)) return false;
			}
			var lastCharIndex = offset + candidate.length;
			if (lastCharIndex < text.length) {
				var nextChar = text[lastCharIndex];
				if ((0, _utf.isInvalidPunctuationSymbol)(nextChar) || (0, _utf.isLatinLetter)(nextChar)) return false;
			}
		}
		return true;
	}
}) });

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