/* Minification failed. Returning unminified contents.
(1267,10-15): run-time warning JS1010: Expected identifier: catch
(1309,12-17): run-time warning JS1010: Expected identifier: catch
(1267,10-15): run-time error JS1137: 'catch' is a new reserved word and should not be used as an identifier: catch
(1309,12-17): run-time error JS1137: 'catch' is a new reserved word and should not be used as an identifier: catch
 */
"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var BiddingInfo = /*#__PURE__*/function () {
  function BiddingInfo(currentBid, openingBid, yourMaxBid, maxBid, biddingEnds, buyItNowPrice, minBid) {
    _classCallCheck(this, BiddingInfo);
    this.currentBid = Utils.parseLocaleFloat(currentBid);
    this.openingBid = Utils.parseLocaleFloat(openingBid);
    this.yourMaxBid = Utils.parseLocaleFloat(yourMaxBid);
    this.maxBid = Utils.parseLocaleFloat(maxBid);
    this.buyItNowPrice = Utils.parseLocaleFloat(buyItNowPrice);
    this.biddingEnds = biddingEnds;
    this.minBid = Utils.parseLocaleFloat(minBid);
  }
  _createClass(BiddingInfo, [{
    key: "openingBidFormat",
    get: function get() {
      return Utils.formatAmount(this.openingBid);
    }
  }, {
    key: "currentBidFormat",
    get: function get() {
      return Utils.formatAmount(this.currentBid);
    }
  }, {
    key: "yourMaxBidFormat",
    get: function get() {
      return Utils.formatAmount(this.yourMaxBid);
    }
  }, {
    key: "maxBidFormat",
    get: function get() {
      return Utils.formatAmount(this.maxBid);
    }
  }, {
    key: "buyItNowPriceFormat",
    get: function get() {
      return Utils.formatAmount(this.buyItNowPrice);
    }
  }]);
  return BiddingInfo;
}();
var BidderInfo = /*#__PURE__*/_createClass(function BidderInfo(bidderId, customerId) {
  _classCallCheck(this, BidderInfo);
  this.bidderId = bidderId;
  this.customerId = customerId;
});
var LotDetails = /*#__PURE__*/function () {
  function LotDetails(imageHref, title, description, detailsHref, currency, biddingInfo, bulkQuantity, lotId, auctionRef, csrf, isPiecemealEnabled, itemId, bidderInfo, auctionId) {
    _classCallCheck(this, LotDetails);
    this.imageHref = imageHref;
    this.title = title;
    this.description = description;
    this.detailsHref = detailsHref;
    this.currency = currency;
    this.bidding = biddingInfo;
    this.bulkQuantity = Utils.parseLocaleInt(bulkQuantity);
    this.lotId = lotId;
    this.auctionRef = auctionRef;
    this.csrf = csrf;
    this.isPiecemealEnabled = isPiecemealEnabled;
    this.itemId = itemId;
    this.bidder = bidderInfo;
    this.auctionId = auctionId;
    this.bidNowEnabled = false;
  }
  _createClass(LotDetails, [{
    key: "isMaxBidValid",
    value: function isMaxBidValid() {
      return this.bidding.maxBid && this.bidding.maxBid > 0;
    }
  }, {
    key: "currentBidPiecemealText",
    value: function currentBidPiecemealText() {
      if (this.isPiecemealEnabled && this.bidding.currentBid) {
        return LotDetails.piecemealText(this.bidding.currentBid, this.bulkQuantity, this.currency);
      }
    }
  }, {
    key: "openingBidPiecemealText",
    value: function openingBidPiecemealText() {
      if (this.isPiecemealEnabled && this.bidding.openingBid) {
        return LotDetails.piecemealText(this.bidding.openingBid, this.bulkQuantity, this.currency);
      }
    }
  }, {
    key: "yourMaximumBidPiecemealText",
    value: function yourMaximumBidPiecemealText() {
      if (this.isPiecemealEnabled && this.bidding.yourMaxBid) {
        return LotDetails.piecemealText(this.bidding.yourMaxBid, this.bulkQuantity, this.currency);
      }
    }
  }, {
    key: "buyItNowPiecemealText",
    value: function buyItNowPiecemealText() {
      if (this.isPiecemealEnabled && this.bidding.buyItNowPrice) {
        return LotDetails.piecemealText(this.bidding.buyItNowPrice, this.bulkQuantity, this.currency);
      }
    }
  }, {
    key: "totalMaxBidFormat",
    get: function get() {
      if (this.isPiecemealEnabled && this.bidding.maxBid) {
        return Utils.formatAmount(this.bulkQuantity * this.bidding.maxBid);
      }
    }
  }, {
    key: "piecemealExists",
    get: function get() {
      return this.isPiecemealEnabled && this.bulkQuantity > 1;
    }
  }, {
    key: "bulkQuantityFormat",
    get: function get() {
      return Utils.formatAmount(this.bulkQuantity);
    }
  }, {
    key: "buyItNowEnabled",
    get: function get() {
      return this.bidding.buyItNowPrice !== undefined && !isNaN(this.bidding.buyItNowPrice) && this.bidding.minBid !== undefined && !isNaN(this.bidding.minBid) && this.bidding.buyItNowPrice >= this.bidding.minBid;
    }
  }], [{
    key: "piecemealText",
    value: function piecemealText(value, quantity, currency) {
      return " x ".concat(Utils.formatAmount(quantity), " = ").concat(Utils.formatAmount(quantity * value), " ").concat(currency);
    }
  }]);
  return LotDetails;
}();
var OffIncrementReason = /*#__PURE__*/function () {
  function OffIncrementReason() {
    _classCallCheck(this, OffIncrementReason);
    this.reasonEnum = {
      bidBelowMinimumValue: 0,
      bidOffIncrement: 1
    };
    this.reasonModeMap = {
      oneButton: 'oneButton',
      twoButtons: 'twoButtons'
    };
  }
  _createClass(OffIncrementReason, [{
    key: "getMode",
    value: function getMode(reason) {
      switch (reason) {
        case this.reasonEnum.bidBelowMinimumValue:
          return this.reasonModeMap.oneButton;
        case this.reasonEnum.bidOffIncrement:
          return this.reasonModeMap.twoButtons;
      }
      ;
    }
  }]);
  return OffIncrementReason;
}();
var BidStatus = /*#__PURE__*/function () {
  function BidStatus() {
    _classCallCheck(this, BidStatus);
    this.statusClassMap = {
      '0': 'bidder-declined',
      '1': 'bid-error',
      '2': 'bid-pending',
      '3': 'bidder-winning',
      '4': 'bidder-losing',
      '5': 'bidder-losing-equal-amount'
    };
    this.statusEnum = {
      declined: 0,
      error: 1,
      pending: 2,
      acceptedLeading: 3,
      acceptedOutbid: 4,
      acceptedOutbidEqualAmount: 5
    };
    this.statusEnumNames = {
      '0': 'declined',
      '1': 'error',
      '2': 'pending',
      '3': 'acceptedLeading',
      '4': 'acceptedOutbid',
      '5': 'acceptedOutbidEqualAmount'
    };
    var statuses = this.statusClassMap;
    this.allStatusesValues = Object.keys(statuses).map(function (e) {
      return statuses[e];
    });
  }
  _createClass(BidStatus, [{
    key: "isSuccess",
    value: function isSuccess(response) {
      return response.status === this.statusEnum.acceptedLeading;
    }
  }, {
    key: "isRetryable",
    value: function isRetryable(response) {
      return response.status === this.statusEnum.acceptedOutbid || response.status === this.statusEnum.acceptedOutbidEqualAmount || response.status === this.statusEnum.error;
    }
  }, {
    key: "isAccepted",
    value: function isAccepted(response) {
      return response.status === this.statusEnum.acceptedLeading || response.status === this.statusEnum.acceptedOutbid || response.status === this.statusEnum.acceptedOutbidEqualAmount;
    }
  }, {
    key: "status",
    value: function status(response) {
      var reason;
      if (response.status === this.statusEnum.error || response.status === this.statusEnum.acceptedOutbid || response.status === this.statusEnum.acceptedOutbidEqualAmount) {
        reason = response.reason;
      }
      return {
        status: this.statusClassMap[response.status],
        allStatuses: this.allStatusesValues.join(' '),
        reason: reason
      };
    }
  }, {
    key: "error",
    value: function error() {
      return {
        status: this.statusClassMap[1],
        allStatuses: this.allStatusesValues.join(' ')
      };
    }
  }, {
    key: "allStatuses",
    value: function allStatuses() {
      return this.allStatusesValues.join(' ');
    }
  }, {
    key: "statusName",
    value: function statusName(response) {
      return this.statusEnumNames[response.status];
    }
  }]);
  return BidStatus;
}();
var apiResponseToEventMapper = function apiResponseToEventMapper(response, lotId) {
  return {
    LotId: lotId,
    LeadBidderId: response.WinningBidderId,
    ReserveMet: response.ReserveMet,
    MinimumBidAmount: response.NextMinimumBid,
    LeadingBid: response.HammerPrice,
    Timestamp: response.Timestamp
  };
};
var portalResponseMapper = function portalResponseMapper(response) {
  var bidStatus = new BidStatus();
  var offIncrementReason = new OffIncrementReason();
  var status = response.Status;
  var offIncrement = null;
  if (response.MessageType === 'error' || !response.Success) {
    status = bidStatus.statusEnum.error;
  }
  if (response.OffIncrement) {
    var offIncrementMode = offIncrementReason.getMode(response.OffIncrement.Reason);
    offIncrement = {
      mode: offIncrementMode,
      lowerIncrement: response.OffIncrement.LowerIncrement,
      higherIncrement: response.OffIncrement.HigherIncrement,
      minimumAmount: response.NextMinimumBid
    };
  }
  return {
    status: status,
    currentBid: response.HammerPrice,
    maximumBid: response.MaximumBid,
    reason: response.Message,
    reserveMet: response.ReserveMet,
    offIncrement: offIncrement
  };
};
var Utils = /*#__PURE__*/function () {
  function Utils() {
    _classCallCheck(this, Utils);
  }
  _createClass(Utils, null, [{
    key: "formatAmount",
    value: function formatAmount(amount) {
      var culture = Utils.currentCulture();
      amount = +amount || 0;
      var digitNumber = amount == amount.toFixed(0) ? 0 : 2;
      return amount.toLocaleString(culture, {
        minimumFractionDigits: digitNumber,
        maximumFractionDigits: digitNumber
      });
    }
  }, {
    key: "parseLocaleFloat",
    value: function parseLocaleFloat(value) {
      if (value == undefined || typeof value === 'number') {
        return value;
      }
      var culture = Utils.currentCulture();

      // Detect the user's locale decimal separator:
      var decimalSeparator = 1.1.toLocaleString(culture).substring(1, 2);
      // Detect the user's locale thousand separator:
      var thousandSeparator = 1000 .toLocaleString(culture).substring(1, 2);
      // In case there are locales that don't use a thousand separator
      if (thousandSeparator.match(/\d/)) {
        thousandSeparator = '';
      }
      value = value.replace(new RegExp(Utils.escapeRegex(thousandSeparator), 'g'), '');
      if (decimalSeparator !== '.') {
        value = value.replace(decimalSeparator, '.');
      }
      return parseFloat(value);
    }
  }, {
    key: "parseLocaleInt",
    value: function parseLocaleInt(value) {
      if (value == undefined || typeof value === 'number') {
        return value;
      }
      var culture = Utils.currentCulture();
      var thousandSeparator = 1000 .toLocaleString(culture).substring(1, 2);
      if (thousandSeparator.match(/\d/)) {
        thousandSeparator = '';
      }
      value = value.replace(new RegExp(Utils.escapeRegex(thousandSeparator), 'g'), '');
      return parseInt(value);
    }
  }, {
    key: "currentCulture",
    value: function currentCulture() {
      var defaultCulture = 'en-gb';
      var htmlTag = document.querySelector('html');
      if (htmlTag) {
        var lang = htmlTag.getAttribute('lang');
        if (lang) {
          return lang;
        }
      }
      var tokens = window.location.pathname.split('/');
      if (tokens[1]) {
        return tokens[1];
      }
      return defaultCulture;
    }
  }, {
    key: "escapeRegex",
    value: function escapeRegex(expression) {
      return expression.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&');
    }
  }, {
    key: "stripLangTags",
    value: function stripLangTags(text) {
      return text.replace(/(<en[^>]+?>|<en>|<\/en>)/g, "").replace(/(<de[^>]+?>|<de>|<\/de>)/g, "");
    }
  }]);
  return Utils;
}();
var QuickBiddingLocalizer = /*#__PURE__*/function () {
  function QuickBiddingLocalizer() {
    _classCallCheck(this, QuickBiddingLocalizer);
  }
  _createClass(QuickBiddingLocalizer, [{
    key: "Maximum_bid_placed_successfully",
    get: function get() {
      if (window.localizer && window.localizer.Maximum_bid_placed_successfully) {
        return window.localizer.Maximum_bid_placed_successfully;
      } else {
        return 'Maximum bid placed successfully';
      }
    }
  }, {
    key: "Bid_successful",
    get: function get() {
      if (window.localizer && window.localizer.Bid_successful) {
        return window.localizer.Bid_successful;
      } else {
        return 'Bid successful';
      }
    }
  }, {
    key: "Maximum_bid_placed_but_reserve_not_met",
    get: function get() {
      if (window.localizer && window.localizer.Maximum_bid_placed_but_reserve_not_met) {
        return window.localizer.Maximum_bid_placed_but_reserve_not_met;
      } else {
        return 'Bid successfully placed but reserve not met';
      }
    }
  }, {
    key: "Lot_closed",
    get: function get() {
      if (window.localizer && window.localizer.Lot_closed) {
        return window.localizer.Lot_closed;
      } else {
        return 'Lot closed';
      }
    }
  }, {
    key: "You_have_won_a_lot_through_Buy_It_Now",
    get: function get() {
      if (window.localizer && window.localizer.You_have_won_a_lot_through_Buy_It_Now) {
        return window.localizer.You_have_won_a_lot_through_Buy_It_Now;
      } else {
        return 'You have won a lot through Buy It Now';
      }
    }
  }, {
    key: "s",
    get: function get() {
      if (window.localizer && window.localizer.s) {
        return window.localizer.s;
      } else {
        return 's';
      }
    }
  }, {
    key: "d",
    get: function get() {
      if (window.localizer && window.localizer.d) {
        return window.localizer.d;
      } else {
        return 'd';
      }
    }
  }, {
    key: "h",
    get: function get() {
      if (window.localizer && window.localizer.h) {
        return window.localizer.h;
      } else {
        return 'h';
      }
    }
  }, {
    key: "m",
    get: function get() {
      if (window.localizer && window.localizer.m) {
        return window.localizer.m;
      } else {
        return 'm';
      }
    }
  }]);
  return QuickBiddingLocalizer;
}();
var ViewModeStates = {
  both: "both",
  buyItNow: "buyItNow",
  bid: "bid"
};
var ModalButtons = {
  confirm: 'confirm',
  minimumAmount: 'minimumAmount',
  lowerIncrement: 'lowerIncrement',
  higherIncrement: 'higherIncrement'
};;"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var QuickBiddingView = /*#__PURE__*/function () {
  function QuickBiddingView() {
    _classCallCheck(this, QuickBiddingView);
    this.styles = {
      endTimeAlert: 'bidding-ending'
    };
    this.errorMessageSelector = '#quick-bidding-error-message';
    this.errorMessageHeaderSelector = '#quick-bidding-error-message-header';
    this.errorMessageReasonSelector = '.lot-messages .bid-error-reason';
    this.errorMessageCustomReasonSelector = '.lot-messages .bid-error-custom-reason';
    this.hasShownSpecificError = false;
  }
  _createClass(QuickBiddingView, [{
    key: "init",
    value: function init(lotDetails) {
      var _this = this;
      this.hasShownSpecificError = false;
      var selectorsProvider = new SelectorsProvider(lotDetails.buyItNowEnabled);
      this.viewSelector = selectorsProvider.viewSelector;
      this.selectors = selectorsProvider.selectors;

      // Ensure modal and confirm button carry lot context for analytics per-item merge
      try {
        $(this.viewSelector).attr('data-lot-id', lotDetails.lotId);
      } catch (e) {}
      try {
        $(this.selectors.buttons.confirm).attr('data-lot-id', lotDetails.lotId);
      } catch (e) {}
      this.buttonSelectors = {};
      this.buttonSelectors[ModalButtons.confirm] = this.selectors.buttons.confirm;
      this.buttonSelectors[ModalButtons.minimumAmount] = this.selectors.offIncrement.minimumAmount;
      this.buttonSelectors[ModalButtons.lowerIncrement] = this.selectors.offIncrement.lowerIncrement;
      this.buttonSelectors[ModalButtons.higherIncrement] = this.selectors.offIncrement.higherIncrement;

      // lets use jquery for now to update modal html
      $(this.selectors.img).attr('src', lotDetails.imageHref);
      if (lotDetails.imageHref.indexOf("blank-image.png") >= 0) {
        $(this.selectors.noImg).show();
      } else {
        $(this.selectors.noImg).hide();
        $(this.selectors.img).attr('alt', lotDetails.title);
      }
      $(this.selectors.title).text(lotDetails.title);
      $(this.selectors.desc).text(lotDetails.description);
      $(this.selectors.detailsHref).attr('href', lotDetails.detailsHref);
      $(this.selectors.actions).show();
      $(this.selectors.current.piecemeal).hide();
      $(this.selectors.opening.piecemeal).hide();
      $(this.selectors.yourMaxBid.piecemeal).hide();
      $(this.selectors.yourMaxBid.bid).hide();
      if (lotDetails.buyItNowEnabled) {
        $(this.selectors.buyItNow.piecemeal).hide();
      }

      // current bid | opening-bid
      if (lotDetails.bidding.openingBid) {
        $(this.selectors.current.bid).hide();
        $(this.selectors.opening.bid).show();
        $(this.selectors.opening.value).text(lotDetails.bidding.openingBidFormat);
        $(this.selectors.opening.currency).text(lotDetails.currency);
        if (lotDetails.piecemealExists) {
          $(this.selectors.opening.piecemeal).text(lotDetails.openingBidPiecemealText()).show();
          $(this.selectors.current.piecemeal).hide();
        }
      } else {
        //don't show either current and opening if no data provided
        if (!lotDetails.bidding.currentBid) {
          $(this.selectors.current.bid).hide();
          $(this.selectors.opening.bid).hide();
        } else {
          $(this.selectors.current.bid).show();
          $(this.selectors.opening.bid).hide();
          $(this.selectors.current.value).text(lotDetails.bidding.currentBidFormat);
          $(this.selectors.current.currency).text(lotDetails.currency);
          $(this.selectors.yourMaxBid.currency).text(lotDetails.currency);
          $(this.selectors.yourMaxBid.newCurrency).text(lotDetails.currency);
          if (lotDetails.piecemealExists) {
            $(this.selectors.current.piecemeal).text(lotDetails.currentBidPiecemealText()).show();
            $(this.selectors.opening.piecemeal).hide();
          }
        }
      }

      // your max bid
      if (lotDetails.bidding.yourMaxBid) {
        $(this.selectors.yourMaxBid.bid).show();
        $(this.selectors.yourMaxBid.value).text(lotDetails.bidding.yourMaxBidFormat);
        $(this.selectors.yourMaxBid.currency).text(lotDetails.currency);
        if (lotDetails.piecemealExists) {
          $(this.selectors.yourMaxBid.piecemeal).text(lotDetails.yourMaximumBidPiecemealText()).show();
        }
      }

      // max bid
      $(this.selectors.maxBid.wrapper).hide();
      $(this.selectors.maxBid.input).val(lotDetails.bidding.maxBidFormat);
      $(this.selectors.maxBid.value).show();
      $(this.selectors.maxBid.value).text(lotDetails.bidding.maxBidFormat);
      $(this.selectors.maxBid.currency).text(lotDetails.currency);
      $(this.selectors.maxBid.newCurrency).text(lotDetails.currency);
      if (lotDetails.piecemealExists) {
        $(this.selectors.totalPiecemeal.container).show();
        $(this.selectors.totalPiecemeal.value).text(lotDetails.totalMaxBidFormat);
        $(this.selectors.totalPiecemeal.currency).text(lotDetails.currency);
      } else {
        $(this.selectors.totalPiecemeal.container).hide();
      }

      // quantity
      if (lotDetails.bulkQuantity > 1) {
        $(this.selectors.quantity).show();
        $(this.selectors.quantityValue).text(lotDetails.bulkQuantityFormat);
      } else {
        $(this.selectors.quantity).hide();
        $(this.selectors.quantityValue).text('');
      }

      // end time
      $(this.selectors.endTime).text(lotDetails.bidding.biddingEnds);
      if ($(this.selectors.endTime).hasClass(this.styles.endTimeAlert)) {
        $(this.selectors.endTime).removeClass(this.styles.endTimeAlert);
      }

      // reset errors
      $(this.errorMessageCustomReasonSelector).text('').hide();
      $(this.errorMessageReasonSelector).show();
      var bidStatus = new BidStatus();
      $(this.viewSelector).removeClass(bidStatus.allStatuses());
      $(this.selectors.buttons.cancel).off('click');
      $(this.selectors.buttons.cancel).on('click', function (e) {
        $(_this.viewSelector).modal('hide');
        _this.handleBidNowModalQuitEvent();
      });
      $(this.selectors.buttons.headerClose).off('click');
      $(this.selectors.buttons.headerClose).on('click', function (e) {
        $(_this.viewSelector).modal('hide');
        _this.handleBidNowModalQuitEvent();
      });
      var selectors = this.selectors;
      $('input[type=radio][name=bidoption]').change(function () {
        var bidChecked = $(selectors.bidOptions.bidRadio).prop('checked');
        var buyItNowChecked = $(selectors.bidOptions.buyItNowRadio).prop('checked');
        if (bidChecked) {
          $(selectors.footerText.buyItNow).hide();
          $(selectors.footerText.standard).show();
        }
        if (buyItNowChecked) {
          $(selectors.footerText.buyItNow).show();
          $(selectors.footerText.standard).hide();
        }
      });

      //buy it now
      if (lotDetails.bidding.buyItNowPrice && lotDetails.bidding.minBid && lotDetails.bidding.buyItNowPrice >= lotDetails.bidding.minBid) {
        $(this.selectors.buyItNow.bid).show();
        $(this.selectors.buyItNow.value).text(lotDetails.bidding.buyItNowPriceFormat);
        $(this.selectors.buyItNow.currency).text(lotDetails.currency);
        if (lotDetails.piecemealExists) {
          $(this.selectors.buyItNow.piecemeal).text(lotDetails.buyItNowPiecemealText()).show();
        }
      }
      this.bidNowEnabled = lotDetails.bidNowEnabled;
      this.selectedItemId = lotDetails.itemId;
      $(this.selectors.offIncrement.twoButtonsContainer).hide();
      $(this.selectors.offIncrement.oneButtonContainer).hide();
    }
  }, {
    key: "activeButton",
    get: function get() {
      return this._activeButton;
    },
    set: function set(button) {
      this._activeButton = button;
    }
  }, {
    key: "viewMode",
    value: function viewMode() {
      return $(this.selectors.bidOptions.buyItNowRadio).prop('checked') ? ViewModes.buyItNow : ViewModes.bid;
    }
  }, {
    key: "setViewModeState",
    value: function setViewModeState(viewModeState) {
      if (viewModeState === ViewModeStates.buyItNow) {
        $(this.selectors.bidOptions.buyItNowRadio).prop('checked', true);
        $(this.selectors.binEqualText).show();
        $(this.selectors.footerText.buyItNow).show();
        $(this.selectors.footerText.standard).hide();
        $(this.selectors.columns.bidColumn).addClass('blocked');
        $(this.selectors.bidOptions.bidRadio).prop('disabled', true);
        $(this.selectors.columns.binColumn).removeClass('blocked');
        $(this.selectors.bidOptions.buyItNowRadio).prop('disabled', false);
      } else if (viewModeState === ViewModeStates.both) {
        $(this.selectors.bidOptions.bidRadio).prop('checked', true);
        $(this.selectors.binEqualText).hide();
        $(this.selectors.footerText.standard).show();
        $(this.selectors.footerText.buyItNow).hide();
        $(this.selectors.columns.bidColumn).removeClass('blocked');
        $(this.selectors.bidOptions.bidRadio).prop('disabled', false);
        $(this.selectors.columns.binColumn).removeClass('blocked');
        $(this.selectors.bidOptions.buyItNowRadio).prop('disabled', false);
      } else if (viewModeState === ViewModeStates.bid) {
        $(this.selectors.bidOptions.bidRadio).prop('checked', true);
        $(this.selectors.binEqualText).hide();
        $(this.selectors.footerText.standard).show();
        $(this.selectors.footerText.buyItNow).hide();
        $(this.selectors.columns.bidColumn).removeClass('blocked');
        $(this.selectors.bidOptions.bidRadio).prop('disabled', false);
        $(this.selectors.columns.binColumn).addClass('blocked');
        $(this.selectors.bidOptions.buyItNowRadio).prop('disabled', true);
      }
    }
  }, {
    key: "onConfirm",
    value: function onConfirm(handler, lotDetails) {
      var _this2 = this;
      $(this.selectors.buttons.confirm).off('click');
      $(this.selectors.buttons.confirm).on('click', function () {
        _this2.activeButton = ModalButtons.confirm;
        handler(_this2, lotDetails);
      });
    }
  }, {
    key: "onMaxBidValueChanged",
    value: function onMaxBidValueChanged(handler, lotDetails) {
      var _this3 = this;
      $(this.selectors.maxBid.input).off('change paste keyup');
      $(this.selectors.maxBid.input).on('change paste keyup', function () {
        handler(_this3, lotDetails);
      });
    }
  }, {
    key: "onOffIncrementMinimumAmount",
    value: function onOffIncrementMinimumAmount(handler, lotDetails) {
      var _this4 = this;
      $(this.selectors.offIncrement.minimumAmount).off('click');
      $(this.selectors.offIncrement.minimumAmount).on('click', function () {
        _this4.activeButton = ModalButtons.minimumAmount;
        handler(_this4, lotDetails);
      });
    }
  }, {
    key: "onOffIncrementLowerIncrement",
    value: function onOffIncrementLowerIncrement(handler, lotDetails) {
      var _this5 = this;
      $(this.selectors.offIncrement.lowerIncrement).off('click');
      $(this.selectors.offIncrement.lowerIncrement).on('click', function () {
        _this5.activeButton = ModalButtons.lowerIncrement;
        handler(_this5, lotDetails);
      });
    }
  }, {
    key: "onOffIncrementHigherIncrement",
    value: function onOffIncrementHigherIncrement(handler, lotDetails) {
      var _this6 = this;
      $(this.selectors.offIncrement.higherIncrement).off('click');
      $(this.selectors.offIncrement.higherIncrement).on('click', function () {
        _this6.activeButton = ModalButtons.higherIncrement;
        handler(_this6, lotDetails);
      });
    }
  }, {
    key: "maxBid",
    get: function get() {
      // when input is visible, get value from imput
      return Utils.parseLocaleFloat($(this.selectors.maxBid.input).val());
    }
  }, {
    key: "disableAllButtons",
    value: function disableAllButtons(disabled) {
      for (var buttonSelector in this.buttonSelectors) {
        $(this.buttonSelectors[buttonSelector]).attr('disabled', disabled);
      }
    }
  }, {
    key: "showSpinner",
    value: function showSpinner(button) {
      var _this7 = this;
      var selector = this.buttonSelectors[button];
      this.disableAllButtons(true);
      $(selector).addClass('loading');
      return function () {
        _this7.disableAllButtons(false);
        $(selector).removeClass('loading');
      };
    }
  }, {
    key: "show",
    value: function show() {
      $(this.viewSelector).modal({
        autofocus: false
      }).modal('show');
      $(this.viewSelector).modal('refresh');
    }
  }, {
    key: "hide",
    value: function hide() {
      $(this.viewSelector).modal('hide');
    }
  }, {
    key: "notifySuccess",
    value: function notifySuccess() {
      var localizer = new QuickBiddingLocalizer();
      if (window.toastr) {
        if (this.viewMode() === ViewModes.bid) {
          window.toastr.success(localizer.Maximum_bid_placed_successfully, localizer.Bid_successful);
        } else {
          window.toastr.success(localizer.You_have_won_a_lot_through_Buy_It_Now);
        }
      }
    }
  }, {
    key: "notifyReserveNotMet",
    value: function notifyReserveNotMet() {
      var localizer = new QuickBiddingLocalizer();
      if (window.toastr) {
        window.toastr.info(localizer.Maximum_bid_placed_but_reserve_not_met);
      }
    }
  }, {
    key: "notifyError",
    value: function notifyError(status) {
      if (this.hasShownSpecificError && !status.reason) {
        return;
      }
      $(this.viewSelector).removeClass(status.allStatuses).addClass(status.status);
      if (status.reason) {
        $(this.errorMessageCustomReasonSelector).text(status.reason).show();
        $(this.errorMessageReasonSelector).hide();
        this.hasShownSpecificError = true;
      } else {
        $(this.errorMessageReasonSelector).show();
        $(this.errorMessageCustomReasonSelector).hide();
      }
      $(this.viewSelector).modal('refresh');
    }
  }, {
    key: "hideErrors",
    value: function hideErrors(status) {
      $(this.viewSelector).removeClass(status.allStatuses);
      $(this.errorMessageReasonSelector).hide();
      $(this.errorMessageCustomReasonSelector).hide();
    }
  }, {
    key: "setRetryState",
    value: function setRetryState(lotDetails) {
      $(this.selectors.maxBid.wrapper).show();
      if (!lotDetails.buyItNowEnabled) {
        $(this.selectors.maxBid.value).hide();
      }
    }
  }, {
    key: "updateCurrentBid",
    value: function updateCurrentBid(bid, piecemealText) {
      if (bid) {
        $(this.selectors.current.bid).show();
        $(this.selectors.opening.bid).hide();
        $(this.selectors.current.value).text(Utils.formatAmount(bid));
        if (this.bidNowEnabled) {
          var lotId = this.selectedItemId.replace('lot-', '');
          var $leadingBidAmountElement = $("#leadingBidAmount-".concat(lotId));
          if ($leadingBidAmountElement.length) {
            $leadingBidAmountElement.html("<strong>".concat(Utils.formatAmount(bid), "</strong>"));
          }
        }
        if (piecemealText) {
          $(this.selectors.current.piecemeal).text(piecemealText).show();
          $(this.selectors.opening.piecemeal).hide();
        }
      }
    }
  }, {
    key: "updateYourMaxBid",
    value: function updateYourMaxBid(bid, piecemealText) {
      if (bid) {
        $(this.selectors.yourMaxBid.bid).show();
        $(this.selectors.yourMaxBid.value).text(Utils.formatAmount(bid));
        if (piecemealText) {
          $(this.selectors.yourMaxBid.piecemeal).text(piecemealText).show();
        }
      }
    }
  }, {
    key: "updateMaxBid",
    value: function updateMaxBid(bid, piecemealText) {
      if (bid) {
        $(this.selectors.maxBid.value).text(Utils.formatAmount(bid));
        $(this.selectors.maxBid.input).val(Utils.formatAmount(bid));
        if (piecemealText) {
          $(this.selectors.maxBid.piecemeal).text(piecemealText);
          $(this.selectors.maxBid.newPiecemeal).text(piecemealText);
        }
      }
    }
  }, {
    key: "handleBidNowModalQuitEvent",
    value: function handleBidNowModalQuitEvent() {
      if (this.bidNowEnabled) {
        this.defaultToBidNowOnMaxbid(this.selectedItemId);
      }
    }
  }, {
    key: "defaultToBidNowOnMaxbid",
    value: function defaultToBidNowOnMaxbid(itemId) {
      var $item = $("#".concat(itemId));
      $item.find("#bidNowInstabidToggle").click();
    }
  }, {
    key: "setMaxBidAsError",
    value: function setMaxBidAsError(isError) {
      $(this.selectors.maxBid.input).prop('disabled', isError);
      if (isError) {
        $(this.selectors.maxBid.input).addClass('error');
      } else {
        $(this.selectors.maxBid.input).removeClass('error');
      }
    }
  }, {
    key: "setDoneState",
    value: function setDoneState() {
      // TODO: hide confirm
    }
  }, {
    key: "setBiddingEnd",
    value: function setBiddingEnd(lotEnd, biddingEndingStyle) {
      $(this.selectors.endTime).text(lotEnd);
      if (biddingEndingStyle) {
        $(this.selectors.endTime).addClass(biddingEndingStyle);
      }
    }
  }, {
    key: "setBiddingEndStyle",
    value: function setBiddingEndStyle() {
      if (!$(this.selectors.endTime).hasClass(this.styles.endTimeAlert)) {
        $(this.selectors.endTime).addClass(this.styles.endTimeAlert);
      }
    }
  }, {
    key: "setPiecemeal",
    value: function setPiecemeal(piecemealValue) {
      $(this.selectors.maxBid.piecemeal).text(piecemealValue);
    }
  }, {
    key: "showPiecemeal",
    value: function showPiecemeal() {
      $(this.selectors.maxBid.piecemeal).show();
      $(this.selectors.maxBid.newPiecemeal).show();
    }
  }, {
    key: "hidePiecemeal",
    value: function hidePiecemeal() {
      $(this.selectors.maxBid.piecemeal).hide();
      $(this.selectors.maxBid.newPiecemeal).hide();
    }
  }, {
    key: "setYourMaximumBidOnParent",
    value: function setYourMaximumBidOnParent(itemId, maximumBid, currency) {
      var $item = $("#".concat(itemId));
      $item.find('.your-maximum-bid-value').text(Utils.formatAmount(maximumBid));
      $item.find('.your-max-bid').addClass('has-maximum-bid');
      GAP.Module.Lot.Model.HideBorderForLastVisibleListElement(itemId);
      var quantity = Utils.parseLocaleFloat($item.find('[id^=lot-maximum-bid-sum]').attr("data-quantity"));
      $item.find('.your-maximum-bid-piecemeal').text("(".concat(Utils.formatAmount(maximumBid * quantity), " ").concat(currency, ")"));
    }
  }, {
    key: "clearInputOnParent",
    value: function clearInputOnParent(itemId) {
      var $item = $("#".concat(itemId));
      $item.find('input[name=maximum-bid]').val('');
    }
  }, {
    key: "clearInputPiecemealOnParent",
    value: function clearInputPiecemealOnParent(itemId) {
      var $item = $("#".concat(itemId));
      var inputPiecemeal = $item.find('[id^=lot-maximum-bid-sum]');
      inputPiecemeal.text(inputPiecemeal.attr('data-default-text'));
    }
  }, {
    key: "lotEnd",
    value: function lotEnd(itemId) {
      return $("#".concat(itemId)).attr('data-lot-end');
    }
  }, {
    key: "updateTotalMaxBid",
    value: function updateTotalMaxBid(bid) {
      $(this.selectors.totalPiecemeal.value).text(bid);
    }
  }, {
    key: "showOffIncrement",
    value: function showOffIncrement(model, lotDetails) {
      var offIncrementReason = new OffIncrementReason();
      var amountWithCurrency = function amountWithCurrency(amount) {
        return "".concat(amount, " ").concat(lotDetails.currency);
      };
      var setValueForSelector = function setValueForSelector(selector, value) {
        var formattedAmount = Utils.formatAmount(value);
        $("".concat(selector, " .content-text")).text(amountWithCurrency(formattedAmount));
        $(selector).attr('data-value', value);
      };
      if (model.mode === offIncrementReason.reasonModeMap.oneButton) {
        $(this.selectors.offIncrement.oneButtonContainer).show();
        $(this.selectors.offIncrement.twoButtonsContainer).hide();
        setValueForSelector(this.selectors.offIncrement.minimumAmount, model.minimumAmount);
      } else {
        $(this.selectors.offIncrement.twoButtonsContainer).show();
        $(this.selectors.offIncrement.oneButtonContainer).hide();
        setValueForSelector(this.selectors.offIncrement.lowerIncrement, model.lowerIncrement);
        setValueForSelector(this.selectors.offIncrement.higherIncrement, model.higherIncrement);
      }
      $(this.selectors.actions).hide();
    }
  }, {
    key: "hideOffIncrement",
    value: function hideOffIncrement() {
      $(this.selectors.offIncrement.oneButtonContainer).hide();
      $(this.selectors.offIncrement.twoButtonsContainer).hide();
      $(this.selectors.actions).show();
    }
  }, {
    key: "offIncrementMinimalAmount",
    get: function get() {
      return $(this.selectors.offIncrement.minimumAmount).attr('data-value');
    }
  }, {
    key: "offIncrementLowerIncrement",
    get: function get() {
      return $(this.selectors.offIncrement.lowerIncrement).attr('data-value');
    }
  }, {
    key: "offIncrementHigherIncrement",
    get: function get() {
      return $(this.selectors.offIncrement.higherIncrement).attr('data-value');
    }
  }]);
  return QuickBiddingView;
}();
var SelectorsProvider = /*#__PURE__*/_createClass(function SelectorsProvider(useBinPrefix) {
  _classCallCheck(this, SelectorsProvider);
  var prefix = '#' + (useBinPrefix ? 'bin-' : '');
  this.viewSelector = "".concat(prefix, "quick-bidding-modal");
  this.selectors = {
    img: "".concat(prefix, "quick-bidding-img"),
    noImg: "".concat(prefix, "no-image"),
    title: "".concat(prefix, "quick-bidding-lot-title"),
    desc: "".concat(prefix, "quick-bidding-lot-desc"),
    detailsHref: "".concat(prefix, "quick-bidding-lot-details-href"),
    actions: "".concat(prefix, "quick-bidding-actions"),
    current: {
      bid: "".concat(prefix, "quick-bidding-current-bid"),
      value: "".concat(prefix, "quick-bidding-current-bid-value"),
      currency: "".concat(prefix, "quick-bidding-current-bid-currency"),
      piecemeal: "".concat(prefix, "quick-bidding-current-bid-piecemeal")
    },
    opening: {
      bid: "".concat(prefix, "quick-bidding-opening-bid"),
      value: "".concat(prefix, "quick-bidding-opening-bid-value"),
      currency: "".concat(prefix, "quick-bidding-opening-bid-currency"),
      piecemeal: "".concat(prefix, "quick-bidding-opening-bid-piecemeal")
    },
    yourMaxBid: {
      bid: "".concat(prefix, "quick-bidding-your-max-bid"),
      value: "".concat(prefix, "quick-bidding-your-max-bid-value"),
      currency: "".concat(prefix, "quick-bidding-your-max-bid-currency"),
      piecemeal: "".concat(prefix, "quick-bidding-your-max-bid-piecemeal")
    },
    maxBid: {
      wrapper: "".concat(prefix, "quick-bidding-max-bid-input-wrapper"),
      input: "".concat(prefix, "quick-bidding-max-bid-input"),
      value: "".concat(prefix, "quick-bidding-max-bid-value"),
      currency: "".concat(prefix, "quick-bidding-max-bid-currency"),
      piecemeal: "".concat(prefix, "quick-bidding-piecemeal"),
      newCurrency: "".concat(prefix, "quick-bidding-new-max-bid-currency"),
      newPiecemeal: "".concat(prefix, "quick-bidding-new-piecemeal")
    },
    totalPiecemeal: {
      container: "".concat(prefix, "quick-bidding-total-piecemeal"),
      value: "".concat(prefix, "quick-bidding-total-piecemeal-value"),
      currency: "".concat(prefix, "quick-bidding-total-piecemeal-currency")
    },
    quantity: "".concat(prefix, "quick-bidding-bulk-quantity"),
    quantityValue: "".concat(prefix, "quick-bidding-bulk-quantity-value"),
    endTime: "".concat(prefix, "quick-bidding-bidding-ends-value"),
    buttons: {
      confirm: "".concat(prefix, "quick-bidding-confirm-button"),
      cancel: "".concat(prefix, "quick-bidding-cancel-button"),
      headerClose: "".concat(prefix, "header-close"),
      all: "".concat(prefix, "quick-bidding-confirm-button #quick-bidding-cancel-button")
    },
    buyItNow: {
      bid: "".concat(prefix, "quick-bidding-bin"),
      value: "".concat(prefix, "quick-bidding-bin-value"),
      currency: "".concat(prefix, "quick-bidding-bin-currency"),
      piecemeal: "".concat(prefix, "quick-bidding-bin-piecemeal")
    },
    bidOptions: {
      bidRadio: '#bidRadio',
      buyItNowRadio: '#buyItNowRadio'
    },
    binEqualText: '#quick-bidding-bin-equal-text',
    footerText: {
      standard: '#standardLegalFooterText',
      buyItNow: '#binLegalFooterText'
    },
    columns: {
      binColumn: '#binColumn',
      bidColumn: '#bidColumn'
    },
    offIncrement: {
      twoButtonsContainer: "".concat(prefix, "quick-bidding-off-increment-two-buttons-container"),
      oneButtonContainer: "".concat(prefix, "quick-bidding-off-increment-one-button-container"),
      minimumAmount: "".concat(prefix, "quick-bidding-off-increment-minimum-amount"),
      lowerIncrement: "".concat(prefix, "quick-bidding-off-increment-lower-increment"),
      higherIncrement: "".concat(prefix, "quick-bidding-off-increment-higher-increment")
    }
  };
});
var ViewModes = {
  bid: 'bid',
  buyItNow: 'bin'
};;"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var TimedbiddingApiClient = /*#__PURE__*/function () {
  function TimedbiddingApiClient() {
    _classCallCheck(this, TimedbiddingApiClient);
  }
  _createClass(TimedbiddingApiClient, [{
    key: "placeBid",
    value: function placeBid(bid, lotId, auctionRef, csrf) {
      var action = this.placeBidActionUri();
      var obj = {
        lotId: lotId,
        auctionReference: auctionRef,
        bidAmount: bid
      };
      return new Promise(function (resolve, reject) {
        $.ajax({
          url: action,
          type: 'POST',
          data: obj,
          headers: {
            '__RequestVerificationToken': csrf
          }
        }).done(function (data) {
          resolve(data);
        }).fail(function (xhr) {
          reject(xhr);
        });
      });
    }
  }, {
    key: "buyItNow",
    value: function buyItNow(lotId, auctionRef, auctionId, csrf) {
      var action = this.buyItNowActionUri(lotId, auctionRef);
      var payload = {
        lotId: lotId,
        auctionReference: auctionRef,
        auctionId: auctionId
      };
      return new Promise(function (resolve, reject) {
        $.ajax({
          url: action,
          type: 'POST',
          data: payload,
          headers: {
            '__RequestVerificationToken': csrf
          }
        }).done(function (data) {
          resolve(data);
        }).fail(function (xhr) {
          reject(xhr);
        });
      });
    }
  }, {
    key: "placeBidActionUri",
    value: function placeBidActionUri() {
      var culture = Utils.currentCulture();
      return "".concat(window.location.origin, "/").concat(culture, "/lot/details");
    }
  }, {
    key: "buyItNowActionUri",
    value: function buyItNowActionUri(lotId, auctionRef) {
      var culture = Utils.currentCulture();
      return "".concat(window.location.origin, "/").concat(culture, "/auction-catalogues/catalogue-id-").concat(auctionRef, "/lot-").concat(lotId, "/buyitnow");
    }
  }]);
  return TimedbiddingApiClient;
}();
var QuickBiddingViewModel = /*#__PURE__*/function () {
  function QuickBiddingViewModel() {
    _classCallCheck(this, QuickBiddingViewModel);
    this.view = new QuickBiddingView();
    this.apiClient = new TimedbiddingApiClient();
  }
  _createClass(QuickBiddingViewModel, [{
    key: "init",
    value: function init(lotDetails) {
      var _this = this;
      this.view.init(lotDetails);
      this.view.onConfirm(this.confirm.bind(this), lotDetails);
      this.view.onMaxBidValueChanged(this.maxBidValueChanged, lotDetails);
      this.view.show();
      this.maxBidValueChanged(this.view, lotDetails);
      if (this.countdownInterval) {
        clearInterval(this.countdownInterval);
      }
      this.startCountdown(this, lotDetails);
      this.countdownInterval = setInterval(function () {
        return _this.startCountdown(_this, lotDetails);
      }, 1000);
      this.view.onOffIncrementMinimumAmount(this.placeBidMinimalAmount.bind(this), lotDetails);
      this.view.onOffIncrementLowerIncrement(this.placeBidLowerIncrement.bind(this), lotDetails);
      this.view.onOffIncrementHigherIncrement(this.placeBidHigherIncrement.bind(this), lotDetails);
    }
  }, {
    key: "placeBid",
    value: function placeBid(bid, view, lotDetails) {
      var _this2 = this;
      var hideSpinner = view.showSpinner(view.activeButton);
      if (appInsights) {
        appInsights.trackEvent("A new Timed bid about to be placed via QuickBid UI", {
          AuctionRef: lotDetails.auctionRef,
          CustomerId: lotDetails.bidder.customerId,
          BidAmount: bid,
          LotId: lotDetails.lotId
        });
        if (lotDetails.flushAIEvents) {
          appInsights.flush();
        }
      }

      //track additional GTM events on clicking before sending to backend
      var gtmIncrementType = GtmOffIncrementValues[view.activeButton];
      var gtmAdditionalData = gtmIncrementType ? {
        increment: gtmIncrementType
      } : null;
      QuickBiddingViewModel.raiseGtmEvent('quickBidInit', {
        maximumBid: bid
      }, lotDetails, gtmAdditionalData);
      var $quickBiddigModal = $('#quick-bidding-modal');
      this.apiClient.placeBid(bid, lotDetails.lotId, lotDetails.auctionRef, lotDetails.csrf).then(function (data) {
        hideSpinner();
        $quickBiddigModal.trigger('timed.bidding.bid.completed', {
          auctionId: lotDetails.auctionId
        });
        var apiResponseToEvent = apiResponseToEventMapper(data, lotDetails.lotId);
        if (Gap.BiddingCommon.isBiddingResponseToApply(lotDetails.lotId, apiResponseToEvent.Timestamp)) {
          Gap.BiddingCommon.applyBiddingData(apiResponseToEvent);
        }
        data = portalResponseMapper(data);
        var bidStatus = new BidStatus();
        if (bidStatus.isSuccess(data)) {
          if (lotDetails.bidNowEnabled) {
            view.defaultToBidNowOnMaxbid(lotDetails.itemId);
          }
          view.hide();
          if (data.reserveMet) {
            view.notifySuccess();
          } else {
            view.notifyReserveNotMet();
          }
        } else if (bidStatus.isRetryable(data)) {
          if (data.offIncrement) {
            view.showOffIncrement(data.offIncrement, lotDetails);
            view.hideErrors(bidStatus.status(data));
            view.setMaxBidAsError(true);
            view.setViewModeState(ViewModeStates.bid);
          } else {
            view.hideOffIncrement();
            view.notifyError(bidStatus.status(data));
            view.setMaxBidAsError(false);
            view.setViewModeState(ViewModeStates.both);
          }
          view.updateMaxBid(bid);
          _this2.maxBidValueChanged(view, lotDetails);
          view.setRetryState(lotDetails);
          lotDetails.bidding.currentBid = data.currentBid;
          if (data.maximumBid) {
            lotDetails.bidding.yourMaxBid = data.maximumBid;
          }
          if (lotDetails.piecemealExists) {
            view.updateCurrentBid(data.currentBid, lotDetails.currentBidPiecemealText());
            view.updateYourMaxBid(data.maximumBid, lotDetails.yourMaximumBidPiecemealText());
          } else {
            view.updateCurrentBid(data.currentBid);
            view.updateYourMaxBid(data.maximumBid);
          }
        } else {
          view.notifyError(bidStatus.status(data));
          view.setDoneState();
        }
        if (bidStatus.isAccepted(data)) {
          view.setYourMaximumBidOnParent(lotDetails.itemId, bid, lotDetails.currency);
          view.clearInputOnParent(lotDetails.itemId);
          view.clearInputPiecemealOnParent(lotDetails.itemId);
        }
        QuickBiddingViewModel.raiseGtmEvent('quickBid', data, lotDetails);
      }).catch(function (error) {
        var bidStatus = new BidStatus();
        hideSpinner();
        view.notifyError(bidStatus.error());
        $quickBiddigModal.trigger('timed.bidding.bid.completed', {
          auctionId: lotDetails.auctionId
        });
      });
    }
  }, {
    key: "placeBidMinimalAmount",
    value: function placeBidMinimalAmount(view, lotDetails) {
      var bid = view.offIncrementMinimalAmount;
      this.placeBid(bid, view, lotDetails);
    }
  }, {
    key: "placeBidLowerIncrement",
    value: function placeBidLowerIncrement(view, lotDetails) {
      var bid = view.offIncrementLowerIncrement;
      this.placeBid(bid, view, lotDetails);
    }
  }, {
    key: "placeBidHigherIncrement",
    value: function placeBidHigherIncrement(view, lotDetails) {
      var bid = view.offIncrementHigherIncrement;
      this.placeBid(bid, view, lotDetails);
    }
  }, {
    key: "confirm",
    value: function confirm(view, lotDetails) {
      var bid = view.maxBid;
      if (lotDetails.buyItNowEnabled && view.viewMode() === ViewModes.buyItNow) {
        var hideSpinner = view.showSpinner(view.activeButton);
        this.apiClient.buyItNow(lotDetails.lotId, lotDetails.auctionRef, lotDetails.auctionId, lotDetails.csrf).then(function (data) {
          hideSpinner();
          var bidStatus = new BidStatus();
          if (data.Success) {
            view.hide();
            view.notifySuccess();
          } else {
            view.notifyError(bidStatus.error());
          }
        }).catch(function (data) {
          var bidStatus = new BidStatus();
          hideSpinner();
          view.notifyError(bidStatus.error());
        });
      } else {
        this.placeBid(bid, view, lotDetails);
      }
    }
  }, {
    key: "maxBidValueChanged",
    value: function maxBidValueChanged(view, lotDetails) {
      var bid = view.maxBid;
      if (lotDetails.buyItNowEnabled) {
        if (view.maxBid >= lotDetails.bidding.buyItNowPrice) {
          view.setViewModeState(ViewModeStates.buyItNow);
        } else {
          view.setViewModeState(ViewModeStates.both);
        }
      }
      if (lotDetails.isPiecemealEnabled && lotDetails.bulkQuantity > 1 && bid > 0) {
        var piecemealValue = " x ".concat(Utils.formatAmount(lotDetails.bulkQuantity), " = ").concat(Utils.formatAmount(bid * lotDetails.bulkQuantity), " ").concat(lotDetails.currency);
        view.setPiecemeal(piecemealValue);
        view.showPiecemeal();
        view.updateTotalMaxBid(Utils.formatAmount(bid * lotDetails.bulkQuantity));
        view.updateMaxBid(bid, piecemealValue);
      } else {
        view.hidePiecemeal();
        view.updateMaxBid(bid);
      }
    }
  }, {
    key: "startCountdown",
    value: function startCountdown(vm, lotDetails) {
      var lotEndEpoch = vm.view.lotEnd(lotDetails.itemId);
      var utcNow = moment.utc().unix().valueOf();
      var duration = lotEndEpoch - utcNow;
      var fourtyEightHours = 48 * 60 * 60;
      var twentyFourHours = 24 * 60 * 60;
      if (duration < fourtyEightHours) {
        vm.view.setBiddingEnd(vm.formatLotEnd(duration));
        if (duration < twentyFourHours) {
          vm.view.setBiddingEndStyle();
        }
      }
    }
  }, {
    key: "formatLotEnd",
    value: function formatLotEnd(duration) {
      var localizer = new QuickBiddingLocalizer();
      if (duration <= 0) {
        return localizer.Lot_closed;
      }
      var momentDuration = moment.duration(duration, 's');
      var d = localizer.d;
      var h = localizer.h;
      var m = localizer.m;
      var s = localizer.s;

      // More than a day left, format as 'Xd Xh'
      if (duration > 86400) return momentDuration.days() + d + ' ' + momentDuration.hours() + h;
      // More than an hour left, format as 'Xh Xm'
      if (duration > 3600) return momentDuration.hours() + h + ' ' + momentDuration.minutes() + m;
      // More than a minute left, format as 'Xm Xs'
      if (duration >= 60) return momentDuration.minutes() + m + ' ' + momentDuration.seconds() + s;

      // Only seconds remain
      return momentDuration.seconds() + s;
    }
  }, {
    key: "stopCountdown",
    value: function stopCountdown() {
      if (this.countdownInterval) {
        clearInterval(this.countdownInterval);
        this.countdownInterval = undefined;
      }
    }
  }], [{
    key: "raiseGtmEvent",
    value: function raiseGtmEvent(eventName, response, lotDetails, additionalData) {
      var bidStatus = new BidStatus();
      var bidEvent = new BidEventModel(eventName, lotDetails.lotId, lotDetails.bidder.bidderId, lotDetails.bidder.customerId, response.maximumBid, bidStatus.statusName(response), additionalData);
      GtmEvents.raiseBidEvent(bidEvent);
    }
  }]);
  return QuickBiddingViewModel;
}();;"use strict";

