{"version":3,"sources":["../../../src/lib/toTitleCase.ts"],"names":[],"mappings":";;;;;;AAAA,IAAM,aAAgB,GAAA,uBAAA;AAef,IAAM,4BAAuD,GAAA;AAAA,EACnE,WAAa,EAAA,aAAA;AAAA,EACb,YAAc,EAAA,cAAA;AAAA,EACd,eAAiB,EAAA,iBAAA;AAAA,EACjB,WAAa,EAAA;AACd;AAcO,SAAS,WAAY,CAAA,GAAA,EAAa,OAA8B,GAAA,EAAY,EAAA;AAClF,EAAA,MAAM,EAAE,kBAAA,GAAqB,EAAC,EAAG,eAAkB,GAAA,OAAA;AACnD,EAAA,MAAM,iBAAoB,GAAA;AAAA,IACzB,GAAG,4BAAA;AAAA,IACH,GAAI,aACD,GAAA,kBAAA,GACA,MAAO,CAAA,OAAA,CAAQ,kBAAkB,CAAE,CAAA,MAAA;AAAA,MACnC,CAAC,QAAA,EAAU,CAAC,GAAA,EAAK,OAAO,CAAO,MAAA,EAAE,GAAG,QAAA,EAAU,CAAC,GAAA,CAAI,WAAY,EAAC,GAAG,OAAQ,EAAA,CAAA;AAAA,MAC3E;AAAC;AACF,GACH;AAEA,EAAA,OAAO,GAAI,CAAA,OAAA;AAAA,IACV,aAAA;AAAA,IACA,CAAC,GAAK,KAAA;AAhDR,MAAA,IAAA,EAAA;AAgDW,MAAA,OAAA,CAAA,EAAA,GAAA,iBAAA,CAAkB,gBAAgB,GAAM,GAAA,GAAA,CAAI,WAAY,EAAC,MAAzD,IAA8D,GAAA,EAAA,GAAA,GAAA,CAAI,MAAO,CAAA,CAAC,EAAE,WAAY,EAAA,GAAI,IAAI,SAAU,CAAA,CAAC,EAAE,WAAY,EAAA;AAAA;AAAA,GACnI;AACD;AAhBgB,MAAA,CAAA,WAAA,EAAA,aAAA,CAAA","file":"toTitleCase.cjs","sourcesContent":["const TO_TITLE_CASE = /[A-Za-zÀ-ÖØ-öø-ÿ]\\S*/g;\n\n/**\n * The variants that will not strictly follow the `toTitleCase` algorithm\n * and will instead return the value matched with the key.\n *\n * This table lists how certain terms are converted.\n * Any terms not included are converted to regular `Titlecase`.\n * |       Term       |   Converted To   |\n * |:---------------- |:---------------- |\n * | textchannel      | TextChannel      |\n * | voicechannel     | VoiceChannel     |\n * | categorychannel  | CategoryChannel  |\n * | guildmember      | GuildMember      |\n */\nexport const toTitleCaseDiscordJsVariants: Record<string, string> = {\n\ttextchannel: 'TextChannel',\n\tvoicechannel: 'VoiceChannel',\n\tcategorychannel: 'CategoryChannel',\n\tguildmember: 'GuildMember'\n};\n\n/**\n * Converts a string to Title Case\n *\n * @description This is designed to also ensure common Discord PascalCased strings\n * are put in their TitleCase {@link toTitleCaseDiscordJsVariants}.\n *\n * You can also provide your own variants to merge with the {@link toTitleCaseDiscordJsVariants} for\n * your own functionality use.\n *\n * @param str The string to title case\n * @param options The options to use when converting the string\n */\nexport function toTitleCase(str: string, options: ToTitleCaseOptions = {}): string {\n\tconst { additionalVariants = {}, caseSensitive } = options;\n\tconst titleCaseVariants = {\n\t\t...toTitleCaseDiscordJsVariants,\n\t\t...(caseSensitive\n\t\t\t? additionalVariants\n\t\t\t: Object.entries(additionalVariants).reduce<Record<string, string>>(\n\t\t\t\t\t(variants, [key, variant]) => ({ ...variants, [key.toLowerCase()]: variant }),\n\t\t\t\t\t{}\n\t\t\t\t))\n\t};\n\n\treturn str.replace(\n\t\tTO_TITLE_CASE,\n\t\t(txt) => titleCaseVariants[caseSensitive ? txt : txt.toLowerCase()] ?? txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()\n\t);\n}\n\n/**\n * The options to use when converting a string to title case\n */\nexport interface ToTitleCaseOptions {\n\t/**\n\t * The optional additional variants to use when converting the string\n\t */\n\tadditionalVariants?: Record<string, string>;\n\n\t/**\n\t * Whether to convert the string to title case in a case sensitive manner.\n\t */\n\tcaseSensitive?: boolean;\n}\n"]}