#ifndef CHAT_HPP_INCLUDED
#define CHAT_HPP_INCLUDED

#include "../../Core/Classes/MessageNode.hpp"
#include "../../Game/Interactable/Widget.hpp"
#include <cstdint>
#include <string>
#include <vector>

namespace Chat
{
    typedef enum DIALOGUE_STATE
    {
        IDLE,
        CLICK_CONTINUE,
        SELECT_OPTION,
        PLEASE_WAIT,
        ENTER_AMOUNT,
        LEVEL_UP,
        PLEASE_WAIT_TIMED
    } DIALOGUE_STATE;

    typedef enum CHAT_TYPE
    {
        /** Game message */
        GAME_MESSAGE = 0,
        /** Public chat message from a moderator */
        MOD = 1,
        /** Public chat message */
        PUBLIC = 2,
        /** Private message from another player */
        PRIVATE = 3,
        ENGINE = 4,
        /** Received when a friend logs in or out */
        LOGIN_LOGOUT_NOTIFICATION = 5,
        /** Private message sent to another player */
        PRIVATE_OUT = 6,
        /** Private message received from a moderator */
        MOD_PRIVATE = 7,
        /** Clan chat message */
        FRIENDS = 9,
        /** Message with information about the current clan chat */
        FRIENDS_NOTIFICATION = 11,
        /** Trade request being sent */
        TRADE_SENT = 12,
        /** Game broadcast */
        BROADCAST = 14,
        /** Abuse report submitted */
        SNAPSHOT_FEEDBACK = 26,
        /** Examine item message */
        EXAMINE_ITEM = 27,
        /** Examine NPC message */
        EXAMINE_NPC = 28,
        /** Examine object message */
        EXAMINE_OBJ = 29,
        /** Message sent when adding a player to friends list */
        FRIEND_NOTIFICATION = 30,
        /** Message sent when adding a player to ignore list */
        IGNORE_NOTIFICATION = 31,
        /** Autotyper message from a player */
        AUTOTYPER = 90,
        /** Autotyper message from a moderator */
        MOD_AUTOTYPER = 91,
        /** Message sent typically when a setting changes */
        CONSOLE = 99,
        /** Message recieved when another sends a trade offer to the local player */
        TRADE_REQUEST = 101,
        /** Message recieved when completing a trade or duel */
        TRADE = 102,
        /** Message received when somebody sends a duel offer */
        CHALREQ_TRADE = 103,
        /** Message received when another player sends a clan challenge offer */
        CHALREQ_FRIENDS = 104,
        /** Filtered message */
        SPAM = 105,
        PLAYER_RELATED = 106,
        TENSEC_TIMEOUT = 107,
        UNKNOWN = -1
    } CHAT_TYPE;

    std::vector<Internal::MessageNode> GetMessages(bool Sort = true);
    std::vector<Internal::MessageNode> GetMessages(CHAT_TYPE Type, bool Sort = true);
    std::vector<Internal::MessageNode> GetMessages(const std::vector<CHAT_TYPE>& Type, bool Sort = true);

    Internal::MessageNode GetLastMessage();
    Internal::MessageNode GetLastMessage(CHAT_TYPE Type);

    std::vector<Interactable::Widget> GetDialogueWidgets();
    DIALOGUE_STATE GetDialogueState();
    std::vector<std::string> GetDialogueOptions();

    bool WaitDialogueState(std::uint32_t Duration, std::uint32_t Step, Chat::DIALOGUE_STATE State, bool Result = true); // Waits until the current chat state equals State

    bool DialogueContains(const std::string& Text);
    bool DialogueContains(const std::vector<std::string>& Texts);

    bool ClickContinue(bool UseKeyboard = false);
    bool EnterAmount(std::int32_t Amount);
    bool SelectDialogueOption(const std::string& Option, bool UseKeyboard = false);
    bool SelectDialogueOption(const std::vector<std::string>& Options, bool UseKeyboard = false);
}

#endif // CHAT_HPP_INCLUDED