function extractLotDetails(lotId) {
  var itemId = "lot-".concat(lotId);
  var $item = $("#".concat(itemId));
  var imageHref = $item.find("#i".concat(lotId)).attr('src');
  var title = Utils.stripLangTags($item.find('a[name=lot-title] .lot-title').text());
  var detailsHref = $item.find('a[name=lot-title]').attr('href');
  var openingBid = $item.find("#openingPrice-".concat(lotId, " strong")).text();
  var currentBid = $item.find("#price-".concat(lotId, " strong")).text();
  if (currentBid && !isNaN(Utils.parseLocaleFloat(currentBid))) {
    openingBid = undefined;
  }
  var yourMaxBid = undefined;
  if ($item.find('.your-max-bid')) {
    yourMaxBid = $item.find('.your-maximum-bid-value').text();
  }
  var currency = $item.find("button[name=quick-bid-button]").data('currency');
  var maxBid = $item.find('input[name=maximum-bid]').val();
  var minBid = $item.find("#minBidPrice-".concat(lotId) + ' span').text();
  var biddingEnds = $item.find("#timer-".concat(lotId, " span")).text();
  var auctionRef = $item.data('auctionRef');
  var auctionId = $item.data('auctionId');
  var bulkQuantity = $item.find('.bulk-quantity-value').text();
  var isPiecemealEnabled = $item.find('.bulk-quantity-value').data('piecemealEnabled') === true;
  var description = $item.find('.description p').text();
  var csrf = $('input[name=__RequestVerificationToken]').val();
  var customerId = $item.data('customerId');
  var bidderId = $item.data('bidderId');
  var buyItNowPrice = $item.find("#buyItNowPrice-".concat(lotId)).text();
  var biddingInfo = new BiddingInfo(currentBid, openingBid, yourMaxBid, maxBid, biddingEnds, buyItNowPrice, minBid);
  var bidderInfo = new BidderInfo(bidderId, customerId);
  var lotDetails = new LotDetails(imageHref, title, description, detailsHref, currency, biddingInfo, bulkQuantity, lotId, auctionRef, csrf, isPiecemealEnabled, itemId, bidderInfo, auctionId);
  lotDetails.flushAIEvents = Gap.Portal.UI.QuickBiddingOptions.flushAIEvents;
  lotDetails.bidNowEnabled = $(".lot-single.bid-now-enabled").length > 0;
  return lotDetails;
}
(function () {
  var isDataLoadedAlready = function isDataLoadedAlready(id) {
    return $(id).hasClass('dynamic-skeleton') === false;
  };
  var quickBiddingVM = new QuickBiddingViewModel();
  var startQuickBidPopup = function startQuickBidPopup(lotId) {
    var lotDetails = extractLotDetails(lotId);
    var showMaxBidError = function showMaxBidError(show) {
      var $maxBidInput = $("#lot-maximum-bid-".concat(lotId));
      var $maxBidErrorMessage = $("#lot-maximum-bid-error-".concat(lotId));
      $maxBidInput.toggleClass('input-bid-ammount-error', show);
      $maxBidErrorMessage.toggleClass('hide', !show);
    };
    if (dataLayer) {
      var payload = {
        event: 'bidButtonClick',
        bidBoxValue: isNaN(lotDetails.bidding.maxBid) ? null : lotDetails.bidding.maxBid
      };
      dataLayer.push(payload);
    }
    if (lotDetails.isMaxBidValid()) {
      showMaxBidError(false);
      quickBiddingVM.init(lotDetails);
    } else {
      showMaxBidError(true);
    }
  };
  var waitTillDataLoaded = function waitTillDataLoaded(lotId, bidButton) {
    var mainElementId = '#lot-'.concat(lotId);
    if (isDataLoadedAlready(mainElementId)) {
      $(bidButton).removeClass('disabled');
      startQuickBidPopup(lotId);
    } else {
      setTimeout(waitTillDataLoaded, 200, lotId, bidButton);
    }
  };
  $('button[name=quick-bid-button]').on('click', function (e) {
    var lotId = $(e.target).data('lotId');
    $(e.target).addClass('disabled');
    waitTillDataLoaded(lotId, e.target);
  });
  $('.input-bid-ammount').autoNumeric({
    aPad: false,
    vMax: 99999999.99,
    vMin: 0.00
  });
  $('#quick-bidding-max-bid-input').autoNumeric({
    aPad: false,
    vMax: 99999999.99,
    vMin: 0.00
  });
  $('#bin-quick-bidding-max-bid-input').autoNumeric({
    aPad: false,
    vMax: 99999999.99,
    vMin: 0.00
  });
})();;"use strict";

