{"version":3,"names":["connectionsI18n","key","de","en","it","fr","nl","connectionsCss","Connections","constructor","hostRef","this","today","Date","travelDate","formatIsoDate","direction","onCountryBlur","refreshConnections","onDirectionSelect","e","target","value","updateSearchData","then","onDateChange","detail","onExpandableOpened","activeTrain","currentTarget","dataset","train","njBookingLink","undefined","partnerLink","destinationCountry","destinationCity","vehicleTransport","type","njBaseUrl","pvAppsBaseUrl","showBestPriceFinder","showAutoTrains","departureCountryCode","data","maxBookableDate","componentWillLoad","lang","findLocale","el","i18n","add","setLang","TrainService","instance","setNjBaseUrl","setPvAppsBaseUrl","searchData","carTransport","date","initConfig","componentDidLoad","initAutocomplete","loadConfig","console","log","getMaxBookableDate","_a","findConnectionsForType","originCountry","findConnectionsForDestinationStation","findConnectionsForDestinationCountry","length","trainNumber","findAvailableCountries","query","findCountriesForDestinationStation","findCountriesForDestinationCountry","countryInput","shadowRoot","querySelector","countryAutocomplete","OebbAutocomplete","withTemplate","item","getLocalizedString","name","onItemActive","index","selectCountry","onItemSelect","preventDefault","hideList","onKeyup","async","getValue","countries","trim","setData","render","withPanelOnFocus","userCountryIso","Promise","all","obtainLocation","userCountry","find","country","iso","setValue","eva","getData","resolve","getGeolocation","fromCountry","fromStation","toCountry","toStation","renderForm","h","class","get","htmlFor","id","mode","htmlId","autocomplete","onBlur","map","checked","onInput","label","disabledBefore","disabledAfter","startDate","onFormDataChanged","disabled","renderConnectionItem","connection","_b","isOpen","slot","stationFrom","stationTo","renderConnections","oebbTrains","filter","partnerTrain","partnerTrains","toString"],"sources":["node_modules/@oebb-web-team/oebb-web-components/dist/collection/components/app-connections/connections-i18n.js","node_modules/@oebb-web-team/oebb-web-components/dist/collection/components/app-connections/connections.css?tag=oebbx-app-connections&encapsulation=shadow","node_modules/@oebb-web-team/oebb-web-components/dist/collection/components/app-connections/connections.js"],"sourcesContent":["export const connectionsI18n = [\n {\n key: 'connections.form.header',\n de: 'Verbindungen',\n en: 'Connections',\n it: 'Composti',\n fr: 'Correspondances',\n nl: 'Aansluitingen',\n },\n {\n key: 'connections.form.from',\n de: 'Abfahrt aus...',\n en: 'Departure from...',\n it: 'Partenza da...',\n fr: 'Départ de...',\n nl: 'Vertrek vanaf...',\n },\n {\n key: 'connections.form.outward',\n de: 'Hinfahrt',\n en: 'Outward',\n it: 'Andata',\n fr: 'Destination',\n nl: 'Heenreis',\n },\n {\n key: 'connections.form.return',\n de: 'Rückfahrt',\n en: 'Return',\n it: 'Ritorno',\n fr: 'Retour',\n nl: 'Terugreis',\n },\n {\n key: 'connections.form.date',\n de: 'Start der Reise',\n en: 'Start of the journey',\n it: 'Data del viaggio',\n fr: 'Début du voyage',\n nl: 'Start van de reis',\n },\n {\n key: 'connections.form.search',\n de: 'Suchen',\n en: 'Search',\n it: 'Search',\n fr: 'Chercher',\n nl: 'Zoeken',\n },\n {\n key: 'connections.cartransport.possible',\n de: 'Fahrzeugtransport möglich',\n en: 'Vehicle transport possible',\n it: 'Trasporto dei veicoli possibile',\n fr: 'Transport de véhicule possible',\n nl: 'Voertuigtransport mogelijk',\n },\n {\n key: 'connections.cartransport.notpossible',\n de: 'Fahrzeugtransport nicht möglich',\n en: 'Vehicle transport not possible',\n it: 'Trasporto dei veicoli non possibile',\n fr: 'Transport de véhicule impossible',\n nl: 'Voertuigtransport niet mogelijk',\n },\n {\n key: 'connections.none',\n de: 'Keine Verbindungen gefunden. Bitte versuchen Sie ein anderes Abfahrtsland.',\n en: 'No connections found. Please try another departure country.',\n it: 'Nessuna connessione trovata. Si prega di provare un altro paese di partenza.',\n fr: 'Aucune correspondance trouvée. Veuillez essayer une autre région de départ.',\n nl: 'Geen aansluitingen gevonden. Probeer het nog een keer met een ander land van vertrek.',\n },\n {\n key: \"connections.results.single\",\n de: \"1 Verbindung gefunden\",\n en: \"1 connection found\",\n it: \"1 connessione trovata\",\n fr: \"1 correspondance trouvée\",\n nl: \"1 aansluiting gevonden\",\n },\n {\n key: \"connections.results.multiple\",\n de: \"{0} Verbindungen gefunden\",\n en: \"{0} connections found\",\n it: \"{0} Composti trovati\",\n fr: \"{0} Correspondances trouvées\",\n nl: \"{0} Aansluitingen gevonden\",\n },\n {\n key: \"connections.oebb\",\n de: \"Verbindungen vom ÖBB Nightjet\",\n en: \"Connections of ÖBB Nightjet\",\n it: \"Collegamenti delle ÖBB Nightjet\",\n fr: \"Connexions de ÖBB Nightjet\",\n nl: \"Aansluitingen van ÖBB Nightjet\",\n },\n {\n key: \"connections.dani\",\n de: \"Verbindungen vom Nightjet der neuen Generation\",\n en: \"Connections of Nightjet of the new generation\",\n it: \"Collegamenti delle Nightjet di nuova generazione\",\n fr: \"Connexions de Nightjet nouvelle génération\",\n nl: \"Aansluitingen van Nightjet van de nieuwe generatie\",\n },\n {\n key: \"connections.partner\",\n de: \"Verbindungen von Partnerbahnen\",\n en: \"Connections of Nightjet partners\",\n it: \"Collegamenti delle ferrovie partner\",\n fr: \"Connexions de partenaires\",\n nl: \"Aansluitingen van partner-spoorwegmaatschappijen\",\n },\n];\n//# sourceMappingURL=connections-i18n.js.map\n","/* Default Colors */\n/* CI/CD Colors */\n/* 2021 TS Colors */\n/* Scrollbars */\n*:focus {\n\toutline: var(--oebb-outline, 2px dotted var(--oebb-accent-color, #e2002a));\n\toutline-offset: var(--oebb-outline-offset, 2px);\n}\n\n*:focus:not(:focus-visible) {\n\toutline: none;\n}\n\n*:focus-visible {\n\toutline: var(--oebb-outline, 2px dotted var(--oebb-accent-color, #e2002a));\n\toutline-offset: var(--oebb-outline-offset, 2px);\n}\n\n.hidden {\n\tdisplay: none;\n}\n\n.invisible {\n\tvisibility: hidden;\n}\n\n.offscreen {\n\tposition: absolute;\n\tleft: -1000em;\n}\n\n.screen-reader-text {\n\tposition: absolute;\n\n\twidth: 1px;\n\theight: 1px;\n\tmargin: -1px;\n\tpadding: 0;\n\toverflow: hidden;\n\n\tborder: 0;\n\tclip-path: inset(50%);\n\n\twhite-space: nowrap;\n}\n\n.screen-reader-text--focusable:active,\n.screen-reader-text--focusable:focus {\n\tposition: relative;\n\n\twidth: auto;\n\theight: auto;\n\tmargin: 0;\n\toverflow: visible;\n\n\tclip-path: none;\n\n\twhite-space: inherit;\n}\n\n/** @deprecated */\n/** \".is-tabbing\" should be added via JavaScript and shows the outline. Used with class to not show outline on clicking elements. */\n.is-tabbing button::-moz-focus-inner,\n:host(.is-tabbing) button::-moz-focus-inner {\n\tborder: 0;\n}\n\n.is-tabbing--focus,\n.is-tabbing a:focus,\n.is-tabbing button:focus,\n.is-tabbing div:focus,\n.is-tabbing input:focus,\n.is-tabbing input:focus ~ span[role=\"presentation\"],\n:host(.is-tabbing) a:focus,\n:host(.is-tabbing) button:focus,\n:host(.is-tabbing) div:focus,\n:host(.is-tabbing) input:focus,\n:host(.is-tabbing) input:focus ~ span[role=\"presentation\"] {\n\toutline: 2px dotted #e2002a;\n\toutline-offset: 2px;\n\tz-index: 10;\n}\n\n/* Default Colors */\n/* CI/CD Colors */\n/* 2021 TS Colors */\n/* Scrollbars */\n/* Default Colors */\n/* CI/CD Colors */\n/* 2021 TS Colors */\n/* Scrollbars */\n.connection-none {\n padding: 1.5rem 8rem;\n}\n.connection-none p {\n margin: 0;\n}\n.connection-results {\n position: relative;\n z-index: 0;\n}\n.connection-results section {\n margin-bottom: 20px;\n}\n.connection-label {\n margin: 0 0 4px;\n font-size: inherit;\n font-weight: inherit;\n}\n.connection-header {\n display: grid;\n grid-template-columns: 4.75rem 1fr 20rem;\n gap: 2rem;\n flex-grow: 1;\n}\n.connection-header > * {\n align-self: center;\n}\n.connection-number {\n color: #e2002a;\n}\n.connection-title {\n color: #111B42;\n}\n.connection-vehicle-possible, .connection-vehicle-not-possible {\n display: flex;\n align-items: center;\n gap: 4px;\n font-weight: normal;\n}\n.connection-vehicle-possible oebbx-icon svg, .connection-vehicle-not-possible oebbx-icon svg {\n display: block;\n fill: currentColor;\n width: 26px;\n height: 22px;\n}\n.connection-vehicle-possible {\n color: #008039;\n}\n.connection-vehicle-not-possible {\n color: #6e6e6e;\n}\n@media screen and (max-width: 768px) {\n .connection-header {\n grid-template-columns: 4.75rem 1fr;\n gap: 0.25rem;\n margin-right: -1.5rem;\n }\n .connection-vehicle-possible, .connection-vehicle-not-possible {\n display: none;\n }\n}\n\n.connections-form {\n background: #ffffff;\n margin-bottom: 0.25rem;\n padding: 1.25rem;\n}\n.connections-form fieldset {\n padding: 0;\n border: none;\n}\n.connections-form-grid {\n display: grid;\n grid-template-columns: 11.5rem 1fr auto;\n gap: 1.25rem 0.75rem;\n}\n.connections-form-label {\n display: inline-block;\n font-weight: bold;\n padding-right: 1rem;\n}\n.connections-form-label span {\n position: relative;\n display: block;\n background: #e2002a;\n color: #ffffff;\n padding: 7px;\n}\n.connections-form-label span:after {\n content: \"\";\n position: absolute;\n top: 50%;\n right: 0;\n width: 22px;\n height: 22px;\n transform: translate(50%, -50%) rotate(45deg);\n transform-origin: 50% 50%;\n background: #e2002a;\n}\n.connections-form-country input {\n padding: 1.125rem 0.875rem;\n width: calc(100% - 35px);\n max-width: 285px;\n box-sizing: border-box;\n font-family: inherit;\n font-size: inherit;\n}\n.connections-form-date {\n width: 100%;\n max-width: 285px;\n min-width: unset;\n}\n.connections-form-radio {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n box-sizing: border-box;\n display: inline-block;\n margin: 0;\n width: 1.25rem;\n height: 1.25rem;\n border: 5px solid #BABDC0;\n background-color: #BABDC0;\n border-radius: 50%;\n}\n.connections-form-radio:checked {\n border-color: #e2002a;\n background-color: #ffffff;\n}\n.connections-form-radio-label {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n padding: 0.375rem;\n}\n.connections-form-radio-label:hover, .connections-form-radio-label:focus-within {\n background-color: #f5f5f5;\n}\n@media screen and (max-width: 540px) {\n .connections-form-grid {\n grid-template-columns: 1fr;\n }\n .connections-form-grid label {\n max-width: 11.5rem;\n }\n}\n@media screen and (min-width: 541px) and (max-width: 768px) {\n .connections-form-grid {\n grid-template-columns: 11.5rem 1fr;\n }\n .connections-form-direction {\n grid-column: 1/-1;\n }\n}\n@media screen and (max-width: 768px) {\n .connections-form-grid {\n gap: 0.5rem;\n }\n .connections-form-direction {\n margin-bottom: 1rem;\n }\n}\n\n.oebb-autocomplete-wrapper {\n position: relative;\n}\n.oebb-autocomplete-list {\n display: none;\n position: absolute;\n box-sizing: border-box;\n z-index: 15;\n min-width: 350px;\n max-height: 300px;\n margin: 0;\n padding: 0;\n background: #ffffff;\n border: 1px solid #babdc0;\n transform: translateY(2px);\n overflow-y: auto;\n box-shadow: -1px -1px 10px -2px rgba(0, 0, 0, 0.5);\n scrollbar-width: thin;\n scrollbar-color: #babdc0 #ffffff;\n}\n.oebb-autocomplete-list {\n scrollbar-face-color: #babdc0;\n scrollbar-track-color: #ffffff;\n}\n.oebb-autocomplete-list::-webkit-scrollbar {\n width: 14px;\n}\n.oebb-autocomplete-list::-webkit-scrollbar-track {\n background: #ffffff;\n}\n.oebb-autocomplete-list::-webkit-scrollbar-thumb {\n background-color: #babdc0;\n border-radius: 6px;\n border: 3px solid #ffffff;\n}\n.oebb-autocomplete-list .oebb-autocomplete-item {\n position: relative;\n padding: 0.75rem 1.25rem;\n cursor: pointer;\n}\n.oebb-autocomplete-list .oebb-autocomplete-item:not(:last-child) {\n border-bottom: 1px solid var(--form-input-border-color);\n}\n.oebb-autocomplete-list .oebb-autocomplete-item:hover, .oebb-autocomplete-list .oebb-autocomplete-item--active {\n background-color: #ebebeb;\n}","import { OebbAutocomplete } from '@oebb-web-team/oebb-web-library/dist/autocomplete/OebbAutocomplete';\nimport { h } from '@stencil/core';\nimport { TrainService } from \"../../service/train.service\";\nimport { findLocale, formatIsoDate, getLocalizedString, i18n } from '../../utils';\nimport { connectionsI18n } from './connections-i18n';\nexport class Connections {\n constructor() {\n this.today = new Date();\n this.travelDate = formatIsoDate(this.today);\n this.direction = 'outward';\n this.onCountryBlur = () => this.refreshConnections();\n this.onDirectionSelect = (e) => {\n const target = e.target;\n this.direction = target.value;\n this.updateSearchData();\n this.refreshConnections().then();\n };\n this.onDateChange = (e) => {\n this.travelDate = formatIsoDate(e.detail.value);\n this.updateSearchData();\n this.refreshConnections().then();\n };\n this.onExpandableOpened = (e) => {\n this.activeTrain = e.detail ? e.currentTarget.dataset.train : null;\n };\n this.njBookingLink = undefined;\n this.partnerLink = undefined;\n this.destinationCountry = undefined;\n this.destinationCity = undefined;\n this.vehicleTransport = false;\n this.type = undefined;\n this.njBaseUrl = undefined;\n this.pvAppsBaseUrl = undefined;\n this.showBestPriceFinder = true;\n this.showAutoTrains = true;\n this.departureCountryCode = undefined;\n this.data = undefined;\n this.maxBookableDate = undefined;\n this.activeTrain = undefined;\n }\n componentWillLoad() {\n this.lang = findLocale(this.el);\n i18n.add(connectionsI18n);\n i18n.setLang(this.lang);\n if (this.njBaseUrl) {\n TrainService.instance.setNjBaseUrl(this.njBaseUrl);\n }\n if (this.pvAppsBaseUrl) {\n TrainService.instance.setPvAppsBaseUrl(this.pvAppsBaseUrl);\n }\n if (this.type) {\n this.travelDate = formatIsoDate(new Date());\n this.searchData = {\n carTransport: this.vehicleTransport,\n date: this.travelDate,\n };\n }\n this.initConfig().then();\n this.refreshConnections().then();\n }\n componentDidLoad() {\n this.initAutocomplete().then();\n }\n async initConfig() {\n try {\n await TrainService.instance.loadConfig();\n }\n catch (e) {\n console.log(\"Error loading config\", e);\n }\n finally {\n // Set the date limit even when the request failed, at least we enforce the 180 day limit\n this.maxBookableDate = TrainService.instance.getMaxBookableDate();\n }\n }\n async refreshConnections() {\n var _a;\n try {\n if (this.type) {\n this.data = await TrainService.instance.findConnectionsForType(this.type, this.travelDate || formatIsoDate(new Date()), this.vehicleTransport);\n }\n else if (!this.originCountry || !this.travelDate) {\n this.data = [];\n }\n else if (this.destinationCity) {\n this.data = await TrainService.instance.findConnectionsForDestinationStation(this.originCountry, this.destinationCity, this.travelDate, this.vehicleTransport, this.direction);\n }\n else {\n this.data = await TrainService.instance.findConnectionsForDestinationCountry(this.originCountry, this.destinationCountry, this.travelDate, this.vehicleTransport, this.direction);\n }\n if (((_a = this.data) === null || _a === void 0 ? void 0 : _a.length) === 1) {\n this.activeTrain = this.data[0].trainNumber;\n }\n }\n catch (e) {\n console.log(\"Error loading connections\", e);\n }\n }\n async findAvailableCountries(query = '') {\n try {\n if (this.destinationCity) {\n return await TrainService.instance.findCountriesForDestinationStation(this.destinationCity, this.vehicleTransport, this.direction, query);\n }\n else {\n return await TrainService.instance.findCountriesForDestinationCountry(this.destinationCountry, this.vehicleTransport, this.direction, query);\n }\n }\n catch (e) {\n console.log('Error loading country list', e);\n return [];\n }\n }\n async initAutocomplete() {\n if (this.type) {\n return;\n }\n const countryInput = this.el.shadowRoot.querySelector('#country-field');\n this.countryAutocomplete = new OebbAutocomplete(countryInput)\n .withTemplate(function (item) {\n return `