var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import { RibbonGroupBase } from '../ribbon-interfaces';
// Constants for UI element IDs
export var TRACKING_GROUP = '_tracking_group';
export var TRACK_CHANGES_ID = '_track_changes';
export var ACCEPT_ALL_ID = '_accept_all';
export var REJECT_ALL_ID = '_reject_all';
/**
 * Represents the Tracking Group in Review tab
 * @private
 */
var TrackingGroup = /** @class */ (function (_super) {
    __extends(TrackingGroup, _super);
    /**
     * Constructor for the TrackingGroup
     * @param {DocumentEditorContainer} container - DocumentEditorContainer instance
     */
    function TrackingGroup(container) {
        return _super.call(this, container) || this;
    }
    /**
     * Gets the ribbon group model for Tracking
     * @returns {RibbonGroupModel} - Ribbon group model for Tracking
     * @private
     */
    TrackingGroup.prototype.getGroupModel = function () {
        var locale = this.localObj;
        return {
            id: this.ribbonId + TRACKING_GROUP,
            header: locale.getConstant('Tracking'),
            enableGroupOverflow: true,
            overflowHeader: locale.getConstant('Tracking'),
            collections: [{
                    items: [
                        {
                            id: this.ribbonId + TRACK_CHANGES_ID,
                            type: 'Button',
                            keyTip: 'G',
                            buttonSettings: {
                                content: locale.getConstant('TrackChanges'),
                                iconCss: 'e-icons e-de-cnt-track',
                                isToggle: true,
                                clicked: this.trackChangesHandler.bind(this)
                            },
                            ribbonTooltipSettings: {
                                content: locale.getConstant('TrackChanges')
                            }
                        }
                    ]
                }, {
                    items: [
                        {
                            id: this.ribbonId + ACCEPT_ALL_ID,
                            type: 'Button',
                            keyTip: 'A2',
                            buttonSettings: {
                                content: locale.getConstant('Accept All'),
                                iconCss: 'e-icons e-de-ctnr-changes-accept',
                                isToggle: false,
                                clicked: this.acceptAllHandler.bind(this)
                            },
                            ribbonTooltipSettings: {
                                content: locale.getConstant('Accept all changes in the document')
                            }
                        },
                        {
                            id: this.ribbonId + REJECT_ALL_ID,
                            type: 'Button',
                            keyTip: 'J',
                            buttonSettings: {
                                content: locale.getConstant('Reject All'),
                                iconCss: 'e-icons e-de-ctnr-changes-reject',
                                isToggle: false,
                                clicked: this.rejectAllHandler.bind(this)
                            },
                            ribbonTooltipSettings: {
                                content: locale.getConstant('Reject all changes in the document')
                            }
                        }
                    ]
                }]
        };
    };
    /**
     * Handle click on track changes button
     * @returns {void}
     */
    TrackingGroup.prototype.trackChangesHandler = function () {
        this.container.enableTrackChanges = !this.container.enableTrackChanges;
    };
    /**
     * Handle click on accept all button
     * @returns {void}
     */
    TrackingGroup.prototype.acceptAllHandler = function () {
        this.documentEditor.revisions.acceptAll();
    };
    /**
     * Handle click on reject all button
     * @returns {void}
     */
    TrackingGroup.prototype.rejectAllHandler = function () {
        this.documentEditor.revisions.rejectAll();
    };
    /**
     * Update tracking controls based on document state
     * @returns {void}
     * @private
     */
    TrackingGroup.prototype.updateSelection = function () {
        var isTrackingEnabled = this.container.enableTrackChanges &&
            this.documentEditor.revisions.length > 0
            && (!this.container.restrictEditing && !this.documentEditor.documentHelper.isDocumentProtected);
        var ribbon = this.container.ribbon.ribbon;
        // Update track changes button state
        var trackChangesElement = document.getElementById(this.ribbonId + TRACK_CHANGES_ID);
        if (trackChangesElement) {
            trackChangesElement.classList.toggle('e-active', this.container.enableTrackChanges);
        }
        // Enable/disable accept/reject buttons based on if there are changes to accept/reject
        if (isTrackingEnabled) {
            ribbon.enableItem(this.ribbonId + ACCEPT_ALL_ID);
            ribbon.enableItem(this.ribbonId + REJECT_ALL_ID);
        }
        else {
            ribbon.disableItem(this.ribbonId + ACCEPT_ALL_ID);
            ribbon.disableItem(this.ribbonId + REJECT_ALL_ID);
        }
    };
    return TrackingGroup;
}(RibbonGroupBase));
export { TrackingGroup };
