text: const advancedDetermine = require("@hugoalh/advanced-determine");
  const undefinish = require("@hugoalh/undefinish");
  /**
   * @private
   * @function changeCaseSwap
   * @param {string} item
   * @returns {string}
   */
  function changeCaseSwap(item) {
  	return item.split("").map((itemElement) => {
  		if (advancedDetermine.isString(itemElement, { lowerCase: true }) === true) {
  			return itemElement.toUpperCase();
  		};
  		if (advancedDetermine.isString(itemElement, { upperCase: true }) === true) {
  			return itemElement.toLowerCase();
  		};
  		return itemElement;
  	}).join("");
  };
  /**
   * @function changeCase
   * @description Change string case.
   * @param {string} item String that need to change case.
   * @param {object} [option={}] Option.
   * @param {boolean} [option.allowNonAlphabetCharacters=false] Allow non alphabet characters.
   * @param {string} [option.case] Preset of case style.
   * @param {string} [option.delimiter="-"] Delimiter between words.
   * @param {boolean} [option.upperCaseFirstWordFirstCharacter=false] Change the first word first character to upper case or not.
   * @param {boolean} [option.upperCaseFirstWordOtherCharacters=false] Change the first word other characters to upper case or not.
   * @param {boolean} [option.upperCaseOtherWordsFirstCharacter=false] Change the other words first character to upper case or not.
   * @param {boolean} [option.upperCaseOtherWordsOtherCharacters=false] Change the other words other characters to upper case or not.
   * @returns {string} A case-changed string.
   */
  function changeCase(item, option = {}) {
  	if (advancedDetermine.isString(item, { allowWhitespaces: false }) !== true) {
  		throw new TypeError(`Argument \`item\` must be type of string (non-nullable)!`);
  	};
  	if (advancedDetermine.isPlainObject(option) === false) {
  		throw new TypeError(`Argument \`option\` must be type of plain object!`);
  	};
  	option.allowNonAlphabetCharacters = undefinish(option.allowNonAlphabetCharacters, option.allowNonAlphabetCharacter, false);
  	if (typeof option.allowNonAlphabetCharacters !== "boolean") {
  		throw new TypeError(`Argument \`option.allowNonAlphabetCharacters\` must be type of boolean!`);
  	};
  	if (option.allowNonAlphabetCharacters === true && item.search(/[^a-z]/giu) !== -1) {
  		console.warn(`Function \`changeCase\` is not fully supported non alphabet characters, and maybe return an unexpected result!`);
  	};
  	option.delimiter = undefinish(option.delimiter, "-");
  	if (advancedDetermine.isString(option.delimiter) !== true) {
  		throw new TypeError(`Argument \`option.delimiter\` must be type of string (non-nullable)!`);
  	};
  	option.upperCaseFirstWordFirstCharacter = undefinish(option.upperCaseFirstWordFirstCharacter, false);
  	if (typeof option.upperCaseFirstWordFirstCharacter !== "boolean") {
  		throw new TypeError(`Argument \`option.upperCaseFirstWordFirstCharacter\` must be type of boolean!`);
  	};
  	option.upperCaseFirstWordOtherCharacters = undefinish(option.upperCaseFirstWordOtherCharacters, option.upperCaseFirstWordOtherCharacter, false);
  	if (typeof option.upperCaseFirstWordOtherCharacters !== "boolean") {
  		throw new TypeError(`Argument \`option.upperCaseFirstWordOtherCharacters\` must be type of boolean!`);
  	};
  	option.upperCaseOtherWordsFirstCharacter = undefinish(option.upperCaseOtherWordsFirstCharacter, option.upperCaseOtherWordFirstCharacter, false);
  	if (typeof option.upperCaseOtherWordsFirstCharacter !== "boolean") {
  		throw new TypeError(`Argument \`option.upperCaseOtherWordsFirstCharacter\` must be type of boolean!`);
  	};
  	option.upperCaseOtherWordsOtherCharacters = undefinish(option.upperCaseOtherWordsOtherCharacters, option.upperCaseOtherWordOtherCharacter, false);
  	if (typeof option.upperCaseOtherWordsOtherCharacters !== "boolean") {
  		throw new TypeError(`Argument \`option.upperCaseOtherWordsOtherCharacters\` must be type of boolean!`);
  	};
  	if (typeof option.case !== "undefined") {
  		if (advancedDetermine.isString(option.case) !== true) {
  			throw new TypeError(`Argument \`option.case\` must be type of string (non-nullable) or undefined!`);
  		};
  		if (option.case.search(/^capital(?:-?case)?$/giu) === 0) {
  			option.delimiter = " ";
  			option.upperCaseFirstWordFirstCharacter = true;
  			option.upperCaseFirstWordOtherCharacters = false;
  			option.upperCaseOtherWordsFirstCharacter = true;
  			option.upperCaseOtherWordsOtherCharacters = false;
  		} else if (option.case.search(/^const(?:ant)?(?:-?case)?$/giu) === 0) {
  			option.delimiter = "_";
  			option.upperCaseFirstWordFirstCharacter = true;
  			option.upperCaseFirstWordOtherCharacters = true;
  			option.upperCaseOtherWordsFirstCharacter = true;
  			option.upperCaseOtherWordsOtherCharacters = true;
  		} else if (option.case.search(/^(?:dash|hyphen)(?:-?case)?$/giu) === 0) {
  			option.delimiter = "-";
  			option.upperCaseFirstWordFirstCharacter = false;
  			option.upperCaseFirstWordOtherCharacters = false;
  			option.upperCaseOtherWordsFirstCharacter = false;
  			option.upperCaseOtherWordsOtherCharacters = false;
  		} else if (option.case.search(/^(?:dromedary|(?:low(?:er)?-?)?camel)(?:-?case)?$/giu) === 0) {
  			option.delimiter = "";
  			option.upperCaseFirstWordFirstCharacter = false;
  			option.upperCaseFirstWordOtherCharacters = false;
  			option.upperCaseOtherWordsFirstCharacter = true;
  			option.upperCaseOtherWordsOtherCharacters = false;
  		} else if (option.case.search(/^(?:pascal|up(?:per)?-?camel)(?:-?case)?$/giu) === 0) {
  			option.delimiter = "";
  			option.upperCaseFirstWordFirstCharacter = true;
  			option.upperCaseFirstWordOtherCharacters = false;
  			option.upperCaseOtherWordsFirstCharacter = true;
  			option.upperCaseOtherWordsOtherCharacters = false;
  		} else if (option.case.search(/^(?:snak|underscor)e(?:-?case)?$/giu) === 0) {
  			option.delimiter = "_";
  			option.upperCaseFirstWordFirstCharacter = false;
  			option.upperCaseFirstWordOtherCharacters = false;
  			option.upperCaseOtherWordsFirstCharacter = false;
  			option.upperCaseOtherWordsOtherCharacters = false;
  		} else if (option.case.search(/^swap(?:-?case)?$/giu) === 0) {
  			return changeCaseSwap(item);
  		} else {
  			throw new SyntaxError(`Argument \`option.case\`'s value is not in the list!`);
  		};
  	}
  	let result = item.replace(/(?<upper>[A-Z])/gu, " $<upper>").replace(((option.allowNonAlphabetCharacters === false) ? /(?:[^a-z]+)/giu : /[-_\n\r\s]+/giu), " ").trim().split(" ").map((itemElement) => {
  		return itemElement.toLowerCase();
  	}).map((itemElement, itemIndex) => {
  		let first = itemElement.charAt(0);
  		let other = itemElement.slice(1);
  		if (itemIndex === 0) {
  			return `${(option.upperCaseFirstWordFirstCharacter === true) ? first.toUpperCase() : first.toLowerCase()}${(option.upperCaseFirstWordOtherCharacters === true) ? other.toUpperCase() : other.toLowerCase()}`;
  		};
  		return `${(option.upperCaseOtherWordsFirstCharacter === true) ? first.toUpperCase() : first.toLowerCase()}${(option.upperCaseOtherWordsOtherCharacters === true) ? other.toUpperCase() : other.toLowerCase()}`;
  	}).join(option.delimiter);
  	while (option.delimiter.length > 0 && result.search(`${option.delimiter}${option.delimiter}`) !== -1) {
  		result = result.replace(`${option.delimiter}${option.delimiter}`, option.delimiter);
  	};
  	return result;
  };
  module.exports = changeCase;
  