export var ProgressStepStatus;
(function (ProgressStepStatus) {
  ProgressStepStatus["DEFAULT"] = "default";
  ProgressStepStatus["IN_PROGRESS"] = "inProgress";
  ProgressStepStatus["COMPLETE"] = "complete";
})(ProgressStepStatus || (ProgressStepStatus = {}));
/**
 * Data Transfer Object representing an internal step in the progress tracker.
 */
export class InternalProgressTrackerStep {
  /**
   * @param {string} stepKey - The unique key for the step.
   * @param {string} title - The title of the step.
   * @param {ProgressStepStatus} progressStatus - The progress status of the step.
   * @param {boolean} isCurrent - Indicates if this step is the current step.
   * @param {boolean} clickable - Indicates if this step is clickable.
   */
  constructor(stepKey, title, progressStatus, isCurrent, clickable) {
    this.stepKey = stepKey;
    this.title = title;
    this.progressStatus = progressStatus;
    this.isCurrent = isCurrent;
    this.clickable = clickable;
  }
  /**
   * Create InternalProgressTrackerStep array from steps property
   *
   * @param {HTMLElement} host - The host element.
   * @param {string[] | VegaProgressTrackerStepItem[]} steps - An array of step keys.
   * @param {number} current - The current step index.
   * @param {string[]} completedSteps - An array of completed step keys.
   * @returns {InternalProgressTrackerStep[]} An array of InternalProgressTrackerStep instances.
   */
  static fromSteps(host, steps, current, completedSteps) {
    return steps.map((step, index) => {
      const stepKey = typeof step === 'string' ? step : step.title;
      return new InternalProgressTrackerStep(stepKey, stepKey, this.getStepStatus(stepKey, index, current, completedSteps), index === current, this.getIsStepClickable(host, step));
    });
  }
  /**
   * Create InternalProgressTrackerStep array from host slot elements
   *
   * @param {HTMLElement} host - The host element containing the slot elements.
   * @param {number} current - The current step index.
   * @param {string[]} completedSteps - An array of completed step keys.
   * @returns {InternalProgressTrackerStep[]} An array of InternalProgressTrackerStep instances.
   */
  static fromHostSlot(host, current, completedSteps) {
    return Array.from(host.querySelectorAll('vega-progress-tracker-step')).map((step, index) => {
      const stepKey = step.stepKey;
      return new InternalProgressTrackerStep(stepKey, '', this.getStepStatus(stepKey, index, current, completedSteps), index === current, this.getIsStepClickable(host, step));
    });
  }
  /**
   * Gets the clickable mode of the step.
   *
   * @param {HTMLElement} host - The host element.
   * @param {string | VegaProgressTrackerStepItem} step - The step element.
   * @returns { boolean } The clickable mode of the step.
   */
  static getIsStepClickable(host, step) {
    //For the legacy string type steps, the clickable mode is determined by the canClickStep property on the host
    if (typeof step === 'string')
      return host.canClickStep;
    //If host has disabled click step, return false regardless of individual step setting
    if (!host.canClickStep)
      return false;
    //Return default VegaProgressTrackerStepItem clickable value
    return typeof step.clickable === 'boolean' ? step.clickable : host.canClickStep;
  }
  /**
   * Checks if the step is completed.
   *
   * @returns { boolean } A boolean value indicating whether the step is completed.
   */
  isCompleted() {
    return this.progressStatus === ProgressStepStatus.COMPLETE;
  }
}
/**
 * Determines the progress status of a step based on its index, the current step, and completed steps.
 *
 * @param {string} stepKey - The unique key for the step.
 * @param {number} stepIndex - The index of the step.
 * @param {number} current - The current step index.
 * @param {string[]} completedSteps - An array of completed step keys. TODO: In the future, this will be derived from the step's own status rather than relying on an external array.
 * @returns {ProgressStepStatus} The progress status of the step.
 */
InternalProgressTrackerStep.getStepStatus = (stepKey, stepIndex, current, completedSteps) => {
  if (completedSteps.includes(stepKey)) {
    return ProgressStepStatus.COMPLETE;
  }
  else if (stepIndex === current) {
    return ProgressStepStatus.IN_PROGRESS;
  }
  else {
    return ProgressStepStatus.DEFAULT;
  }
};
