const coachUserId = "af5a87be-8f9c-4630-902a-37a60b7005ba";
const clientUserId = "5bc531ab-611f-41f3-9373-b7cc5d09c93d";

module.exports = {
  async up(queryInterface) {
    const now = new Date();
    const tomorrow = new Date(Date.now() + 24 * 60 * 60 * 1000);
    const nextWeek = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000);

    const packageId = "4e529dc6-5c02-4903-9b47-0ab0adac1001";
    const clientAId = "98405fa4-fec0-4207-98d0-5d2c60ba4001";
    const clientBId = "98405fa4-fec0-4207-98d0-5d2c60ba4002";
    const sessionAId = "2263bfd3-3ee9-49f3-9af8-c78ce49f1001";
    const sessionBId = "2263bfd3-3ee9-49f3-9af8-c78ce49f1002";

    await queryInterface.bulkInsert("packages", [
      {
        id: packageId,
        title: "Executive Momentum",
        description: "A focused coaching package for founders and operators who need sharper decisions, clearer priorities, and calmer execution.",
        price: "$2,400",
        duration: "8 weeks",
        cta: "Book discovery call",
        included_sessions: 6,
        is_active: true,
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
    ]);

    await queryInterface.bulkInsert("clients", [
      {
        id: clientAId,
        name: "Demo Client One",
        email: "demo-client-one@example.invalid",
        status: "active",
        goals: "Delegate operational decisions, build a steadier weekly planning rhythm, and prepare for a senior leadership transition.",
        notes: "Prefers direct feedback and concise written follow-ups. Avoid overloading with frameworks.",
        company: "Fictional Company One",
        role_title: "Founder",
        tags: "founder,leadership,delegation",
        next_session_at: tomorrow,
        last_session_at: now,
        packageId,
        ownerId: coachUserId,
        portalUserId: clientUserId,
        ai_processing_consent_granted: true,
        ai_processing_consent_at: now,
        ai_processing_consent_policy_version: "2026-07-22-v1",
        recording_consent_granted: true,
        recording_consent_at: now,
        recording_consent_policy_version: "2026-07-22-v1",
        consent_updated_by_id: coachUserId,
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
      {
        id: clientBId,
        name: "Demo Client Two",
        email: "demo-client-two@example.invalid",
        status: "active",
        goals: "Move from reactive management to repeatable team rituals and stronger feedback conversations.",
        notes: "Responds well to experiments with clear success criteria.",
        company: "Fictional Company Two",
        role_title: "Head of Product",
        tags: "product,management,feedback",
        next_session_at: nextWeek,
        last_session_at: now,
        packageId,
        ownerId: coachUserId,
        ai_processing_consent_granted: true,
        ai_processing_consent_at: now,
        ai_processing_consent_policy_version: "2026-07-22-v1",
        recording_consent_granted: true,
        recording_consent_at: now,
        recording_consent_policy_version: "2026-07-22-v1",
        consent_updated_by_id: coachUserId,
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
    ]);

    await queryInterface.bulkInsert("sessions", [
      {
        id: sessionAId,
        clientId: clientAId,
        title: "Delegation and decision boundaries",
        session_at: now,
        status: "shared",
        transcript_notes: "[FICTIONAL DEMO TRANSCRIPT] Demo Client One noticed they still review every hiring decision. We mapped which decisions need founder review and which can be delegated.",
        ai_summary: "Demo Client One is ready to test a decision-rights matrix for hiring and customer escalations. The central theme was trusting senior leads without disappearing from critical calls.",
        key_topics: "delegation,decision rights,hiring,leadership transition",
        goals_discussed: "Reduce founder bottlenecks; create a weekly leadership decision review.",
        blockers: "Fear that delegated decisions will lower quality; unclear escalation rules.",
        commitments: "Draft decision-rights matrix before Friday and review with COO.",
        homework: "Write three examples of decisions the client will stop approving personally.",
        emotional_themes: "Cautious optimism, control, trust",
        important_quotes: "\"I know I am the bottleneck, but I do not know what good letting go looks like.\"",
        follow_up_email: "Thanks for today. Your next step is to draft the decision-rights matrix and identify three decisions you will stop approving personally.",
        next_session_prep: "Ask what happened when the client shared the matrix with the COO.",
        private_coach_notes: "Watch for over-correcting into vague oversight. She needs specific operating agreements.",
        shared_client_notes: "This week is about making delegation concrete through visible decision boundaries.",
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
      {
        id: sessionBId,
        clientId: clientBId,
        title: "Feedback rituals",
        session_at: now,
        status: "shared",
        transcript_notes: "[FICTIONAL DEMO TRANSCRIPT] Demo Client Two wants weekly 1:1s to feel less like status updates. We designed a three-question feedback pattern.",
        ai_summary: "Demo Client Two will pilot a simple 1:1 structure that separates status, friction, and feedback. They want the team to surface blockers earlier.",
        key_topics: "1:1s,feedback,team rituals,management",
        goals_discussed: "Improve team feedback cadence; reduce late surprises.",
        blockers: "The client worries direct questions may feel too intense for newer team members.",
        commitments: "Pilot the 1:1 structure with two team members this week.",
        homework: "Ask each team member: What is stuck? What needs a decision? What feedback do you have for me?",
        emotional_themes: "Curiosity, hesitation, responsibility",
        important_quotes: "\"I want fewer surprises without becoming the person everyone fears updating.\"",
        follow_up_email: "Your experiment this week is two 1:1s with the new three-question structure. Keep notes on what changed.",
        next_session_prep: "Review what surfaced earlier and whether the questions need softening.",
        private_coach_notes: "He benefits from practical scripts more than theory.",
        shared_client_notes: "Use structure to make feedback safer and more routine.",
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
    ]);

    await queryInterface.bulkInsert("action_items", [
      {
        id: "5c58d06d-15f2-4f6d-9a61-6d495c5d5001",
        clientId: clientAId,
        sessionId: sessionAId,
        title: "Draft decision-rights matrix",
        due_at: tomorrow,
        status: "in_progress",
        notes: "Start with hiring, customer escalations, and roadmap tradeoffs.",
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
      {
        id: "5c58d06d-15f2-4f6d-9a61-6d495c5d5002",
        clientId: clientBId,
        sessionId: sessionBId,
        title: "Pilot new 1:1 structure",
        due_at: nextWeek,
        status: "not_started",
        notes: "Run with two team members and capture what surfaced earlier.",
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
    ]);

    await queryInterface.bulkInsert("resources", [
      {
        id: "2d913f0b-3277-4244-9c8d-102f57cd7001",
        clientId: clientAId,
        packageId,
        title: "Decision Rights Worksheet",
        description: "A worksheet for separating owner-only decisions from team-owned decisions.",
        url: "/how-it-works/",
        resource_type: "worksheet",
        is_shared: true,
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
      {
        id: "2d913f0b-3277-4244-9c8d-102f57cd7002",
        clientId: clientBId,
        packageId,
        title: "1:1 Feedback Script",
        description: "A lightweight script for making feedback and blockers part of every 1:1.",
        url: "/how-it-works/",
        resource_type: "worksheet",
        is_shared: true,
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
    ]);

    await queryInterface.bulkInsert("testimonials", [
      {
        id: "f9476bc0-5c2a-406a-a329-dbcd1b4a9001",
        name: "Demo Testimonial",
        role_company: "Fictional sample — not a customer claim",
        quote: "The sessions turned scattered leadership pressure into a simple operating rhythm we could actually keep.",
        visible_on_site: true,
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
    ]);

    await queryInterface.bulkInsert("prep_briefs", [
      {
        id: "f5e25961-6fd7-4038-870c-12db120d3001",
        clientId: clientAId,
        sessionId: sessionAId,
        next_session_at: tomorrow,
        previous_summary: "Demo Client One committed to drafting decision boundaries and testing them with their COO.",
        open_commitments: "Decision-rights matrix; three decisions no longer requiring founder approval.",
        suggested_questions: "What felt risky to delegate? Where did the team ask for more clarity? What decision still needs your direct voice?",
        sensitive_topics: "Founder control and trust in senior leadership.",
        client_reflection: "I shared the decision-rights draft with the COO. The hardest part was naming which decisions I no longer need to approve.",
        client_reflection_at: now,
        status: "ready",
        createdById: coachUserId,
        updatedById: coachUserId,
        createdAt: now,
        updatedAt: now,
      },
    ]);
  },

  async down(queryInterface) {
    await queryInterface.bulkDelete("prep_briefs", null, {});
    await queryInterface.bulkDelete("testimonials", null, {});
    await queryInterface.bulkDelete("resources", null, {});
    await queryInterface.bulkDelete("action_items", null, {});
    await queryInterface.bulkDelete("sessions", null, {});
    await queryInterface.bulkDelete("clients", null, {});
    await queryInterface.bulkDelete("packages", null, {});
  },
};
