local X=game:GetService("\077\097\114\107\101\116\112\108\097\099\101\083\101\114\118\105\099\101")local Y=require(script.Parent.Cache)local w=require(script.Parent.Settings)local A=require(script.Parent.Util.Promise)local e=Y.new(w.PRODUCT_INFO_CACHE_SIZE)local function J(Y)assert(typeof(Y)=="\110\117\109\098\101\114")local w=e:Get(tostring(Y))if w then return A.resolve(w)end return A.new(function(w,A)local J,P=pcall(function()return X:GetProductInfo(Y)end)if J then e:Set(tostring(Y),P)w(P)else A(P)end end)end return J
local Marketplace = game:GetService("MarketplaceService")

local Cache = require(script.Parent.Cache)
local Settings = require(script.Parent.Settings)
local Promise = require(script.Parent.Util.Promise)

local cache = Cache.new(Settings.PRODUCT_INFO_CACHE_SIZE)


local function getProductInfo(assetId)
	assert(typeof(assetId) == "number")
	
	local cached = cache:Get(tostring(assetId))
	if cached then
		return Promise.resolve(cached)
	end
	
	return Promise.new(function(resolve, reject)
		local success, result = pcall(function()
			return Marketplace:GetProductInfo(assetId)
		end)
		if success then
			cache:Set(tostring(assetId), result)
			resolve(result)
		else
			reject(result)
		end
	end)
end


return getProductInfo