"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BorrowerNote = exports.BorrowerNoteSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const BorrowerNoteAttachmentSchema = new mongoose_1.default.Schema({
    fileId: {
        type: String,
        required: true,
    },
    fileName: {
        type: String,
        required: true,
    },
    filePath: {
        type: String,
        required: true,
    },
    mimeType: {
        type: String,
        required: false,
    },
    size: {
        type: Number,
        required: false,
    },
    fieldName: {
        type: String,
        required: false,
    },
    contentId: {
        type: String,
        required: false,
        default: null,
    },
    isInline: {
        type: Boolean,
        required: true,
        default: false,
    },
});
exports.BorrowerNoteSchema = new mongoose_1.default.Schema({
    taskId: {
        type: String,
        required: true,
        index: true,
    },
    borrowerId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.borrowers,
        required: true,
        index: true,
    },
    status: {
        type: String,
        enum: ['draft', 'processing', 'ready', 'failed'],
        default: 'draft',
        index: true,
    },
    text: {
        type: String,
        required: false,
    },
    subjectId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.borrowerNoteSubject,
        required: false,
        index: true,
    },
    createdBy: {
        type: String,
        required: true,
    },
    updatedBy: {
        type: String,
    },
    attachments: [BorrowerNoteAttachmentSchema],
    source: {
        type: {
            type: String,
            enum: ['manual', 'email'],
            default: 'manual',
        },
        emailFrom: { type: String },
        emailTo: { type: String },
        emailText: { type: String },
        emailHtml: { type: String },
    },
}, {
    timestamps: true,
    versionKey: false,
});
exports.BorrowerNote = mongoose_1.default.model(_models_1.MODEL_NAMES.borrowerNote, exports.BorrowerNoteSchema);
