/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#pragma once

#include <ox/event/signal.hpp>

#include <turbine/context.hpp>

#include "project.hpp"

namespace studio {

class StudioUI;

struct Context {
	public:
		friend void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept;
		friend void navigateBack(Context &ctx) noexcept;
		friend void navigateForward(Context &ctx) noexcept;
		friend StudioUI;
		StudioUI &ui;
		Project *project = nullptr;
		turbine::Context &tctx;
	protected:
		struct NavPath {
			ox::String filePath;
			ox::String navArgs;
		};
		size_t navIdx{};
		ox::Vector<NavPath> navStack;
		std::function<void(ox::StringParam filePath, ox::StringParam navArgs)> navCallback;
		Context(StudioUI &pUi, turbine::Context &pTctx) noexcept:
			ui{pUi}, tctx{pTctx} {}
};

[[nodiscard]]
inline keel::Context &keelCtx(Context &ctx) noexcept {
	return keelCtx(ctx.tctx);
}

[[nodiscard]]
inline keel::Context const &keelCtx(Context const &ctx) noexcept {
	return keelCtx(ctx.tctx);
}

void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs = "") noexcept;

void navigateBack(Context &ctx) noexcept;

void navigateForward(Context &ctx) noexcept;

}
