/**
 * External dependencies.
 */
import { addFilter } from '@wordpress/hooks';

/**
 * Internal dependencies
 */
import addGSControls from './controls';
import {
	extendBlockAttributes,
	addGSClasses,
	applyDefaultsToNestedBlocks,
} from './helpers';

/**
 * Extends block attributes with animation-related properties.
 *
 * @since x.x.x
 *
 * @param {Object} settings - The block settings object.
 * @param {string} name     - The block name.
 * @return {Object} Modified settings with animation attributes.
 */
addFilter( 'blocks.registerBlockType', 'spectra/ext-global-styles', extendBlockAttributes );



/**
 * Enhances BlockEdit component with animation controls in the editor.
 *
 * @since x.x.x
 *
 * @param {Function} BlockEdit - The original BlockEdit component.
 * @return {Function} Enhanced BlockEdit component with Global Style controls.
 */
addFilter( 'editor.BlockEdit', 'spectra/ext-global-styles', addGSControls, 5 );

/**
 * Add the Global Style classes to all supported blocks.
 *
 * @since x.x.x
 *
 * @param {Function} BlockListBlock - The original BlockListBlock component.
 * @return {Function} Enhanced Block from the BlockListBlock component with the applied Global styles.
 */
addFilter( 'editor.BlockListBlock', 'your-plugin/custom-block-class', addGSClasses );

/**
 * Apply default classes to nested blocks when they are created from templates.
 *
 * @since x.x.x
 *
 * @param {Object} block - The block object being created.
 * @return {Object} Block object with default classes applied to nested blocks.
 */
addFilter( 'blocks.createBlock', 'spectra/ext-global-styles-nested', applyDefaultsToNestedBlocks );