export default class OathHammerUtils {
  static registerHandlebarsHelpers() {
    Handlebars.registerHelper("includes", (collection, value) => {
      if (!collection) return false
      if (collection instanceof Set) return collection.has(value)
      if (Array.isArray(collection)) return collection.includes(value)
      return false
    })
    Handlebars.registerHelper("capitalize", (str) => {
      if (typeof str !== "string") return str
      return str.charAt(0).toUpperCase() + str.slice(1)
    })
    Handlebars.registerHelper("concat", (...args) => {
      args.pop() // remove handlebars options object
      return args.join("")
    })
  }

  static async loadCompendium(packId) {
    const pack = game.packs.get(packId)
    if (!pack) return []
    return await pack.getDocuments()
  }
}
