"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = NextStepButton;
const contexts_1 = require("../../../contexts/index.js");
const react_1 = __importStar(require("react"));
const BEButton_1 = __importDefault(require("../BEButton"));
const Icon_1 = require("../Icon/Icon");
const HistoryConsistentPush_1 = require("../../../hooks/HistoryConsistentPush");
const useNextStepAction_1 = require("../../../hooks/useNextStepAction");
const ScreenSize_1 = __importDefault(require("../../../util/ScreenSize"));
const StepManager_1 = __importDefault(require("../../../util/StepManager"));
const ButtonWithNextStepConfirmationDialog = (0, useNextStepAction_1.withNextStepConfirmationDialog)(BEButton_1.default);
function NextStepButton(props) {
    const context = (0, react_1.useContext)(contexts_1.BookingEngineContext);
    const { currentStep } = (0, react_1.useContext)(contexts_1.FullPageEngineContext);
    const historyConsistentPush = (0, HistoryConsistentPush_1.useHistoryConsistentPush)();
    const buttonClickHandler = () => __awaiter(this, void 0, void 0, function* () {
        if (!props.onClick || (props.onClick && (yield props.onClick()))) {
            historyConsistentPush(StepManager_1.default.getNextStepUrl(currentStep));
        }
    });
    return (react_1.default.createElement("div", { className: "next-step-button" },
        react_1.default.createElement(ButtonWithNextStepConfirmationDialog, { size: "large", icon: props.hideIcon ? undefined : Icon_1.IconType.ArrowRight, iconPosition: "right", filled: true, primary: true, isLoading: props.isLoading, disabled: props.disabled, wide: props.wideByDefault || context.screenSize <= ScreenSize_1.default.Medium, onClick: buttonClickHandler }, props.text)));
}
//# sourceMappingURL=NextStepButton.js.map