local R=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local x=game:GetService("\080\108\097\121\101\114\115")local K=R.AvatarEditor local I=require(K.Shared.Util.Maid)local t=require(K.Shared.Util.Promise)local U=require(K.Client.GuiLib.LazyLoader)local d=require(K.Client.Theme)local A=x.LocalPlayer local h={}h.__index=h function h.new(R)local x=setmetatable({},h)x.Frame=R x.ScrollingFrame=x.Frame.ScrollingFrame x.Maid=I.new()x.Maid:GiveTask(d:Bind(x.ScrollingFrame,"\083\099\114\111\108\108\066\097\114\073\109\097\103\101\067\111\108\111\114\051","\083\099\114\111\108\108\098\097\114"))x.Maid:GiveTask(d:Bind(x.ScrollingFrame.Theme.DropdownButton,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051","\084\101\114\116\105\097\114\121"))x.Maid:GiveTask(d:Bind(x.ScrollingFrame.Theme.DropdownButton.ListFrame,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051","\084\101\114\116\105\097\114\121"))x.Maid:GiveTask(d:Bind(x.ScrollingFrame.Theme.DropdownButton.Arrow,"\073\109\097\103\101\067\111\108\111\114\051","\068\101\115\101\108\101\099\116\101\100"))x.Maid:GiveTask(d:Bind(x.ScrollingFrame.Theme.DropdownButton.Option,"\084\101\120\116\067\111\108\111\114\051","\084\101\120\116"))x.Maid:GiveTask(d:Bind(x.ScrollingFrame.Theme.TextLabel,"\084\101\120\116\067\111\108\111\114\051","\084\101\120\116"))local F=x.ScrollingFrame.Theme.DropdownButton for R,I in ipairs(d:GetAll())do local t=K.DropdownTemplate:Clone()t.LayoutOrder=R t.Text=I t.Name=I x.Maid:GiveTask(d:Bind(t,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051","\084\101\114\116\105\097\114\121"))x.Maid:GiveTask(d:Bind(t,"\084\101\120\116\067\111\108\111\114\051","\084\101\120\116"))x.Maid:GiveTask(t)t.Parent=F.ListFrame.ScrollFrame end x.Maid:GiveTask(d:Bind(F.ListFrame.ScrollFrame,"\083\099\114\111\108\108\066\097\114\073\109\097\103\101\067\111\108\111\114\051","\083\099\114\111\108\108\098\097\114"))F.ListFrame.ScrollFrame.CanvasSize=UDim2.new(0,0,0,F.ListFrame.ScrollFrame.UIListLayout.AbsoluteContentSize.Y)local u=U.Classes.Dropdown.new(F,F.ListFrame)x.Maid:GiveTask(u)x.Maid:GiveTask(u.Changed:Connect(function(R)local x=R.Name d:Set(x)end));((t.new(function(R,x)local K=A:WaitForChild("\065\069\095\083\101\116\116\105\110\103\115")R(K)end)):andThen(function(R)x.Folder=R u:Set(F.ListFrame.ScrollFrame[x.Folder:GetAttribute("\084\104\101\109\101")])d:Set((u:Get()).Name)end)):catch(warn)return x end function h.Destroy(R)R.Maid:DoCleaning()R.Maid=nil setmetatable(R,nil)end return h
--[[



]]

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local AvatarEditor = ReplicatedStorage.AvatarEditor
local Maid = require(AvatarEditor.Shared.Util.Maid)
local Promise = require(AvatarEditor.Shared.Util.Promise)
local GuiLib = require(AvatarEditor.Client.GuiLib.LazyLoader)
local Theme = require(AvatarEditor.Client.Theme)

local player = Players.LocalPlayer

local Class = {}
Class.__index = Class

function Class.new(frame)
	local self = setmetatable({}, Class)

	self.Frame = frame
	self.ScrollingFrame = self.Frame.ScrollingFrame
	self.Maid = Maid.new()

	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame, "ScrollBarImageColor3", "Scrollbar"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton, "BackgroundColor3", "Tertiary"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton.ListFrame, "BackgroundColor3", "Tertiary"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton.Arrow, "ImageColor3", "Deselected"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton.Option, "TextColor3", "Text"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.TextLabel, "TextColor3", "Text"))

	local dropdownButton = self.ScrollingFrame.Theme.DropdownButton
	for i, v in ipairs(Theme:GetAll()) do
		local button = AvatarEditor.DropdownTemplate:Clone()
		button.LayoutOrder = i
		button.Text = v
		button.Name = v
		self.Maid:GiveTask(Theme:Bind(button, "BackgroundColor3", "Tertiary"))
		self.Maid:GiveTask(Theme:Bind(button, "TextColor3", "Text"))
		self.Maid:GiveTask(button)
		button.Parent = dropdownButton.ListFrame.ScrollFrame
	end
	self.Maid:GiveTask(Theme:Bind(dropdownButton.ListFrame.ScrollFrame, "ScrollBarImageColor3", "Scrollbar"))

	-- for some reason AutomaticCanvasSize doesnt want to work here...
	dropdownButton.ListFrame.ScrollFrame.CanvasSize =
		UDim2.new(0, 0, 0, dropdownButton.ListFrame.ScrollFrame.UIListLayout.AbsoluteContentSize.Y)

	local themeDropdown = GuiLib.Classes.Dropdown.new(dropdownButton, dropdownButton.ListFrame)
	self.Maid:GiveTask(themeDropdown)

	self.Maid:GiveTask(themeDropdown.Changed:Connect(function(button)
		local theme = button.Name
		Theme:Set(theme)
	end))

	Promise.new(function(resolve, reject)
		local folder = player:WaitForChild("AE_Settings")
		resolve(folder)
	end)
		:andThen(function(folder)
			self.Folder = folder

			themeDropdown:Set(dropdownButton.ListFrame.ScrollFrame[self.Folder:GetAttribute("Theme")])
			Theme:Set(themeDropdown:Get().Name)
		end)
		:catch(warn)

	return self
end

function Class:Destroy()
	self.Maid:DoCleaning()
	self.Maid = nil
	setmetatable(self, nil)
end

return Class
