#pragma once

#include "platform_api/platform_services.h"

#include <string_view>
#include <vector>

namespace pp::platform {

enum class PlatformFamily {
    generic_desktop,
    windows,
    macos,
    ios,
    android,
    linux_desktop,
    webgl,
};

enum class XrRuntimeBackend {
    none,
    openxr,
    openvr,
};

struct XrRuntimeSelection {
    XrRuntimeBackend backend = XrRuntimeBackend::none;
    bool uses_legacy_openvr_fallback = false;
};

[[nodiscard]] PlatformFamily current_platform_family() noexcept;

[[nodiscard]] const char* xr_runtime_backend_name(XrRuntimeBackend backend) noexcept;
[[nodiscard]] XrRuntimeSelection select_desktop_xr_runtime(
    bool openxr_available,
    bool openvr_available,
    bool allow_legacy_openvr_fallback) noexcept;

[[nodiscard]] bool platform_deletes_recorded_files_on_clear(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_publishes_exported_images(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_flushes_persistent_storage(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_enables_live_asset_reloading(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_uses_asset_file_mtime_reload(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_saves_native_ui_state(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_supports_working_directory_picker(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_uses_prepared_file_writes(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_uses_work_directory_document_export_collections(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_uses_ppbr_export_data_directory_override(PlatformFamily family) noexcept;
[[nodiscard]] bool platform_supports_sonarpen(PlatformFamily family) noexcept;
[[nodiscard]] int platform_default_canvas_resolution(PlatformFamily family) noexcept;

[[nodiscard]] bool platform_draws_canvas_tip_for_pointer(
    PlatformFamily family,
    bool is_mouse,
    bool is_stylus,
    bool is_left_button_release) noexcept;

[[nodiscard]] std::vector<std::string> platform_document_browse_roots(
    PlatformFamily family,
    std::string_view work_path,
    std::string_view data_path);

[[nodiscard]] PreparedFileTarget plan_platform_writable_file(
    PlatformFamily family,
    std::string_view type,
    std::string_view default_name,
    std::string_view data_path,
    std::string_view temporary_path);

}
