<?php

namespace Digtective\Integrations;

use Digtective\Connectors\DigtectiveCoreConnector;
use Digtective\Repository\FormSubmissionRepository\FormSubmissionRepository;
use Digtective\Repository\FormSubmissionRepository\FormSubmissionRepositoryInterface;
use Digtective\Repository\TokenRepository;

class ElementorIntegration {
    public function __construct(){
    }

    public static function isActive(): bool {
        // Check by Elementor constant (safe & fast)
        if ( defined( 'ELEMENTOR_VERSION' ) ) {
            return true;
        }

        // Fallback: Check if plugin is active
        if ( ! function_exists( 'is_plugin_active' ) ) {
            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
        }

        return is_plugin_active( 'elementor/elementor.php' );
    }

    public function applyFilters(){
        add_action('wp_enqueue_scripts', function(){
            wp_enqueue_script('digtective-elementor-script', DIGTECTIVE_URL . 'Digtective/Assets/elementor-session.js', [], "1.1.4", false);
        });
    }
}
