-- ROBLOX TODO END


function exports.supportsLookbehinds()
	-- ROBLOX CHECK: do we suppoert lookbehind in Lua?
	-- ROBLOX deviation: no equivalent check in Lua. Returning always false
	return false
end

function exports.isWindows(options: Object?): boolean
	if typeof(options) == "table" and typeof(options.windows) == "boolean" then
		return options.windows
	end
	--[[
		ROBLOX deviation: not using path.sep as it's not available
		original code:
		return win32 === true || path.sep === '\\';
	]]
	return win32 == true
end

function exports.escapeLast(input: string, char: string, lastIdx: number?)
	local idx = String.lastIndexOf(input, char, lastIdx)
	if idx == -1 then
		return input
	end
	if input:sub(idx - 1, idx - 1) == "\\" then
		return exports.escapeLast(input, char, idx - 1)
	end
	return ("%s%s"):format(String.slice(input, 1, idx), String.slice(input, idx))
end

function exports.removePrefix(input: string, state_: Object?)
	local state: Object = state_ or {}

	local output = input
	if String.startsWith(output, "./") then
		output = String.slice(output, 3)
		state.prefix = "./"
	end
	return output
end
function exports.wrapOutput(input, state_: Object?, options_: Object?)
	local state: Object = state_ or {}
	local options: Object = options_ or {}

	local prepend = if Boolean.toJSBoolean(options.contains) then "" else "^"
	local append = if Boolean.toJSBoolean(options.contains) then "" else "$"

	local output = ("%s(?:%s)%s"):format(prepend, input, append)
	if state.negated == true then
		output = ("(?:^(?!%s).*$)"):format(output)
	end
	return output
end

return exports
