<?php
/**
 * Blocks Enqueue Assets
 *
 * @package NativeBlocks
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Enqueue Editor Assets
 *
 * @since 1.0.0
 * @return void
 */
function ntvb_enqueue_editor_assets() {
        // modules 
        if ( file_exists( trailingslashit( NTVB_PLUGIN_DIR ) . '/build/modules/index.asset.php' ) ) {
            $moduleDependencies = require trailingslashit( NTVB_PLUGIN_DIR ) . '/build/modules/index.asset.php';
            wp_enqueue_script(
                'ntvb-block-module-script',
                trailingslashit( NTVB_URL_FILE ) . 'build/modules/index.js',
                $moduleDependencies['dependencies'],
                NTVB_VERSION,
                false
            );

            // Enqueue block styles
            wp_enqueue_style(
                'ntvb-block-module-style',
                trailingslashit( NTVB_URL_FILE ) . 'build/modules/index.css',
                array(),
                NTVB_VERSION
            );

            $breakpoints = get_option( 'ntvb_breakpoints', ntvb_get_default_breakpoints() );

            // localize 
            wp_localize_script(
                'ntvb-block-module-script',
                'ntvbBlockModule',
                array(
                    'mobile' => !empty( $breakpoints['mobile'] ) ? $breakpoints['mobile'] : '767',
                    'tablet' => !empty( $breakpoints['tablet'] ) ? $breakpoints['tablet'] : '1024'
                )
            );
        }
}
add_action( 'enqueue_block_editor_assets', 'ntvb_enqueue_editor_assets', 2 ); // Editor Assets.
