local M=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local B={}do B.Folder="\070\108\117\101\110\116\083\101\116\116\105\110\103\115"B.Settings={Theme="\068\097\114\107";Acrylic=true;Transparency=true;MenuKeybind="\076\101\102\116\067\111\110\116\114\111\108"}function B.SetFolder(B,M)B.Folder=M B:BuildFolderTree()end function B.SetLibrary(B,M)B.Library=M end function B.BuildFolderTree(M)local B={}local f=M.Folder:split("\047")for M=1,#f,1 do B[#B+1]=table.concat(f,"\047",1,M)end table.insert(B,M.Folder)table.insert(B,M.Folder.."\047\115\101\116\116\105\110\103\115")for M=1,#B,1 do local f=B[M]if not isfolder(f)then makefolder(f)end end end function B.SaveSettings(f)writefile(f.Folder.."\047\111\112\116\105\111\110\115\046\106\115\111\110",M:JSONEncode(B.Settings))end function B.LoadSettings(f)local e=f.Folder.."\047\111\112\116\105\111\110\115\046\106\115\111\110"if isfile(e)then local f=readfile(e)local D,A=pcall(M.JSONDecode,M,f)if D then for M,f in next,A do B.Settings[M]=f end end end end function B.BuildInterfaceSection(f,M)assert(f.Library,"\077\117\115\116 \115\101\116 \073\110\116\101\114\102\097\099\101\077\097\110\097\103\101\114\046\076\105\098\114\097\114\121")local e=f.Library local D=B.Settings B:LoadSettings()local A=M:AddSection("\073\110\116\101\114\102\097\099\101")local n=A:AddDropdown("\073\110\116\101\114\102\097\099\101\084\104\101\109\101",{Title="\084\104\101\109\101",Description="\067\104\097\110\103\101\115 \116\104\101 \105\110\116\101\114\102\097\099\101 \116\104\101\109\101\046";Values=e.Themes;Default=D.Theme,Callback=function(M)e:SetTheme(M)D.Theme=M B:SaveSettings()end})n:SetValue(D.Theme)if e.UseAcrylic then A:AddToggle("\065\099\114\121\108\105\099\084\111\103\103\108\101",{Title="\065\099\114\121\108\105\099";Description="\084\104\101 \098\108\117\114\114\101\100 \098\097\099\107\103\114\111\117\110\100 \114\101\113\117\105\114\101\115 \103\114\097\112\104\105\099 \113\117\097\108\105\116\121 \056\043";Default=D.Acrylic,Callback=function(M)e:ToggleAcrylic(M)D.Acrylic=M B:SaveSettings()end})end A:AddToggle("\084\114\097\110\115\112\097\114\101\110\116\084\111\103\103\108\101",{Title="\084\114\097\110\115\112\097\114\101\110\099\121";Description="\077\097\107\101\115 \116\104\101 \105\110\116\101\114\102\097\099\101 \116\114\097\110\115\112\097\114\101\110\116\046";Default=D.Transparency;Callback=function(M)e:ToggleTransparency(M)D.Transparency=M B:SaveSettings()end})local H=A:AddKeybind("\077\101\110\117\075\101\121\098\105\110\100",{Title="\077\105\110\105\109\105\122\101 \066\105\110\100";Default=D.MenuKeybind})H:OnChanged(function()D.MenuKeybind=H.Value B:SaveSettings()end)e.MinimizeKeybind=H end end return B
local httpService = game:GetService("HttpService")

local InterfaceManager = {} do
	InterfaceManager.Folder = "FluentSettings"
    InterfaceManager.Settings = {
        Theme = "Dark",
        Acrylic = true,
        Transparency = true,
        MenuKeybind = "LeftControl"
    }

    function InterfaceManager:SetFolder(folder)
		self.Folder = folder;
		self:BuildFolderTree()
	end

    function InterfaceManager:SetLibrary(library)
		self.Library = library
	end

    function InterfaceManager:BuildFolderTree()
		local paths = {}

		local parts = self.Folder:split("/")
		for idx = 1, #parts do
			paths[#paths + 1] = table.concat(parts, "/", 1, idx)
		end

		table.insert(paths, self.Folder)
		table.insert(paths, self.Folder .. "/settings")

		for i = 1, #paths do
			local str = paths[i]
			if not isfolder(str) then
				makefolder(str)
			end
		end
	end

    function InterfaceManager:SaveSettings()
        writefile(self.Folder .. "/options.json", httpService:JSONEncode(InterfaceManager.Settings))
    end

    function InterfaceManager:LoadSettings()
        local path = self.Folder .. "/options.json"
        if isfile(path) then
            local data = readfile(path)
            local success, decoded = pcall(httpService.JSONDecode, httpService, data)

            if success then
                for i, v in next, decoded do
                    InterfaceManager.Settings[i] = v
                end
            end
        end
    end

    function InterfaceManager:BuildInterfaceSection(tab)
        assert(self.Library, "Must set InterfaceManager.Library")
		local Library = self.Library
        local Settings = InterfaceManager.Settings

        InterfaceManager:LoadSettings()

		local section = tab:AddSection("Interface")

		local InterfaceTheme = section:AddDropdown("InterfaceTheme", {
			Title = "Theme",
			Description = "Changes the interface theme.",
			Values = Library.Themes,
			Default = Settings.Theme,
			Callback = function(Value)
				Library:SetTheme(Value)
                Settings.Theme = Value
                InterfaceManager:SaveSettings()
			end
		})

        InterfaceTheme:SetValue(Settings.Theme)
	
		if Library.UseAcrylic then
			section:AddToggle("AcrylicToggle", {
				Title = "Acrylic",
				Description = "The blurred background requires graphic quality 8+",
				Default = Settings.Acrylic,
				Callback = function(Value)
					Library:ToggleAcrylic(Value)
                    Settings.Acrylic = Value
                    InterfaceManager:SaveSettings()
				end
			})
		end
	
		section:AddToggle("TransparentToggle", {
			Title = "Transparency",
			Description = "Makes the interface transparent.",
			Default = Settings.Transparency,
			Callback = function(Value)
				Library:ToggleTransparency(Value)
				Settings.Transparency = Value
                InterfaceManager:SaveSettings()
			end
		})
	
		local MenuKeybind = section:AddKeybind("MenuKeybind", { Title = "Minimize Bind", Default = Settings.MenuKeybind })
		MenuKeybind:OnChanged(function()
			Settings.MenuKeybind = MenuKeybind.Value
            InterfaceManager:SaveSettings()
		end)
		Library.MinimizeKeybind = MenuKeybind
    end
end

return InterfaceManager