import { r as u, c as g, h as s, H as m } from "./reactcomponent-44b70bf6.mjs";
import { R as v } from "./route-travel-mode.enum-7f4ce9c7-a9c95a83.mjs";
import { U as f } from "./unit-system.enum-eaefb53e-0f424da4.mjs";
import { c as S } from "./utils-ae714467-b07fc3be.mjs";
import "react";
import "react-dom";
const x = ':host{display:block;background-color:#fcfcfc;font-family:Figtree, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"}:host mi-route-instructions-step:hover{cursor:pointer;background-color:#f9fafb;transition:300ms ease}:host mi-route-instructions-step.active{background-color:#f3f4f6;transition:none;cursor:default}:host .instructions-destination{display:flex}:host .instructions-destination-icon{width:40px;display:flex;justify-content:center;align-items:center}:host .instructions-destination-icon mi-icon{width:24px;height:24px;background-color:#1c1917}:host .instructions-destination-details{flex:1;padding:12px}:host .instructions-destination-details mi-location-info{font-size:0.875rem}', I = class {
  constructor(t) {
    u(this, t), this.clicked = g(this, "clicked", 7), this.miStepElements = [], this.lastStepRouteContext = null, this.lastStepTravelMode = null, this.lastStepTransitStop = null, this.activeStep = {
      legIndex: 0,
      stepIndex: 0
    }, this.unit = f.Metric, this.route = void 0, this.hideIndoorSubsteps = !1, this.travelMode = v.Walking, this.originLocation = void 0, this.originName = void 0, this.destinationLocation = void 0, this.destinationName = void 0, this.translations = {
      walk: "Walk",
      bike: "Bike",
      transit: "Transit",
      drive: "Drive",
      leave: "Leave",
      from: "From",
      park: "Park",
      at: "at",
      building: "Building",
      venue: "Venue",
      takeStaircaseToLevel: "Take staircase to level",
      takeLadderToLevel: "Take the ladder to level",
      takeElevatorToLevel: "Take elevator to level",
      takeEscalatorToLevel: "Take escalator to level",
      takeWheelchairLiftToLevel: "Take wheelchair lift to level",
      takeWheelchairRampToLevel: "Take wheelchair ramp to level",
      exit: "Exit",
      enter: "Enter",
      stops: "stops",
      andContinue: "and continue",
      continueStraightAhead: "Continue straight ahead",
      goLeft: "Go left",
      goSharpLeft: "Go sharp left",
      goSlightLeft: "Go slight left",
      goRight: "Go right",
      goSharpRight: "Go sharp right",
      goSlightRight: "Go slight right",
      turnAround: "Turn around",
      days: "d",
      hours: "h",
      minutes: "min",
      rideTheBus: "Ride the bus"
    };
  }
  componentDidRender() {
    this.miStepElements.forEach((t) => {
      t.hideIndoorSubsteps = this.hideIndoorSubsteps;
    });
  }
  /**
   * Transform the step in legs to a flat array of steps.
   *
   * @returns {Step[]}
   */
  getRouteSteps() {
    return this.route ? this.route.legs.reduce((t, i, e) => {
      for (const o in i.steps) {
        const n = i.steps[o];
        n.originalLegIndex = e, n.originalStepIndex = parseInt(o), t.push(n);
      }
      return t;
    }, []) : [];
  }
  /**
   * Updates the activeStep attribute and emits an object with leg, step and maneuver index information.
   *
   * @param {CustomEvent<any>} event Step object.
   * @param {number} stepIndex step index.
   */
  stepClickedHandler(t, i) {
    const e = this.getRouteSteps()[i];
    this.activeStep = {
      legIndex: e.originalLegIndex,
      stepIndex: e.originalStepIndex
    }, this.clicked.emit({
      legIndex: e.originalLegIndex,
      stepIndex: e.originalStepIndex,
      maneuverIndex: t.detail.maneuverIndex
    });
  }
  /**
   * Check if the step is active.
   *
   * @param {Step} step
   * @returns {boolean}
   */
  isActiveStep(t) {
    return this.activeStep ? this.activeStep.legIndex === t.originalLegIndex && this.activeStep.stepIndex === t.originalStepIndex : !1;
  }
  render() {
    return this.route ? this.renderInstructions() : null;
  }
  /**
   * Render instructions.
   *
   * @returns {JSX.Element}
   */
  renderInstructions() {
    return s(m, null, this.getRouteSteps().map((t, i) => {
      var e, o, n, a, r;
      const d = !((o = (e = this.originLocation) === null || e === void 0 ? void 0 : e.properties) === null || o === void 0) && o.name ? this.originLocation.properties.name : this.originName || "", c = t.originalLegIndex === 0 && t.originalStepIndex === 0 ? d : this.lastStepRouteContext, p = this.lastStepTravelMode, h = this.lastStepTransitStop;
      return this.lastStepRouteContext = t.route_context, this.lastStepTravelMode = t.travel_mode, this.lastStepTransitStop = !((a = (n = t.transit_information) === null || n === void 0 ? void 0 : n.arrival_stop) === null || a === void 0) && a.name ? (r = t.transit_information) === null || r === void 0 ? void 0 : r.arrival_stop.name : null, s("mi-route-instructions-step-legacy", {
        ref: (l) => this.miStepElements.push(l),
        "from-travel-mode": p,
        "from-route-context": c,
        "from-transit-stop": h,
        step: JSON.stringify(t),
        translations: JSON.stringify(this.translations),
        unit: this.unit,
        onStepClicked: (l) => this.stepClickedHandler(l, i),
        class: this.isActiveStep(t) ? "active" : "",
        part: this.isActiveStep(t) ? "step active" : "step",
        // @ts-ignore
        exportparts: `
                            step-toggle,
                            step-heading,
                            step-description,
                            step-info,
                            step-travel-mode,
                            step-travel-mode-icon,
                            maneuver-icon,
                            maneuver-description,
                            maneuver-description-distance,
                            maneuver-description-distance-border`
      });
    }), this.destinationLocation || this.destinationName ? this.renderDestination() : null);
  }
  /**
   * Render destination.
   *
   * @returns {JSX.Element}
   */
  renderDestination() {
    return s("div", { class: "instructions-destination" }, s("div", { class: "instructions-destination-icon" }, S() ? null : s("mi-icon", { "icon-name": "marker" })), s("div", { part: "instructions-destination", class: "instructions-destination-details" }, this.destinationLocation ? this.destinationLocation.properties.name : this.destinationName, this.destinationLocation ? s("mi-location-info", { part: "instructions-destination-info", location: this.destinationLocation }) : null));
  }
};
I.style = x;
export {
  I as mi_route_instructions
};
//# sourceMappingURL=mi-route-instructions.entry-5651000f.mjs.map
