"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtendedExchangeState = void 0;
exports.getExchangeState = getExchangeState;
const subgraph_1 = require("../subgraph");
var ExtendedExchangeState;
(function (ExtendedExchangeState) {
    ExtendedExchangeState["NotRedeemableYet"] = "NOT REDEEMABLE YET";
    ExtendedExchangeState["Expired"] = "EXPIRED";
})(ExtendedExchangeState || (exports.ExtendedExchangeState = ExtendedExchangeState = {}));
function getExchangeState(exchange) {
    const { offer } = exchange;
    if (Number(offer.voucherRedeemableFromDate) * 1000 > Date.now()) {
        return ExtendedExchangeState.NotRedeemableYet;
    }
    if (exchange.state === subgraph_1.ExchangeState.COMMITTED &&
        Number(exchange.validUntilDate) * 1000 < Date.now()) {
        return ExtendedExchangeState.Expired;
    }
    return exchange.state;
}
//# sourceMappingURL=getExchangeState.js.map