"use strict";
/**
 * Kickback event handler
 *
 *  Copyright (C) 2010-2019 R-T Specialty, LLC.
 *
 *  This file is part of the Liza Data Collection Framework
 *
 *  Liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.KickbackEventHandler = void 0;
/**
 * Handles kickback events
 */
var KickbackEventHandler = /** @class */ (function () {
    /**
     * Initializes with client that will delegate the event
     *
     * @param client - client object
     */
    function KickbackEventHandler(_client) {
        this._client = _client;
    }
    /**
     * Handles kick-back
     *
     * @param type - event id; ignored
     * @param c    - continuation to invoke on completion
     * @param data - event data
     */
    KickbackEventHandler.prototype.handle = function (_type, c, data) {
        var step_id = +data.stepId;
        var quote = this._client.getQuote();
        var nav = this._client.nav;
        var ui = this._client.getUi();
        if (quote.getTopVisitedStepId() > step_id) {
            quote.setTopVisitedStepId(step_id);
            nav.setTopVisitedStepId(step_id);
            if (quote.getCurrentStepId() > step_id) {
                nav.navigateToStep(step_id, !!(data === null || data === void 0 ? void 0 : data.force));
            }
            ui.redrawNav();
        }
        c();
        return this;
    };
    return KickbackEventHandler;
}());
exports.KickbackEventHandler = KickbackEventHandler;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiS2lja2JhY2tFdmVudEhhbmRsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJLaWNrYmFja0V2ZW50SGFuZGxlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0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