$(document).ready(function () {
  /* ALTERE O VALOR 10 PARA OS SEGUNDOS EM QUE AS SEÇÕES VÃO APARECER */
  const SECONDS_TO_DISPLAY = 1;
  //const CLASS_TO_DISPLAY = 'esconder';

  /* DAQUI PARA BAIXO NÃO PRECISA ALTERAR */
  let attempts = 0;
  let elsDisplayed = false;
  let elsHiddenList = $(".esconder").toArray();
  const alreadyDisplayedKey = `alreadyElsDisplayed${SECONDS_TO_DISPLAY}`;
  const alreadyElsDisplayed = localStorage.getItem(alreadyDisplayedKey);

  const showHiddenElements = () => {
    elsDisplayed = true;
    $(elsHiddenList).removeClass("esconder");
    localStorage.setItem(alreadyDisplayedKey, "true");
    $(window).trigger("showHiddenElements");
  };

  const startWatchVideoProgress = () => {
    if (
      typeof smartplayer === "undefined" ||
      !(smartplayer.instances && smartplayer.instances.length)
    ) {
      if (attempts >= 10) return;
      attempts++;
      setTimeout(startWatchVideoProgress, 1000);
      return;
    }

    smartplayer.instances[0].on("timeupdate", () => {
      if (elsDisplayed || smartplayer.instances[0].smartAutoPlay) return;
      if (smartplayer.instances[0].video.currentTime < SECONDS_TO_DISPLAY) return;
      showHiddenElements();
    });
  };

  if (alreadyElsDisplayed === "true") {
    setTimeout(showHiddenElements, 100);
  } else {
    startWatchVideoProgress();
  }
});
