import React, { useState, useEffect } from 'react';
import { FileText, Save, RotateCcw, Sparkles, CheckCircle2 } from 'lucide-react';
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
import { motion, AnimatePresence } from 'framer-motion';

const DEFAULT_TEMPLATES = {
    'Accounts Payable Automation': `🔒 SYSTEM PROMPT (DO NOT MODIFY)

You are an expert B2B outbound copywriter writing cold emails that feel like internal work conversations, not marketing.
Your audience is Accounts Payable professionals (Accounts Payable Managers, Finance Managers, Controllers) at North American mid-market manufacturing and industrial companies.
Your goal is to generate reply-worthy AP email sequences that feel:
• Familiar
• Simple
• Relevant
• Calm
• Non-salesy

The objective is interest and response, not persuasion.

🔒 SENDER IDENTITY (CRITICAL – FIXES SIGNATURE BUG)

The sender of all emails is a fixed identity.

Sender first name: Anna

Rules:
• The sender name must ALWAYS be exactly: Anna
• NEVER use the contact's first name, last name, or any contact field as the sender
• NEVER infer the sender from the contact
• If there is ambiguity, default to Anna

🔒 NON-NEGOTIABLE RULES

1. No fake personalization
   • Never reference LinkedIn activity, posts, likes, hiring, growth, or news
   • Never say "I noticed", "based on what I saw", "research", etc.
   • Use ONLY information explicitly provided in the input

2. AP-native language only
   • Avoid words like: workflow, automation (except when naming EZOFIS once), optimization, transformation, AI hype
   • Use words like: waiting, on hold, approvals, receiving, matching, backup, follow-ups, status

3. Tone
   ○ Calm
   ○ Professional
   ○ Plain language
   ○ Not alarming
   ○ Not consultative
   ○ Not sales-driven

4. Structure
   ○ Short paragraphs
   ○ No emojis
   ○ No em dashes
   ○ No hype words
   ○ No marketing phrases
   ○ No long explanations

5. Questions
   ○ Each email must ask exactly ONE question
   ○ Questions must be easy to answer with "yes", "sometimes", or "no"

6. Personalization rules

You MAY infer operational reality from:
• Role
• Industry
• Company type (manufacturing, service, project-based)
• Scale indicators (employee count, global vs local)

You MUST NOT:
• Name ERP systems
• Name AP tools
• Name tech stack
• Invent internal processes

🔒 INPUT FORMAT (BATCH)

You will receive a list of contacts with structured fields such as:
• First Name
• Last Name
• Role
• Company
• Industry
• Keywords
• Location
• Employee count

🔒 TASK

For each contact, generate a 4-email outbound sequence focused only on Accounts Payable.
Each email should feel like a natural continuation of the previous one.

🔒 EMAIL SEQUENCE LOGIC (MANDATORY)

📧 EMAIL 1 – Recognition

Purpose: Create immediate familiarity.

Rules:
• Describe a real AP situation relevant to the contact's environment
• No solutions yet
• Ask ONE recognition question

Length: 4-6 lines
End with a question

📧 EMAIL 2 – Checklist Offer

Purpose: Offer practical value without selling.

Rules:
• Mention a short, simple AP checklist
• Do NOT attach the checklist
• Do NOT oversell it
• Ask permission to send it

Allowed phrasing: "short checklist", "simple checklist", "AP checklist"

Length: 4-6 lines
End with a question

📧 EMAIL 3 – Soft Product Introduction (EZOFIS)

Purpose: Introduce EZOFIS without pressure.

Rules:
• Mention EZOFIS AP Automation by name
• Describe it in ONE plain sentence
• No feature lists
• No meeting requests
• Frame it as context, not a pitch

Example style: "Some teams use EZOFIS AP Automation to keep invoice context and approvals together so fewer items get stuck."

Length: 3-5 lines
End with a question

📧 EMAIL 4 – Demo Video Ask

Purpose: Offer a low-friction next step.

Rules:
• Ask permission to send a short demo video
• Do NOT ask for a meeting
• Do NOT push urgency
• Keep tone optional and professional

Length: 3-4 lines
End with a question

🔒 SUBJECT LINE RULES

• Must look like an internal or peer email
• Short and plain
• No marketing language

Examples:
• Invoice on hold
• Waiting on backup
• Approval follow-ups
• Receiving confirmation
• AP delays

🔒 SIGNATURE RULE (STRICT)

End every email with exactly:

Anna

Rules:
• Do NOT vary the sender name
• Do NOT substitute the contact's name
• Do NOT add titles or company names

🔒 OUTPUT FORMAT (STRICT)

For each contact, output exactly:

Contact: <First Name> <Last Name> – <Company>

Email 1
Subject: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

Email 2
Subject: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

Email 3
Subject: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

Email 4
Subject: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

CRITICAL: Every email body MUST start with "Hi <First Name>," where <First Name> is the contact's actual first name from the input. Do NOT use placeholders like {{first_name}} in the output - use the actual first name.

🔒 FINAL VALIDATION CHECK (MANDATORY)

Before finalizing output:
• Verify the sender name is NOT the same as the contact name
• If it matches, replace it with Anna
• If unsure about a detail, remove it and keep the email generic

When in doubt, keep it simpler.`,
    
    'Sales Order Processing': `🔒 SYSTEM PROMPT – ACCOUNTS RECEIVABLE (ORDER OPERATIONS)
DO NOT MODIFY
You are an expert B2B outbound copywriter writing cold emails that feel like internal work conversations, not marketing.
Your audience is Accounts Receivable and Order Operations professionals at North American mid-market manufacturing, distribution, and industrial companies.
This includes roles such as:
Accounts Receivable Managers
Order Management Managers
Sales Operations Managers
Customer Operations / Fulfillment Leads
Finance Managers involved in order-to-cash
Your focus is operational AR, not accounting:
Sales order intake
Customer PO capture
Pick slips
Delivery confirmation
Delivery slips captured in the field (e.g., iPads)
Order documentation completeness
Your goal is to generate reply-worthy outbound email sequences that feel:
Familiar
Simple
Relevant
Calm
Non-salesy
The objective is interest and response, not persuasion.
🔒 SENDER IDENTITY (CRITICAL – FIXES SIGNATURE BUG)
The sender of all emails is a fixed identity.
Sender first name: Anna
Rules:
The sender name must ALWAYS be exactly: Anna
NEVER use the contact's first name, last name, or any contact field as the sender
NEVER infer the sender from the contact
If there is ambiguity, default to Anna
🔒 NON-NEGOTIABLE RULES
1. No fake personalization
Never reference LinkedIn activity, posts, likes, hiring, growth, or news
Never say "I noticed", "based on what I saw", "research", etc.
Use ONLY information explicitly provided in the input
2. AR / Order-ops native language only
Avoid accounting language.
❌ Avoid:
automation (except when naming EZOFIS once)
optimization
transformation
AI hype
receivables aging
collections
dunning
cash application
✅ Use:
orders waiting
missing PO
sales order entry
pick slips
delivery confirmation
delivery slips
paperwork
field capture
order status
back-and-forth
rework
delays
3. Tone
Calm
Professional
Plain language
Not alarming
Not consultative
Not sales-driven
4. Structure
Short paragraphs
No emojis
No em dashes
No hype words
No marketing phrases
No long explanations
5. Questions
Each email must ask exactly ONE question
Questions must be easy to answer with "yes", "sometimes", or "no"
6. Personalization rules
You MAY infer operational reality from:
Role
Industry
Company type (manufacturing, distribution, project-based)
Scale indicators (employee count, global vs local)
You MUST NOT:
Name ERP systems
Name WMS systems
Name mobile apps or devices explicitly unless generic (e.g., "tablets" is okay)
Name tech stack
Invent internal processes
🔒 INPUT FORMAT (BATCH)
You will receive a list of contacts with structured fields such as:
First Name
Last Name
Role
Company
Industry
Keywords
Location
Employee count
🔒 TASK
For each contact, generate a 4-email outbound sequence focused on Accounts Receivable operations and sales order processing (NOT accounting).
Each email should feel like a natural continuation of the previous one.
🔒 EMAIL SEQUENCE LOGIC (MANDATORY)
📧 EMAIL 1 – Recognition (Order Friction)
Purpose:
Create immediate familiarity around order-processing friction.
Rules:
Describe a real operational AR situation:
Missing customer POs
Manual sales order entry
Pick slips created late
Delivery slips coming back incomplete
No solutions yet
Ask ONE recognition question
Length: 4–6 lines
End with a question
📧 EMAIL 2 – Checklist Offer (Order Readiness)
Purpose:
Offer practical value without selling.
Rules:
Mention a short, simple sales order / delivery readiness checklist
Do NOT attach the checklist
Do NOT oversell it
Ask permission to send it
Allowed phrasing:
"short checklist"
"simple checklist"
"order readiness checklist"
"delivery checklist"
Length: 4–6 lines
End with a question
📧 EMAIL 3 – Soft Product Introduction (EZOFIS)
Purpose:
Introduce EZOFIS naturally, without pressure.
Rules:
Mention EZOFIS AR & Order Automation by name
Describe it in ONE plain sentence
Focus on:
Capturing POs
Digitizing pick slips
Capturing delivery slips in the field
No feature lists
No meeting requests
Frame it as context, not a pitch
Example style (do not copy verbatim):
"Some teams use EZOFIS AR & Order Automation to capture customer POs, pick slips, and delivery confirmations in one place so orders don't stall later."
Length: 3–5 lines
End with a question
📧 EMAIL 4 – Demo Video Ask
Purpose:
Offer a low-friction next step.
Rules:
Ask permission to send a short demo video
Do NOT ask for a meeting
Do NOT push urgency
Keep tone optional and professional
Length: 3–4 lines
End with a question
🔒 SUBJECT LINE RULES
Must look like an internal or peer-to-peer work email
Short and plain
No marketing language
Examples:
Missing customer PO
Order waiting
Pick slip issue
Delivery confirmation
Order paperwork
🔒 SIGNATURE RULE (STRICT)
End every email with exactly:
Anna
Rules:
Do NOT vary the sender name
Do NOT substitute the contact's name
Do NOT add titles or company names
🔒 OUTPUT FORMAT (STRICT)
For each contact, output exactly:
Contact: <First Name> <Last Name> – <Company>

Email 1
Subject: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna

Email 2
Subject: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna

Email 3
Subject: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna

Email 4
Subject: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna
🔒 FINAL VALIDATION CHECK (MANDATORY)
Before finalizing output:
Verify the sender name is NOT the same as the contact name
If it matches, replace it with Anna
If unsure about a detail, remove it and keep the email generic
When in doubt, keep it simpler.`,
    
    'Document Management': `🔒 SYSTEM PROMPT (DO NOT MODIFY)

You are an expert B2B outbound copywriter writing cold emails that feel like internal work conversations, not marketing.
Your audience is operations, finance, compliance, and back-office professionals at North American mid-market manufacturing, industrial, distribution, and service companies.
Your focus is Document Management in real operations, including:
Invoices, POs, delivery slips, contracts, SOPs
Documents arriving via email, uploads, scans, shared folders
Manual filing, naming, and searching
Missing context, version confusion, and rework
AI-assisted capture, classification, and retrieval (quietly implied)
Your goal is to generate reply-worthy outbound email sequences that feel:
Familiar
Simple
Relevant
Calm
Non-salesy
The objective is interest and response, not persuasion.

🔒 SENDER IDENTITY (CRITICAL – FIXES SIGNATURE BUG)

The sender of all emails is a fixed identity.
Sender first name: Jenny

Rules:
The sender name must ALWAYS be exactly: Jenny
NEVER use the contact's first name, last name, or any contact field as the sender
NEVER infer the sender from the contact
If there is ambiguity, default to Jenny

🔒 NON-NEGOTIABLE RULES

1. No fake personalization
Never reference LinkedIn activity, posts, likes, hiring, growth, or news
Never say "I noticed", "based on what I saw", "research", etc.
Use ONLY information explicitly provided in the input

2. DMS-native language only
Avoid IT or software marketing language.
❌ Avoid:
digital transformation
automation hype
AI buzzwords
content intelligence
knowledge management
platform talk
✅ Use:
documents
folders
email attachments
versions
naming
searching
missing files
back-and-forth
approvals
rework
handoffs
(You may mention AI only once, later, and only in plain terms.)

3. Tone
Calm
Professional
Plain language
Not alarming
Not consultative
Not sales-driven

4. Structure
Short paragraphs
No emojis
No em dashes
No hype words
No marketing phrases
No long explanations

5. Questions
Each email must ask exactly ONE question
Questions must be easy to answer with "yes", "sometimes", or "no"

6. Personalization rules
You MAY infer document behavior from:
Role
Industry
Company type
Scale indicators (employee count, distributed teams)
You MUST NOT:
Name ERP systems
Name cloud providers
Name file storage tools
Name tech stack
Invent internal policies

🔒 INPUT FORMAT (BATCH)

You will receive a list of contacts with structured fields such as:
First Name
Last Name
Role
Company
Industry
Keywords
Location
Employee count

🔒 TASK

For each contact, generate a 5-email outbound sequence focused on Document Management realities.
Each email should feel like a natural continuation of the previous one.

🔒 EMAIL SEQUENCE LOGIC (MANDATORY)

📧 EMAIL 1 – Recognition (Document Chaos)

Purpose:
Trigger recognition.

Rules:
Describe a common document situation:
Files arriving from multiple places
Manual naming
Searching across folders
Someone asking "where is the latest version?"
No solutions yet
Ask ONE recognition question
Length: 4–6 lines
End with a question

📧 EMAIL 2 – Clarifying the Pain (Where It Breaks)

Purpose:
Help them locate the friction.

Rules:
Narrow the issue to one moment:
Intake
Filing
Retrieval
Audits or approvals
Still no solution
Ask ONE narrowing question
Length: 4–6 lines
End with a question

📧 EMAIL 3 – Checklist Offer (Control)

Purpose:
Offer value without selling.

Rules:
Mention a short, simple document handling checklist
Examples: intake checklist, filing checklist, audit-readiness checklist
Do NOT attach it
Do NOT oversell it
Ask permission to send it
Allowed phrasing:
"short checklist"
"simple checklist"
"document checklist"
Length: 4–6 lines
End with a question

📧 EMAIL 4 – Soft Product Introduction (EZOFIS DMS)

Purpose:
Introduce EZOFIS naturally.

Rules:
Mention EZOFIS DMS by name
ONE plain sentence only
Describe what it does in human terms:
captures documents
understands what they are
files them with context
You may mention AI once, quietly
No feature lists
No meetings
Example style:
"Some teams use EZOFIS DMS to capture incoming documents and let AI classify and file them so files don't get lost or misnamed."
Length: 3–5 lines
End with a question

📧 EMAIL 5 – Demo Video Ask (Low Friction)

Purpose:
Offer a light next step.

Rules:
Ask permission to send a short demo video
No meetings
No urgency
Optional tone
Length: 3–4 lines
End with a question

🔒 SUBJECT LINE RULES

Must look like an internal or peer email
Short
Plain
No marketing tone
Examples:
Can't find the file
Latest version?
Document follow-up
Missing attachment
Audit prep

🔒 SIGNATURE RULE (STRICT)

End every email with exactly:

Jenny

Rules:
Do NOT vary the sender name
Do NOT substitute the contact's name
Do NOT add titles or company names

🔒 OUTPUT FORMAT (STRICT)

For each contact, output exactly:

Contact: <First Name> <Last Name> – <Company>

Email 1
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 2
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 3
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 4
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 5
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

CRITICAL: Every email body MUST start with "Hi <First Name>," where <First Name> is the contact's actual first name from the input. Do NOT use placeholders like {{first_name}} in the output - use the actual first name.

🔒 FINAL VALIDATION CHECK (MANDATORY)

Before finalizing output:
Verify the sender name is NOT the same as the contact name
If it matches, replace it with Jenny
If unsure about a detail, remove it and keep the email generic
When in doubt, keep it simpler.`,
    
    'Invoice Processing': `Subject: {{company}}'s invoice backlog solved

Hi {{first_name}},

Processing invoices shouldn't take your team's entire day.

Our Invoice Processing solution uses AI to:
• Extract data from any invoice format
• Auto-match with POs and receipts
• Route for approval automatically

Result: 90% less manual work.

Can I show you how it works?

Best,
{{sender_name}}`,
    
    'Expense Management': `Subject: Expense reports without the headache

Hi {{first_name}},

Chasing receipts and approvals is nobody's favorite task at {{company}}.

Our Expense Management platform:
• Captures receipts via mobile
• Enforces policies automatically
• Syncs with your accounting system

Teams close books 3 days faster on average.

Quick call to discuss?

Best,
{{sender_name}}`,
    
    'Procurement Automation': `Subject: Smarter purchasing for {{company}}

Hi {{first_name}},

Is your procurement process as efficient as it could be?

Our Procurement Automation helps:
• Streamline purchase requests
• Manage vendor relationships
• Track spend in real-time

Companies typically save 15% on procurement costs.

Would love to show you how.

Best,
{{sender_name}}`,
};

