#pragma once

#include "foundation/result.h"

#include <string_view>

namespace pp::app {

enum class BrushPackageImportKind {
    abr,
    ppbr,
};

class BrushPackageImportServices {
public:
    virtual ~BrushPackageImportServices() = default;

    virtual void import_brush_package(BrushPackageImportKind kind, std::string_view path) = 0;
};

[[nodiscard]] inline const char* brush_package_import_kind_name(BrushPackageImportKind kind) noexcept
{
    switch (kind) {
    case BrushPackageImportKind::abr:
        return "abr";
    case BrushPackageImportKind::ppbr:
        return "ppbr";
    }

    return "abr";
}

[[nodiscard]] inline pp::foundation::Status validate_brush_package_import_path(std::string_view path) noexcept
{
    if (path.empty()) {
        return pp::foundation::Status::invalid_argument("brush package import path must not be empty");
    }

    return pp::foundation::Status::success();
}

[[nodiscard]] inline pp::foundation::Status execute_brush_package_import(
    BrushPackageImportKind kind,
    std::string_view path,
    BrushPackageImportServices& services)
{
    const auto status = validate_brush_package_import_path(path);
    if (!status.ok()) {
        return status;
    }

    services.import_brush_package(kind, path);
    return pp::foundation::Status::success();
}

} // namespace pp::app
