/**
 * Helper class to check whether a node has particular format or not
 *
 * @hidden
 */
var FormattingHelper = /** @class */ (function () {
    function FormattingHelper() {
    }
    /**
     * isBold method
     *
     * @param {Node} node - specifies the node value
     * @returns {boolean} - returns the boolean value
     * @hidden
     */
    FormattingHelper.isBold = function (node) {
        var nodeName = node.nodeName.toLowerCase();
        if (this.validBoldTags.has(nodeName)) {
            return true;
        }
        else if (this.inlineTagsSet.has(nodeName) && node.style) {
            var fontWeight = node.style.fontWeight;
            return fontWeight && (fontWeight === 'bold' || parseInt(fontWeight, 10) >= 600);
        }
        return false;
    };
    /**
     * isItalic method
     *
     * @param {Node} node - specifies the node value
     * @returns {boolean} - returns the boolean value
     * @hidden
     */
    FormattingHelper.isItalic = function (node) {
        var nodeName = node.nodeName.toLowerCase();
        if (this.validItalicTags.has(nodeName)) {
            return true;
        }
        if (this.inlineTagsSet.has(nodeName) && node.style) {
            return node.style.fontStyle === 'italic';
        }
        return false;
    };
    /**
     * isUnderline method
     *
     * @param {Node} node - specifies the node value
     * @returns {boolean} - returns the boolean value
     * @hidden
     */
    FormattingHelper.isUnderline = function (node) {
        var nodeName = node.nodeName.toLowerCase();
        if (this.validUnderlineTags.has(nodeName)) {
            return true;
        }
        if (this.inlineTagsSet.has(nodeName) && node.style) {
            var style = node.style;
            return style.textDecoration === 'underline' || style.textDecorationLine === 'underline';
        }
        return false;
    };
    /**
     * isStrikethrough method
     *
     * @param {Node} node - specifies the node value
     * @returns {boolean} - returns the boolean value
     * @hidden
     */
    FormattingHelper.isStrikethrough = function (node) {
        var nodeName = node.nodeName.toLowerCase();
        if (this.validStrikethroughTags.has(nodeName)) {
            return true;
        }
        if (this.inlineTagsSet.has(nodeName) && node.style) {
            var style = node.style;
            return style.textDecoration === 'line-through' || style.textDecorationLine === 'line-through';
        }
        return false;
    };
    /**
     * isSuperscript method
     *
     * @param {Node} node - specifies the node value
     * @returns {boolean} - returns the boolean value
     * @hidden
     */
    FormattingHelper.isSuperscript = function (node) {
        return this.validSuperscriptTags.has(node.nodeName.toLowerCase());
    };
    /**
     * isSubscript method
     *
     * @param {Node} node - specifies the node value
     * @returns {boolean} - returns the boolean value
     * @hidden
     */
    FormattingHelper.isSubscript = function (node) {
        return this.validSubscriptTags.has(node.nodeName.toLowerCase());
    };
    /**
     * isInlineCode method
     *
     * @param {Node} node - specifies the node value
     * @returns {boolean} - returns the boolean value
     * @hidden
     */
    FormattingHelper.isInlineCode = function (node) {
        var nodeName = node.nodeName.toLowerCase();
        if (this.validInlineCodeTags.has(nodeName)) {
            return true;
        }
        return false;
    };
    FormattingHelper.getFontColor = function (node) {
        return this.getStyleProperty(node, 'color');
    };
    FormattingHelper.getBackgroundColor = function (node) {
        return this.getStyleProperty(node, 'backgroundColor');
    };
    FormattingHelper.getStyleProperty = function (node, property) {
        var nodeName = node.nodeName.toLowerCase();
        if (this.inlineTagsSet.has(nodeName) && node.style) {
            return node.style[property] || '';
        }
        return '';
    };
    FormattingHelper.validBoldTags = new Set(['strong', 'b']);
    FormattingHelper.validItalicTags = new Set(['em', 'i']);
    FormattingHelper.validUnderlineTags = new Set(['u']);
    FormattingHelper.validStrikethroughTags = new Set(['del', 'strike', 's']);
    FormattingHelper.validSuperscriptTags = new Set(['sup']);
    FormattingHelper.validSubscriptTags = new Set(['sub']);
    FormattingHelper.validInlineCodeTags = new Set(['code']);
    FormattingHelper.inlineTagsSet = new Set(['a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'cite', 'code', 'dfn', 'em',
        'font', 'i', 'kbd', 'label', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'u', 'var', 'del']);
    return FormattingHelper;
}());
export { FormattingHelper };
