local T=require(script.Parent.Binding)local function x()local x,h=T.create(nil)local y={}setmetatable(y,{__index=function(T,h)if h=="\099\117\114\114\101\110\116"then return x:getValue()else return x[h]end end;__newindex=function(T,h,y)if h=="\099\117\114\114\101\110\116"then error("\067\097\110\110\111\116 \097\115\115\105\103\110 \116\111 \116\104\101 \'\099\117\114\114\101\110\116\' \112\114\111\112\101\114\116\121 \111\102 \114\101\102\115",2)end x[h]=y end,__tostring=function(T)return("\082\111\097\099\116\082\101\102\040\037\115\041"):format(tostring(x:getValue()))end})return y end return x

local Binding = require(script.Parent.Binding)

local function createRef()
	local binding, _ = Binding.create(nil)

	local ref = {}

	--[[
		A ref is just redirected to a binding via its metatable
	]]
	setmetatable(ref, {
		__index = function(_self, key)
			if key == "current" then
				return binding:getValue()
			else
				return binding[key]
			end
		end,
		__newindex = function(_self, key, value)
			if key == "current" then
				error("Cannot assign to the 'current' property of refs", 2)
			end

			binding[key] = value
		end,
		__tostring = function(_self)
			return ("RoactRef(%s)"):format(tostring(binding:getValue()))
		end,
	})

	return ref
end

return createRef
