
import * as path from "path";
import { IMAPFolderNativeBinding } from "../types";
import { NodeTrustedMailcore2NativeBinding } from '../types/NodeTrustedMailcore2NativeBinding'
import { FolderFlag } from '../enums/FolderFlag'

// tslint:disable-next-line: no-var-requires
let bindings: NodeTrustedMailcore2NativeBinding;
try {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2.node"));
} catch(e) {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2_no_crypto.node"));
}

// tslint:disable-next-line
const { IMAPFolder: _IMAPFolder } = bindings

/**
 * IMAPFolder Class
 *
 * @public
 */
class IMAPFolder extends bindings.IMAPFolder {
    public handle: IMAPFolderNativeBinding

    constructor() {
        super()

        const handle = new _IMAPFolder();
        this.handle = handle;
    }

    /**
     * Get path
     *
     * @type {string}
     * @memberof IMAPFolder
     */
    get path(): string {
        return this.handle.path;
    }

    /**
     * Set path
     *
     * @memberof IMAPFolder
     */
    set path(pathV: string) {
        this.handle.path = pathV;
    }

    /**
     * Get delimiter
     *
     * @type {string}
     * @memberof IMAPFolder
     */
    get delimiter(): string {
        return this.handle.delimiter;
    }

    /**
     * Set delimiter
     *
     * @memberof IMAPFolder
     */
    set delimiter(delimiterV: string) {
        this.handle.delimiter = delimiterV;
    }

    /**
     * Folder description
     *
     * @memberof IMAPSession
     */
    public description(): string {
        return this.handle.description();
    }

    /**
     * Get flags
     *
     * @type {FolderFlag}
     * @memberof IMAPFolder
     */
    get flags(): FolderFlag {
        return this.handle.flags;
    }

    /**
     * Set flags
     *
     * @memberof IMAPFolder
     */
    set flags(flagsVal: FolderFlag) {
        this.handle.flags = flagsVal;
    }
}

export { IMAPFolder }
