import React from 'react'; const TopicSelector = ({ onTopicsChange, availableTopics = [], selectedTopics = [], customTopics = [], onCustomTopicsChange, customSentence = '', onSentenceChange, multiTheme = true, onMultiThemeChange }) => { const handleTopicToggle = (topic) => { const newSelectedTopics = selectedTopics.includes(topic) ? selectedTopics.filter(t => t !== topic) : [...selectedTopics, topic]; onTopicsChange(newSelectedTopics); }; const handleAddCustomTopic = () => { const newCustomTopics = [...customTopics, '']; onCustomTopicsChange && onCustomTopicsChange(newCustomTopics); }; const handleCustomTopicChange = (index, value) => { // Limit to 3 words (max 2 spaces) const spaceCount = (value.match(/ /g) || []).length; if (spaceCount > 2) { return; // Don't update if more than 2 spaces } const newCustomTopics = [...customTopics]; newCustomTopics[index] = value; onCustomTopicsChange && onCustomTopicsChange(newCustomTopics); }; const handleRemoveCustomTopic = (index) => { const newCustomTopics = customTopics.filter((_, i) => i !== index); onCustomTopicsChange && onCustomTopicsChange(newCustomTopics); }; return (
Add your own topics (up to 3 words per box)
{customTopics.map((topic, index) => ({multiTheme ? "AI will process each theme separately and balance results" : "AI will blend all themes into a single concept" }
{selectedTopics.length + customTopics.filter(t => t.trim()).length} total topic{(selectedTopics.length + customTopics.filter(t => t.trim()).length) !== 1 ? 's' : ''} selected