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