local t=require(script.Parent.HookUtility)local B=require(script.Parent.UseEffect)local c=require(script.Parent.UseState)local function p(p)t.ResolveCurrentlyRenderingComponent()local j=t.CreateWorkInProgressHook()local i=j.MemoizedState if not t.IsReRender then local B=setmetatable({},{__index=t.CurrentlyRenderingComponent})p.Consumer.init(B)i=B.contextEntry j.MemoizedState=i end local N,X=c(i and i.value)local function m()return i.onUpdate:subscribe(X)end B(m,{})return N end return p
--!optimize 2
--!strict

local HookUtility = require(script.Parent.HookUtility)
local UseEffect = require(script.Parent.UseEffect)
local UseState = require(script.Parent.UseState)

local function UseContext(context)
	HookUtility.ResolveCurrentlyRenderingComponent()
	local hook = HookUtility.CreateWorkInProgressHook()

	local contextEntry = hook.MemoizedState

	if not HookUtility.IsReRender then
		local consumer = setmetatable({}, {__index = HookUtility.CurrentlyRenderingComponent})
		context.Consumer.init(consumer)
		contextEntry = consumer.contextEntry
		hook.MemoizedState = contextEntry
	end

	local value, setValue = UseState(contextEntry and contextEntry.value)

	local function subscribeEffect()
		return contextEntry.onUpdate:subscribe(setValue)
	end
	UseEffect(subscribeEffect, {})

	return value
end

return UseContext