(function () {
  function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)", "i"),
      results = regex.exec(window.location);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  }
  $('a[name=register-button]').on('click', function (e) {
    var $button = $(e.target);
    var href = $button.attr('href');
    var lotId = $button.data('lotId');
    var placedBid = $button.closest('.bidder-not-registered').find('input[name=maximum-bid]').val();
    if (placedBid) {
      var newHref = "".concat(href, "?quickbid=").concat(lotId, "%7C").concat(placedBid);
      $button.attr('href', newHref);
    }
  });
  var qb = getParameterByName('quickbid');
  if (qb) {
    var quickBid = qb.split('|');
    var lotId = quickBid[0];
    var bid = quickBid[1];
    if (lotId && bid) {
      $(".catalogue-page #lot-".concat(lotId, " input[name=maximum-bid]")).val(bid);
    }

    // after returning from registration (we will have info in query string), try to make bid right away
    if (/[?&]quickbid=/i.test(location.search)) {
      var buttonSelector = "button.bid[data-lot-id=\"" + lotId + "\"]:visible";
      if ($(buttonSelector).length) {
        $(buttonSelector).click();

        // then remove 'quickbid' from query string
        var uri = location.pathname + location.search.replace(/[?&]quickbid=[^&]+/i, '').replace(/^&/, '?') + location.hash;
        window.history.replaceState({}, document.title, uri);
      }
    }
  }
})();;"use strict";

