--[[
	Returns the scene with the given name in the given list of scenes.
	Returns nil if no scene with the given name was found.

	Parameters:
	ScenesList: {Folder} - An array of scenes
	SceneName: string - The name of the scene to find

	Returns:
	Folder? - The scene with the given name or nil if no scene matches the
	given name.
]]


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

local function GetSceneByName(SceneName: string): Folder?
	local OrchestraScenes = ReplicatedStorage:FindFirstChild("SequencerScenes")
	if OrchestraScenes then
		for _, folder in ipairs(OrchestraScenes:GetChildren()) do
			if folder:IsA("Configuration") or folder:IsA("Folder") then
				if folder.Name == SceneName then
					return folder
				end
			end
		end
	end

	local ScenesList = CollectionService:GetTagged("SequencerScene")
	for _, SceneItem in ipairs(ScenesList) do
		if SceneItem.Name == SceneName then
			return SceneItem
		end
	end

	return nil
end

return GetSceneByName
