// Import Configuration Object
import { rmfrp } from "./module/config.js";
//import { registerGetSceneControlButtonsHook } from "./module/controls.js";

// Import document classes.
import { RMFRPActor } from "./module/documents/actor.js";
import { RMFRPItem } from "./module/documents/item.js";

// Import Sheets
import RMFRPItemSheet from "./module/sheets/items/rmfrp_item_sheet.js";
import RMFRPArmorSheet from "./module/sheets/items/rmfrp_armor_sheet.js";
import RMFRPTransportSheet from "./module/sheets/items/rmfrp_transport_sheet.js";
import RMFRPWeaponSheet from "./module/sheets/items/rmfrp_weapon_sheet.js";
import RMFRPHerbOrPoisonSheet from "./module/sheets/items/rmfrp_herb_or_poison_sheet.js";
import RMFRPSpellSheet from "./module/sheets/spells/rmfrp_spell_sheet.js";
import RMFRPSkillCategorySheet from "./module/sheets/skills/rmfrp_skill_category_sheet.js";
import RMFRPSkillSheet from "./module/sheets/skills/rmfrp_skill_sheet.js";

import RMFRPPlayerSheet from "./module/sheets/actors/rmfrp_player_sheet.js";
import RMFRPToolsSCImporter from "./module/sheets/apps/rmfrp_import_skill_categories.js";
import RMFRPToolsDiceRoller from "./module/sheets/apps/rmfrp_dice_roller.js";
import { RFRPUtility } from "./module/rfrp-utility.js";

// Register Scene Controls
// registerGetSceneControlButtonsHook();

// Hook the init function and set up our system
Hooks.once("init", function () {
  console.log("rmfrp | Initialising Rolemaster Standard System");

  // Load our custom actor and item classes
  console.log("rmfrp | Loading Rolemaster Actor and Item classes");
  game.rmfrp = {
    RMFRPActor,
    RMFRPItem,
    applications: {
      RMFRPToolsSCImporter,
      RMFRPToolsDiceRoller
    }
  };

  // Define custom Document classes
  CONFIG.Actor.documentClass = RMFRPActor;
  CONFIG.Item.documentClass = RMFRPItem;

  // Add PragRoman Font
  CONFIG.fontDefinitions["PragRoman"] = {
    editor: true,
    fonts: [
      { urls: ["systems/fvtt-rolemaster-frp/assets/fonts/PragRoman.woff2"] }
    ]
  };

  // Make Config Data Available
  CONFIG.rmfrp = rmfrp;

  // Unregister Default Sheets
  console.log("rmfrp | Unregistering core sheets");

  Items.unregisterSheet("core", ItemSheet);
  Actors.unregisterSheet("core", ActorSheet);

  // Register RMFRP Sheets
  console.log("rmfrp | Registering RMFRP sheets");

  // Items
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPItemSheet, { makeDefault: true, label: "rmfrp.entity_sheet.item", types: ["item"] });
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPArmorSheet, { makeDefault: true, label: "rmfrp.entity_sheet.armor", types: ["armor"] });
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPTransportSheet, { makeDefault: true, label: "rmfrp.entity_sheet.transport", types: ["transport"] });
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPWeaponSheet, { makeDefault: true, label: "rmfrp.entity_sheet.weapon", types: ["weapon"] });
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPHerbOrPoisonSheet, { makeDefault: true, label: "rmfrp.entity_sheet.herb_or_poison", types: ["herb_or_poison"] });

  // Spells
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPSpellSheet, { makeDefault: true, label: "rmfrp.entity_sheet.spell", types: ["spell"] });

  // Skills
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPSkillCategorySheet, { makeDefault: true, label: "rmfrp.entity_sheet.skill_category", types: ["skill_category"] });
  Items.registerSheet("fvtt-rolemaster-frp", RMFRPSkillSheet, { makeDefault: true, label: "rmfrp.entity_sheet.skill", types: ["skill"] });

  // Actors
  Actors.registerSheet("fvtt-rolemaster-frp", RMFRPPlayerSheet, { makeDefault: true, label: "rmfrp.entity_sheet.player_characrer", types: ["character"] });

  RFRPUtility.loadHandlebarsTemplates();
  RFRPUtility.loadHandlebarsHelpers();

});

Hooks.once("ready", async function () {
  console.log("rmfrp | Ready");

  // Load Utility
  await RFRPUtility.ready();
})
