disable,Trilium Breadcrumbs

// src/template.html
var template_default = '<div id="breadcrumbs-bar">\r\n    <div id="history-buttons">\r\n        <button onclick="window.history.back()" class="tree-floating-button bx bx-left-arrow-circle tree-settings-button" title="Go Back"></button>\r\n        <button onclick="window.history.forward()" class="tree-floating-button bx bx-right-arrow-circle tree-settings-button" title="Go Back"></button>\r\n    </div>\r\n    <div id="breadcrumbs"></div>\r\n</div>';

// src/styles.css
var styles_default = "#breadcrumbs-bar {\r\n    display: flex;\r\n    align-items: center;\r\n    gap: 10px;\r\n    padding: 10px;\r\n    border-top: 1px solid var(--main-border-color);\r\n    border-bottom: 1px solid var(--main-border-color);\r\n    contain: none;\r\n}\r\n\r\n#breadcrumbs-bar.bottom {\r\n    border-bottom: 0;\r\n}\r\n\r\n.note-split > #breadcrumbs-bar {\r\n    border-top: 0;\r\n    margin: 0 5px 0 10px;\r\n    padding: 10px 10px 15px 10px;\r\n}\r\n\r\n#breadcrumbs-bar.borderless {\r\n    border: 0;\r\n}\r\n\r\n#breadcrumbs {\r\n    display: flex;\r\n    align-items: center;\r\n    gap: 6px;\r\n}\r\n\r\n#breadcrumbs a {\r\n    display: inline-flex;\r\n    line-height: 1;\r\n    padding: 5px 10px;\r\n    background-color: rgba(255, 255, 255, 0.1);\r\n    border-radius: 12px;\r\n    transition: transform 200ms ease, background-color 200ms ease, filter 200ms ease;\r\n}\r\n\r\n#breadcrumbs a:hover {\r\n    text-decoration: none;\r\n    background-color: rgba(255, 255, 255, 0.2);\r\n    filter: brightness(1.2);\r\n    transform: translateY(-3px);\r\n}\r\n\r\n#history-buttons {\r\n    display: inline-flex;\r\n    white-space: nowrap;\r\n}\r\n\r\n#breadcrumbs span a {\r\n    white-space: pre;\r\n    overflow: hidden;\r\n    text-overflow: ellipsis;\r\n    display: inherit;\r\n}";

// src/index.ts
var position = api.startNote.getLabelValue("position") ?? "center";
var BreadcrumbWidget = class extends api.NoteContextAwareWidget {
  get position() {
    return position === "bottom" ? 100 : position === "top" ? 1 : 50;
  }
  static get parentWidget() {
    return position === "bottom" || position === "top" ? "center-pane" : "note-detail-pane";
  }
  constructor() {
    super();
    this.title = "";
  }
  isEnabled() {
    var _a;
    if (!super.isEnabled()) return false;
    const widgetDisable = api.startNote.getLabelValue("globalDisable") === "true";
    const noteDisable = (_a = this.note) == null ? void 0 : _a.hasLabel("breadcrumbsDisable");
    return !widgetDisable && !noteDisable;
  }
  doRender() {
    this.$widget = $(template_default);
    this.$breadcrumbs = this.$widget.find("#breadcrumbs");
    this.updateStyles();
    const maxWidth = api.startNote.getLabelValue("maxCrumbWidth") ?? 250;
    const maxCrumbWidth = `#breadcrumbs span a { max-width: ${maxWidth}px; }`;
    this.cssBlock(`${styles_default}
${maxCrumbWidth}`);
    return this.$widget;
  }
  async refreshWithNote() {
    await this.makeBreadcrumb();
  }
  async entitiesReloadedEvent({ loadResults }) {
    var _a;
    if ((_a = loadResults == null ? void 0 : loadResults.attributeRows) == null ? void 0 : _a.length) this.updateStyles();
    if (!this.note) {
      this.title = "";
      return;
    }
    if (!this.title) this.title = this.note.title;
    if (this.note.title != this.title) {
      this.title = this.note.title;
      await this.refresh();
    }
  }
  async makeBreadcrumb() {
    var _a;
    this.$breadcrumbs.empty();
    const notePath = ((_a = api.getActiveContextNotePath()) == null ? void 0 : _a.split("/")) ?? [];
    for (let n = 0; n < notePath.length; n++) {
      const path = notePath.slice(0, n + 1);
      const link = await api.createLink(path.join("/"));
      this.$breadcrumbs.append(link);
      if (n < notePath.length - 1) this.$breadcrumbs.append("/");
    }
  }
  updateStyles() {
    this.updateHistoryButtons();
    this.updateWidths();
    this.updateBorders();
    this.updatePosition();
  }
  updateHistoryButtons() {
    const buttonWrapper = this.$widget.find("#history-buttons");
    if (!buttonWrapper) return;
    const isVisible = buttonWrapper.css("display") !== "none";
    const shouldHide = api.startNote.getLabelValue("hideHistory") === "true";
    if (isVisible && shouldHide) buttonWrapper.hide();
    if (!isVisible && !shouldHide) buttonWrapper.show();
  }
  updateWidths() {
    const maxWidth = api.startNote.getLabelValue("maxCrumbWidth") ?? 250;
    const maxCrumbWidth = `#breadcrumbs span a { max-width: ${maxWidth}px; }`;
    if (!this.styleElement) this.styleElement = this.$widget.find("style").first()[0];
    if (this.styleElement) this.styleElement.textContent = `${styles_default}
${maxCrumbWidth}`;
  }
  updateBorders() {
    const shouldHide = api.startNote.getLabelValue("hideBorders") === "true";
    const isVisible = !this.$widget.hasClass("borderless");
    if (isVisible && shouldHide) this.$widget.addClass("borderless");
    if (!isVisible && !shouldHide) this.$widget.removeClass("borderless");
  }
  updatePosition() {
    if (position === "bottom") this.$widget.addClass("bottom");
  }
};
module.exports = BreadcrumbWidget;