/** * Gating System Type Definitions * * Pre-conversation lead capture form with i18n support. * Single source of truth for all BuzzTrail packages. */ /** * ISO 639-1 language codes (all 32 Tavus-supported languages) */ export type GatingLanguage = | 'en' // English | 'fr' // French | 'de' // German | 'es' // Spanish | 'pt' // Portuguese | 'zh' // Chinese | 'ja' // Japanese | 'hi' // Hindi | 'it' // Italian | 'ko' // Korean | 'nl' // Dutch | 'pl' // Polish | 'ru' // Russian | 'sv' // Swedish | 'tr' // Turkish | 'id' // Indonesian | 'fil' // Filipino | 'bg' // Bulgarian | 'ro' // Romanian | 'ar' // Arabic | 'cs' // Czech | 'el' // Greek | 'fi' // Finnish | 'hr' // Croatian | 'ms' // Malay | 'sk' // Slovak | 'da' // Danish | 'ta' // Tamil | 'uk' // Ukrainian | 'hu' // Hungarian | 'no' // Norwegian | 'vi'; // Vietnamese /** * Information fields that can be collected from user */ export type GatingInfoField = 'name' | 'email' | 'phone' | 'company'; /** * Storage destination for lead data */ export type StorageDestination = 'supabase' | 'webhook' | 'both'; /** * Email validation configuration */ export interface EmailValidationConfig { /** Block common free email providers (Gmail, Yahoo, etc.) */ blockFreeProviders: boolean; /** Custom domains to block (e.g., ['competitor.com']) */ customBlockedDomains?: string[]; } /** * Storage configuration */ export interface StorageConfig { /** Where to store/send lead data */ destination: StorageDestination; /** Supabase table name (only used if destination is 'supabase' or 'both') */ supabaseTable?: string; /** Webhook URL (only used if destination is 'webhook' or 'both') */ webhookUrl?: string; } /** * Custom translation overrides for gating form */ export interface GatingTranslationOverrides { /** Form title (e.g., "Get Started") */ title?: string; /** Form subtitle/description */ subtitle?: string; /** Submit button text */ submitButton?: string; /** Field labels */ labels?: { name?: string; email?: string; phone?: string; company?: string; }; /** Field placeholders */ placeholders?: { name?: string; email?: string; phone?: string; company?: string; }; /** Privacy policy text */ privacyText?: string; /** Terms of service text */ termsText?: string; /** Consent checkbox text */ consentText?: string; /** Error messages */ errors?: { required?: string; invalidEmail?: string; freeEmailBlocked?: string; invalidPhone?: string; submissionFailed?: string; }; } /** * Complete gating configuration */ export interface GatingConfig { /** Enable gating form (if false, conversation starts immediately) */ enabled: boolean; /** Form language (ISO 639-1 code) */ language: GatingLanguage; /** Which information fields to collect */ collectInfo: GatingInfoField[]; /** Which fields are required */ requiredInfo: GatingInfoField[]; /** Email validation rules */ emailValidation: EmailValidationConfig; /** Privacy policy URL */ privacyPolicyUrl?: string; /** Terms of service URL */ termsOfServiceUrl?: string; /** GDPR compliance mode (shows detailed consent) */ gdprCompliant: boolean; /** Pass collected info to Tavus conversation context */ passToConversation: boolean; /** Where to store/send lead data */ storage: StorageConfig; /** Custom translation overrides */ translations?: GatingTranslationOverrides; } /** * Lead data collected from gating form */ export interface GatingLeadData { /** User's full name */ name?: string; /** User's email address */ email?: string; /** User's phone number */ phone?: string; /** User's company name */ company?: string; /** Timestamp when form was submitted */ submittedAt: string; /** Customer ID (from BuzzTrail config) */ customerId: string; /** Language selected */ language: GatingLanguage; /** User consented to privacy policy/terms */ consented: boolean; } /** * Form validation state */ export interface GatingValidationState { /** Overall form validity */ isValid: boolean; /** Field-specific errors */ errors: { name?: string; email?: string; phone?: string; company?: string; consent?: string; }; } /** * Form submission state */ export interface GatingSubmissionState { /** Currently submitting */ isSubmitting: boolean; /** Submission completed successfully */ isSuccess: boolean; /** Submission failed */ isError: boolean; /** Error message if submission failed */ errorMessage?: string; }