/// Represents a single CMS section from the landing page. class CmsSection { final String id; final String pageSlug; final String sectionKey; final Map content; final bool isPublished; const CmsSection({ required this.id, required this.pageSlug, required this.sectionKey, required this.content, this.isPublished = true, }); factory CmsSection.fromJson(Map json) { return CmsSection( id: json['id'] as String, pageSlug: json['pageSlug'] as String? ?? '', sectionKey: json['sectionKey'] as String? ?? '', content: json['content'] as Map? ?? {}, isPublished: json['isPublished'] as bool? ?? true, ); } } // --- Top Professionals Section --- class TopProfessionalsContent { final String title; final String ctaText; final String ctaButtonText; final List agents; final List lenders; const TopProfessionalsContent({ this.title = '"Meet top real estate professionals"', this.ctaText = 'Discover 5,000+ Top Real Estate Agents in Our Network.', this.ctaButtonText = 'Browse Experts', this.agents = const [], this.lenders = const [], }); factory TopProfessionalsContent.fromJson(Map json) { return TopProfessionalsContent( title: json['title'] as String? ?? '"Meet top real estate professionals"', ctaText: json['ctaText'] as String? ?? 'Discover 5,000+ Top Real Estate Agents in Our Network.', ctaButtonText: json['ctaButtonText'] as String? ?? 'Browse Experts', agents: (json['agents'] as List?) ?.map((e) => ProfessionalItem.fromJson(e as Map)) .toList() ?? [], lenders: (json['lenders'] as List?) ?.map((e) => ProfessionalItem.fromJson(e as Map)) .toList() ?? [], ); } } class ProfessionalItem { final String name; final String subtitle; final String location; final String experience; final List expertise; final String imageUrl; const ProfessionalItem({ required this.name, this.subtitle = '', this.location = '', this.experience = '', this.expertise = const [], this.imageUrl = '', }); factory ProfessionalItem.fromJson(Map json) { return ProfessionalItem( name: json['name'] as String? ?? '', subtitle: json['subtitle'] as String? ?? '', location: json['location'] as String? ?? '', experience: json['experience'] as String? ?? '', expertise: (json['expertise'] as List?) ?.map((e) => e.toString()) .toList() ?? [], imageUrl: json['imageUrl'] as String? ?? '', ); } } // --- Hero Section --- class HeroContent { final String headline; final String description; final String ctaButtonText; final String helperText; const HeroContent({ this.headline = '', this.description = '', this.ctaButtonText = '', this.helperText = '', }); factory HeroContent.fromJson(Map json) { return HeroContent( headline: json['headline'] as String? ?? '', description: json['description'] as String? ?? '', ctaButtonText: json['ctaButtonText'] as String? ?? '', helperText: json['helperText'] as String? ?? '', ); } } // --- Features Section --- class FeaturesContent { final String title; final String subtitle; final List features; const FeaturesContent({ this.title = '', this.subtitle = '', this.features = const [], }); factory FeaturesContent.fromJson(Map json) { return FeaturesContent( title: json['title'] as String? ?? '', subtitle: json['subtitle'] as String? ?? '', features: (json['features'] as List?) ?.map( (e) => FeatureItem.fromJson(e as Map)) .toList() ?? [], ); } } class FeatureItem { final String iconPath; final String title; final String description; const FeatureItem({ this.iconPath = '', this.title = '', this.description = '', }); factory FeatureItem.fromJson(Map json) { return FeatureItem( iconPath: json['iconPath'] as String? ?? '', title: json['title'] as String? ?? '', description: json['description'] as String? ?? '', ); } } // --- Testimonials Section --- class TestimonialsContent { final String title; final String subtitle; final String ratingInfo; final List stats; final List testimonials; const TestimonialsContent({ this.title = '', this.subtitle = '', this.ratingInfo = '', this.stats = const [], this.testimonials = const [], }); factory TestimonialsContent.fromJson(Map json) { return TestimonialsContent( title: json['title'] as String? ?? '', subtitle: json['subtitle'] as String? ?? '', ratingInfo: json['ratingInfo'] as String? ?? '', stats: (json['stats'] as List?) ?.map((e) => StatItem.fromJson(e as Map)) .toList() ?? [], testimonials: (json['testimonials'] as List?) ?.map((e) => TestimonialItem.fromJson(e as Map)) .toList() ?? [], ); } } class StatItem { final String iconPath; final String boldText; final String normalText; const StatItem({ this.iconPath = '', this.boldText = '', this.normalText = '', }); factory StatItem.fromJson(Map json) { return StatItem( iconPath: json['iconPath'] as String? ?? '', boldText: json['boldText'] as String? ?? '', normalText: json['normalText'] as String? ?? '', ); } } class TestimonialItem { final int rating; final String title; final String content; final String author; final String role; const TestimonialItem({ this.rating = 5, this.title = '', this.content = '', this.author = '', this.role = '', }); factory TestimonialItem.fromJson(Map json) { return TestimonialItem( rating: json['rating'] as int? ?? 5, title: json['title'] as String? ?? '', content: json['content'] as String? ?? '', author: json['author'] as String? ?? '', role: json['role'] as String? ?? '', ); } } /// Parsed landing page content from all CMS sections. class LandingPageContent { final HeroContent? hero; final FeaturesContent? features; final TopProfessionalsContent? topProfessionals; final TestimonialsContent? testimonials; const LandingPageContent({ this.hero, this.features, this.topProfessionals, this.testimonials, }); factory LandingPageContent.fromSections(List sections) { HeroContent? hero; FeaturesContent? features; TopProfessionalsContent? topProfessionals; TestimonialsContent? testimonials; for (final section in sections) { switch (section.sectionKey) { case 'hero': hero = HeroContent.fromJson(section.content); break; case 'features': features = FeaturesContent.fromJson(section.content); break; case 'topProfessionals': topProfessionals = TopProfessionalsContent.fromJson(section.content); break; case 'testimonials': testimonials = TestimonialsContent.fromJson(section.content); break; } } return LandingPageContent( hero: hero, features: features, topProfessionals: topProfessionals, testimonials: testimonials, ); } }