import { r as e, h as l } from "./reactcomponent-44b70bf6.mjs";
import "react";
import "react-dom";
const D = class {
  constructor(t) {
    e(this, t), this.seconds = void 0, this.translations = void 0, this.translationsData = void 0;
  }
  setTranslations() {
    this.translations ? this.translationsData = JSON.parse(this.translations) : this.translationsData = { days: "d", hours: "h", minutes: "min" };
  }
  componentWillLoad() {
    this.setTranslations();
  }
  /**
   * Get display string in days, hours, and minutes, eg. "1 d 23 h 4 min".
   * Minimum display value is 1 minute.
   *
   * @param {number} seconds Duration in seconds.
   * @returns {string}
   */
  getDurationDisplayString(t) {
    const n = Math.floor(t / 86400), a = Math.floor(t % 86400 / 3600), i = Math.floor(t % 86400 % 3600 / 60), r = n > 0 ? `${n} ${this.translationsData.days} ` : "", o = a > 0 ? `${a} ${this.translationsData.hours} ` : "";
    let s = i > 0 ? `${i} ${this.translationsData.minutes}` : "";
    return !r && !o && !s && (s = "1 min"), `${r}${o}${s}`.trim();
  }
  render() {
    return this.seconds >= 0 && this.translationsData ? this.renderDuration() : null;
  }
  /**
   * Render formatted duration string.
   *
   * @returns {JSX.Element}
   */
  renderDuration() {
    return l("span", null, this.getDurationDisplayString(this.seconds));
  }
  static get watchers() {
    return {
      translations: ["setTranslations"]
    };
  }
};
export {
  D as mi_time
};
//# sourceMappingURL=mi-time.entry-cd08387e.mjs.map