var _GtmOffIncrementValue;
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var BidEventModel = /*#__PURE__*/_createClass(function BidEventModel(event, lotId, bidderId, customerId, bidAmount, status, additionalData) {
  _classCallCheck(this, BidEventModel);
  this.event = event;
  this.lotId = lotId;
  this.bidderId = bidderId;
  this.customerId = customerId;
  this.bidAmount = bidAmount;
  this.status = status;
  this.additionalData = additionalData;
});
var GtmEvents = /*#__PURE__*/function () {
  function GtmEvents() {
    _classCallCheck(this, GtmEvents);
  }
  _createClass(GtmEvents, null, [{
    key: "raiseBidEvent",
    value: function raiseBidEvent(data) {
      if (dataLayer) {
        var payload = {
          'event': data.event,
          'lotId': data.lotId,
          'bidderId': data.bidderId,
          'userId': data.customerId,
          'bidAmount': data.bidAmount,
          'bidStatus': data.status
        };
        if (data.additionalData !== null && _typeof(data.additionalData) === 'object') {
          Object.assign(payload, data.additionalData);
        }
        dataLayer.push(payload);
      }
    }
  }]);
  return GtmEvents;
}();
var GtmOffIncrementValues = (_GtmOffIncrementValue = {}, _defineProperty(_GtmOffIncrementValue, ModalButtons.minimumAmount, 'On increment'), _defineProperty(_GtmOffIncrementValue, ModalButtons.lowerIncrement, 'Low increment'), _defineProperty(_GtmOffIncrementValue, ModalButtons.higherIncrement, 'High increment'), _GtmOffIncrementValue);;