-- For Testing

ClientSceneFramework.task = task

local hasBeenCalled = false

return function(stubs)
	if hasBeenCalled then
		error("Client Scene Framework has already been called")
		return
	end

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

	-- Anchor Client For Scene Transition: Anchors a client while they're transitioning so their velocity doesn't launch people
	ClientSceneFramework.handleAnchorClientForSceneTransition =
		ClientSceneFramework.AnchorClientForSceneTransitionModule
	ClientSceneFramework.AnchorClientForSceneTransition.OnClientEvent:Connect(
		ClientSceneFramework.handleAnchorClientForSceneTransition
	)

	-- Unload Scene Client Remote Event: removes their scene
	ClientSceneFramework.handleUnloadSceneClientRemoteEvent = ClientSceneFramework.UnloadSceneClientRemoteEventModule(
		ClientSceneFramework.DefaultUnloadScene
	)
	ClientSceneFramework.UnloadSceneClientRemoteEvent.OnClientEvent:Connect(
		ClientSceneFramework.handleUnloadSceneClientRemoteEvent
	)

	-- Load Scene Remote Event: Loads a scene for the client and tells them they're ready to transition
	ClientSceneFramework.handleLoadSceneRemoteEvent =
		ClientSceneFramework.LoadSceneRemoteEventModule.LoadSceneRemoteEventFn
	ClientSceneFramework.LoadSceneRemoteEvent.OnClientEvent:Connect(ClientSceneFramework.handleLoadSceneRemoteEvent)

	-- Get Current Scene Environment: Returns the scene's client folder from workspace
	ClientSceneFramework.handleGetCurrentSceneEnvironment = ClientSceneFramework.GetCurrentSceneEnvironmentModule
	ClientSceneFramework.GetCurrentSceneEnvironment.OnInvoke = ClientSceneFramework.handleGetCurrentSceneEnvironment

	ClientSceneFramework.InitModule()

	hasBeenCalled = true

	return ClientSceneFramework
end
