-- ROBLOX FIXME: these *should* return a function, but they don't. we're misaligned on types and implementation here

local function getReceivedColorForChalkInstance(chalkInstance: Chalk): any --: DiffOptionsColor
	-- return function(_: string): string
	local level = chalkInstance.level

	if level == 3 then
		return chalkInstance.rgb(bForeground3[1], bForeground3[2], bForeground3[3])
			.. chalkInstance.bgRgb(bBackground3[1], bBackground3[2], bBackground3[3])
	end

	if level == 2 then
		return chalkInstance.ansi256(bForeground2) .. chalkInstance.bgAnsi256(bBackground2)
	end

	return chalkInstance.cyan .. chalk.bgWhiteBright -- also known as teal
	-- end
end

local aSnapshotColor = getSnapshotColorForChalkInstance(chalk)
local bReceivedColor = getReceivedColorForChalkInstance(chalk)

local function noColor(string_: string)
	return string_
end

local HINT_ARG = "hint"
local SNAPSHOT_ARG = "snapshot"
local PROPERTIES_ARG = "properties"

local function matcherHintFromConfig(matchSnapshotConfig: MatchSnapshotConfig, isUpdatable: boolean): string
	local context = matchSnapshotConfig.context
	local hint = matchSnapshotConfig.hint
	local inlineSnapshot = matchSnapshotConfig.inlineSnapshot
	local matcherName = matchSnapshotConfig.matcherName
	local properties = matchSnapshotConfig.properties

	local options: MatcherHintOptions = {
		isNot = context.isNot,
		promise = context.promise,
	}
	if isUpdatable then
		options.receivedColor = bReceivedColor
	end

	local expectedArgument = ""

	if typeof(properties) == "table" then
		expectedArgument = PROPERTIES_ARG
		if isUpdatable then
			options.expectedColor = noColor
		end

		if typeof(hint) == "string" and #hint ~= 0 then
			options.secondArgument = HINT_ARG
			options.secondArgumentColor = BOLD_WEIGHT
		elseif typeof(inlineSnapshot) == "string" then
			options.secondArgument = SNAPSHOT_ARG
			if isUpdatable then
				options.secondArgumentColor = aSnapshotColor
			else
				options.secondArgumentColor = noColor
			end
		end
	else
		if typeof(hint) == "string" and #hint ~= 0 then
			expectedArgument = HINT_ARG
			options.expectedColor = BOLD_WEIGHT
		elseif typeof(inlineSnapshot) == "string" then
			expectedArgument = SNAPSHOT_ARG
			if isUpdatable then
				options.expectedColor = aSnapshotColor
			end
		end
	end

	return matcherHint(matcherName, nil, expectedArgument, options)
end
