local function d(d)return function(y)local I=Roact.Component:extend("\067\117\115\116\111\109\071\117\105")function I.init(y)y.StarterGui=y.props.StarterGui or StarterGui local I=y.StarterGui:FindFirstChild(d,true)if not I then return end if not I:IsA("\070\114\097\109\101")then warn(string.format("\091\070\114\105\101\110\100\115\076\111\099\097\116\111\114\093 \067\117\115\116\111\109 \071\085\073 \112\114\111\118\105\100\101\100 \101\120\112\101\099\116\101\100 \116\111 \098\101 \070\114\097\109\101\044 \103\111\116 \037\115 \105\110\115\116\101\097\100",I.ClassName))return end y.instance=I:Clone()end function I.render(d)return Roact.createElement(y,Cryo.Dictionary.join(d.props,{customGui=d.instance}))end function I.willUnmount(d)if d.instance then d.instance:Destroy()d.instance=nil end end return I end end return d
--[[
	HOC that wraps a component that can be hot swapped with a GUI instance.

	Parameters:
	- guiName (string): name of GUI that is stored in the `CustomGui` folder

	Returns:
	- Function that injects the custom GUI instance into the wrapped component as a prop
]]
local function withCustomGui(guiName)
	return function(Component)
		local CustomGui = Roact.Component:extend("CustomGui")

		function CustomGui:init()
			self.StarterGui = self.props.StarterGui or StarterGui

			-- Find the custom GUI folder and clone the instance
			local instance = self.StarterGui:FindFirstChild(guiName, true)

			-- No custom GUI defined
			if not instance then
				return
			end

			-- Invalid class of GUI defined
			if not instance:IsA("Frame") then
				warn(
					string.format(
						"[FriendsLocator] Custom GUI provided expected to be Frame, got %s instead",
						instance.ClassName
					)
				)
				return
			end

			-- Clone GUI
			self.instance = instance:Clone()
		end

		function CustomGui:render()
			return Roact.createElement(
				Component,
				Cryo.Dictionary.join(self.props, {
					customGui = self.instance,
				})
			)
		end

		function CustomGui:willUnmount()
			if self.instance then
				self.instance:Destroy()
				self.instance = nil
			end
		end

		return CustomGui
	end
end

return withCustomGui
