// Overlays: cart drawer, search, quiz, chatbot, search modal const StarRow = ({ rating, size = 12 }) => ( {[1,2,3,4,5].map(i => )} ); function CartDrawer({ open, onClose, items, updateQty, removeItem, goto }) { const [closing, setClosing] = React.useState(false); const close = () => { setClosing(true); setTimeout(() => { setClosing(false); onClose(); }, 280); }; if (!open) return null; const subtotal = items.reduce((s, i) => s + i.price * i.qty, 0); const shipping = subtotal > 999 ? 0 : 80; return ( <>
); }; function SearchModal({ open, onClose, goto }) { const [q, setQ] = React.useState(''); const [closing, setClosing] = React.useState(false); const close = () => { setClosing(true); setTimeout(() => { setClosing(false); onClose(); }, 250); }; if (!open) return null; const suggestions = ['Muejaza For Men', 'Shahi Kalp', 'Kashmiri Shilajit', 'Testo Vardhak', 'Muejaza Plus']; return (
e.stopPropagation()} style={{ width: 'min(640px, 100%)', background: 'var(--bg)', borderRadius: 16, padding: 24, animation: closing ? 'slideUpOut 0.25s forwards' : 'slideUp 0.25s' }}>
setQ(e.target.value)} placeholder="Search pastes, ingredients, concerns..." style={{ flex: 1, background: 'transparent', border: 'none', outline: 'none', fontSize: 18, color: 'var(--ink)' }}/>
Popular
{suggestions.map(s => ( ))}
); }; // Find-my-formula quiz const QUIZ = [ { q: 'What is your primary goal?', opts: [ { l: 'Boost energy & stamina', tag: 'energy' }, { l: 'Improve immunity', tag: 'immunity' }, { l: 'Better sleep & less stress', tag: 'sleep' }, { l: 'Overall vitality & strength', tag: 'vitality' }, ]}, { q: 'Who is this for?', opts: [ { l: 'For me — men\'s health', tag: 'men' }, { l: 'For me — women\'s health', tag: 'women' }, { l: 'For both of us', tag: 'couple' }, { l: 'Looking for best quality', tag: 'premium' }, ]}, { q: 'How committed are you?', opts: [ { l: 'Curious — want to try', tag: 'starter' }, { l: 'Ready for a full routine', tag: 'classic' }, { l: 'Want the absolute best', tag: 'premium' }, { l: 'Great value matters', tag: 'value' }, ]}, { q: 'Any preference?', opts: [ { l: 'Just the purest Shilajit', tag: 'shilajit' }, { l: 'Multi-herb formula', tag: 'formula' }, { l: 'Bundle & save more', tag: 'bundle' }, { l: 'No preference', tag: 'classic' }, ]}, ]; function QuizModal({ open, onClose, goto, addToCart }) { const [step, setStep] = React.useState(0); const [answers, setAnswers] = React.useState([]); const [closing, setClosing] = React.useState(false); const close = () => { setClosing(true); setTimeout(() => { setClosing(false); onClose(); }, 250); }; React.useEffect(() => { if (open) { setStep(0); setAnswers([]); setClosing(false); } }, [open]); if (!open) return null; const done = step >= QUIZ.length; const pick = () => { const tags = answers; if (tags.includes('bundle') || tags.includes('couple')) return window.PRODUCTS.find(p => p.id === 'muejaza-shahi-kalp-combo'); if (tags.includes('premium')) return window.PRODUCTS.find(p => p.id === 'muejaza-plus'); if (tags.includes('shilajit')) return window.PRODUCTS.find(p => p.id === 'kashmiri-shilajit'); if (tags.includes('women')) return window.PRODUCTS.find(p => p.id === 'shahi-kalp'); if (tags.includes('sleep') || tags.includes('immunity')) return window.PRODUCTS.find(p => p.id === 'shahi-kalp'); if (tags.includes('energy') || tags.includes('vitality')) return window.PRODUCTS.find(p => p.id === 'testo-vardhak'); return window.PRODUCTS.find(p => p.id === 'muejaza-for-men'); }; const getReasons = (tags) => { const reasons = []; if (tags.includes('energy') || tags.includes('vitality')) reasons.push('Supports daily energy & stamina'); if (tags.includes('immunity')) reasons.push('Strengthens natural immunity'); if (tags.includes('sleep')) reasons.push('Promotes restful sleep'); if (tags.includes('premium')) reasons.push('Our most potent formulation'); if (tags.includes('shilajit')) reasons.push('Purest Himalayan resin, 70% Fulvic Acid'); if (tags.includes('bundle')) reasons.push('Best value for couples & families'); return reasons.length ? reasons : ['Broad-spectrum daily wellness', 'Cold-processed, 40+ herbs']; }; const rec = done ? pick() : null; const reasons = done ? getReasons(answers) : []; return (
e.stopPropagation()} style={{ width: 'min(680px, 100%)', maxHeight: '90vh', background: 'var(--bg)', borderRadius: 20, padding: 0, animation: closing ? 'slideUpOut 0.25s forwards' : 'slideUp 0.3s', overflow: 'hidden', display: 'flex', flexDirection: 'column' }}>
Find my formula · {done ? 'your match' : `${step+1}/${QUIZ.length}`}
{!done ? ( <>

{QUIZ[step].q}

{QUIZ[step].opts.map(o => ( ))}
{step > 0 && } ) : rec ? (
Your perfect match

{rec.name}

{rec.tagline}

{rec.name}
₹{rec.price.toLocaleString('en-IN')}
MRP ₹{rec.mrp} · incl. taxes
{rec.hero.slice(0,3).map(h => {h})}
Why this formula for you
{reasons.map((r, i) => (
{r}
))}
) : null}
); }; // AI Chatbot function Chatbot({ open, onClose }) { const [messages, setMessages] = React.useState([ { role: 'bot', text: 'Namaste 🙏 I\'m Vaidya, your nkherbal guide. Ask me anything — ingredients, doses, sourcing, or which paste fits your routine.' }, ]); const [input, setInput] = React.useState(''); const [loading, setLoading] = React.useState(false); const listRef = React.useRef(); React.useEffect(() => { if (listRef.current) listRef.current.scrollTop = listRef.current.scrollHeight; }, [messages, loading]); const send = async () => { if (!input.trim()) return; const userMsg = input.trim(); setMessages(m => [...m, { role: 'user', text: userMsg }]); setInput(''); setLoading(true); try { const system = `You are Vaidya, the helpful AI consultant for nkherbal — a premium Ayurvedic brand specializing in slow-cooked chyawanprash and herbal pastes. Be warm, concise, knowledgeable. Recommend specific nkherbal products when relevant: Classic Chyawanprash (₹890, immunity), Sugar-Free (₹1090, diabetic-friendly), Kids (₹690, ages 3+), Gold (₹2890, premium with swarna bhasma), Nidra Paste (₹990, sleep), Saundarya Paste (₹1190, skin/hair). Keep replies under 80 words. Use plain text, no markdown.`; const reply = await window.claude.complete({ messages: [ { role: 'user', content: `${system}\n\nUser: ${userMsg}` }, ], }); setMessages(m => [...m, { role: 'bot', text: reply }]); } catch (e) { setMessages(m => [...m, { role: 'bot', text: 'Sorry — I\'m having trouble reaching the herb garden. Try again in a moment, or write to care@nkherbal.com.' }]); } finally { setLoading(false); } }; if (!open) return null; return (
Vaidya · AI guide
online
{messages.map((m, i) => (
{m.text}
))} {loading &&
}
setInput(e.target.value)} onKeyDown={e => e.key === 'Enter' && send()} placeholder="Ask about a remedy..." style={{ flex: 1, padding: '10px 14px', borderRadius: 999, border: '1px solid var(--line)', background: 'var(--surface)', fontSize: 13, outline: 'none' }}/>
); }; window.StarRow = StarRow; window.CartDrawer = CartDrawer; window.SearchModal = SearchModal; window.QuizModal = QuizModal; window.Chatbot = Chatbot;