"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NoteApiImpl = void 0;
const tslib_1 = require("tslib");
const ApiBase_1 = require("./ApiBase");
const NoteRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/NoteRedux"));
const NoteInternalApi_1 = require("../Internal/NoteInternalApi");
class NoteApiImpl extends ApiBase_1.ApiBase {
    internalApi;
    constructor(_adaptable) {
        super(_adaptable);
        this.internalApi = new NoteInternalApi_1.NoteInternalApi(_adaptable);
    }
    addNote(noteStr, primaryKeyValue, columnId) {
        const note = {
            Text: noteStr,
            PrimaryKeyValue: primaryKeyValue,
            ColumnId: columnId,
            Timestamp: Date.now(),
        };
        this.dispatchAction(NoteRedux.NoteAdd(note));
    }
    editNote(note) {
        note.Timestamp = Date.now();
        this.dispatchAction(NoteRedux.NoteEdit(note));
    }
    updateNoteText(noteStr, note) {
        this.editNote({
            ...note,
            Text: noteStr,
        });
    }
    deleteNote(note) {
        this.dispatchAction(NoteRedux.NoteDelete(note));
    }
    getNoteState() {
        return this.getAdaptableState().Note;
    }
    getAllNotes() {
        return this.getNoteState().Notes;
    }
    getNoteForCell(cellAddress) {
        return NoteRedux.GetNoteSelector(this.getAdaptableState().Note, cellAddress);
    }
    getNoteByUuid(uuid) {
        return this.getAllNotes().find((note) => note.Uuid === uuid);
    }
}
exports.NoteApiImpl = NoteApiImpl;
