;(function ($) {
    'use strict';
    var CircleMenuHandler = function ($scope, $) {
        var $container = $scope.find('.floating-menu-container');
        var $fab = $container.find('.fab');

        if (!$container.length || !$fab.length) {
            return;
        }

        // Main click event to toggle the menu
        $fab.on('click', function (e) {
            e.preventDefault();
            $container.toggleClass('active');
        });

        // Event to close the menu when clicking outside of it
        $(document).on('click', function (event) {
            if ($container.hasClass('active') && !$container[0].contains(event.target)) {
                $container.removeClass('active');
            }
        });
    };

    $(window).on('elementor/frontend/init', function () {
        elementorFrontend.hooks.addAction('frontend/element_ready/unlockafe-circle-menu.default', CircleMenuHandler);
    });

})(jQuery);