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