/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const DEDICATED_PAGE_DOCLET_KINDS = [
	'module', 'class', 'typedef', 'mixin', 'interface', 'namespace'
];

/**
 * Set of utils used in helpers to generate links to API definitions.
 */
module.exports = {
	/**
	 * A regular expression used for extracting a member name from doclet full name, member of or just a name.
	 */
	MEMBER_NAME_REGEXP: /([{}\-\w$]+)(?::([A-Z0-9a-z_:{}]+))?$/,
	//                               ^ Sync with the `LONG_NAME_LABEL_REGEXP` value.

	/**
	 * A regular expression used for removing a label (if specified) from a member name.
	 * The regexp is used in `MEMBER_NAME_REGEXP` as a group, so the particular group should be synced.
	 */
	LONG_NAME_LABEL_REGEXP: /(?::([A-Z0-9a-z_:{}]+))?$/,

	/**
	 * A regular expression used for separating a definition (a class, an interface, etc.) and a member name.
	 */
	LONG_NAME_MEMBER_SEPARATOR_REGEXP: /[#.]/,

	/**
	 * @param {Object} doclet
	 * @param {String} doclet.kind
	 * @returns {Boolean}
	 */
	hasDedicatedApiPages( doclet ) {
		return DEDICATED_PAGE_DOCLET_KINDS.includes( doclet.kind );
	}
};
