#pragma once

#include "platform_api/platform_policy.h"
#include "platform_api/platform_services.h"

#include <functional>
#include <string>
#include <string_view>
#include <vector>

namespace pp::platform::apple {

struct AppleDocumentPickerBridge {
    std::function<void(PickedPathCallback callback)> pick_image;
    std::function<void(std::vector<std::string> file_types, PickedPathCallback callback)> pick_file;
    std::function<void(std::vector<std::string> file_types, PickedPathCallback callback)> pick_save_file;
    std::function<void(PickedPathCallback callback)> pick_directory;
    std::function<std::string(std::string_view path)> format_working_directory_path;
};

class AppleDocumentPlatformServices {
public:
    explicit AppleDocumentPlatformServices(
        PlatformFamily family,
        AppleDocumentPickerBridge bridge = {});

    [[nodiscard]] std::vector<std::string> document_browse_roots(
        std::string_view work_path,
        std::string_view data_path) const;

    void pick_image(PickedPathCallback callback) const;
    void pick_file(std::vector<std::string> file_types, PickedPathCallback callback) const;
    void pick_save_file(std::vector<std::string> file_types, PickedPathCallback callback) const;
    void pick_directory(PickedPathCallback callback) const;

    [[nodiscard]] bool supports_working_directory_picker() const;
    [[nodiscard]] std::string format_working_directory_path(std::string_view path) const;
    [[nodiscard]] std::string clipboard_text() const;
    [[nodiscard]] bool set_clipboard_text(std::string_view text) const;
    void display_file(std::string_view path) const;
    void share_file(std::string_view path) const;
    void set_cursor_visible(bool visible) const;
    void save_ui_state() const;

private:
    PlatformFamily family_;
    AppleDocumentPickerBridge bridge_;
};

}
