( function( window, document ) {
  function weight_loss_center_keepFocusInMenu() {
    document.addEventListener( 'keydown', function( e ) {
      const weight_loss_center_nav = document.querySelector( '.sidenav' );
      if ( ! weight_loss_center_nav || ! weight_loss_center_nav.classList.contains( 'open' ) ) {
        return;
      }
      const elements = [...weight_loss_center_nav.querySelectorAll( 'input, a, button' )],
        weight_loss_center_lastEl = elements[ elements.length - 1 ],
        weight_loss_center_firstEl = elements[0],
        weight_loss_center_activeEl = document.activeElement,
        tabKey = e.keyCode === 9,
        shiftKey = e.shiftKey;
      if ( ! shiftKey && tabKey && weight_loss_center_lastEl === weight_loss_center_activeEl ) {
        e.preventDefault();
        weight_loss_center_firstEl.focus();
      }
      if ( shiftKey && tabKey && weight_loss_center_firstEl === weight_loss_center_activeEl ) {
        e.preventDefault();
        weight_loss_center_lastEl.focus();
      }
    } );
  }
  weight_loss_center_keepFocusInMenu();
} )( window, document );