local h=game:GetService("\067\111\108\108\101\099\116\105\111\110\083\101\114\118\105\099\101")local z=game:GetService("\083\101\108\101\099\116\105\111\110")local r=script.Parent.Parent local k=require(r.Constants)local P=require(r.Vendor.Roact)local x=require(r.Vendor.StudioComponents)local w=x.Button local D=P.Component:extend("\077\111\118\101")function D.init(h)h:setState({Selection=z:Get()})h.onActivated=function()local z={}for h,r in pairs(h.state.Selection)do local P=false for h,z in pairs(k.ValidInstances)do if r:IsA(z)then P=true continue end end if P then table.insert(z,r)end end h.props.BatchSetLayer(z)end end function D.didMount(h)h.selectionChanged=z.SelectionChanged:Connect(function()h:setState({Selection=z:Get()})end)end function D.willUnmount(h)h.selectionChanged:Disconnect()end function D.render(h)local z=false for h,r in pairs(h.state.Selection)do for h,k in pairs(k.ValidInstances)do if r:IsA(k)then z=true continue end end if z then continue end end if h.props.Disabled then z=false end return P.createElement(w,{LayoutOrder=h.props.LayoutOrder,Size=h.props.Size,Text="\077\111\118\101",Disabled=not z;OnActivated=h.onActivated})end return D
local CollectionService = game:GetService("CollectionService")
local SelectionService = game:GetService("Selection")

local Plugin = script.Parent.Parent

local Constants = require(Plugin.Constants)
local Roact = require(Plugin.Vendor.Roact)
local StudioComponents = require(Plugin.Vendor.StudioComponents)

local Button = StudioComponents.Button

local Move = Roact.Component:extend("Move")

function Move:init()
	self:setState({ Selection = SelectionService:Get() })

	self.onActivated = function()
		local targets = {}
		for _, instance in pairs(self.state.Selection) do
			local valid = false

			for _, baseType in pairs(Constants.ValidInstances) do
				if instance:IsA(baseType) then
					valid = true
					continue
				end
			end
	
			if valid then
				table.insert(targets, instance)
			end

		end
		self.props.BatchSetLayer(targets)
	end
end

function Move:didMount()
	self.selectionChanged = SelectionService.SelectionChanged:Connect(function()
		self:setState({ Selection = SelectionService:Get() })
	end)
end

function Move:willUnmount()
	self.selectionChanged:Disconnect()
end

function Move:render()
	local valid = false

	for _, instance in pairs(self.state.Selection) do

		for _, baseType in pairs(Constants.ValidInstances) do
			if instance:IsA(baseType) then
				valid = true
				continue
			end
		end

		if valid then
			continue
		end
	end

	if self.props.Disabled then
		valid = false
	end

	return Roact.createElement(Button, {
		LayoutOrder = self.props.LayoutOrder,
		Size = self.props.Size,
		Text = "Move",
		Disabled = not valid,
		OnActivated = self.onActivated,
	})
end

return Move