disable a dropdown based on another facet selection

<?php
/**
 ** change facet1 to the name of your first facet (the facet to check selection)
 ** facet2 to the name of your second facet (to be disabled)
 **/

add_action( 'facetwp_scripts', function() {
?>
<script>
    (function($) {
        document.addEventListener('facetwp-loaded', function() {
            if ( 'undefined' !== typeof FWP.facets['facet1'] && FWP.facets['facet1'].length > 0 ) {
                $( '.facetwp-facet-facet2 select' ).attr('disabled', 'disabled');
            }
        });
    })(fUtil);
</script>
<?php
}, 100 );