local K={}function K.GetActionInput(K,L)local M="\110\105\108"local J={Zero="\048";One="\049";Two="\050",Three="\051",Four="\052";Five="\053",Six="\054";Seven="\055",Eight="\056",Nine="\057";MouseButton1="\077\066\049",MouseButton2="\077\066\050";MouseButton3="\077\066\051",Return="\069\110\116\101\114",Slash="\047",Tilde="~";Backquote="\096"}if actions[L]then local K,J=actions[L].Primary,actions[L].Secondary if K then M=K.Name elseif J then M=J.Name end end if J[M]then M=J[M]end return string.upper(M)end if not initialized then local L=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")K.KeybindChanged=L.Event actionBegan=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")actionEnded=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")K.ActionBegan=actionBegan.Event K.ActionEnded=actionEnded.Event local function M(K,M,J)local V,U if M then local K,L=string.match(M,"\040\046-\041\037\046\040\046\043\041")if K and L then V=Enum[K][L]end end if J then local K,L=string.match(J,"\040\046-\041\037\046\040\046\043\041")if K and L then U=Enum[K][L]end end RegisterAction(K,V,U)L:Fire(K)end local function J(K)local L=K.Name local J=K.Value if string.match(J,"\059")then local K,V=string.match(J,"\040\046-\041\059\040\046\043\041")if K and V then M(L,K,V)elseif K then M(L,K)elseif V then M(L,nil,V)end else M(L,J)end end initialized=true end return K
-- module

local INPUT = {}

function INPUT.GetActionInput(self, action)
	local input = "nil"

	local replacements = {
		Zero = "0",
		One = "1",
		Two = "2",
		Three = "3",
		Four = "4",
		Five = "5",
		Six = "6",
		Seven = "7",
		Eight = "8",
		Nine = "9",

		MouseButton1 = "MB1",
		MouseButton2 = "MB2",
		MouseButton3 = "MB3",
		Return = "Enter",
		Slash = "/",
		Tilde = "~",
		Backquote = "`",
	}

	if actions[action] then
		local primary, secondary = actions[action].Primary, actions[action].Secondary

		if primary then
			input = primary.Name
		elseif secondary then
			input = secondary.Name
		end
	end

	if replacements[input] then
		input = replacements[input]
	end

	return string.upper(input)
end

if not initialized then
	local keybindChanged = Instance.new("BindableEvent")
	INPUT.KeybindChanged = keybindChanged.Event

	actionBegan = Instance.new("BindableEvent")
	actionEnded = Instance.new("BindableEvent")

	INPUT.ActionBegan = actionBegan.Event
	INPUT.ActionEnded = actionEnded.Event

	-- register actions

	local function Register(action, bindP, bindS)
		local primary, secondary
		if bindP then
			local A, B = string.match(bindP, "(.-)%.(.+)")

			if A and B then
				primary = Enum[A][B]
			end
		end
		if bindS then
			local A, B = string.match(bindS, "(.-)%.(.+)")

			if A and B then
				secondary = Enum[A][B]
			end
		end

		RegisterAction(action, primary, secondary)
		keybindChanged:Fire(action)
	end

	local function Handle(keybind)
		local action = keybind.Name
		local bind = keybind.Value

		if string.match(bind, ";") then
			local bindP, bindS = string.match(bind, "(.-);(.+)")

			if bindP and bindS then
				Register(action, bindP, bindS)
			elseif bindP then
				Register(action, bindP)
			elseif bindS then
				Register(action, nil, bindS)
			end
		else
			Register(action, bind)
		end
	end

	initialized = true
end

return INPUT
