-- jest --expand
--
-- Given array of aligned strings with inverse highlight formatting,
-- return joined lines with diff formatting.

local function joinAlignedDiffsExpand(diffs: Array<Diff>, options: DiffOptionsNormalized): string
	return table.concat(
		Array.map(diffs, function(diff, i: number, diffs_: { [number]: any }): string
			local line = diff[2]
			-- ROBLOX deviation: 1-indexing
			local isFirstOrLast = i == 1 or i == #diffs_

			local case = diff[1]
			if case == DIFF_DELETE then
				return printDeleteLine(line, isFirstOrLast, options)
			elseif case == DIFF_INSERT then
				return printInsertLine(line, isFirstOrLast, options)
			else
				return printCommonLine(line, isFirstOrLast, options)
			end
		end),
		"\n"
	)
end

return {
	joinAlignedDiffsNoExpand = joinAlignedDiffsNoExpand,
	joinAlignedDiffsExpand = joinAlignedDiffsExpand,
}
