"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerMessageCategory = exports.ServerMessageType = void 0;
var ServerMessageType;
(function (ServerMessageType) {
    ServerMessageType[ServerMessageType["general"] = 0] = "general";
    ServerMessageType[ServerMessageType["info"] = 1] = "info";
    ServerMessageType[ServerMessageType["error"] = 2] = "error";
})(ServerMessageType = exports.ServerMessageType || (exports.ServerMessageType = {}));
var ServerMessageCategory;
(function (ServerMessageCategory) {
    ServerMessageCategory[ServerMessageCategory["general"] = 0] = "general";
})(ServerMessageCategory = exports.ServerMessageCategory || (exports.ServerMessageCategory = {}));
class ServerMessage {
    #fullMessage;
    #message;
    #type = ServerMessageType.general;
    #date;
    #category = ServerMessageCategory.general;
    get fullMessage() {
        return this.#fullMessage;
    }
    get message() {
        return this.#message;
    }
    get type() {
        return this.#type;
    }
    get category() {
        return this.#category;
    }
    get date() {
        return this.#date;
    }
    constructor(message) {
        this.#fullMessage = message;
        this.#date = new Date(0);
        const firstBracket = message.indexOf("[");
        if (firstBracket === 0) {
            const lastBracket = message.indexOf("] ", firstBracket);
            if (lastBracket > firstBracket && lastBracket > 10) {
                this.#message = message.substring(lastBracket + 2);
                if (message.substring(lastBracket - 4, lastBracket) === "INFO") {
                    this.#type = ServerMessageType.info;
                }
                else if (message.substring(lastBracket - 5, lastBracket) === "ERROR") {
                    this.#type = ServerMessageType.error;
                }
                const lastSpace = message.lastIndexOf(" ", lastBracket);
                const dateTime = message.substring(firstBracket + 1, lastSpace);
                this.#date = new Date(dateTime);
            }
            else {
                this.#message = this.#fullMessage;
            }
        }
        else {
            this.#message = this.#fullMessage;
        }
        this.#message = this.#message.trim();
    }
}
exports.default = ServerMessage;

//# sourceMappingURL=../maps/local/ServerMessage.js.map
