local v=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\118\101\114\109\111\114\101"))local E=v("\080\114\111\109\105\115\101")local F={}F.ClassName="\066\105\110\100\101\114\080\114\111\118\105\100\101\114"F.__index=F function F.new(v)local N=setmetatable({},F)N.BindersAddedPromise=E.new()N._initMethod=v or error("\078\111 \105\110\105\116\077\101\116\104\111\100")N._afterInit=false N._binders={}return N end function F.Init(v)v:_initMethod(v)v.BindersAddedPromise:Resolve(true)end function F.__index(E,v)if F[v]then return F[v]end error(("\'\037\115\' \078\111\116 \097 \118\097\108\105\100 \105\110\100\101\120"):format(tostring(v)))end function F.AfterInit(v)v._afterInit=true for v,E in pairs(v._binders)do E:Init()end end function F.Get(E,v)assert(type(v)=="\115\116\114\105\110\103","\116\097\103\078\097\109\101 \109\117\115\116 \098\101 \097 \115\116\114\105\110\103")return rawget(E,v)end function F.Add(E,v)assert(not E._afterInit,"\065\108\114\101\097\100\121 \105\110\105\116\101\100")assert(not E:Get(v:GetTag()))table.insert(E._binders,v)E[v:GetTag()]=v end return F
--- Provides a basis for binders that can be retrieved anywhere
-- @classmod BinderProvider
-- @author Quenty

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))

local Promise = require("Promise")

local BinderProvider = {}
BinderProvider.ClassName = "BinderProvider"
BinderProvider.__index = BinderProvider

function BinderProvider.new(initMethod)
	local self = setmetatable({}, BinderProvider)

	-- Pretty sure this is a bad idea
	self.BindersAddedPromise = Promise.new()

	self._initMethod = initMethod or error("No initMethod")
	self._afterInit = false
	self._binders = {}

	return self
end

function BinderProvider:Init()
	self:_initMethod(self)
	self.BindersAddedPromise:Resolve(true)
end

function BinderProvider:__index(index)
	if BinderProvider[index] then
		return BinderProvider[index]
	end

	error(("'%s' Not a valid index"):format(tostring(index)))
end

function BinderProvider:AfterInit()
	self._afterInit = true
	for _, binder in pairs(self._binders) do
		binder:Init()
	end
end

function BinderProvider:Get(tagName)
	assert(type(tagName) == "string", "tagName must be a string")
	return rawget(self, tagName)
end

function BinderProvider:Add(binder)
	assert(not self._afterInit, "Already inited")

	assert(not self:Get(binder:GetTag()))
	table.insert(self._binders, binder)
	self[binder:GetTag()] = binder
end

return BinderProvider