local t=Cheer.CreateComponent("\066\084\068\114\111\112\100\111\119\110",View)function t.Start(l,q,N)Cheer.Bind(View,t.Toggle)t.Draw(l,q,N)return t end function t.Toggle()local t=View.Options:GetChildren()for t,l in pairs(t)do l.Visible=not l.Visible end end function t.SetOption(t)View.CurrentOption.Text=t:upper()end function t.Draw(l,q,N)View.Options:ClearAllChildren()for l,q in ipairs(l)do local o=View.OptionButton:Clone()o.Parent=View.Options o.OptionLabel.Text=q:upper()o.MouseButton1Click:connect(function()N(q)t.SetOption(q)t.Toggle()end)o.Position=UDim2.new(math.ceil(l/9)-1,(o.Position.X.Offset+math.ceil(l/9)*-1)+1,(l%9==0 and 9 or l%9)*o.Size.Y.Scale,o.Position.Y.Offset)end View.Visible=true end return t

local Component = Cheer.CreateComponent('BTDropdown', View);

function Component.Start(Options, CurrentOption, Callback)

	-- Toggle options when clicked
	Cheer.Bind(View, Component.Toggle);

	-- Draw the component with the given options
	Component.Draw(Options, CurrentOption, Callback);

	-- Return component for chaining
	return Component;

end;

function Component.Toggle()
	-- Toggles the visibility of the dropdown options

	-- Show each option button open or closed
	local Buttons = View.Options:GetChildren();
	for _, Button in pairs(Buttons) do
		Button.Visible = not Button.Visible;
	end;

end;

function Component.SetOption(Option)
	-- Draws the current option into the dropdown

	-- Set the label
	View.CurrentOption.Text = Option:upper();

end;

function Component.Draw(Options, CurrentOption, Callback)
	-- Draws the dropdown with the given data

	-- Clear existing buttons
	View.Options:ClearAllChildren();

	-- Create a button for each option
	for Index, Option in ipairs(Options) do

		-- Create the button
		local Button = View.OptionButton:Clone();
		Button.Parent = View.Options;
		Button.OptionLabel.Text = Option:upper();
		Button.MouseButton1Click:connect(function ()
			Callback(Option);
			Component.SetOption(Option);
			Component.Toggle();
		end);

		-- Position the button
		Button.Position = UDim2.new(
			math.ceil(Index / 9) - 1, Button.Position.X.Offset + (math.ceil(Index / 9) * -1) + 1,
			(Index % 9 == 0 and 9 or Index % 9) * Button.Size.Y.Scale, Button.Position.Y.Offset
		);

	end;

	-- Show the view
	View.Visible = true;

end;

return Component;
