/**
 * List — Display Settings panel body (Figma "List" sidebar, 446:101984):
 * the card design (all three free), Image Position, Zig Zag Orientation
 * (Pro-locked), Vertical Gap and the team-group addon toggles — Ajax
 * Pagination (free), Live Frontend Filter / Ajax Search (Pro-locked).
 */

import { __ } from '@wordpress/i18n';
import { Layouts, ProNotice, SPRangeControl, SPToggleGroupControl, Toggle } from '../../components';
import { PRO_NOTICE_LIST_DISPLAY } from '../shared/proNotices';
import { ListStyleOne, ListStyleTwo, ListStyleThree } from './icons';
import { designSwitchPatch, resolveDesign } from './styles';

const DESIGN_ITEMS = [
	{ value: 'list-1', name: __('List Style One', 'team-free'), icon: <ListStyleOne /> },
	{ value: 'list-2', name: __('List Style Two', 'team-free'), icon: <ListStyleTwo /> },
	{ value: 'list-3', name: __('List Style Three', 'team-free'), icon: <ListStyleThree /> },
];

export function DisplaySettings({ attributes, setAttributes }) {
	const { imagePosition, verticalGap, ajaxPagination } = attributes;

	return (
		<>
			<div className="sptp-list-style-picker">
				<Layouts
					label={__('Choose Card Design', 'team-free')}
					attributes={resolveDesign(attributes.cardDesign)}
					attributesKey="cardDesign"
					setAttributes={({ cardDesign }) =>
						setAttributes(designSwitchPatch(attributes, cardDesign))
					}
					items={DESIGN_ITEMS}
					grid={2}
					displayActive
				/>
			</div>

			<SPToggleGroupControl
				label={__('Image Position', 'team-free')}
				attributes={imagePosition || 'left'}
				attributesKey="imagePosition"
				setAttributes={setAttributes}
				items={[
					{ label: __('Left', 'team-free'), value: 'left' },
					{ label: __('Right', 'team-free'), value: 'right' },
				]}
			/>

			{/* Zig Zag Orientation is Pro: locked off, never written — a Pro-saved
			    `zigZag` is kept as is but never rendered. */}
			<Toggle label={__('Zig Zag Orientation', 'team-free')} attributes={false} isPro />

			<SPRangeControl
				label={__('Vertical Gap', 'team-free')}
				attributes={verticalGap}
				attributesKey="verticalGap"
				setAttributes={setAttributes}
				units={['px']}
				min={0}
				max={200}
				step={1}
			/>

			<Toggle
				label={__('Ajax Pagination', 'team-free')}
				attributes={!!ajaxPagination}
				onChange={(current) => setAttributes({ ajaxPagination: !current })}
			/>
			{/* Live Frontend Filter and Ajax Search are Pro: locked off, never
			    written — a Pro-saved `true` (and its team-group child) is left as is. */}
			<Toggle label={__('Live Frontend Filter', 'team-free')} attributes={false} isPro />
			<Toggle label={__('Ajax Search', 'team-free')} attributes={false} isPro />

			<ProNotice {...PRO_NOTICE_LIST_DISPLAY} />
		</>
	);
}
