import { sliceWrap } from "./sliceWrap.js";
function loremIpsum(count = 4, units = "sentences") {
  switch (units) {
    case "words":
      return wordsToSentence(sliceWrap(WORDS, 0, count));
    case "sentences":
      return sliceWrap(SENTENCES, 0, count).map((sentence) => wordsToSentence(sentence.words)).join(" ");
    case "paragraphs":
      return sliceWrap(PARAGRAPHS, 0, count).map((paragraph) => paragraph.sentences.map((sentence) => wordsToSentence(sentence.words)).join(" ")).join("\n");
  }
}
function wordsToSentence(words) {
  let sentence = "";
  for (const word of words) {
    if (sentence.length > 0) sentence += " ";
    sentence += word;
  }
  if (sentence.endsWith(",")) {
    sentence = sentence.slice(0, -1);
  }
  if (sentence.length > 0 && !sentence.endsWith(".")) {
    sentence += ".";
  }
  return sentence;
}
const LOREM_IPSUM = {
  paragraphs: [
    {
      sentences: [
        {
          words: [
            "Lorem",
            "ipsum",
            "dolor",
            "sit",
            "amet,",
            "consectetur",
            "adipiscing",
            "elit,",
            "sed",
            "do",
            "eiusmod",
            "tempor",
            "incididunt",
            "ut",
            "labore",
            "et",
            "dolore",
            "magna",
            "aliqua."
          ]
        },
        {
          words: [
            "Ut",
            "enim",
            "ad",
            "minim",
            "veniam,",
            "quis",
            "nostrud",
            "exercitation",
            "ullamco",
            "laboris",
            "nisi",
            "ut",
            "aliquip",
            "ex",
            "ea",
            "commodo",
            "consequat."
          ]
        },
        {
          words: [
            "Duis",
            "aute",
            "irure",
            "dolor",
            "in",
            "reprehenderit",
            "in",
            "voluptate",
            "velit",
            "esse",
            "cillum",
            "dolore",
            "eu",
            "fugiat",
            "nulla",
            "pariatur."
          ]
        },
        {
          words: [
            "Excepteur",
            "sint",
            "occaecat",
            "cupidatat",
            "non",
            "proident,",
            "sunt",
            "in",
            "culpa",
            "qui",
            "officia",
            "deserunt",
            "mollit",
            "anim",
            "id",
            "est",
            "laborum."
          ]
        }
      ]
    }
  ]
};
const PARAGRAPHS = LOREM_IPSUM.paragraphs;
const SENTENCES = PARAGRAPHS.flatMap((paragraph) => paragraph.sentences);
const WORDS = SENTENCES.flatMap((sentence) => sentence.words);
export {
  loremIpsum
};
