jQuery(function ($) {
  function toggleAuctionFields() {
    var mode = $('#_stakmv_auction_sale_mode').val();
    var startPrice = $('#_stakmv_auction_start_price').closest('.form-field');
    var buyNowPrice = $('#_stakmv_auction_buy_now_price').closest('.form-field');

    if (mode === 'buy_now') {
      startPrice.hide();
      buyNowPrice.show();
    } else if (mode === 'auction') {
      startPrice.show();
      buyNowPrice.hide();
    } else {
      startPrice.show();
      buyNowPrice.show();
    }
  }

  toggleAuctionFields();
  $('#_stakmv_auction_sale_mode').on('change', toggleAuctionFields);
});
