--[[
	Higher order component that lets the wrapped component consume the EmoteContext.
]]

local function withEmoteContext(component)
	return function(props)
		if props.emoteContext then
			warn("Child component has a prop named `emoteContext` and will be overriden by EmoteContext.")
		end

		return Roact.createElement(Context.Consumer, {
			render = function(emoteContext)
				local mergedProps = Cryo.Dictionary.join({ emoteContext = emoteContext }, props)

				return Roact.createElement(component, mergedProps)
			end,
		})
	end
end

local EmoteContext = {
	Consumer = Context.Consumer,
	Provider = withConfiguration(EmoteContextProvider),
	withEmoteContext = withEmoteContext,
}

return EmoteContext
