local g=require(script.Parent.Parent.Runtime)local j=require(script.Parent.Parent.create)return g.widget(function(D,v)v=v or{}local F,G=g.useState(false)local P,B=g.useState(false)local X=g.useInstance(function(g)local D=j("\070\114\097\109\101",{[g]="\099\104\101\099\107\098\111\120",BackgroundTransparency=1;Name="\067\104\101\099\107\098\111\120",Size=UDim2.new(0,30,0,30);AutomaticSize=Enum.AutomaticSize.X;j("\084\101\120\116\066\117\116\116\111\110",{BackgroundColor3=Color3.fromRGB(54,54,54),BorderSizePixel=0;Font=Enum.Font.SourceSansBold;Size=UDim2.new(0,30,0,30);TextColor3=Color3.fromRGB(153,153,153),TextSize=24,j("\085\073\067\111\114\110\101\114",{CornerRadius=UDim.new(0,8)});Activated=function()B(true)G(function(g)return not g end)end}),j("\084\101\120\116\076\097\098\101\108",{BackgroundColor3=Color3.fromRGB(255,255,255),Font=Enum.Font.GothamMedium,TextColor3=Color3.fromRGB(203,203,203);TextSize=18;AutomaticSize=Enum.AutomaticSize.X;RichText=true}),j("\085\073\076\105\115\116\076\097\121\111\117\116",{FillDirection=Enum.FillDirection.Horizontal,Padding=UDim.new(0,10),SortOrder=Enum.SortOrder.LayoutOrder;VerticalAlignment=Enum.VerticalAlignment.Center})})return D end)local c=X.checkbox c.TextLabel.Text=D c.TextButton.AutoButtonColor=not v.disabled g.useEffect(function()local g if v.checked~=nil then g=v.checked else g=F end c.TextButton.Text=g and"\226\156\147"or""end,v.checked,F)g.useEffect(function()c.TextButton.BackgroundColor3=v.disabled and Color3.fromRGB(112,112,112)or Color3.fromRGB(54,54,54)end,v.disabled)local T={checked=function()if v.checked or F then return true end return false end,clicked=function()if P then B(false)return true end return false end}return T end)


local Runtime = require(script.Parent.Parent.Runtime)
local create = require(script.Parent.Parent.create)

return Runtime.widget(function(text, options)
	options = options or {}

	local checked, setChecked = Runtime.useState(false)
	local clicked, setClicked = Runtime.useState(false)

	local refs = Runtime.useInstance(function(ref)
		local Checkbox = create("Frame", {
			[ref] = "checkbox",
			BackgroundTransparency = 1,
			Name = "Checkbox",
			Size = UDim2.new(0, 30, 0, 30),
			AutomaticSize = Enum.AutomaticSize.X,

			create("TextButton", {
				BackgroundColor3 = Color3.fromRGB(54, 54, 54),
				BorderSizePixel = 0,
				Font = Enum.Font.SourceSansBold,
				Size = UDim2.new(0, 30, 0, 30),
				TextColor3 = Color3.fromRGB(153, 153, 153),
				TextSize = 24,

				create("UICorner", {
					CornerRadius = UDim.new(0, 8),
				}),

				Activated = function()
					setClicked(true)
					setChecked(function(currentlyChecked)
						return not currentlyChecked
					end)
				end,
			}),

			create("TextLabel", {
				BackgroundColor3 = Color3.fromRGB(255, 255, 255),
				Font = Enum.Font.GothamMedium,
				TextColor3 = Color3.fromRGB(203, 203, 203),
				TextSize = 18,
				AutomaticSize = Enum.AutomaticSize.X,
				RichText = true,
			}),

			create("UIListLayout", {
				FillDirection = Enum.FillDirection.Horizontal,
				Padding = UDim.new(0, 10),
				SortOrder = Enum.SortOrder.LayoutOrder,
				VerticalAlignment = Enum.VerticalAlignment.Center,
			}),
		})

		return Checkbox
	end)

	local instance = refs.checkbox

	instance.TextLabel.Text = text
	instance.TextButton.AutoButtonColor = not options.disabled

	Runtime.useEffect(function()
		local isChecked
		if options.checked ~= nil then
			isChecked = options.checked
		else
			isChecked = checked
		end

		instance.TextButton.Text = isChecked and "✓" or ""
	end, options.checked, checked)

	Runtime.useEffect(function()
		instance.TextButton.BackgroundColor3 = options.disabled and Color3.fromRGB(112, 112, 112)
			or Color3.fromRGB(54, 54, 54)
	end, options.disabled)

	local handle = {
		checked = function()
			if options.checked or checked then
				return true
			end

			return false
		end,
		clicked = function()
			if clicked then
				setClicked(false)
				return true
			end

			return false
		end,
	}

	return handle
end)
