import type { DigitalPresence } from "@/lib/types";

const DEMO_DIGITAL_PRESENCE: Record<string, DigitalPresence> = {
  "apex-roofing": {
    websiteUrl: "https://apexroofingco.com",
    websiteTitle: "Apex Roofing Co. — Austin Storm & Hail Experts",
    websiteDescription: "Free inspections, insurance claim help, and same-week installs across Austin metro.",
    socialProfiles: [
      { platform: "facebook", handle: "@apexroofingco", url: "https://facebook.com/apexroofingco", followers: "2.4K" },
      { platform: "instagram", handle: "@apexroofingco", url: "https://instagram.com/apexroofingco", followers: "1.8K" },
      { platform: "google", handle: "Apex Roofing Co.", url: "https://g.page/apex-roofing-austin", followers: "4.7★ · 89 reviews" },
    ],
    connectedSoftware: [
      { name: "WordPress", category: "Website CMS", url: "https://apexroofingco.com/wp-admin", usedByRoles: ["Marketing Manager", "Local SEO Specialist"] },
      { name: "Jobber", category: "Field service CRM", url: "https://app.getjobber.com", usedByRoles: ["Dispatcher", "Estimator", "CRM Admin"] },
      { name: "Google Ads", category: "Paid search", url: "https://ads.google.com", usedByRoles: ["Marketing Manager", "Local SEO Specialist"] },
      { name: "Twilio", category: "SMS / voice", url: "https://console.twilio.com", usedByRoles: ["Dispatcher", "Office Manager"] },
    ],
  },
  "glow-studio": {
    websiteUrl: "https://glowstudiomiami.com",
    websiteTitle: "Glow Studio Med Spa — Miami Aesthetics",
    websiteDescription: "Botox, fillers, laser, and memberships. Book online or text to reserve.",
    socialProfiles: [
      { platform: "instagram", handle: "@glowstudiomiami", url: "https://instagram.com/glowstudiomiami", followers: "12.6K" },
      { platform: "tiktok", handle: "@glowstudiomiami", url: "https://tiktok.com/@glowstudiomiami", followers: "8.2K" },
      { platform: "facebook", handle: "@GlowStudioMiami", url: "https://facebook.com/GlowStudioMiami", followers: "3.1K" },
      { platform: "google", handle: "Glow Studio Med Spa", url: "https://g.page/glow-studio-miami", followers: "4.9★ · 214 reviews" },
    ],
    connectedSoftware: [
      { name: "Square Appointments", category: "Booking", url: "https://squareup.com/dashboard/appointments", usedByRoles: ["Patient Coordinator", "Front Desk"] },
      { name: "Meta Ads", category: "Paid social", url: "https://business.facebook.com", usedByRoles: ["Marketing Manager", "Reputation Manager"] },
      { name: "Klaviyo", category: "Email / SMS", url: "https://www.klaviyo.com", usedByRoles: ["Patient Coordinator", "Marketing Manager"] },
      { name: "Webflow", category: "Website CMS", url: "https://webflow.com/dashboard", usedByRoles: ["Marketing Manager"] },
    ],
  },
  stackline: {
    websiteUrl: "https://stackline.io",
    websiteTitle: "Stackline — Workflow automation for ops teams",
    websiteDescription: "Product-led SaaS with demo booking, API docs, and customer onboarding hub.",
    socialProfiles: [
      { platform: "linkedin", handle: "Stackline", url: "https://linkedin.com/company/stackline-io", followers: "3.2K" },
      { platform: "x", handle: "@stackline_io", url: "https://x.com/stackline_io", followers: "890" },
      { platform: "youtube", handle: "Stackline", url: "https://youtube.com/@stackline", followers: "1.1K" },
    ],
    connectedSoftware: [
      { name: "HubSpot", category: "CRM", url: "https://app.hubspot.com", usedByRoles: ["SDR", "Onboarding Concierge", "CRM Admin"] },
      { name: "Intercom", category: "Support / chat", url: "https://app.intercom.com", usedByRoles: ["Onboarding Concierge"] },
      { name: "LinkedIn Sales Nav", category: "Outbound", url: "https://linkedin.com/sales", usedByRoles: ["SDR", "Business Development Rep"] },
      { name: "Vercel", category: "Marketing site", url: "https://vercel.com/dashboard", usedByRoles: ["Marketing Manager"] },
    ],
  },
  launchpad: {
    websiteUrl: "https://launchpadai.io",
    websiteTitle: "Launchpad AI — Outbound copilot for founder-led teams",
    websiteDescription: "Waitlist, product demo video, and design partner application.",
    socialProfiles: [
      { platform: "linkedin", handle: "Launchpad AI", url: "https://linkedin.com/company/launchpad-ai", followers: "840" },
      { platform: "x", handle: "@launchpad_ai", url: "https://x.com/launchpad_ai", followers: "620" },
      { platform: "youtube", handle: "Launchpad AI", url: "https://youtube.com/@launchpadai", followers: "210" },
    ],
    connectedSoftware: [
      { name: "Notion", category: "Ops wiki", url: "https://notion.so", usedByRoles: ["Founder", "SDR"] },
      { name: "HubSpot", category: "CRM (free tier)", url: "https://app.hubspot.com", usedByRoles: ["Founder", "SDR"] },
      { name: "Linear", category: "Product", url: "https://linear.app", usedByRoles: ["Founder", "Engineering"] },
      { name: "Vercel", category: "Marketing site", url: "https://vercel.com/dashboard", usedByRoles: ["Founder"] },
    ],
  },
  "farm-table": {
    websiteUrl: "https://farmtablepdx.com",
    websiteTitle: "Farm Table Kitchen — Portland Farm-to-Table",
    websiteDescription: "Dinner reservations, catering inquiry form, and seasonal menu PDF.",
    socialProfiles: [
      { platform: "instagram", handle: "@farmtablepdx", url: "https://instagram.com/farmtablepdx", followers: "9.4K" },
      { platform: "facebook", handle: "@farmtablepdx", url: "https://facebook.com/farmtablepdx", followers: "5.7K" },
      { platform: "google", handle: "Farm Table Kitchen", url: "https://g.page/farm-table-kitchen-pdx", followers: "4.6★ · 312 reviews" },
    ],
    connectedSoftware: [
      { name: "Toast", category: "POS / catering", url: "https://pos.toasttab.com", usedByRoles: ["Catering Sales Coordinator", "Office Manager"] },
      { name: "OpenTable", category: "Reservations", url: "https://restaurant.opentable.com", usedByRoles: ["Front Desk"] },
      { name: "Mailchimp", category: "Email marketing", url: "https://mailchimp.com", usedByRoles: ["Marketing Manager"] },
      { name: "Squarespace", category: "Website CMS", url: "https://farmtablepdx.com/config", usedByRoles: ["Marketing Manager"] },
    ],
  },
  "momentum-fitness": {
    websiteUrl: "https://momentumfitdenver.com",
    websiteTitle: "Momentum Fitness — Denver Small-Group Training",
    websiteDescription: "Membership signup, class schedule, and corporate wellness inquiry page.",
    socialProfiles: [
      { platform: "instagram", handle: "@momentumfitdenver", url: "https://instagram.com/momentumfitdenver", followers: "6.8K" },
      { platform: "facebook", handle: "@MomentumFitDenver", url: "https://facebook.com/MomentumFitDenver", followers: "2.9K" },
      { platform: "youtube", handle: "Momentum Fitness", url: "https://youtube.com/@momentumfitdenver", followers: "540" },
    ],
    connectedSoftware: [
      { name: "Mindbody", category: "Gym software", url: "https://clients.mindbodyonline.com", usedByRoles: ["Front Desk", "Membership Retention Specialist"] },
      { name: "GoHighLevel", category: "CRM / SMS", url: "https://app.gohighlevel.com", usedByRoles: ["Sales Coordinator", "Marketing Manager"] },
      { name: "Wix", category: "Website CMS", url: "https://wix.com/dashboard", usedByRoles: ["Marketing Manager"] },
      { name: "Meta Ads", category: "Paid social", url: "https://business.facebook.com", usedByRoles: ["Marketing Manager"] },
    ],
  },
  "greenedge-landscaping": {
    websiteUrl: "https://greenedgelscape.com",
    websiteTitle: "GreenEdge Landscaping — Nashville HOA & Estate Care",
    websiteDescription: "Spring packages, HOA proposals, and service area map for Brentwood/Franklin.",
    socialProfiles: [
      { platform: "instagram", handle: "@greenedgelscape", url: "https://instagram.com/greenedgelscape", followers: "4.2K" },
      { platform: "facebook", handle: "@greenedgelscape", url: "https://facebook.com/greenedgelscape", followers: "3.6K" },
      { platform: "google", handle: "GreenEdge Landscaping", url: "https://g.page/greenedge-landscaping", followers: "4.7★ · 41 reviews" },
    ],
    connectedSoftware: [
      { name: "ServiceTitan", category: "Field service CRM", url: "https://go.servicetitan.com", usedByRoles: ["Dispatcher", "Estimator", "CRM Admin"] },
      { name: "Google Ads", category: "Paid search", url: "https://ads.google.com", usedByRoles: ["Marketing Manager", "Local SEO Specialist"] },
      { name: "CompanyCam", category: "Photo / proof", url: "https://app.companycam.com", usedByRoles: ["Marketing Manager"] },
      { name: "WordPress", category: "Website CMS", url: "https://greenedgelscape.com/wp-admin", usedByRoles: ["Marketing Manager"] },
    ],
  },
  "vitalmed-supply": {
    websiteUrl: "https://vitalmedsupply.com",
    websiteTitle: "VitalMed Supply Co. — DFW Surgical & Clinic Supplies",
    websiteDescription: "B2B catalog, compliance docs, and RFP submission portal for clinic buyers.",
    socialProfiles: [
      { platform: "linkedin", handle: "VitalMed Supply Co.", url: "https://linkedin.com/company/vitalmed-supply", followers: "1.4K" },
      { platform: "google", handle: "VitalMed Supply Co.", url: "https://g.page/vitalmed-supply-dallas", followers: "4.5★ · 28 reviews" },
    ],
    connectedSoftware: [
      { name: "Salesforce", category: "B2B CRM", url: "https://vitalmed.lightning.force.com", usedByRoles: ["Business Development Rep", "Account Manager"] },
      { name: "PandaDoc", category: "Proposals / RFP", url: "https://app.pandadoc.com", usedByRoles: ["Business Development Rep", "Compliance Lead"] },
      { name: "NetSuite", category: "ERP / inventory", url: "https://system.netsuite.com", usedByRoles: ["Account Manager", "Billing Specialist"] },
      { name: "WordPress", category: "Catalog site", url: "https://vitalmedsupply.com/wp-admin", usedByRoles: ["Marketing Manager"] },
    ],
  },
  "clearsmile-dental": {
    websiteUrl: "https://clearsmiledental.com",
    websiteTitle: "ClearSmile Dental Group — East Phoenix",
    websiteDescription: "New patient form, Invisalign quiz, and anxiety-free care positioning.",
    socialProfiles: [
      { platform: "instagram", handle: "@clearsmiledental", url: "https://instagram.com/clearsmiledental", followers: "3.7K" },
      { platform: "facebook", handle: "@ClearSmileDental", url: "https://facebook.com/ClearSmileDental", followers: "2.1K" },
      { platform: "google", handle: "ClearSmile Dental Group", url: "https://g.page/clearsmile-dental-phoenix", followers: "4.8★ · 156 reviews" },
    ],
    connectedSoftware: [
      { name: "Dentrix", category: "Practice management", url: "https://www.dentrix.com", usedByRoles: ["Front Desk", "Treatment Coordinator"] },
      { name: "Weave", category: "SMS / reviews", url: "https://www.getweave.com", usedByRoles: ["Front Desk", "Reputation Manager"] },
      { name: "Google Ads", category: "Paid search", url: "https://ads.google.com", usedByRoles: ["Marketing Manager"] },
      { name: "WordPress", category: "Website CMS", url: "https://clearsmiledental.com/wp-admin", usedByRoles: ["Marketing Manager"] },
    ],
  },
  "comfortzone-hvac": {
    websiteUrl: "https://comfortzonehvac.com",
    websiteTitle: "ComfortZone HVAC — Atlanta Same-Day AC Repair",
    websiteDescription: "ComfortClub maintenance plans, emergency booking, and service area pages.",
    socialProfiles: [
      { platform: "facebook", handle: "@ComfortZoneHVAC", url: "https://facebook.com/ComfortZoneHVAC", followers: "5.3K" },
      { platform: "instagram", handle: "@comfortzonehvac", url: "https://instagram.com/comfortzonehvac", followers: "1.9K" },
      { platform: "google", handle: "ComfortZone HVAC", url: "https://g.page/comfortzone-hvac-atlanta", followers: "4.6★ · 203 reviews" },
    ],
    connectedSoftware: [
      { name: "ServiceTitan", category: "Field service CRM", url: "https://go.servicetitan.com", usedByRoles: ["Dispatcher", "ComfortClub Sales Specialist"] },
      { name: "CallRail", category: "Call tracking", url: "https://app.callrail.com", usedByRoles: ["Dispatcher", "Marketing Manager"] },
      { name: "Google Ads", category: "Paid search", url: "https://ads.google.com", usedByRoles: ["Marketing Manager", "Local SEO Specialist"] },
      { name: "WordPress", category: "Website CMS", url: "https://comfortzonehvac.com/wp-admin", usedByRoles: ["Marketing Manager"] },
    ],
  },
  "luxe-realty": {
    websiteUrl: "https://luxerealtypartners.com",
    websiteTitle: "Luxe Realty Partners — Charlotte Luxury & Investor Sales",
    websiteDescription: "Listing search, investor ROI hub, and Ballantyne neighborhood guides.",
    socialProfiles: [
      { platform: "instagram", handle: "@luxerealtypartners", url: "https://instagram.com/luxerealtypartners", followers: "7.1K" },
      { platform: "facebook", handle: "@LuxeRealtyPartners", url: "https://facebook.com/LuxeRealtyPartners", followers: "4.4K" },
      { platform: "linkedin", handle: "Luxe Realty Partners", url: "https://linkedin.com/company/luxe-realty-partners", followers: "980" },
      { platform: "youtube", handle: "Luxe Realty Partners", url: "https://youtube.com/@luxerealtypartners", followers: "620" },
    ],
    connectedSoftware: [
      { name: "Follow Up Boss", category: "Real estate CRM", url: "https://app.followupboss.com", usedByRoles: ["Investor Relations Specialist", "Transaction Coordinator"] },
      { name: "kvCORE", category: "IDX website", url: "https://kvcore.com", usedByRoles: ["Marketing Manager"] },
      { name: "Zillow Premier Agent", category: "Lead source", url: "https://zillow.com/premier-agent", usedByRoles: ["Lead Agent", "Marketing Manager"] },
      { name: "Canva", category: "Listing creative", url: "https://canva.com", usedByRoles: ["Marketing Manager"] },
    ],
  },
};

export function getDemoDigitalPresence(demoId: string): DigitalPresence | undefined {
  return DEMO_DIGITAL_PRESENCE[demoId];
}

export function attachDemoDigitalPresence<T extends { input: { websiteUrl: string }; id?: string }>(
  business: T,
  demoSlug: string,
): T & { digitalPresence?: DigitalPresence } {
  const preset = DEMO_DIGITAL_PRESENCE[demoSlug];
  if (!preset) return business;
  return {
    ...business,
    input: { ...business.input, websiteUrl: preset.websiteUrl },
    digitalPresence: preset,
  };
}

export function inferDigitalPresenceFromBusiness(business: {
  input: { businessName: string; websiteUrl: string; productsServices: string };
  digitalPresence?: DigitalPresence;
}): DigitalPresence | null {
  if (business.digitalPresence) return business.digitalPresence;
  if (!business.input.websiteUrl?.trim()) return null;
  return {
    websiteUrl: business.input.websiteUrl,
    websiteTitle: business.input.businessName,
    websiteDescription: business.input.productsServices,
    socialProfiles: [],
    connectedSoftware: [],
  };
}
