{"version":3,"file":"text.es.mjs","names":[],"sources":["../src/text/normalizeText.ts","../src/text/normalizeTextForSearch.ts","../src/text/truncateText.ts"],"sourcesContent":["// Zero-width characters that JS's \\s does not match but that creep into\n// CMS-pasted content: zero-width space (U+200B), non-joiner (U+200C), joiner\n// (U+200D) and the byte-order mark (U+FEFF). Built from code points to keep the\n// source strictly ASCII.\nconst ZERO_WIDTH_PATTERN = new RegExp('\\\\u200B|\\\\u200C|\\\\u200D|\\\\uFEFF', 'g')\n\n/**\n * Normalizes text for case-insensitive comparison and matching.\n *\n * Lowercases, trims, strips zero-width characters, and collapses all remaining\n * whitespace (which `\\s` already covers, including NBSP and ideographic spaces)\n * into single ASCII spaces, so visually-identical strings compare equal.\n * @param {string | null | undefined} text - The text to normalize.\n * @returns {string} The normalized text.\n */\nexport const normalizeText = (text: string | null | undefined): string => {\n  if (!text) return ''\n\n  return text\n    .toLowerCase()\n    .trim()\n    .replace(ZERO_WIDTH_PATTERN, '')\n    .replace(/\\s+/g, ' ')\n}\n","import { stripHtmlTags } from '../html/stripHtmlTags'\nimport { normalizeText } from './normalizeText'\n\n// Punctuation removed before indexing so \"alpha-beta\" and \"alpha beta\" match.\nconst PUNCTUATION_PATTERN = /[.,!?;:\"'()[\\]\\-_/\\\\]/g\n\n/**\n * Produces a plain, normalized search string from possibly-HTML content.\n *\n * Strips tags, removes punctuation, then applies the shared text normalization\n * (lowercase, zero-width removal, whitespace collapse). Suitable for building\n * full-text indexes (e.g. lunr) or matching free-text queries.\n * @param {string | null | undefined} html - Content that may contain HTML.\n * @returns {string} The normalized, tag-free search text.\n */\nexport const normalizeTextForSearch = (\n  html: string | null | undefined,\n): string =>\n  normalizeText(stripHtmlTags(html ?? '').replace(PUNCTUATION_PATTERN, ' '))\n","/**\n * Truncates text to a maximum length, replacing the overflow with an ellipsis.\n *\n * The returned string is at most `maxLength` characters (the ellipsis takes the\n * last slot). An absent value yields an empty string; a value already within\n * the limit is returned unchanged.\n * @param {string | null | undefined} text - The text to truncate.\n * @param {number} maxLength - The maximum length of the result, including the ellipsis.\n * @returns {string} The truncated text.\n */\nexport const truncateText = (\n  text: string | null | undefined,\n  maxLength: number,\n): string => {\n  if (!text) return ''\n  if (text.length <= maxLength) return text\n\n  return `${text.substring(0, maxLength - 1)}…`\n}\n"],"mappings":";;AAIA,IAAM,IAAqB,gBAAI,OAAO,mCAAmC,GAAG,GAW/D,KAAiB,MACvB,IAEE,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,GAAoB,EAAE,EAC9B,QAAQ,QAAQ,GAAG,IANJ,ICZd,IAAsB,0BAWf,KACX,MAEA,EAAc,EAAc,KAAQ,EAAE,EAAE,QAAQ,GAAqB,GAAG,CAAC,GCR9D,KACX,GACA,MAEK,IACD,EAAK,UAAU,IAAkB,IAE9B,GAAG,EAAK,UAAU,GAAG,IAAY,CAAC,EAAE,KAHzB"}