import DocumentDirectory from "../document-directory.mjs";

/**
 * @import JournalEntry from "@client/documents/journal-entry.mjs";
 */

/**
 * The World Journal.
 * @extends {DocumentDirectory<JournalEntry>}
 */
export default class JournalDirectory extends DocumentDirectory {

  /** @inheritDoc */
  static DEFAULT_OPTIONS = {
    collection: "JournalEntry"
  };

  /** @override */
  static tabName = "journal";

  /* -------------------------------------------- */
  /*  Rendering                                   */
  /* -------------------------------------------- */

  /** @inheritDoc */
  _getEntryContextOptions() {
    const options = super._getEntryContextOptions();
    const configureOwnershipIndex = options.findIndex(o => o.label === "OWNERSHIP.Configure");
    options.splice(configureOwnershipIndex + 1, 0, {
      label: "SIDEBAR.JumpPin",
      icon: "fa-solid fa-crosshairs",
      visible: li => !!this.collection.get(li.dataset.entryId)?.sceneNote,
      onClick: (event, li) => this.collection.get(li.dataset.entryId)?.panToNote()
    });
    return options;
  }
}
