<commit_before>// This is a large file being touched by open PRs. It should be typescripted
// in a separate PR.
/* eslint-disable */
import coreUtils from '@opentripplanner/core-utils'
import React from 'react'
import {
  FormattedMessage,
  FormattedNumber,
  FormattedTime,
  injectIntl
} from 'react-intl'
import { connect } from 'react-redux'
import styled from 'styled-components'
import { AccessibilityRating } from '@opentripplanner/itinerary-body'

import FieldTripGroupSize from '../../admin/field-trip-itinerary-group-size'
import NarrativeItinerary from '../narrative-itinerary'
import ItineraryBody from '../line-itin/connected-itinerary-body'
import SimpleRealtimeAnnotation from '../simple-realtime-annotation'
import FormattedDuration from '../../util/formatted-duration'
import FormattedMode from '../../util/formatted-mode'
import { getTotalFare } from '../../../util/state'
import {
  getAccessibilityScoreForItinerary,
  itineraryHasAccessibilityScores
} from '../../../util/accessibility-routing'
import Icon from '../../util/icon'

import { FlexIndicator } from './flex-indicator'
import ItinerarySummary from './itinerary-summary'

const { isBicycle, isMicromobility, isTransit, isFlex, isOptional, isContinuousDropoff } = coreUtils.itinerary

// Styled components
const LegIconWrapper = styled.div`
  display: inline-block;
  height: 20px;
  padding-bottom: 6px;
  padding-left: 2px;
  width: 20px;

  /* Equivalent of a single space before the leg icon. */
  &::before {
    content: "";
    margin: 0 0.125em;
  }

  &::before {
    content: "";
    margin: 0 0.125em;
  }
`

const DetailsHint = styled.div`
  clear: both;
  color: #685c5c;
  font-size: small;
  text-align: center;
`

const ItinerarySummaryWrapper = styled.div`
  display: flex;
  justify-content: space-between;
`

/**
 * Obtains the description of an itinerary in the given locale.
 */
function ItineraryDescription({ itinerary }) {
  let primaryTransitDuration = 0
  let accessModeId = 'walk'
  let transitMode
  itinerary.legs.forEach((leg, i) => {
    const { duration, mode, rentedBike, rentedVehicle } = leg
    if (isTransit(mode) && duration > primaryTransitDuration) {
      // TODO: convert OTP's TRAM mode to the correct wording for Portland
      primaryTransitDuration = duration
      transitMode = <FormattedMode mode={mode.toLowerCase()} />
    }
    if (isBicycle(mode)) accessModeId = 'bicycle'
    if (isMicromobility(mode)) accessModeId = 'micromobility'
    if (rentedVehicle) accessModeId = 'micromobility_rent'
    if (rentedBike) accessModeId = 'bicycle_rent'
    if (mode === 'CAR') accessModeId = 'drive'
  })

  const mainMode = <FormattedMode mode={accessModeId} />
  return transitMode
    ? <FormattedMessage
      id='components.DefaultItinerary.multiModeSummary'
      values={{ accessMode: mainMode, transitMode }}
    />
    : mainMode
}

