// External Dependencies.
import React, { ReactElement, useEffect, useRef } from 'react';

// Divi Dependencies.
import {
	ModuleContainer,
	ElementComponents,
} from '@divi/module';

// Local Dependencies.
import { RadioFilterEditProps } from './types';
import { ModuleStyles } from './styles';
import ServerSideRender from '../../server-side-render';
import { convertAttributes } from '../../utils';
import { __ } from '@wordpress/i18n';
import { ModuleScriptData } from './module-script-data';
import { moduleClassnames } from './module-classnames';

declare global {
	interface Window {
		JetEngineDiviViews: any;
	}
}

/**
 * Static Module edit component of visual builder.
 *
 * @since ??
 *
 * @param {RadioFilterEditProps} props React component props.
 *
 * @returns {ReactElement}
 */
const RadioFilterEdit = (props: RadioFilterEditProps): ReactElement => {
	const {
		attrs,
		id,
		name,
		elements,
	} = props;

	return (
		<ModuleContainer
			attrs={attrs}
			elements={elements}
			id={id}
			name={name}
			stylesComponent={ModuleStyles}
			classnamesFunction={moduleClassnames}
			scriptDataComponent={ModuleScriptData}
		>
			{elements.styleComponents({
				attrName: 'module',
			})}
			{
				<>
					<ElementComponents
						attrs={attrs?.module?.decoration ?? {}}
						id={id}
					/>
					<ServerSideRender
						block="jet-smart-filters-divi/radio-filter"
						attributes={ attrs }
					/>
				</>
			}
		</ModuleContainer>
	);
}

export {
	RadioFilterEdit,
};
