Spaces:
Running
Running
Commit ·
6f4307f
1
Parent(s): 6495612
gemini integration
Browse filesFiles changed (4)
12345678910111213141516171819202122232425262728293031323334353637383940414237 unmodified lines808182838485868788899091929394951 unmodified line979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166import React, { useState } from 'react';import { motion, AnimatePresence } from 'framer-motion';import { useTranslation } from 'react-i18next';import { Sparkles, X, Send, Lightbulb, Compass, Award, Wrench, AlertCircle } from 'lucide-react';const AIHintOverlay = ({ isAIActive, setIsAIActive, aiLoading, submitAICanvasPrompt }) => {const { t } = useTranslation();const [prompt, setPrompt] = useState('');const suggestions = [{text: t('canvas.ai_suggest_details', 'Break down the current step into subtasks'),icon: <Lightbulb size={18} className="text-amber-600" />,tag: t('canvas.ai_suggest_details_tag', 'Breakdown')},{text: t('canvas.ai_suggest_route', 'Suggest an alternative route in case of failure'),icon: <Compass size={18} className="text-emerald-600" />,tag: t('canvas.ai_suggest_route_tag', 'Alternative')},{text: t('canvas.ai_suggest_habits', 'Create daily habits to reinforce this goal'),icon: <Award size={18} className="text-indigo-600" />,tag: t('canvas.ai_suggest_habits_tag', 'Habits')}];const handleSubmit = async (e) => {e.preventDefault();if (!prompt.trim() || aiLoading) return;const success = await submitAICanvasPrompt(prompt);if (success) {setPrompt('');setIsAIActive(false); // Auto-dismiss on success to show the newly rendered paths!}};const handleSuggestionClick = (text) => {setPrompt(text);};return (37 unmodified lines/>{/* Content Container */}<div className="flex-1 flex flex-col pl-14 pr-8 py-8 overflow-y-auto relative z-0">{/* Header */}<div className="flex items-start justify-between mb-8"><div><div className="flex items-center gap-2 mb-1"><Sparkles className="text-amber-500 animate-pulse" size={24} /><span className="font-accent-note text-amber-600 font-bold uppercase tracking-wider text-sm">QuestboardAI AI</span></div><h2 className="font-display-lg text-4xl text-primary leading-none">{t('canvas.ai_roadmap_strategist', 'Roadmap Strategist')}</h2></div>1 unmodified line<buttononClick={() => !aiLoading && setIsAIActive(false)}disabled={aiLoading}className="p-1.5 border-2 border-primary/20 hover:border-primary rounded-xl transition-all hover:scale-105"><X size={20} className="text-primary/70" /></button></div>{/* Main Content Area */}{aiLoading ? (/* Beautiful animated handwriting sketch loader */<div className="flex-1 flex flex-col items-center justify-center py-12 text-center"><div className="relative mb-6">{/* Pulsing aura */}<div className="absolute -inset-4 bg-amber-200/40 rounded-full blur-xl animate-pulse" />{/* Animated Pencil icon sketching */}<motion.divanimate={{x: [0, 15, -15, 10, 0],y: [0, -10, 15, -5, 0],rotate: [0, 10, -10, 5, 0]}}transition={{duration: 3,repeat: Infinity,ease: "easeInOut"}}className="relative z-10 w-16 h-16 bg-[#faf7f2] border-2 border-primary rounded-2xl flex items-center justify-center shadow-lg"><Sparkles className="text-amber-500 animate-bounce" size={32} /></motion.div></div><h3 className="font-display text-2xl text-primary mb-2">{t('canvas.ai_drafting', 'Drafting your Roadmap...')}</h3><p className="font-accent-note text-xl text-primary/70 max-w-xs leading-relaxed">"{t('canvas.ai_drafting_desc', 'The strategist is sketching optimal path connections, sub-goals and checkpoints on your sketchbook canvas...')}"</p></div>) : (/* Beautiful maintenance state */<div className="flex-grow flex flex-col items-center justify-center py-6 text-center"><div className="relative mb-6"><div className="absolute -inset-4 bg-amber-100/50 rounded-full blur-lg animate-pulse" /><div className="relative z-10 w-20 h-20 bg-[#faf7f2] border-2 border-dashed border-amber-500 rounded-3xl flex items-center justify-center shadow-md"><Wrench className="text-amber-600 animate-bounce" size={36} /></div></div><h3 className="font-display text-2xl text-primary mb-3">{t('canvas.ai_maintenance_title', 'AI Under Maintenance')}</h3><p className="font-accent-note text-xl text-primary/70 max-w-sm leading-relaxed mb-8">"{t('canvas.ai_maintenance_desc', 'We are upgrading our AI strategist to deliver even faster, more accurate, and flexible plan generation. Thank you for your patience!')}"</p><buttononClick={() => setIsAIActive(false)}className="px-6 py-2.5 bg-primary text-[#fff] border-2 border-primary rounded-xl font-bold transition-all shadow-[3px_3px_0px_0px_rgba(0,0,0,0.15)] hover:scale-105 active:translate-y-0.5 active:shadow-[1px_1px_0px_0px_rgba(0,0,0,0.15)]">{t('canvas.ai_maintenance_btn', 'Got it')}</button></div>)}</div></motion.div>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914037 unmodified lines1781791801811821831841851861871881891901911921931 unmodified line195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320import React, { useState, useEffect, useRef } from 'react';import { motion, AnimatePresence } from 'framer-motion';import { useTranslation } from 'react-i18next';import { Sparkles, X, Send, Lightbulb, Compass, Award, AlertCircle, Pencil, Loader2 } from 'lucide-react';const AIHintOverlay = ({isAIActive,setIsAIActive,aiLoading,submitAICanvasPrompt,chatMessages = [],setChatMessages}) => {const { t } = useTranslation();const [prompt, setPrompt] = useState('');const [loadingStepIndex, setLoadingStepIndex] = useState(0);const messagesEndRef = useRef(null);const loadingSteps = ["Гостримо графітові олівці...","Відкриваємо чистий пергамент...","Калібруємо творчий компас...","Консультуємось з цифровим оракулом...","Малюємо контури вузлів...","Накладаємо зв'язки...","Задуваємо свіже чорнило..."];const suggestions = [{text: t('canvas.ai_suggest_details', 'Розпиши поточний крок на підзадачі'),icon: <Lightbulb size={14} className="text-amber-600" />,tag: t('canvas.ai_suggest_details_tag', 'Деталізація')},{text: t('canvas.ai_suggest_route', 'Запропонуй альтернативний шлях на випадок сбою'),icon: <Compass size={14} className="text-emerald-600" />,tag: t('canvas.ai_suggest_route_tag', 'Альтернатива')},{text: t('canvas.ai_suggest_habits', 'Створи щоденні звички для підкріплення цієї цілі'),icon: <Award size={14} className="text-indigo-600" />,tag: t('canvas.ai_suggest_habits_tag', 'Звички')}];useEffect(() => {let interval;if (aiLoading) {setLoadingStepIndex(0);interval = setInterval(() => {setLoadingStepIndex((prev) => (prev + 1) % loadingSteps.length);}, 3000);}return () => clearInterval(interval);}, [aiLoading]);// Auto scroll to bottomuseEffect(() => {messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });}, [chatMessages, aiLoading]);const handleSubmit = async (e) => {if (e) e.preventDefault();if (!prompt.trim() || aiLoading) return;const promptToSend = prompt;setPrompt('');await submitAICanvasPrompt(promptToSend);};const handleKeyDown = (e) => {if (e.key === 'Enter' && !e.shiftKey) {e.preventDefault();handleSubmit();}};const parseInlineMarkdown = (text) => {const parts = [];let remaining = text;const boldRegex = /\*\*([^*]+)\*\*/g;let match;let lastIndex = 0;while ((match = boldRegex.exec(text)) !== null) {const textBefore = text.substring(lastIndex, match.index);if (textBefore) parts.push(textBefore);parts.push(<strong key={match.index} className="font-extrabold text-primary">{match[1]}</strong>);lastIndex = boldRegex.lastIndex;}const textAfter = text.substring(lastIndex);if (textAfter) parts.push(textAfter);return parts.length > 0 ? parts : text;};const renderMarkdown = (text) => {if (!text) return null;return text.split('\n').map((line, idx) => {const cleanLine = line.trim();if (!cleanLine) return <div key={idx} className="h-2" />;const listMatch = cleanLine.match(/^[\*\-\u2022]\s+(.*)/);if (listMatch) {return (<li key={idx} className="ml-4 list-disc pl-1 text-sm text-primary/80 font-body my-1">{parseInlineMarkdown(listMatch[1])}</li>);}const numListMatch = cleanLine.match(/^\d+\.\s+(.*)/);if (numListMatch) {return (<li key={idx} className="ml-4 list-decimal pl-1 text-sm text-primary/80 font-body my-1">{parseInlineMarkdown(numListMatch[1])}</li>);}const headingMatch = cleanLine.match(/^(#{1,6})\s+(.*)/);if (headingMatch) {const level = headingMatch[1].length;const headingText = headingMatch[2];const classes = level === 1 ? "text-xl font-bold font-display mt-3 mb-1.5" :level === 2 ? "text-lg font-bold font-display mt-2.5 mb-1.5" :"text-base font-bold font-display mt-2 mb-1";return <div key={idx} className={`${classes} text-primary`}>{parseInlineMarkdown(headingText)}</div>;}return (<p key={idx} className="text-sm text-primary/85 font-body leading-relaxed mb-1.5 break-words">{parseInlineMarkdown(cleanLine)}</p>);});};return (37 unmodified lines/>{/* Content Container */}<div className="flex-grow flex flex-col pl-14 pr-6 py-6 overflow-hidden relative z-0">{/* Header */}<div className="flex items-start justify-between mb-4 border-b-2 border-primary/10 pb-4"><div><div className="flex items-center gap-2 mb-1"><Sparkles className="text-amber-500 animate-pulse" size={20} /><span className="font-accent-note text-amber-600 font-bold uppercase tracking-wider text-xs">QuestboardAI AI</span></div><h2 className="font-display text-2xl text-primary leading-none">{t('canvas.ai_roadmap_strategist', 'Roadmap Strategist')}</h2></div>1 unmodified line<buttononClick={() => !aiLoading && setIsAIActive(false)}disabled={aiLoading}className="p-1.5 border-2 border-primary/20 hover:border-primary rounded-xl transition-all hover:scale-105 cursor-pointer disabled:opacity-50"><X size={18} className="text-primary/70" /></button></div>{/* Chat Message Area */}<div className="flex-1 overflow-y-auto pr-2 mb-4 space-y-4 scrollbar-hide">{chatMessages.map((msg) => (<divkey={msg.id}className={`flex flex-col ${msg.sender === 'user' ? 'items-end' : 'items-start'}`}><divclassName={`max-w-[90%] p-3.5 rounded-2xl shadow-[2px_2px_0px_0px_rgba(0,0,0,0.15)] border-2 ${msg.sender === 'user'? 'bg-[#eef5fc] border-blue-500/30 text-primary rounded-tr-none rotate-[0.5deg]': msg.isError? 'bg-red-50 border-red-500/30 text-red-700 rounded-tl-none rotate-[-0.5deg]': 'bg-[#faf7f2] border-primary/20 text-primary rounded-tl-none rotate-[-0.5deg]'}`}>{msg.sender === 'user' ? (<p className="text-sm font-body leading-relaxed whitespace-pre-wrap">{msg.text}</p>) : (<div className="space-y-1">{renderMarkdown(msg.text)}</div>)}</div>{/* Timestamp */}<span className="text-[9px] font-extrabold text-primary/40 uppercase tracking-widest mt-1.5 px-2">{msg.sender === 'user' ? 'Ви' : 'Стратег'}</span></div>))}{/* Loading state showing pencil sketching & steps */}{aiLoading && (<div className="flex flex-col items-start animate-pulse"><div className="max-w-[90%] p-4 bg-[#faf7f2] border-2 border-primary/20 rounded-2xl rounded-tl-none shadow-[2px_2px_0px_0px_rgba(0,0,0,0.15)] flex flex-col gap-3"><div className="flex items-center gap-3">{/* Pencil writing micro-animation */}<motion.divanimate={{x: [0, 8, -8, 6, 0],y: [0, -5, 8, -4, 0],rotate: [0, 15, -15, 10, 0]}}transition={{duration: 2,repeat: Infinity,ease: "easeInOut"}}className="w-8 h-8 rounded-lg bg-[#faf7f2] border border-primary flex items-center justify-center shadow-sm"><Pencil className="text-amber-500" size={16} /></motion.div><div className="flex flex-col"><span className="text-xs font-bold text-primary">Стратег планує...</span><span className="text-[10px] font-extrabold text-primary/40 uppercase tracking-wider">Генерація графів</span></div></div><div className="flex items-center gap-2 bg-[#f4ebd0]/30 border border-primary/10 px-3 py-2 rounded-xl"><Loader2 className="animate-spin text-amber-600" size={14} /><span className="text-xs font-body italic text-primary/75">{loadingSteps[loadingStepIndex]}</span></div></div></div>)}<div ref={messagesEndRef} /></div>{/* Suggestions chips (only visible if not loading) */}{!aiLoading && chatMessages.length === 1 && (<div className="flex flex-col gap-2 mb-4 bg-primary/5 p-3 rounded-2xl border-2 border-dashed border-primary/10"><span className="text-[10px] font-extrabold uppercase text-primary/60 tracking-wider flex items-center gap-1.5"><Sparkles size={12} className="text-amber-500" /><span>Підказки для старту</span></span><div className="flex flex-wrap gap-2">{suggestions.map((sug, idx) => (<buttonkey={idx}onClick={() => setPrompt(sug.text)}className="flex items-center gap-1.5 px-3 py-1.5 bg-[#faf7f2] hover:bg-[#faf7f2]/80 border border-primary/20 hover:border-primary rounded-xl text-xs font-bold text-primary transition-all cursor-pointer shadow-[1px_1px_0px_0px_rgba(0,0,0,0.1)] hover:scale-[1.02]">{sug.icon}<span>{sug.tag}</span></button>))}</div></div>)}{/* Chat Input Form */}<form onSubmit={handleSubmit} className="mt-auto"><div className="relative border-2 border-primary rounded-2xl bg-[#faf7f2] shadow-[3px_3px_0px_0px_var(--color-primary)] flex items-center p-1 group focus-within:shadow-[4px_4px_0px_0px_var(--color-primary)] transition-all"><textarearows={1}value={prompt}onChange={(e) => setPrompt(e.target.value)}onKeyDown={handleKeyDown}disabled={aiLoading}placeholder={t('canvas.ask_ai_placeholder', 'Спроси стратега...')}className="flex-grow pl-3 pr-12 py-2 bg-transparent text-sm text-primary font-body outline-none resize-none max-h-24 scrollbar-hide placeholder:text-primary/40 placeholder:font-bold disabled:opacity-50"/><buttontype="submit"disabled={!prompt.trim() || aiLoading}className="absolute right-2 top-1/2 -translate-y-1/2 p-2 bg-primary text-white rounded-xl hover:scale-105 active:scale-95 disabled:scale-100 disabled:opacity-35 disabled:cursor-not-allowed transition-all cursor-pointer flex items-center justify-center"><Send size={14} /></button></div></form></div></motion.div>
150 unmodified lines1511521531541551561337 unmodified lines1494149514961497149814991 unmodified line15011502150315041505150615073 unmodified lines151115121513151415151516151762 unmodified lines1580158115821583158415851586158715881589148 unmodified lines173817391740174117421743150 unmodified linesconst [clipboardVersion, setClipboardVersion] = useState(0);const [isAIActive, setIsAIActive] = useState(false);const [aiLoading, setAiLoading] = useState(false);const [showPaywall, setShowPaywall] = useState(false);const [isSaving, setIsSaving] = useState(false);const [isManualSaving, setIsManualSaving] = useState(false);1337 unmodified linesconst submitAICanvasPrompt = async (promptText) => {if (!promptText || !projectId) return false;setAiLoading(true);try {const res = await axios.post(`${API_URL}/AI/assist`, {1 unmodified lineuserPrompt: promptText});const { newNodes, newEdges } = res.data;if (newNodes && newNodes.length > 0) {const mappedNewNodes = newNodes.map((n) => {3 unmodified lineslet resetRule = { type: 'daily', time: '00:00' };let lastResetTime = undefined;let createdAt = undefined;let description = '';let decision = n.decision || (n.type === 'condition' ? 'True' : 'bottom');if (n.type === 'condition') {62 unmodified linessetNodes((nds) => nds.concat(mappedNewNodes));setEdges((eds) => eds.concat(mappedNewEdges));}return true;} catch (err) {console.error('AI assistant error:', err);alert(err.response?.data?.message || 'Error occurred while talking to AI Assistant');return false;} finally {setAiLoading(false);148 unmodified linessetIsAIActive,aiLoading,submitAICanvasPrompt,showPaywall,setShowPaywall,handleAIRequest,150 unmodified lines1511521531541551561571581591601611621631337 unmodified lines15011502150315041505150615071508150915101511151215131514151515161 unmodified line15181519152015211522152315243 unmodified lines152815291530153115321533153462 unmodified lines15971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622148 unmodified lines17711772177317741775177617771778150 unmodified linesconst [clipboardVersion, setClipboardVersion] = useState(0);const [isAIActive, setIsAIActive] = useState(false);const [aiLoading, setAiLoading] = useState(false);const [chatMessages, setChatMessages] = useState([{id: 'welcome',sender: 'agent',text: 'Привіт! Я твій ШІ-стратег. Опиши, що ти хочеш додати на доску або як хочеш змінити поточний план. Я можу будувати підзадачі, умови та звички, позначаючи всі зв\'язки.'}]);const [showPaywall, setShowPaywall] = useState(false);const [isSaving, setIsSaving] = useState(false);const [isManualSaving, setIsManualSaving] = useState(false);1337 unmodified linesconst submitAICanvasPrompt = async (promptText) => {if (!promptText || !projectId) return false;// Append user messageconst userMsg = {id: crypto.randomUUID(),sender: 'user',text: promptText,timestamp: new Date()};setChatMessages(prev => [...prev, userMsg]);setAiLoading(true);try {const res = await axios.post(`${API_URL}/AI/assist`, {1 unmodified lineuserPrompt: promptText});const { newNodes, newEdges, explanation } = res.data;if (newNodes && newNodes.length > 0) {const mappedNewNodes = newNodes.map((n) => {3 unmodified lineslet resetRule = { type: 'daily', time: '00:00' };let lastResetTime = undefined;let createdAt = undefined;let description = n.description || '';let decision = n.decision || (n.type === 'condition' ? 'True' : 'bottom');if (n.type === 'condition') {62 unmodified linessetNodes((nds) => nds.concat(mappedNewNodes));setEdges((eds) => eds.concat(mappedNewEdges));}// Append agent messageconst agentMsg = {id: crypto.randomUUID(),sender: 'agent',text: explanation || 'Я оновив твою доску та додав необхідні елементи.',timestamp: new Date()};setChatMessages(prev => [...prev, agentMsg]);return true;} catch (err) {console.error('AI assistant error:', err);const errorMsg = {id: crypto.randomUUID(),sender: 'agent',text: 'Помилка: ' + (err.response?.data?.message || 'Не вдалося зв\'язатися з ШІ-стратегом.'),isError: true,timestamp: new Date()};setChatMessages(prev => [...prev, errorMsg]);return false;} finally {setAiLoading(false);148 unmodified linessetIsAIActive,aiLoading,submitAICanvasPrompt,chatMessages,setChatMessages,showPaywall,setShowPaywall,handleAIRequest,
1995 unmodified lines199619971998199920002001865 unmodified lines2867286828692870287128721995 unmodified linessetIsAIActive,aiLoading,submitAICanvasPrompt,showPaywall,setShowPaywall,handleAIRequest,865 unmodified linessetIsAIActive={setIsAIActive}aiLoading={aiLoading}submitAICanvasPrompt={submitAICanvasPrompt}/><PaywallModal showPaywall={showPaywall} setShowPaywall={setShowPaywall} />1995 unmodified lines19961997199819992000200120022003865 unmodified lines286928702871287228732874287528761995 unmodified linessetIsAIActive,aiLoading,submitAICanvasPrompt,chatMessages,setChatMessages,showPaywall,setShowPaywall,handleAIRequest,865 unmodified linessetIsAIActive={setIsAIActive}aiLoading={aiLoading}submitAICanvasPrompt={submitAICanvasPrompt}chatMessages={chatMessages}setChatMessages={setChatMessages}/><PaywallModal showPaywall={showPaywall} setShowPaywall={setShowPaywall} />
36 unmodified lines37383940414231 unmodified lines74757677787990 unmodified lines17017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221336 unmodified lines// Custom Creation Modal statesconst [scratchTitle, setScratchTitle] = useState('');// Sketchbook Loader statesconst [loadingStepIndex, setLoadingStepIndex] = useState(0);31 unmodified linessetIsCreateOpen(false);};return (<div className="flex min-h-screen bg-background"><Sidebar />90 unmodified lines<span>{t('dashboard.create_project_title')}</span></h3><p className="font-body-md text-on-surface-variant">{t('dashboard.create_project_desc', 'Create an empty roadmap and shape your connections manually.')}</p></div><form onSubmit={handleScratchSubmit} className="flex flex-col gap-6 mt-4"><div className="relative group"><label className="text-sm font-bold text-primary uppercase tracking-wider block mb-1">{t('dashboard.project_name')}</label><inputautoFocustype="text"value={scratchTitle}onChange={(e) => setScratchTitle(e.target.value)}placeholder={t('dashboard.project_name_placeholder', 'e.g. Master Classical Piano')}className="w-full bg-surface-container-low border-b-2 border-primary/20 focus:border-primary px-2 py-3 text-xl font-body-md outline-none transition-all"/></div><div className="flex items-center justify-end gap-4 mt-4"><buttontype="button"onClick={() => setIsCreateOpen(false)}className="px-6 py-2 font-bold text-lg text-on-surface-variant hover:text-primary transition-all">{t('dashboard.cancel')}</button><motion.buttonwhileHover={{ scale: 1.05, rotate: -1 }}whileTap={{ scale: 0.95 }}type="submit"className="bg-primary text-on-primary px-8 py-3 text-xl font-bold rough-border rough-shadow-hover flex items-center gap-2"><Plus size={20} /><span>{t('dashboard.create')}</span></motion.button></div></form></motion.div></div>)}36 unmodified lines3738394041424344454647484950515231 unmodified lines8485868788899091929394959690 unmodified lines18718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130236 unmodified lines// Custom Creation Modal statesconst [scratchTitle, setScratchTitle] = useState('');const [createMode, setCreateMode] = useState('ai'); // 'ai' | 'manual'const [aiGoal, setAiGoal] = useState('');useEffect(() => {if (!isCreateOpen) {setScratchTitle('');setAiGoal('');setCreateMode('ai');}}, [isCreateOpen]);// Sketchbook Loader statesconst [loadingStepIndex, setLoadingStepIndex] = useState(0);31 unmodified linessetIsCreateOpen(false);};const handleAISubmit = (e) => {e.preventDefault();if (!aiGoal.trim()) return;handleCreateProjectWithAI(aiGoal);setIsCreateOpen(false);};return (<div className="flex min-h-screen bg-background"><Sidebar />90 unmodified lines<span>{t('dashboard.create_project_title')}</span></h3><p className="font-body-md text-on-surface-variant">{createMode === 'ai'? 'Дозвольте ШІ розробити для вас детальну дорожню карту цілі.': t('dashboard.create_project_desc', 'Create an empty roadmap and shape your connections manually.')}</p></div>{/* Tab Switcher */}<div className="flex border-b-2 border-primary/10 gap-2 pb-1"><buttontype="button"onClick={() => setCreateMode('ai')}className={`flex-grow py-2 text-sm font-bold uppercase transition-all flex items-center justify-center gap-1.5 border-2 ${createMode === 'ai'? 'bg-primary text-white border-primary shadow-[2px_2px_0px_0px_var(--color-primary)]': 'border-transparent text-primary/75 hover:bg-secondary/5 hover:border-primary/20'} rounded-xl cursor-pointer`}><Sparkles size={16} /><span>AI Стратег</span></button><buttontype="button"onClick={() => setCreateMode('manual')}className={`flex-grow py-2 text-sm font-bold uppercase transition-all flex items-center justify-center gap-1.5 border-2 ${createMode === 'manual'? 'bg-primary text-white border-primary shadow-[2px_2px_0px_0px_var(--color-primary)]': 'border-transparent text-primary/75 hover:bg-secondary/5 hover:border-primary/20'} rounded-xl cursor-pointer`}><Pencil size={16} /><span>Ручний ескіз</span></button></div>{createMode === 'ai' ? (<form onSubmit={handleAISubmit} className="flex flex-col gap-6 mt-2"><div className="relative group"><label className="text-sm font-bold text-primary uppercase tracking-wider block mb-1">Опишіть вашу мету</label><textareaautoFocusrows={3}value={aiGoal}onChange={(e) => setAiGoal(e.target.value)}placeholder="Наприклад: Вивчити основи React та побудувати портфоліо за 4 тижні"className="w-full bg-surface-container-low border-b-2 border-primary/20 focus:border-primary px-2 py-3 text-lg font-body-md outline-none transition-all resize-none"/><p className="text-[10px] font-extrabold uppercase text-amber-600 mt-1">* Наш ШІ розіб'є вашу мету на кроки, додасть звички та розрахує позиції!</p></div><div className="flex items-center justify-end gap-4 mt-2"><buttontype="button"onClick={() => setIsCreateOpen(false)}className="px-6 py-2 font-bold text-lg text-on-surface-variant hover:text-primary transition-all">{t('dashboard.cancel')}</button><motion.buttonwhileHover={{ scale: 1.05, rotate: -1 }}whileTap={{ scale: 0.95 }}type="submit"disabled={!aiGoal.trim()}className="bg-primary text-on-primary px-8 py-3 text-xl font-bold rough-border rough-shadow-hover flex items-center gap-2 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"><Sparkles size={20} /><span>Генерувати</span></motion.button></div></form>) : (<form onSubmit={handleScratchSubmit} className="flex flex-col gap-6 mt-2"><div className="relative group"><label className="text-sm font-bold text-primary uppercase tracking-wider block mb-1">{t('dashboard.project_name')}</label><inputautoFocustype="text"value={scratchTitle}onChange={(e) => setScratchTitle(e.target.value)}placeholder={t('dashboard.project_name_placeholder', 'e.g. Master Classical Piano')}className="w-full bg-surface-container-low border-b-2 border-primary/20 focus:border-primary px-2 py-3 text-xl font-body-md outline-none transition-all"/></div><div className="flex items-center justify-end gap-4 mt-4"><buttontype="button"onClick={() => setIsCreateOpen(false)}className="px-6 py-2 font-bold text-lg text-on-surface-variant hover:text-primary transition-all">{t('dashboard.cancel')}</button><motion.buttonwhileHover={{ scale: 1.05, rotate: -1 }}whileTap={{ scale: 0.95 }}type="submit"disabled={!scratchTitle.trim()}className="bg-primary text-on-primary px-8 py-3 text-xl font-bold rough-border rough-shadow-hover flex items-center gap-2 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"><Plus size={20} /><span>{t('dashboard.create')}</span></motion.button></div></form>)}</motion.div></div>)}
src/features/canvas/components/AIHintOverlay.jsx+229-75
src/features/canvas/hooks/useCanvasLogic.js+38-3
src/pages/CanvasPage.jsx+4
src/pages/DashboardPage.jsx+123-34