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 __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var StepService = /** @class */ (function () {
    function StepService(checkout) {
        var _this = this;
        this.checkout = checkout;
        /** Persistir el id del paso para luego indicarle al CheckoutService quien le habla */
        this.initialize = function (step_id) {
            _this.step_id = step_id;
        };
        /** Reinicia información en CheckoutService del paso */
        this.restartStep = function () { return _this.checkout.setStepDoing(_this.step_id); };
        /**
         * Obtener información obtenida en el paso de datos asociados al usuario y a la facturación
         */
        this.getUserData = function () { return _this.checkout.getStepData('address'); };
        /**
         * Obtener información obtenida en el paso de envío
         */
        this.getShipmentData = function () { return _this.checkout.getStepData('shipment'); };
        /**
         * Obtener información obtenida en el paso de pago
         */
        this.getPaymentData = function () { return _this.checkout.getStepData('payment'); };
        /**
         *
         * @param step_data Información obtenida en el paso
         * @param order Información de la orden que devolvió el backend al terminar el paso
         */
        this.setStepReady = function (step_data, order) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, this.restartStep()];
                case 1: return [2 /*return*/, (_a.sent()) && this.checkout.setStepReady(this.step_id, step_data, order)];
            }
        }); }); };
    }
    return StepService;
}());
export { StepService };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RlcC1zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctZWFzeWNvbW1lcmNlLyIsInNvdXJjZXMiOlsibGliL2NsYXNzZXMvY2hlY2tvdXQvc3RlcC1zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUdBO0lBSUkscUJBQW9CLFFBQXlCO1FBQTdDLGlCQUFrRDtRQUE5QixhQUFRLEdBQVIsUUFBUSxDQUFpQjtRQUU3QyxzRkFBc0Y7UUFDdEYsZUFBVSxHQUFHLFVBQUMsT0FBTztZQUNqQixLQUFJLENBQUMsT0FBTyxHQUFHLE9BQU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