import type * as Diff2Html from 'diff2html'
import HoganJsUtils from 'diff2html/lib/hoganjs-utils'
import { get } from 'lodash-es'
import type { CommentItem } from 'components/CommentBox/CommentBox'
import type { TypesPullReqActivity } from 'services/code'
import type { DiffFileEntry } from 'utils/types'
export enum ViewStyle {
SIDE_BY_SIDE = 'side-by-side',
LINE_BY_LINE = 'line-by-line'
}
export enum CommentType {
COMMENT = 'comment',
CODE_COMMENT = 'code-comment',
TITLE_CHANGE = 'title-change',
REVIEW_SUBMIT = 'review-submit',
MERGE = 'merge',
BRANCH_UPDATE = 'branch-update',
STATE_CHANGE = 'state-change'
}
/**
* @deprecated
*/
export interface PullRequestCodeCommentPayload {
type: CommentType
version: string // used to avoid rendering old payload structure
file_id: string // unique id of the changed file
file_title: string
language: string
is_on_left: boolean // comment made on the left side pane
at_line_number: number
line_number_range: number[]
range_text_content: string // raw text content where the comment is made
diff_html_snapshot: string // snapshot used to render diff in comment (PR Conversation). Could be used to send email notification too (with more work on capturing CSS styles and put them inline)
}
export const DIFF_VIEWER_HEADER_HEIGHT = 36
// const DIFF_MAX_CHANGES = 100
// const DIFF_MAX_LINE_LENGTH = 100
export interface DiffCommentItem {
left: boolean
right: boolean
lineNumber: number
height: number
commentItems: CommentItem[]
filePath: string
}
export const DIFF2HTML_CONFIG = {
outputFormat: 'side-by-side',
drawFileList: false,
fileListStartVisible: false,
fileContentToggle: true,
// diffMaxChanges: DIFF_MAX_CHANGES,
// diffMaxLineLength: DIFF_MAX_LINE_LENGTH,
// diffTooBigMessage: index => `${index} - is too big`,
matching: 'lines',
synchronisedScroll: true,
highlight: true,
renderNothingWhenEmpty: false,
compiledTemplates: {
'generic-line': HoganJsUtils.compile(`