const ITINERARY_ATTRIBUTES = [
  {
    alias: 'best',
    id: 'duration',
    order: 0,
    render: (itinerary, options) => (
      <FormattedDuration duration={itinerary.duration} />
    )
  },
  {
    alias: 'departureTime',
    id: 'arrivalTime',
    order: 1,
    render: (itinerary, options) => {
      const formattedStartTime = itinerary.startTime + options.offset
      const formattedEndTime = itinerary.endTime + options.offset
      if (options.isSelected) {
        if (options.selection === 'ARRIVALTIME') {
          return <FormattedTime value={formattedStartTime} />
        } else {
          return <FormattedTime value={formattedEndTime} />
        }
      }
      return (
        <FormattedMessage
          id='common.time.departureArrivalTimes'
          values={{
            endTime: formattedEndTime,
            startTime: formattedStartTime
          }}
        />
      )
    }
  },
  {
    id: 'cost',
    order: 2,
    render: (itinerary, options, defaultFareKey = 'regular') => {
      const fareInCents = getTotalFare(itinerary, options.configCosts, defaultFareKey)
      const fareCurrency = itinerary.fare?.fare?.regular?.currency?.currencyCode
      const fare = fareInCents === null ? null : fareInCents / 100
      if (fare === null) return <FormattedMessage id="common.itineraryDescriptions.noTransitFareProvided" />
      return (
        <FormattedNumber
          // Currency from itinerary fare or from config.
          currency={fareCurrency || options.currency}
          currencyDisplay='narrowSymbol'
          style='currency'
          value={fare} 
        />
      )
    }
  },
  {
    id: 'walkTime',
    order: 3,<commit_msg>fix(default-itinerary): don't display fares explictly set <0<commit_after>// This is a large file being touched by open PRs. It should be typescripted
// in a separate PR.
/* eslint-disable */
import coreUtils from '@opentripplanner/core-utils'
import React from 'react'
import {
  FormattedMessage,
  FormattedNumber,
  FormattedTime,
  injectIntl
} from 'react-intl'
import { connect } from 'react-redux'
import styled from 'styled-components'
import { AccessibilityRating } from '@opentripplanner/itinerary-body'

import FieldTripGroupSize from '../../admin/field-trip-itinerary-group-size'
import NarrativeItinerary from '../narrative-itinerary'
import ItineraryBody from '../line-itin/connected-itinerary-body'
import SimpleRealtimeAnnotation from '../simple-realtime-annotation'
import FormattedDuration from '../../util/formatted-duration'
import FormattedMode from '../../util/formatted-mode'
import { getTotalFare } from '../../../util/state'
import {
  getAccessibilityScoreForItinerary,
  itineraryHasAccessibilityScores
} from '../../../util/accessibility-routing'
import Icon from '../../util/icon'

import { FlexIndicator } from './flex-indicator'
import ItinerarySummary from './itinerary-summary'

const { isBicycle, isMicromobility, isTransit, isFlex, isOptional, isContinuousDropoff } = coreUtils.itinerary

// Styled components
const LegIconWrapper = styled.div`
  display: inline-block;
  height: 20px;
  padding-bottom: 6px;
  padding-left: 2px;
  width: 20px;

  /* Equivalent of a single space before the leg icon. */
  &::before {
    content: "";
    margin: 0 0.125em;
  }

  &::before {
    content: "";
    margin: 0 0.125em;
  }
`

const DetailsHint = styled.div`
  clear: both;
  color: #685c5c;
  font-size: small;
  text-align: center;
`

const ItinerarySummaryWrapper = styled.div`
  display: flex;
  justify-content: space-between;
`

/**
 * Obtains the description of an itinerary in the given locale.
 */
function ItineraryDescription({ itinerary }) {
  let primaryTransitDuration = 0
  let accessModeId = 'walk'
  let transitMode
  itinerary.legs.forEach((leg, i) => {
    const { duration, mode, rentedBike, rentedVehicle } = leg
    if (isTransit(mode) && duration > primaryTransitDuration) {
      // TODO: convert OTP's TRAM mode to the correct wording for Portland
      primaryTransitDuration = duration
      transitMode = <FormattedMode mode={mode.toLowerCase()} />
    }
    if (isBicycle(mode)) accessModeId = 'bicycle'
    if (isMicromobility(mode)) accessModeId = 'micromobility'
    if (rentedVehicle) accessModeId = 'micromobility_rent'
    if (rentedBike) accessModeId = 'bicycle_rent'
    if (mode === 'CAR') accessModeId = 'drive'
  })

  const mainMode = <FormattedMode mode={accessModeId} />
  return transitMode
    ? <FormattedMessage
      id='components.DefaultItinerary.multiModeSummary'
      values={{ accessMode: mainMode, transitMode }}
    />
    : mainMode
}

const ITINERARY_ATTRIBUTES = [
  {
    alias: 'best',
    id: 'duration',
    order: 0,
    render: (itinerary, options) => (
      <FormattedDuration duration={itinerary.duration} />
    )
  },
  {
    alias: 'departureTime',
    id: 'arrivalTime',
    order: 1,
    render: (itinerary, options) => {
      const formattedStartTime = itinerary.startTime + options.offset
      const formattedEndTime = itinerary.endTime + options.offset
      if (options.isSelected) {
        if (options.selection === 'ARRIVALTIME') {
          return <FormattedTime value={formattedStartTime} />
        } else {
          return <FormattedTime value={formattedEndTime} />
        }
      }
      return (
        <FormattedMessage
          id='common.time.departureArrivalTimes'
          values={{
            endTime: formattedEndTime,
            startTime: formattedStartTime
          }}
        />
      )
    }
  },
  {
    id: 'cost',
    order: 2,
    render: (itinerary, options, defaultFareKey = 'regular') => {
      const fareInCents = getTotalFare(itinerary, options.configCosts, defaultFareKey)
      const fareCurrency = itinerary.fare?.fare?.regular?.currency?.currencyCode
      const fare = fareInCents === null ? null : fareInCents / 100
      if (fare === null || fare < 0) return <FormattedMessage id="common.itineraryDescriptions.noTransitFareProvided" />
      return (
        <FormattedNumber
          // Currency from itinerary fare or from config.
          currency={fareCurrency || options.currency}
          currencyDisplay='narrowSymbol'
          style='currency'
          value={fare} 
        />
      )
    }
  },
  {
    id: 'walkTime',
    order: 3,
{'fraction_non_alphanumeric': 0.119195892057249, 'fraction_numerical': 0.0063367202010269855, 'mean_word_length': 3.138336347197107, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '526088', 'n_tokens_mistral': 2895, 'n_tokens_neox': 2822, 'n_words': 673}