local T=game:GetService("\080\104\121\115\105\099\115\083\101\114\118\105\099\101")local O=script.Parent.Parent local a=require(O.Packages.Roact)local D=require(O.Packages.StudioComponents)local w=D.ScrollFrame local v=require(script.ListEntry)local H=require(script.ListActionEntry)local function t(O)local D={}local t={}for w,A in ipairs(O.Groups)do local c=T:CollisionGroupsAreCollidable(O.SelectedGroupName,A.name)table.insert(D,a.createElement(v,{Order=w,Group=A;Selected=A.name==O.SelectedGroupName;OnActivated=function()O.SetSelectedGroupName(A.name)end;Disabled=O.Disabled}))table.insert(t,a.createElement(H,{Order=w;Group=A;Collides=c,OnActivated=function()O.SetGroupsCollidable(O.SelectedGroupName,A.name,not c)end;Disabled=O.Disabled}))end return a.createFragment({Left=a.createElement(w,{Size=UDim2.new(.5,1,1,0),Disabled=O.Disabled},D),Right=a.createElement(w,{Position=UDim2.fromScale(.5,0),Size=UDim2.fromScale(.5,1),Disabled=O.Disabled},t)})end return t
local PhysicsService = game:GetService("PhysicsService")

local Plugin = script.Parent.Parent

local Roact = require(Plugin.Packages.Roact)
local StudioComponents = require(Plugin.Packages.StudioComponents)

local ScrollFrame = StudioComponents.ScrollFrame
local ListEntry = require(script.ListEntry)
local ListActionEntry = require(script.ListActionEntry)

local function ListView(props)
	local childrenLeft = {}
	local childrenRight = {}
	for i, group in ipairs(props.Groups) do
		local collides = PhysicsService:CollisionGroupsAreCollidable(props.SelectedGroupName, group.name)
		table.insert(
			childrenLeft,
			Roact.createElement(ListEntry, {
				Order = i,
				Group = group,
				Selected = group.name == props.SelectedGroupName,
				OnActivated = function()
					props.SetSelectedGroupName(group.name)
				end,
				Disabled = props.Disabled,
			})
		)
		table.insert(
			childrenRight,
			Roact.createElement(ListActionEntry, {
				Order = i,
				Group = group,
				Collides = collides,
				OnActivated = function()
					props.SetGroupsCollidable(props.SelectedGroupName, group.name, not collides)
				end,
				Disabled = props.Disabled,
			})
		)
	end
	return Roact.createFragment({
		Left = Roact.createElement(ScrollFrame, {
			Size = UDim2.new(0.5, 1, 1, 0),
			Disabled = props.Disabled,
		}, childrenLeft),
		Right = Roact.createElement(ScrollFrame, {
			Position = UDim2.fromScale(0.5, 0),
			Size = UDim2.fromScale(0.5, 1),
			Disabled = props.Disabled,
		}, childrenRight),
	})
end

return ListView
