import Logger from "./utils/Logger"
import M5ItemSheet from "./module/sheets/M5ItemSheet"
import M5CharacterSheet from "./module/sheets/M5CharacterSheet"
import preloadTemplates from "./PreloadTemplates"
import M5Character from "./module/actors/M5Character"

Hooks.once("init", async () => {
	Logger.log("M5 | Initialisierung Midgard 5")

	Handlebars.registerHelper("localizeMidgard", (str: string) => {
		const template = Handlebars.compile("{{localize value}}")
		return template({
			value: "midgard5." + str
		})
	})

	// Default Sheet für Items definieren und das Standardsheet deaktivieren
	Items.unregisterSheet("core", ItemSheet)
	Items.registerSheet("midgard5", M5ItemSheet, { makeDefault: true })

	// Default Sheet für Actors definieren und das Standardsheet deaktivieren
	Actors.unregisterSheet("core", ActorSheet)
	Actors.registerSheet("midgard5", M5CharacterSheet, { makeDefault: true })

	CONFIG.Actor.documentClass = M5Character

	//RegisterSettings();
	await preloadTemplates()
})

Hooks.once("setup", () => {
	Logger.log("Template module is being setup.")
})

Hooks.once("ready", () => {
	Logger.Ok("Template module is now ready.")
})
