-- Events

Conductor.SeekEvent = Orchestra.Events.ClientEvents.Seek
Conductor.SeekSceneServer = Orchestra.Events.OrchestrationEvents.SeekSceneServer
Conductor.Orchestrate = Orchestra.Events.OrchestrationEvents.Orchestrate
Conductor.SendSceneConfigForPlayer = Orchestra.Events.OrchestrationEvents.SendSceneConfigForPlayer
Conductor.PauseEvent = Orchestra.Events.ClientEvents.Pause

local hasBeenCalled = false
return function(stubs)
	if hasBeenCalled then
		error("Conductor has already been called")
		return
	end

	-- Used for testing only
	if stubs then
		for i, v in pairs(stubs) do
			Conductor[i] = v
		end
	end

	-- Seek Event: Seek from the UI when user has permissions
	Conductor.handleSeekEvent = Conductor.SeekEventModule
	Conductor.SeekEvent.OnServerEvent:Connect(Conductor.handleSeekEvent)

	-- Seek Scene Server: Seek programmatically from a server script
	Conductor.handleSeekSceneServer = Conductor.SeekSceneServerModule
	Conductor.SeekSceneServer.Event:Connect(Conductor.handleSeekSceneServer)

	-- Creates a new media controller, if necessary, and orchestrates
	Conductor.handleOrchestration = Conductor.OrchestrateModule()
	Conductor.Orchestrate.Event:Connect(Conductor.handleOrchestration)

	-- Sends over the current scene's config for a player to orchestrate client side
	Conductor.handleSendSceneConfigForPlayer = Conductor.SendSceneConfigForPlayerModule()
	Conductor.SendSceneConfigForPlayer.Event:Connect(Conductor.handleSendSceneConfigForPlayer)

	-- Pause Event: Pause from the UI when user has permissions
	Conductor.handlePauseEvent = Conductor.PauseEventModule
	Conductor.PauseEvent.OnServerEvent:Connect(Conductor.handlePauseEvent)

	hasBeenCalled = true
	script:SetAttribute(enums.Attribute.FrameworkReady, true)

	return Conductor
end
