import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import { PanelBody, RangeControl, ToggleControl } from '@wordpress/components';

export default function Edit( { attributes, setAttributes } ) {
	const { maxLength, hideIfEmpty } = attributes;

	return (
		<>
			<InspectorControls>
				<PanelBody title={ __( 'Result Excerpt', 'wlc-search-integration-with-algolia' ) } initialOpen={ true }>
					<RangeControl
						label={ __( 'Max length', 'wlc-search-integration-with-algolia' ) }
						min={ 60 }
						max={ 400 }
						value={ maxLength || 220 }
						onChange={ ( v ) => setAttributes( { maxLength: v || 220 } ) }
					/>
					<ToggleControl
						label={ __( 'Hide if empty', 'wlc-search-integration-with-algolia' ) }
						checked={ hideIfEmpty !== false }
						onChange={ ( v ) => setAttributes( { hideIfEmpty: !! v } ) }
					/>
				</PanelBody>
			</InspectorControls>

			<div style={ { fontSize: 13, opacity: 0.75 } }>
				{ __( 'Excerpt / snippet…', 'wlc-search-integration-with-algolia' ) }
			</div>
		</>
	);
}




