Exclude facets from flyout

<?php

add_action( 'wp_head', function() {

  /**
   ** excludes facets from the flyout rather than having
   ** set array of facets to exclude to exclude_flyout
   ** to create an include list manually
   ** in facetwp/flyout/facets filter
   ** https://facetwp.com/help-center/add-on-features-and-extras/mobile-flyout/#customize-the-facets-and-facet-order
   **/

  ?>
    <script>
      (function($) {
        $(function() {
          if ('object' !== typeof FWP) {
            return;
          }
          FWP.hooks.addFilter('facetwp/flyout/facets', function(facets) {
            const exclude_flyout = ['search', 'sort', 'reset']; /* list facets to exclude as array */
            facets = facets.filter(function(el) {
              return exclude_flyout.indexOf(el) < 0;
            });
            return facets;
          });
        });
      })(jQuery);
    </script>

  <?php
}, 100 );