--[[*
 * Create a regular expression from a parsed glob pattern.
 *
 * ```js
 * const picomatch = require('picomatch');
 * const state = picomatch.parse('*.js');
 * // picomatch.compileRe(state[, options]);
 *
 * console.log(picomatch.compileRe(state));
 * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
 * ```
 * @param {String} `state` The object returned from the `.parse` method.
 * @param {Object} `options`
 * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
 * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
 * @return {RegExp} Returns a regex created from the given pattern.
 * @api public
 ]]


function picomatch.makeRe(input: string, options_: Object?, returnOutput_: boolean?, returnState_: boolean?): RegExp
	local options: Object = options_ or {}
	local returnOutput = returnOutput_ or false
	local returnState = returnState_ or false

	if not Boolean.toJSBoolean(input) or typeof(input) ~= "string" then
		error(Error.new("TypeError: Expected a non-empty string"))
	end

	local parsed = { negated = false, fastpaths = true }

	if options.fastpaths ~= false and (string.sub(input, 1, 1) == "." or string.sub(input, 1, 1) == "*") then
		parsed.output = parse.fastpaths(input, options)
	end

	if not Boolean.toJSBoolean(parsed.output) then
		parsed = parse(input, options)
	end

	return picomatch.compileRe(parsed, options, returnOutput, returnState)
end
