import MaleficesActorSheet from "./malefices-base-actor-sheet.mjs"

export default class MaleficesPersonnageSheet extends MaleficesActorSheet {

  /** @override */
  static DEFAULT_OPTIONS = {
    classes: ["personnage"],
    position: { width: 640, height: 680 },
  }

  /** @override */
  static PARTS = {
    main: { template: "systems/fvtt-malefices/templates/actors/actor-sheet.hbs" },
  }

  /** @override */
  tabGroups = { primary: "main" }

  /** @override */
  async _prepareContext() {
    const context = await super._prepareContext()
    const actor = this.document

    context.armes       = foundry.utils.duplicate(actor.getArmes())
    context.tarots      = foundry.utils.duplicate(actor.getTarots())
    context.tarotsCache = foundry.utils.duplicate(actor.getHiddenTarots())
    context.archetype   = foundry.utils.duplicate(actor.getArchetype())
    context.equipements = foundry.utils.duplicate(actor.getEquipements())
    context.elementsbio = actor.getElementsBio()
    context.sorts       = actor.getSorts()
    context.phyMalus    = actor.getPhysiqueMalus()
    context.subActors   = foundry.utils.duplicate(actor.getSubActors())

    // Expose nested biodata schema fields for {{formInput}} helper
    context.biodataFields = actor.system.schema.fields.biodata.fields

    context.enrichedDescription     = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
      actor.system.biodata?.description ?? "", { async: true }
    )
    context.enrichedNotes           = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
      actor.system.biodata?.notes ?? "", { async: true }
    )
    context.enrichedEquipementlibre = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
      actor.system.equipementlibre ?? "", { async: true }
    )
    return context
  }
}
