import type { AbilitySlotId, HealerClassId } from "./types";

export type HealerSynergyKind = "mechanic" | "combo";

export interface HealerAbilitySynergy {
  with: AbilitySlotId;
  kind: HealerSynergyKind;
  summary: string;
}

export interface HealerAbilityGuide {
  useWhen: string;
  fieldTip: string;
  synergies: readonly HealerAbilitySynergy[];
}

export interface HealerClassGuide {
  role: string;
  learningCurve: "Approachable" | "Intermediate" | "Advanced";
  resourceGuide: string;
  coreLoop: readonly [string, string, string];
  abilityGuides: Record<AbilitySlotId, HealerAbilityGuide>;
}

export const HEALER_GUIDES: Record<HealerClassId, HealerClassGuide> = {
  priest: {
    role: "Reactive all-rounder",
    learningCurve: "Approachable",
    resourceGuide: "Grace is your mana pool. Keep enough in reserve for Radiance or Barrier when party-wide damage is coming.",
    coreLoop: [
      "Maintain Renew on allies taking steady damage.",
      "Use Aegis before a hit, then Mend whoever still drops.",
      "Answer group pressure with Barrier before damage or Radiance after it.",
    ],
    abilityGuides: {
      ability1: {
        useWhen: "One ally needs reliable healing now and you have time to finish the short cast.",
        fieldTip: "Shield a critical target first when incoming damage could interrupt the recovery window.",
        synergies: [
          { with: "ability3", kind: "combo", summary: "Aegis absorbs the next hit while Mend finishes its cast." },
          { with: "ability2", kind: "combo", summary: "Renew keeps recovery moving after Mend handles the immediate deficit." },
        ],
      },
      ability2: {
        useWhen: "An ally will take sustained damage or needs gradual recovery between larger hits.",
        fieldTip: "Apply early. Recasting on a healthy ally wastes mana that may be needed for burst healing.",
        synergies: [
          { with: "ability3", kind: "combo", summary: "Aegis buys time for Renew's eight healing ticks to work." },
          { with: "ability1", kind: "combo", summary: "Mend covers the urgent gap while Renew completes the recovery." },
        ],
      },
      ability3: {
        useWhen: "A selected ally is about to take a predictable heavy hit.",
        fieldTip: "Absorption is strongest before damage lands. Avoid spending it after the danger has passed.",
        synergies: [
          { with: "ability6", kind: "combo", summary: "Layer Aegis with Barrier for a protected target inside a safer party field." },
          { with: "ability1", kind: "combo", summary: "The shield protects the target while Mend restores missing health." },
        ],
      },
      ability4: {
        useWhen: "A harmful magic effect appears and its mechanic calls for a dispel.",
        fieldTip: "Do not cleanse automatically: some debuffs punish poor timing or leave a hazard where the ally stands.",
        synergies: [
          { with: "ability3", kind: "combo", summary: "Aegis protects the ally from follow-up damage after the debuff is removed." },
          { with: "ability1", kind: "combo", summary: "Mend restores health already lost before the successful cleanse." },
        ],
      },
      ability5: {
        useWhen: "Several party members are injured at the same time.",
        fieldTip: "Wait for meaningful group damage; its 14-second cooldown makes light chip damage a poor trade.",
        synergies: [
          { with: "ability6", kind: "combo", summary: "Barrier slows the next wave of damage while Radiance repairs the party." },
          { with: "ability2", kind: "combo", summary: "Renew can finish stabilizing the ally Radiance leaves lowest." },
        ],
      },
      ability6: {
        useWhen: "The party can stack near you before a dangerous damage window.",
        fieldTip: "Place the field before the hit. Allies outside its four-meter radius receive no reduction.",
        synergies: [
          { with: "ability5", kind: "combo", summary: "Barrier reduces incoming group damage; Radiance repairs what gets through." },
          { with: "ability3", kind: "combo", summary: "Aegis adds focused protection for the ally most likely to be hit." },
        ],
      },
    },
  },
  druid: {
    role: "Proactive healing-over-time specialist",
    learningCurve: "Intermediate",
    resourceGuide: "Druid healing ticks generate up to 5 Verdancy. Regrowth consumes up to 3 for bonus healing; a three-stack Lifebloom can spend 2 to bloom immediately.",
    coreLoop: [
      "Seed Rejuvenation and Lifebloom before pressure starts.",
      "Spend Verdancy through Regrowth or an emergency Lifebloom bloom.",
      "Layer several growths before Flourish, then use Nature's Cure for a targeted burst.",
    ],
    abilityGuides: {
      ability1: {
        useWhen: "An ally needs direct healing but can also benefit from a six-second healing effect.",
        fieldTip: "Build Verdancy first when possible; Regrowth automatically spends up to 3 for a much larger initial heal.",
        synergies: [
          { with: "ability2", kind: "mechanic", summary: "Rejuvenation ticks generate the Verdancy that powers Regrowth." },
          { with: "ability4", kind: "mechanic", summary: "Nature's Cure immediately triggers Regrowth's active healing tick." },
          { with: "ability6", kind: "mechanic", summary: "Flourish extends Regrowth and accelerates its healing ticks." },
        ],
      },
      ability2: {
        useWhen: "An ally is likely to take damage soon or needs efficient sustained healing.",
        fieldTip: "Spread it before group pressure so its ticks build Verdancy while healing is useful.",
        synergies: [
          { with: "ability1", kind: "mechanic", summary: "Its ticks generate Verdancy for a stronger Regrowth." },
          { with: "ability4", kind: "mechanic", summary: "Nature's Cure triggers an immediate Rejuvenation tick on the cleansed target." },
          { with: "ability6", kind: "mechanic", summary: "Flourish extends Rejuvenation and doubles its tick rate during the window." },
        ],
      },
      ability3: {
        useWhen: "A tank or focused ally will take repeated damage. Stack it up to 3 times.",
        fieldTip: "At 3 stacks, recast with 2 Verdancy available to force the bloom instead of waiting for expiration.",
        synergies: [
          { with: "ability2", kind: "mechanic", summary: "Rejuvenation supplies Verdancy for Lifebloom's instant three-stack bloom." },
          { with: "ability4", kind: "mechanic", summary: "Nature's Cure triggers Lifebloom's current healing tick immediately." },
          { with: "ability6", kind: "mechanic", summary: "Flourish extends the stack and accelerates its periodic healing." },
        ],
      },
      ability4: {
        useWhen: "A debuffed ally also has one or more active Druid healing effects.",
        fieldTip: "More active growths mean a larger instant healing burst when the cleanse succeeds.",
        synergies: [
          { with: "ability1", kind: "mechanic", summary: "Immediately triggers Regrowth's healing-over-time component." },
          { with: "ability2", kind: "mechanic", summary: "Immediately triggers Rejuvenation on the cleansed ally." },
          { with: "ability3", kind: "mechanic", summary: "Immediately triggers the active Lifebloom healing tick." },
        ],
      },
      ability5: {
        useWhen: "Three allies are injured or group damage is about to continue for several seconds.",
        fieldTip: "It automatically chooses the three most injured allies, so no target setup is required.",
        synergies: [
          { with: "ability6", kind: "mechanic", summary: "Flourish extends Wild Growth and makes its party healing tick twice as fast." },
          { with: "ability1", kind: "mechanic", summary: "Wild Growth ticks build Verdancy for a stronger follow-up Regrowth." },
        ],
      },
      ability6: {
        useWhen: "Several Druid healing effects are already active across the party.",
        fieldTip: "Flourish does not create new effects. Layer growths first, then cast it during sustained damage.",
        synergies: [
          { with: "ability5", kind: "mechanic", summary: "Wild Growth becomes a longer, faster group-healing window." },
          { with: "ability3", kind: "mechanic", summary: "Extends Lifebloom stacks and accelerates their healing ticks." },
          { with: "ability2", kind: "mechanic", summary: "Extended rapid Rejuvenation ticks also generate Verdancy faster." },
        ],
      },
    },
  },
  shaman: {
    role: "Position-aware reactive burst healer",
    learningCurve: "Intermediate",
    resourceGuide: "Riptide, Earth Shield triggers, and successful cleanses generate up to 2 Tidal Surge. Healing Wave spends 1; Chain Heal spends all available Surge for extra jumps.",
    coreLoop: [
      "Keep Earth Shield on the ally taking repeated hits.",
      "Use Riptide to create a Chain Heal anchor and build Tidal Surge.",
      "Spend Surge on a fast Healing Wave or a longer Chain Heal when allies are grouped.",
    ],
    abilityGuides: {
      ability1: {
        useWhen: "One ally is badly hurt, especially below half health.",
        fieldTip: "Hold 1 Tidal Surge for emergencies: it halves the cast time and adds 10 healing.",
        synergies: [
          { with: "ability2", kind: "mechanic", summary: "Riptide grants the Tidal Surge that accelerates and strengthens Healing Wave." },
          { with: "ability3", kind: "mechanic", summary: "Earth Shield triggers grant Tidal Surge for the next Healing Wave." },
          { with: "ability4", kind: "mechanic", summary: "A successful Cleanse Spirit supplies Tidal Surge for the follow-up heal." },
        ],
      },
      ability2: {
        useWhen: "An ally needs an instant top-up plus sustained healing, or should anchor Chain Heal.",
        fieldTip: "Place it on the ally where you want Chain Heal's strongest first hit to land.",
        synergies: [
          { with: "ability5", kind: "mechanic", summary: "Riptide strengthens Chain Heal's first heal by 25% and marks its starting anchor." },
          { with: "ability1", kind: "mechanic", summary: "The granted Tidal Surge makes Healing Wave faster and stronger." },
        ],
      },
      ability3: {
        useWhen: "An ally will take frequent damage over the next 30 seconds.",
        fieldTip: "Its six charges cannot help if placed on someone who is not being attacked.",
        synergies: [
          { with: "ability1", kind: "mechanic", summary: "Damage-triggered Earth Shield heals generate Tidal Surge for Healing Wave." },
          { with: "ability5", kind: "mechanic", summary: "Generated Tidal Surge can be saved to add targets to Chain Heal." },
        ],
      },
      ability4: {
        useWhen: "A harmful magic effect must be removed and its encounter timing is safe.",
        fieldTip: "A successful cleanse grants Tidal Surge, so plan the next cast before using it.",
        synergies: [
          { with: "ability1", kind: "mechanic", summary: "Spend the new Tidal Surge on an accelerated Healing Wave." },
          { with: "ability5", kind: "mechanic", summary: "Bank the new Tidal Surge to extend Chain Heal by one target." },
        ],
      },
      ability5: {
        useWhen: "Several injured allies are close enough for the heal to jump between them.",
        fieldTip: "It jumps to nearby injured allies. Spread formations can end the chain early even with Tidal Surge.",
        synergies: [
          { with: "ability2", kind: "mechanic", summary: "Start on a Riptide target for a 25% stronger first heal." },
          { with: "ability3", kind: "mechanic", summary: "Tidal Surge generated by Earth Shield adds one jump per stored charge." },
          { with: "ability6", kind: "combo", summary: "After Spirit Link equalizes the group, Chain Heal restores the shared deficit." },
        ],
      },
      ability6: {
        useWhen: "Stacked allies have uneven health percentages during heavy pressure.",
        fieldTip: "The field redistributes health; it does not create healing. Follow it with an actual heal.",
        synergies: [
          { with: "ability5", kind: "combo", summary: "Chain Heal restores the group after Spirit Link redistributes the danger." },
          { with: "ability3", kind: "combo", summary: "Earth Shield keeps healing the focused ally while health is shared." },
        ],
      },
    },
  },
  paladin: {
    role: "Offensive single-target healer",
    learningCurve: "Intermediate",
    resourceGuide: "Crusader Strike builds up to 3 Conviction. Word of Glory spends all of it; at 3 Conviction the cast also heals the whole party.",
    coreLoop: [
      "Keep Beacon of Light on the ally who needs steady indirect healing.",
      "Use Crusader Strike on cooldown when safe to build Conviction.",
      "Spend Conviction with Word of Glory, ideally at 3 during group damage.",
    ],
    abilityGuides: {
      ability1: {
        useWhen: "One ally needs a strong direct heal and you can complete the short cast.",
        fieldTip: "Heal someone other than your Beacon target to recover two allies from one cast.",
        synergies: [
          { with: "ability3", kind: "mechanic", summary: "Holy Light on another ally echoes 40% of effective healing to the Beacon." },
          { with: "ability5", kind: "combo", summary: "Use Holy Light between Conviction spends for steady spot healing." },
        ],
      },
      ability2: {
        useWhen: "The boss is reachable and the party can benefit from free smart healing.",
        fieldTip: "Keep using it when safe; every cast advances your next Word of Glory.",
        synergies: [
          { with: "ability5", kind: "mechanic", summary: "Each Crusader Strike adds 1 Conviction to Word of Glory." },
          { with: "ability6", kind: "combo", summary: "Crusader Strike keeps offense and smart healing active during Avenging Crusader." },
        ],
      },
      ability3: {
        useWhen: "One ally, usually the tank, will need steady healing for the next 30 seconds.",
        fieldTip: "Direct heals cast on the Beacon itself do not echo; heal other allies to trigger it.",
        synergies: [
          { with: "ability1", kind: "mechanic", summary: "Holy Light on another ally echoes 40% of its effective healing to the Beacon." },
          { with: "ability5", kind: "mechanic", summary: "Word of Glory on another ally also echoes healing to the Beacon." },
          { with: "ability4", kind: "mechanic", summary: "Cleanse Light on another ally echoes its 10-point heal to the Beacon." },
        ],
      },
      ability4: {
        useWhen: "A harmful magic effect must be dispelled and the target also needs a small heal.",
        fieldTip: "Cleanse another ally while Beacon is active to gain value on both targets.",
        synergies: [
          { with: "ability3", kind: "mechanic", summary: "Its 10-point heal echoes to a different Beacon target." },
          { with: "ability1", kind: "combo", summary: "Follow with Holy Light if the cleansed ally remains in danger." },
        ],
      },
      ability5: {
        useWhen: "An ally needs an instant heal or the party needs the bonus from spending 3 Conviction.",
        fieldTip: "It spends every Conviction point. Wait for 3 when safe, but spend early to prevent a death.",
        synergies: [
          { with: "ability2", kind: "mechanic", summary: "Crusader Strike generates the Conviction that scales Word of Glory." },
          { with: "ability3", kind: "mechanic", summary: "Casting on someone else echoes 40% of effective healing to the Beacon." },
        ],
      },
      ability6: {
        useWhen: "The party is dealing sustained damage while allies need steady smart healing.",
        fieldTip: "Use during an offensive burst window; 20% of party attack damage heals the most injured living ally.",
        synergies: [
          { with: "ability2", kind: "combo", summary: "Crusader Strike maintains your damage-and-healing rhythm during the window." },
          { with: "ability5", kind: "combo", summary: "A full Conviction Word of Glory covers group damage while offense supplies smart heals." },
        ],
      },
    },
  },
  chronomancer: {
    role: "Predictive timeline healer",
    learningCurve: "Advanced",
    resourceGuide: "A successful Time Anchor rewind and Erase Affliction each grant 1 of 3 Chronoshards. Accelerate spends all shards for stronger party healing and cooldown reduction.",
    coreLoop: [
      "Anchor a healthy ally before predictable damage, then recast to rewind it.",
      "Schedule Echo of Tomorrow so its delayed heal lands after damage.",
      "Bank Chronoshards for an empowered Accelerate and use Time Loop before major group hits.",
    ],
    abilityGuides: {
      ability1: {
        useWhen: "One ally needs dependable immediate recovery and no timeline setup is available.",
        fieldTip: "Use it to stabilize between planned Anchor rewinds and delayed Echo healing.",
        synergies: [
          { with: "ability2", kind: "combo", summary: "Mend Timeline covers health lost before or after the Time Anchor window." },
          { with: "ability3", kind: "combo", summary: "Mend handles the immediate deficit while Echo schedules the follow-up." },
        ],
      },
      ability2: {
        useWhen: "A healthy ally is about to take predictable damage within 6 seconds.",
        fieldTip: "Recast on the same ally before the anchor expires. No restored damage means no Chronoshard.",
        synergies: [
          { with: "ability5", kind: "mechanic", summary: "A successful rewind grants the Chronoshard that powers Accelerate." },
          { with: "ability3", kind: "combo", summary: "Echo can land after the rewind to continue stabilizing the target." },
        ],
      },
      ability3: {
        useWhen: "An ally needs a small heal now and is likely to need a larger heal 3 seconds later.",
        fieldTip: "Cast before a telegraphed hit so the 28-point echo lands after the damage instead of overhealing early.",
        synergies: [
          { with: "ability6", kind: "combo", summary: "Time Loop reverses burst damage while Echo smooths the health window before restoration." },
          { with: "ability5", kind: "combo", summary: "Accelerate supplies immediate party healing while Echo resolves on its target later." },
        ],
      },
      ability4: {
        useWhen: "A harmful magic effect must be removed and its encounter timing is safe.",
        fieldTip: "Plan to spend the gained Chronoshard; holding at the cap wastes later generation.",
        synergies: [
          { with: "ability5", kind: "mechanic", summary: "Erase Affliction grants 1 Chronoshard for stronger healing and cooldown reduction." },
          { with: "ability2", kind: "combo", summary: "Anchor first if the debuff will deal damage before the correct cleanse moment." },
        ],
      },
      ability5: {
        useWhen: "The party is injured and you have Chronoshards or important active cooldowns to advance.",
        fieldTip: "At 3 shards it heals the party for 34 and removes 3 seconds from every active cooldown.",
        synergies: [
          { with: "ability2", kind: "mechanic", summary: "Successful Time Anchor rewinds generate Chronoshards for Accelerate." },
          { with: "ability4", kind: "mechanic", summary: "Successful cleanses generate Chronoshards for Accelerate." },
          { with: "ability6", kind: "mechanic", summary: "Shard-powered cooldown reduction can bring Time Loop back sooner." },
        ],
      },
      ability6: {
        useWhen: "Major party damage will land during the next 6 seconds.",
        fieldTip: "Cast before damage. It restores lost health to the recorded value but cannot resurrect dead allies.",
        synergies: [
          { with: "ability3", kind: "combo", summary: "Echo of Tomorrow stabilizes an ally during the six-second loop window." },
          { with: "ability5", kind: "mechanic", summary: "Accelerate's cooldown reduction helps recover this long defensive cooldown." },
        ],
      },
    },
  },
};
