{"version":3,"file":"text.cjs","names":[],"sources":["../src/text/declension.ts","../src/text/split-text-by-lines.ts"],"sourcesContent":["/**\n * Returns the correct word form based on the provided count.\n * @example\n * declension(1, ['slovo', 'slova', 'slov']) // 'slovo'\n * @example\n * declension(2, ['slovo', 'slova', 'slov']) // 'slova'\n * @example\n * declension(5, ['slovo', 'slova', 'slov']) // 'slov'\n */\nexport const declension = (\n  count: number,\n  txt: readonly [one: string, two: string, five: string],\n  cases = [2, 0, 1, 1, 1, 2],\n) =>\n  txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];\n","/**\n * Splits text into lines with a maximum line length.\n */\nexport const splitTextByLines = (\n  text: string,\n  lineLingth: number = 60,\n): string[] => {\n  const words = text.split(/\\s+/).filter((word) => word !== '');\n  const lines = [];\n  let currentLine = '';\n\n  for (const word of words) {\n    if (word.length > lineLingth) {\n      if (currentLine !== '') {\n        lines.push(currentLine);\n        currentLine = '';\n      }\n\n      let start = 0;\n      while (start < word.length) {\n        const chunk = word.slice(start, start + lineLingth);\n        lines.push(chunk);\n        start += lineLingth;\n      }\n      continue;\n    }\n\n    // Проверка возможности добавления слова в текущую строку\n    if (currentLine === '') {\n      currentLine = word;\n    } else if (currentLine.length + 1 + word.length <= lineLingth) {\n      currentLine += ` ${word}`;\n    } else {\n      lines.push(currentLine);\n      currentLine = word;\n    }\n  }\n\n  if (currentLine !== '' || lines.length === 0) {\n    lines.push(currentLine);\n  }\n\n  return lines;\n};\n"],"mappings":";;;;;;;;;;;AASA,IAAa,cACX,OACA,KACA,QAAQ;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC,MAEzB,IAAI,QAAQ,MAAM,KAAK,QAAQ,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,QAAQ,IAAI,CAAC;;;;;;ACX5E,IAAa,oBACX,MACA,aAAqB,OACR;CACb,MAAM,QAAQ,KAAK,MAAM,KAAK,EAAE,QAAQ,SAAS,SAAS,EAAE;CAC5D,MAAM,QAAQ,CAAC;CACf,IAAI,cAAc;CAElB,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,SAAS,YAAY;GAC5B,IAAI,gBAAgB,IAAI;IACtB,MAAM,KAAK,WAAW;IACtB,cAAc;GAChB;GAEA,IAAI,QAAQ;GACZ,OAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,QAAQ,KAAK,MAAM,OAAO,QAAQ,UAAU;IAClD,MAAM,KAAK,KAAK;IAChB,SAAS;GACX;GACA;EACF;EAGA,IAAI,gBAAgB,IAClB,cAAc;OACT,IAAI,YAAY,SAAS,IAAI,KAAK,UAAU,YACjD,eAAe,IAAI;OACd;GACL,MAAM,KAAK,WAAW;GACtB,cAAc;EAChB;CACF;CAEA,IAAI,gBAAgB,MAAM,MAAM,WAAW,GACzC,MAAM,KAAK,WAAW;CAGxB,OAAO;AACT"}