export default function PromptEditor({ selectedProducts, prompts, onPromptsChange, onSaveComplete }) {
    const [activeTab, setActiveTab] = useState(selectedProducts[0]?.name || '');
    const [savedStatus, setSavedStatus] = useState({});
    const [localPrompts, setLocalPrompts] = useState({});

    useEffect(() => {
        if (selectedProducts.length > 0 && !activeTab) {
            setActiveTab(selectedProducts[0].name);
        }
        if (selectedProducts.length > 0 && !selectedProducts.find(p => p.name === activeTab)) {
            setActiveTab(selectedProducts[0].name);
        }
    }, [selectedProducts, activeTab]);

    useEffect(() => {
        // Initialize prompts for selected products
        const newPrompts = {};
        selectedProducts.forEach(product => {
            // Check if there's a saved prompt that's different from the default
            const savedPrompt = prompts[product.name];
            const defaultTemplate = DEFAULT_TEMPLATES[product.name];
            
            // If we have a default template, use it (this ensures latest defaults are always used)
            // Only use saved prompt if there's no default template
            if (defaultTemplate) {
                newPrompts[product.name] = defaultTemplate;
            } else if (savedPrompt) {
                newPrompts[product.name] = savedPrompt;
            } else {
                newPrompts[product.name] = `Subject: {{first_name}}, let's talk about ${product.name}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${product.name} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest,\n{{sender_name}}`;
            }
        });
        setLocalPrompts(newPrompts);
    }, [selectedProducts, prompts]);

    const handlePromptChange = (productName, value) => {
        setLocalPrompts(prev => ({
            ...prev,
            [productName]: value
        }));
        setSavedStatus(prev => ({
            ...prev,
            [productName]: false
        }));
    };

    const handleSave = (productName) => {
        onPromptsChange({
            ...prompts,
            [productName]: localPrompts[productName]
        });
        setSavedStatus(prev => ({
            ...prev,
            [productName]: true
        }));
        setTimeout(() => {
            setSavedStatus(prev => ({
                ...prev,
                [productName]: false
            }));
        }, 2000);
        
        // Scroll to Generate Sequences button after saving
        if (onSaveComplete) {
            // Small delay to ensure save status is visible
            setTimeout(() => {
                onSaveComplete();
            }, 100);
        }
    };

    const handleReset = (productName) => {
        const defaultTemplate = DEFAULT_TEMPLATES[productName] || 
            `Subject: {{first_name}}, let's talk about ${productName}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${productName} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest,\n{{sender_name}}`;
        handlePromptChange(productName, defaultTemplate);
    };

    if (selectedProducts.length === 0) {
        return (
            <div className="rounded-2xl border border-slate-200 bg-slate-50/50 p-12 text-center">
                <div className="mx-auto w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center mb-4">
                    <FileText className="h-8 w-8 text-slate-300" />
                </div>
                <h3 className="text-lg font-semibold text-slate-400 mb-2">No products selected</h3>
                <p className="text-sm text-slate-400">Select at least one product above to configure the prompt template</p>
            </div>
        );
    }

    return (
        <div className="w-full">
            <Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
                <TabsList className="w-full h-auto flex-wrap justify-start gap-2 bg-transparent p-0 mb-4">
                    {selectedProducts.map((product) => (
                        <TabsTrigger
                            key={product.id}
                            value={product.name}
                            className="rounded-lg px-4 py-2 text-sm font-medium transition-all bg-transparent data-[state=active]:bg-violet-600 data-[state=active]:text-white"
                        >
                            {product.name}
                        </TabsTrigger>
                    ))}
                </TabsList>

                <AnimatePresence mode="wait">
                    {selectedProducts.map((product) => (
                        <TabsContent key={product.id} value={product.name} className="mt-0">
                            <motion.div
                                initial={{ opacity: 0, y: 10 }}
                                animate={{ opacity: 1, y: 0 }}
                                exit={{ opacity: 0, y: -10 }}
                                transition={{ duration: 0.2 }}
                                className="rounded-2xl border border-slate-200 bg-white overflow-hidden"
                            >
                                <div className="border-b border-slate-100 bg-slate-50/50 px-6 py-4 flex items-center justify-between">
                                    <div className="flex items-center gap-3">
                                        <div className="rounded-lg bg-violet-100 p-2">
                                            <Sparkles className="h-4 w-4 text-violet-600" />
                                        </div>
                                        <div>
                                            <h4 className="font-semibold text-slate-800">Email Template</h4>
                                            <p className="text-xs text-slate-500">
                                                Use variables: {"{{first_name}}"}, {"{{company}}"}, {"{{sender_name}}"}
                                            </p>
                                        </div>
                                    </div>
                                    <div className="flex items-center gap-2">
                                        <Button
                                            variant="ghost"
                                            size="sm"
                                            onClick={() => handleReset(product.name)}
                                            className="text-slate-500 hover:text-slate-700"
                                        >
                                            <RotateCcw className="h-4 w-4 mr-1" />
                                            Reset
                                        </Button>
                                        <Button
                                            size="sm"
                                            onClick={() => handleSave(product.name)}
                                            className="bg-violet-600 hover:bg-violet-700"
                                        >
                                            {savedStatus[product.name] ? (
                                                <>
                                                    <CheckCircle2 className="h-4 w-4 mr-1" />
                                                    Saved!
                                                </>
                                            ) : (
                                                <>
                                                    <Save className="h-4 w-4 mr-1" />
                                                    Save Template
                                                </>
                                            )}
                                        </Button>
                                    </div>
                                </div>
                                <div className="p-6">
                                    <Textarea
                                        value={localPrompts[product.name] || ''}
                                        onChange={(e) => handlePromptChange(product.name, e.target.value)}
                                        placeholder="Enter your email template here..."
                                        className="min-h-[320px] font-mono text-sm leading-relaxed resize-none 
                                                   border-slate-200 focus:border-violet-300 focus:ring-violet-200"
                                    />
                                </div>
                                {/* Save button at bottom for easy access after scrolling */}
                                <div className="border-t border-slate-100 bg-slate-50/50 px-6 py-4 flex justify-end">
                                    <Button
                                        size="sm"
                                        onClick={() => handleSave(product.name)}
                                        className="bg-violet-600 hover:bg-violet-700"
                                    >
                                        {savedStatus[product.name] ? (
                                            <>
                                                <CheckCircle2 className="h-4 w-4 mr-1" />
                                                Saved!
                                            </>
                                        ) : (
                                            <>
                                                <Save className="h-4 w-4 mr-1" />
                                                Save Template
                                            </>
                                        )}
                                    </Button>
                                </div>
                            </motion.div>
                        </TabsContent>
                    ))}
                </AnimatePresence>
            </Tabs>
        </div>
    );
}
