{"version":3,"file":"util.capture-relevant-comments.cjs","sources":["../../../../src/rules/limit-single-line-comments/util.capture-relevant-comments.ts"],"sourcesContent":["import type { TSESLint, TSESTree } from \"@typescript-eslint/utils\";\n\nimport type { Context } from \"../../typings.context.js\";\nimport { isLineOverflowing } from \"../../utils/is-line-overflowing.js\";\nimport { isCommentOnOwnLine } from \"../../utils/is-on-own-line.js\";\nimport { isSemanticComment } from \"../../utils/is-semantic-comment.js\";\n\nimport type { CommentBlock } from \"./typings.block.js\";\nimport { mergeComments } from \"./util.merge-comments.js\";\n\nexport function captureRelevantCommentsIntoBlock(\n  sourceCode: TSESLint.SourceCode,\n  comments: TSESTree.LineComment[],\n  startIndex: number,\n  context: Context,\n): CommentBlock {\n  let comment = comments[startIndex];\n\n  if (!comment) {\n    return { mergedComment: undefined, startIndex, endIndex: startIndex };\n  }\n\n  let endIndex = startIndex;\n\n  for (let i = startIndex + 1; i < comments.length; i++) {\n    const nextComment = comments[i];\n\n    if (\n      (context.mode === \"overflow-only\" &&\n        !isLineOverflowing(comment.value, context)) ||\n      !nextComment ||\n      nextComment.value.trim() === \"\" ||\n      nextComment.loc?.start.line !== (comment.loc?.end.line ?? 0) + 1 ||\n      isSemanticComment(nextComment, context.semanticComments) ||\n      !isCommentOnOwnLine(sourceCode, nextComment)\n    ) {\n      break;\n    }\n\n    comment = mergeComments(comment, nextComment);\n    endIndex = i;\n  }\n\n  return { mergedComment: comment, startIndex, endIndex };\n}\n"],"names":["isLineOverflowing","isSemanticComment","isCommentOnOwnLine","mergeComments"],"mappings":";;;;;;;AAUO,SAAS,gCAAA,CACd,UAAA,EACA,QAAA,EACA,UAAA,EACA,OAAA,EACc;AACd,EAAA,IAAI,OAAA,GAAU,SAAS,UAAU,CAAA;AAEjC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAO,EAAE,aAAA,EAAe,MAAA,EAAW,UAAA,EAAY,UAAU,UAAA,EAAW;AAAA,EACtE;AAEA,EAAA,IAAI,QAAA,GAAW,UAAA;AAEf,EAAA,KAAA,IAAS,IAAI,UAAA,GAAa,CAAA,EAAG,CAAA,GAAI,QAAA,CAAS,QAAQ,CAAA,EAAA,EAAK;AACrD,IAAA,MAAM,WAAA,GAAc,SAAS,CAAC,CAAA;AAE9B,IAAA,IACG,OAAA,CAAQ,IAAA,KAAS,eAAA,IAChB,CAACA,oCAAkB,OAAA,CAAQ,KAAA,EAAO,OAAO,CAAA,IAC3C,CAAC,WAAA,IACD,WAAA,CAAY,KAAA,CAAM,IAAA,OAAW,EAAA,IAC7B,WAAA,CAAY,GAAA,EAAK,KAAA,CAAM,UAAU,OAAA,CAAQ,GAAA,EAAK,GAAA,CAAI,IAAA,IAAQ,KAAK,CAAA,IAC/DC,mCAAA,CAAkB,WAAA,EAAa,OAAA,CAAQ,gBAAgB,CAAA,IACvD,CAACC,8BAAA,CAAmB,UAAA,EAAY,WAAW,CAAA,EAC3C;AACA,MAAA;AAAA,IACF;AAEA,IAAA,OAAA,GAAUC,gCAAA,CAAc,SAAS,WAAW,CAAA;AAC5C,IAAA,QAAA,GAAW,CAAA;AAAA,EACb;AAEA,EAAA,OAAO,EAAE,aAAA,EAAe,OAAA,EAAS,UAAA,EAAY,QAAA,EAAS;AACxD;;;;"}