local Z local function I()if Z==nil then Z=(settings()):GetService("\083\116\117\100\105\111")end return Z end local S=script:FindFirstAncestor("\077\097\122\101\071\101\110\101\114\097\116\111\114\080\108\117\103\105\110")local C=require(S:WaitForChild("\082\111\097\099\116"))local f=require(S.Log)local L=require(script.Parent.Parent.strict)local n=L("\084\104\101\109\101",{ButtonFont=Enum.Font.SourceSans,InputFont=Enum.Font.SourceSans;TitleFont=Enum.Font.SourceSans,MainFont=Enum.Font.SourceSans;Brand1=Color3.fromRGB(124,0,215);Text1=Color3.fromRGB(64,64,64);Text2=Color3.fromRGB(160,160,160);TextOnAccent=Color3.fromRGB(235,235,235);Background1=Color3.fromRGB(255,255,255),Background2=Color3.fromRGB(235,235,235)})local y=L("\084\104\101\109\101",{ButtonFont=Enum.Font.SourceSans,InputFont=Enum.Font.SourceSans;TitleFont=Enum.Font.SourceSans,MainFont=Enum.Font.SourceSans,Brand1=Color3.fromRGB(124,0,215);Text1=Color3.fromRGB(235,235,235),Text2=Color3.fromRGB(200,200,200),TextOnAccent=Color3.fromRGB(235,235,235),Background1=Color3.fromRGB(48,48,48),Background2=Color3.fromRGB(64,64,64)})local i=C.createContext(n)local s=C.Component:extend("\083\116\117\100\105\111\080\114\111\118\105\100\101\114")function s.updateTheme(Z)local S=(I()).Theme if S.Name=="\076\105\103\104\116"then Z:setState({theme=n})elseif S.Name=="\068\097\114\107"then Z:setState({theme=y})else f.warn("\085\110\101\120\112\101\099\116\101\100 \116\104\101\109\101 \'\123\125\'\' -- \102\097\108\108\105\110\103 \098\097\099\107 \116\111 \108\105\103\104\116 \116\104\101\109\101\033",S.Name)Z:setState({theme=n})end end function s.init(Z)Z:updateTheme()end function s.render(Z)return C.createElement(i.Provider,{value=Z.state.theme},Z.props[C.Children])end function s.didMount(Z)Z.connection=(I()).ThemeChanged:Connect(function()Z:updateTheme()end)end function s.willUnmount(Z)Z.connection:Disconnect()end local function U(Z)return C.createElement(i.Consumer,{render=Z})end return{StudioProvider=s;Consumer=i.Consumer,with=U}
--[[
	Theming system taking advantage of Roact's new context API.

	Doesn't use colors provided by Studio and instead just branches on theme
	name. This isn't exactly best practice.
]]

-- Studio does not exist outside Roblox Studio, so we'll lazily initialize it
-- when possible.
local _Studio
local function getStudio()
	if _Studio == nil then
		_Studio = settings():GetService('Studio')
	end

	return _Studio
end

local Root = script:FindFirstAncestor('MazeGeneratorPlugin')

local Roact = require(Root:WaitForChild('Roact'))
local Log = require(Root.Log)

local strict = require(script.Parent.Parent.strict)

local lightTheme = strict('Theme', {
	ButtonFont = Enum.Font.SourceSans,
	InputFont = Enum.Font.SourceSans,
	TitleFont = Enum.Font.SourceSans,
	MainFont = Enum.Font.SourceSans,
	Brand1 = Color3.fromRGB(124, 0, 215),
	Text1 = Color3.fromRGB(64, 64, 64),
	Text2 = Color3.fromRGB(160, 160, 160),
	TextOnAccent = Color3.fromRGB(235, 235, 235),
	Background1 = Color3.fromRGB(255, 255, 255),
	Background2 = Color3.fromRGB(235, 235, 235),
})

local darkTheme = strict('Theme', {
	ButtonFont = Enum.Font.SourceSans,
	InputFont = Enum.Font.SourceSans,
	TitleFont = Enum.Font.SourceSans,
	MainFont = Enum.Font.SourceSans,
	Brand1 = Color3.fromRGB(124, 0, 215),
	Text1 = Color3.fromRGB(235, 235, 235),
	Text2 = Color3.fromRGB(200, 200, 200),
	TextOnAccent = Color3.fromRGB(235, 235, 235),
	Background1 = Color3.fromRGB(48, 48, 48),
	Background2 = Color3.fromRGB(64, 64, 64),
})

local Context = Roact.createContext(lightTheme)

local StudioProvider = Roact.Component:extend('StudioProvider')

-- Pull the current theme from Roblox Studio and update state with it.
function StudioProvider:updateTheme()
	local studioTheme = getStudio().Theme

	if studioTheme.Name == 'Light' then
		self:setState({ theme = lightTheme })
	elseif studioTheme.Name == 'Dark' then
		self:setState({ theme = darkTheme })
	else
		Log.warn("Unexpected theme '{}'' -- falling back to light theme!", studioTheme.Name)

		self:setState({ theme = lightTheme })
	end
end

function StudioProvider:init()
	self:updateTheme()
end

function StudioProvider:render()
	return Roact.createElement(
		Context.Provider,
		{ value = self.state.theme },
		self.props[Roact.Children]
	)
end

function StudioProvider:didMount()
	self.connection = getStudio().ThemeChanged:Connect(function()
		self:updateTheme()
	end)
end

function StudioProvider:willUnmount()
	self.connection:Disconnect()
end

local function with(callback)
	return Roact.createElement(Context.Consumer, { render = callback })
end

return {
	StudioProvider = StudioProvider,
	Consumer = Context.Consumer,
	with = with,
}