/**
 * Intro Script Model
 * Comprehensive intro script generation with introduction types, event types, tones, and profile data
 */

import mongoose, { Schema, Document } from 'mongoose';

// ============================================
// TYPE DEFINITIONS
// ============================================

export type IntroductionType =
  | 'company'
  | 'founder'
  | 'employee'
  | 'team'
  | 'speaker'
  | 'guest'
  | 'event-host';

export type EventType =
  | 'corporate-meeting'
  | 'conference'
  | 'webinar'
  | 'workshop'
  | 'product-launch'
  | 'investor-pitch'
  | 'networking-event'
  | 'award-ceremony'
  | 'employee-onboarding'
  | 'annual-function'
  | 'training-session'
  | 'social-media-video'
  | 'youtube-video'
  | 'podcast'
  | 'college-seminar'
  | 'public-event';

export type IntroScriptLanguage =
  | 'en'
  | 'hi'
  | 'mr'
  | 'bilingual'
  | 'multilingual';

export type IntroScriptDuration =
  | '30s'
  | '1min'
  | '2min'
  | '3min'
  | '5min';

export type IntroScriptTone =
  | 'professional'
  | 'corporate'
  | 'inspirational'
  | 'friendly'
  | 'motivational'
  | 'formal'
  | 'luxury'
  | 'premium'
  | 'startup'
  | 'humorous';

export type IntroScriptContext =
  | 'stage'
  | 'self'
  | 'video'
  | 'networking'
  | 'investor'
  | 'conference-speaker'
  | 'award-ceremony';

export type IntroScriptSource =
  | 'ai-generation'
  | 'manual';

export type IntroScriptStatus =
  | 'draft'
  | 'review'
  | 'approved'
  | 'published';

export interface IIntroScript extends Document {
  // Core fields
  companyId: string;
  name: string;
  introductionType: IntroductionType;
  eventType: EventType;
  language: IntroScriptLanguage;
  duration: IntroScriptDuration;
  tone: IntroScriptTone;
  context?: IntroScriptContext;
  content: string;
  summaryPoints: string[];
  personalizationNotes?: string;
  source: IntroScriptSource;
  status: IntroScriptStatus;

  // Profile data fields
  designation?: string;
  industry?: string;
  experience?: string;
  location?: string;
  achievements?: string;
  education?: string;
  expertise?: string;
  certifications?: string;
  awards?: string;
  mission?: string;
  vision?: string;
  personalStory?: string;
  companyDescription?: string;

  // Timestamps
  createdAt: Date;
  updatedAt: Date;
}

// ============================================
// MAIN SCHEMA
// ============================================

const IntroScriptSchema = new Schema<IIntroScript>({
  // Core fields
  companyId: {
    type: String,
    required: [true, 'Company ID is required'],
    index: true,
  },
  name: {
    type: String,
    required: [true, 'Script name is required'],
    trim: true,
    maxlength: [300, 'Name cannot exceed 300 characters'],
  },
  introductionType: {
    type: String,
    enum: ['company', 'founder', 'employee', 'team', 'speaker', 'guest', 'event-host'],
    required: [true, 'Introduction type is required'],
  },
  eventType: {
    type: String,
    enum: [
      'corporate-meeting', 'conference', 'webinar', 'workshop', 'product-launch',
      'investor-pitch', 'networking-event', 'award-ceremony', 'employee-onboarding',
      'annual-function', 'training-session', 'social-media-video', 'youtube-video',
      'podcast', 'college-seminar', 'public-event',
    ],
    required: [true, 'Event type is required'],
  },
  language: {
    type: String,
    enum: ['en', 'hi', 'mr', 'bilingual', 'multilingual'],
    default: 'en',
  },
  duration: {
    type: String,
    enum: ['30s', '1min', '2min', '3min', '5min'],
    default: '1min',
  },
  tone: {
    type: String,
    enum: [
      'professional', 'corporate', 'inspirational', 'friendly', 'motivational',
      'formal', 'luxury', 'premium', 'startup', 'humorous',
    ],
    default: 'professional',
  },
  context: {
    type: String,
    enum: ['stage', 'self', 'video', 'networking', 'investor', 'conference-speaker', 'award-ceremony'],
  },
  content: {
    type: String,
    required: [true, 'Script content is required'],
    trim: true,
  },
  summaryPoints: [{
    type: String,
    trim: true,
  }],
  personalizationNotes: {
    type: String,
    trim: true,
  },
  source: {
    type: String,
    enum: ['ai-generation', 'manual'],
    default: 'manual',
  },
  status: {
    type: String,
    enum: ['draft', 'review', 'approved', 'published'],
    default: 'draft',
  },

  // Profile data fields
  designation: { type: String, trim: true },
  industry: { type: String, trim: true },
  experience: { type: String, trim: true },
  location: { type: String, trim: true },
  achievements: { type: String, trim: true },
  education: { type: String, trim: true },
  expertise: { type: String, trim: true },
  certifications: { type: String, trim: true },
  awards: { type: String, trim: true },
  mission: { type: String, trim: true },
  vision: { type: String, trim: true },
  personalStory: { type: String, trim: true },
  companyDescription: { type: String, trim: true },
}, {
  timestamps: true,
});

// ============================================
// INDEXES
// ============================================

IntroScriptSchema.index({ companyId: 1, introductionType: 1 });
IntroScriptSchema.index({ companyId: 1, status: 1 });

// ============================================
// EXPORT
// ============================================

export const IntroScript = mongoose.model<IIntroScript>('IntroScript', IntroScriptSchema);