<?php

namespace HelpGent\App\Providers;

defined( 'ABSPATH' ) || exit;

use HelpGent\App\Repositories\FormRepository;
use HelpGent\WpMVC\Contracts\Provider;
use HelpGent\WpMVC\View\View;

class ChatBubbleServiceProvider implements Provider {
    public function boot() {
        add_action( 'wp_footer', [ $this, 'action_wp_footer' ] );
    }

    /**
     * Prints scripts or data before the closing body tag on the front end.
     */
    public function action_wp_footer() : void {
        //phpcs:ignore WordPress.Security.NonceVerification.Recommended
        if ( isset( $_REQUEST['elementor-preview'] ) ) {
            return;
        }

        $print_bubbles = apply_filters( 'helpgent_print_chat_bubbles', ! helpgent_is_preview() );

        if ( ! $print_bubbles ) {
            return;
        }

        View::render( 'chat-bubbles' );
    }
}