local function Q(Q,R,Y)return function(...)local n,x=wpcallPacked(Q,...)local D=x[1]if D then R(unpack(x,2,n))else Y(unpack(x,2,n))end end end local function R(Q)return next(Q)==nil end local function Y(Q)assert(type(Q)=="\115\116\114\105\110\103","\099\114\101\097\116\101\083\121\109\098\111\108 \114\101\113\117\105\114\101\115 \096\110\097\109\101\096 \116\111 \098\101 \097 \115\116\114\105\110\103\046")local R=newproxy(true);(getmetatable(R)).__tostring=function()return("\083\121\109\098\111\108\040\037\115\041"):format(Q)end return R end local n=Y("\080\114\111\109\105\115\101\077\097\114\107\101\114")local x={}x.prototype={}x.__index=x.prototype x.Status={Started=Y("\083\116\097\114\116\101\100"),Resolved=Y("\082\101\115\111\108\118\101\100"),Rejected=Y("\082\101\106\101\099\116\101\100"),Cancelled=Y("\067\097\110\099\101\108\108\101\100")}

local function createAdvancer(callback, resolve, reject)
	return function(...)
		local resultLength, result = wpcallPacked(callback, ...)
		local ok = result[1]

		if ok then
			resolve(unpack(result, 2, resultLength))
		else
			reject(unpack(result, 2, resultLength))
		end
	end
end

local function isEmpty(t)
	return next(t) == nil
end

local function createSymbol(name)
	assert(type(name) == "string", "createSymbol requires `name` to be a string.")

	local symbol = newproxy(true)

	getmetatable(symbol).__tostring = function()
		return ("Symbol(%s)"):format(name)
	end

	return symbol
end

local PromiseMarker = createSymbol("PromiseMarker")

local Promise = {}
Promise.prototype = {}
Promise.__index = Promise.prototype

Promise.Status = {
	Started = createSymbol("Started"),
	Resolved = createSymbol("Resolved"),
	Rejected = createSymbol("Rejected"),
	Cancelled = createSymbol("Cancelled"),
}
