local h=game:GetService("\067\104\097\110\103\101\072\105\115\116\111\114\121\083\101\114\118\105\099\101")local z=game:GetService("\083\101\108\101\099\116\105\111\110")local r=script.Parent local k=require(script.Parent.Layers)local P=require(script.Parent.Constants)local x=require(r.Vendor.Roact)local w=require(r.Components.MainPlugin)k:Init()local D=plugin:CreateToolbar("\076\097\121\101\114\115")local t=D:CreateButton("\076\097\121\101\114\115","\076\097\121\101\114\115","\114\098\120\097\115\115\101\116\105\100\058\047\047\055\050\048\051\050\053\053\050\054\056")t.ClickableWhenViewportHidden=true local X={}for h,z in pairs(P.PluginActions)do X[h]=plugin:CreatePluginAction(unpack(z))end local O=x.createElement(w,{Button=t,Actions=X,OnEnabled=function(h)k:SetEnabled(h)end})local Z=x.mount(O,nil)plugin.Unloading:Connect(function()x.unmount(Z)k:SetEnabled(false)end);(settings()).Studio.ThemeChanged:Connect(function()x.update(Z,O)end);(plugin:CreatePluginAction("\109\097\107\101\095\102\111\108\100\101\114","\077\097\107\101 \070\111\108\100\101\114","\071\114\111\117\112 \116\104\101 \115\101\108\101\099\116\101\100 \112\097\114\116\115 \105\110\116\111 \097 \070\111\108\100\101\114\046")).Triggered:Connect(function()local r=z:Get()if#r>0 then h:SetWaypoint("\095\109\097\107\101\070\111\108\100\101\114"..tick())local k=Instance.new("\070\111\108\100\101\114")k.Parent=workspace for h,z in pairs(r)do z.Parent=k end z:Set({k})h:SetWaypoint("\095\109\097\100\101\070\111\108\100\101\114"..tick())end end)
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")

local Plugin = script.Parent

local Layers = require(script.Parent.Layers)
local Constants = require(script.Parent.Constants)
local Roact = require(Plugin.Vendor.Roact)
local MainPlugin = require(Plugin.Components.MainPlugin)

Layers:Init()

local toolbar = plugin:CreateToolbar("Layers")
local button = toolbar:CreateButton(
	"Layers",
	"Layers",
	"rbxassetid://7203255268"
)
button.ClickableWhenViewportHidden = true

local Actions = {}

for actionName, action in pairs(Constants.PluginActions) do
	Actions[actionName] = plugin:CreatePluginAction(unpack(action))
end

local main = Roact.createElement(MainPlugin, {
	Button = button,
	Actions = Actions,
	OnEnabled = function(Enabled)
		Layers:SetEnabled(Enabled)
	end
})

local handle = Roact.mount(main, nil)

plugin.Unloading:Connect(function()
	Roact.unmount(handle)
	Layers:SetEnabled(false)
end)

settings().Studio.ThemeChanged:Connect(function()
	Roact.update(handle, main)
end)

plugin:CreatePluginAction("make_folder", "Make Folder", "Group the selected parts into a Folder.").Triggered:Connect(function()
	local currentSelection = Selection:Get()

	if #currentSelection > 0 then
		ChangeHistoryService:SetWaypoint("_makeFolder" .. tick())
		local folder = Instance.new("Folder")
		folder.Parent = workspace

		for _, object in pairs(currentSelection) do
			object.Parent = folder
		end

		Selection:Set({folder})
		ChangeHistoryService:SetWaypoint("_madeFolder" .. tick())
	end
end)