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