local A=require(Vendor:WaitForChild("\082\111\097\099\116"))local W=require(UI:WaitForChild("\084\111\111\108\077\097\110\117\097\108\087\105\110\100\111\119"))local function X(X,Z,p)local u=p:WaitForChild("\072\101\108\112\066\117\116\116\111\110")local L=false local x=nil local function R()if not L then u.TextTransparency=0;(u:WaitForChild("\066\097\099\107\103\114\111\117\110\100")).BackgroundTransparency=0 end end local function e()if not L then u.TextTransparency=.5;(u:WaitForChild("\066\097\099\107\103\114\111\117\110\100")).BackgroundTransparency=.75 end end local function r()u.TextTransparency=L and 0 or.5;(u:WaitForChild("\066\097\099\107\103\114\111\117\110\100")).BackgroundTransparency=L and 0 or.75 if L then e()L=false x=A.unmount(x)else R()L=true local p=A.createElement(W,{Text=X;ThemeColor=Z})x=A.mount(p,Core.UI,"\084\111\111\108\077\097\110\117\097\108\087\105\110\100\111\119")end end p.Activated:Connect(r)u.Activated:Connect(r)p.InputBegan:Connect(R)p.InputEnded:Connect(e)u.InputBegan:Connect(R)u.InputEnded:Connect(e)end return X

local Roact = require(Vendor:WaitForChild('Roact'))
local ToolManualWindow = require(UI:WaitForChild('ToolManualWindow'))

local function ListenForManualWindowTrigger(Text, ThemeColor, SignatureButton)
    local HelpButton = SignatureButton:WaitForChild('HelpButton')

	local IsManualOpen = false
	local ManualHandle = nil

	local function BeginHover()
		if not IsManualOpen then
			HelpButton.TextTransparency = 0
			HelpButton:WaitForChild('Background').BackgroundTransparency = 0
		end
	end

	local function EndHover()
		if not IsManualOpen then
			HelpButton.TextTransparency = 0.5
			HelpButton:WaitForChild('Background').BackgroundTransparency = 0.75
		end
	end

	local function ToggleManual()
		HelpButton.TextTransparency = IsManualOpen and 0 or 0.5
		HelpButton:WaitForChild('Background').BackgroundTransparency = IsManualOpen and 0 or 0.75

        -- Close manual if open
        if IsManualOpen then
			EndHover()
			IsManualOpen = false
			ManualHandle = Roact.unmount(ManualHandle)

        -- Open manual if closed
        else
			BeginHover()
			IsManualOpen = true
			local ManualElement = Roact.createElement(ToolManualWindow, {
				Text = Text;
				ThemeColor = ThemeColor;
			})
			ManualHandle = Roact.mount(ManualElement, Core.UI, 'ToolManualWindow')
		end
	end

	-- Enable help button
	SignatureButton.Activated:Connect(ToggleManual)
	HelpButton.Activated:Connect(ToggleManual)
	SignatureButton.InputBegan:Connect(BeginHover)
	SignatureButton.InputEnded:Connect(EndHover)
	HelpButton.InputBegan:Connect(BeginHover)
	HelpButton.InputEnded:Connect(EndHover)
end

return ListenForManualWindowTrigger
