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