{"version":3,"names":["stripUmlauts","str","toLowerCase","replace","async","fetchCountries","apiBaseUrl","language","fetch","then","res","json","data","_embedded","sort","a","b","aa","_id","name","bb","fetchComponents","countryId","fetchRegulations","componentId","sewWsLexfinderCss","SewWsLexfinder","constructor","hostRef","this","resultBaseUrl","convertedCountries","convertedComponents","convertedRegulations","countryDisabled","componentsDisabled","regulationsDisabled","linkDisabled","getCountries","fetchedCountries","map","country","push","id","country_id","value","getComponents","fetchedComponents","component","component_id","getRegulations","fetchedRegulations","regulation","shortTitle","generateLink","resultParams","currentSelectedCountry","currentSelectedComponent","currentSelectedRegulation","queryParams","location","href","encodeURI","componentWillLoad","length","catch","err","console","error","render","h","Host","key","class","text","ws","comboboxId","placeholder","countryLabel","onItemSelected","selectedItem","componentDropdownRef","regulationDropdownRef","detail","Number","item","componentLabel","disabled","noSearch","ref","regulationLabel","onClick","gettrackmeEventCategory","gettrackmeEventObject","servicesItemLabel","buttonText"],"sources":["src/components/website-components/sew-ws-lexfinder/sew-ws-lexfinder.service.tsx","src/components/website-components/sew-ws-lexfinder/sew-ws-lexfinder.scss?tag=sew-ws-lexfinder&encapsulation=shadow","src/components/website-components/sew-ws-lexfinder/sew-ws-lexfinder.tsx"],"sourcesContent":["const stripUmlauts = str => {\n return str.toLowerCase().replace(/ä/, 'ae').replace(/ö/, 'oe').replace(/ü/, 'ue');\n};\n\nexport async function fetchCountries(apiBaseUrl: string, language: string): Promise<[]> {\n return await fetch(\n `${apiBaseUrl}/market_regulation_mapping/_aggrs/countries?avars={'fs_language':'${language}'}`\n )\n .then(res => res.json())\n .then(data => {\n return data._embedded['rh:result'].sort((a, b) => {\n const aa = stripUmlauts(a._id.name);\n const bb = stripUmlauts(b._id.name);\n\n if (aa < bb) {\n return -1;\n } else {\n return 1;\n }\n });\n });\n}\n\nexport async function fetchComponents(apiBaseUrl: string, language: string, countryId: number): Promise<[]> {\n return await fetch(\n `${apiBaseUrl}/market_regulation_mapping/_aggrs/components_by_country?avars={'country':${countryId},'fs_language':'${language}'}`\n )\n .then(res => res.json())\n .then(data => {\n return data._embedded['rh:result'];\n });\n}\n\nexport async function fetchRegulations(\n apiBaseUrl: string,\n language: string,\n countryId: number,\n componentId: number\n): Promise<[]> {\n return await fetch(\n `${apiBaseUrl}/market_regulations?filter={'$and':[{'countries':${countryId}},{'components':${componentId}},{'fs_language':'${language}'},{'visible':true}]}&keys={'shortTitle':1}`\n )\n .then(res => res.json())\n .then(data => {\n return data._embedded['rh:doc'];\n });\n}\n",":host {\n @include grid;\n\n .main-content-container {\n display: grid;\n grid-template-columns: repeat(4, 1fr);\n column-gap: var(--column-gap);\n align-items: flex-end;\n padding: 48px 0 60px;\n }\n\n p {\n @include typo-ws-paragraph-bold;\n\n grid-row: 1;\n grid-column: 1 / -1;\n margin: 0;\n margin-bottom: 36px;\n }\n\n sew-combobox,\n sew-ws-button {\n grid-row: 2;\n min-width: 0;\n min-height: 0;\n }\n\n sew-combobox {\n --label-color: #{$color-grey-01-dark};\n }\n}\n\n@include mq-1 {\n :host {\n .main-content-container {\n grid-template-columns: 1fr;\n padding: 40px 0;\n }\n\n p {\n margin-bottom: 24px;\n }\n\n sew-combobox,\n sew-ws-button {\n margin-top: 20px;\n grid-column: 1;\n grid-row: auto;\n }\n\n sew-combobox:first-of-type {\n margin-top: 0;\n }\n\n sew-ws-button {\n margin-top: 40px;\n }\n }\n}\n","import { Component, Host, h, Prop, State } from '@stencil/core';\nimport { gettrackmeEventCategory, gettrackmeEventObject } from '../../../utils/tracking-helpers';\nimport { fetchComponents, fetchCountries, fetchRegulations } from './sew-ws-lexfinder.service';\nimport { SelectOption } from '../../forms/sew-combobox/sew-combobox.types';\nimport { SewComboboxCustomEvent } from '../../../components';\n\n@Component({\n tag: 'sew-ws-lexfinder',\n styleUrl: 'sew-ws-lexfinder.scss',\n shadow: true,\n})\nexport class SewWsLexfinder {\n @Prop() text: string;\n @Prop() language: string;\n @Prop() apiBaseUrl = 'https://caas.sew-d.com/direct/SEWDE';\n @Prop() resultBaseUrl = '/international-regulations/result';\n @Prop() buttonText: string;\n @Prop() regulationLabel: string;\n @Prop() countryLabel: string;\n @Prop() componentLabel: string;\n @Prop() servicesItemLabel: string;\n\n @State() convertedCountries: { name: string; id: number }[] = [];\n @State() convertedComponents: { name: string; id: number }[] = [];\n @State() convertedRegulations: { name: string; id: number }[] = [];\n @State() currentSelectedCountry: { name: string; id: number };\n @State() currentSelectedComponent: { name: string; id: number };\n @State() currentSelectedRegulation: { name: string; id: number };\n @State() countryDisabled = true;\n @State() componentsDisabled = true;\n @State() regulationsDisabled = true;\n @State() linkDisabled = true;\n\n private componentDropdownRef: HTMLSelectElement;\n private regulationDropdownRef: HTMLSelectElement;\n\n private getCountries(fetchedCountries: []): void {\n const convertedCountries = [];\n\n fetchedCountries.map((country: { _id }) =>\n convertedCountries.push({\n name: country._id.name,\n id: country._id.country_id,\n value: country._id.country_id,\n })\n );\n\n this.convertedCountries = convertedCountries;\n }\n\n private getComponents(fetchedComponents: []): void {\n const convertedComponents = [];\n\n fetchedComponents.map((component: { _id }) =>\n convertedComponents.push({\n name: component._id.name,\n id: component._id.component_id,\n value: component._id.component_id,\n })\n );\n\n this.convertedComponents = convertedComponents;\n }\n\n private getRegulations(fetchedRegulations: []): void {\n const convertedRegulations = [];\n\n fetchedRegulations.map((regulation: { shortTitle; _id }) =>\n convertedRegulations.push({\n name: regulation.shortTitle,\n id: regulation._id,\n value: regulation._id,\n })\n );\n\n this.convertedRegulations = convertedRegulations;\n }\n\n private generateLink(): void {\n const resultParams = `${this.currentSelectedCountry.name}/${this.currentSelectedComponent.name}/${this.currentSelectedRegulation.name}`;\n const queryParams = `language=${this.language}`;\n\n location.href = encodeURI(`${this.resultBaseUrl}/${resultParams}?${queryParams}`);\n }\n\n componentWillLoad(): void {\n // handle empty property same as default\n this.resultBaseUrl =\n this.resultBaseUrl.length > 0 ? this.resultBaseUrl : '/international-regulations/result';\n\n fetchCountries(this.apiBaseUrl, this.language)\n .then(res => {\n this.getCountries(res);\n this.countryDisabled = false;\n })\n .catch(err => {\n console.error(err);\n this.countryDisabled = true;\n });\n }\n\n render() {\n return (\n \n
\n

{this.text}

\n\n ) => {\n this.componentDropdownRef.value = '';\n this.regulationDropdownRef.value = '';\n this.componentsDisabled = true;\n this.regulationsDisabled = true;\n this.linkDisabled = true;\n this.currentSelectedCountry = {\n name: selectedItem.detail.name,\n id: Number(selectedItem.detail.value),\n };\n\n fetchComponents(this.apiBaseUrl, this.language, this.currentSelectedCountry.id)\n .then(res => {\n this.getComponents(res);\n this.componentsDisabled = false;\n this.regulationsDisabled = true;\n this.linkDisabled = true;\n })\n .catch(err => {\n //@TODO proper error handlings\n console.error(err);\n });\n }}\n >\n \n \n\n ) => {\n this.currentSelectedComponent = {\n name: selectedItem.detail.name,\n id: Number(selectedItem.detail.value),\n };\n this.regulationDropdownRef.value = '';\n this.regulationsDisabled = true;\n this.linkDisabled = true;\n\n selectedItem.detail.value &&\n fetchRegulations(\n this.apiBaseUrl,\n this.language,\n this.currentSelectedCountry.id,\n this.currentSelectedComponent.id\n )\n .then(res => {\n this.getRegulations(res);\n this.regulationsDisabled = false;\n this.linkDisabled = true;\n })\n .catch(err => {\n //@TODO proper error handlings\n console.error(err);\n });\n }}\n >\n \n \n\n ) => {\n this.currentSelectedRegulation = {\n name: selectedItem.detail.name,\n id: Number(selectedItem.detail.value),\n };\n\n this.linkDisabled = !selectedItem.detail.value;\n }}\n >\n \n \n\n \n this.generateLink()}\n disabled={this.linkDisabled}\n data-sew-trackme-event-category={gettrackmeEventCategory('Services')}\n data-sew-trackme-event-object={gettrackmeEventObject(\n `Services_${this.servicesItemLabel}_${this.buttonText}`\n )}\n data-sew-trackme-event-action=\"Click\"\n >\n {this.buttonText}\n \n \n
\n
\n );\n }\n}\n"],"mappings":"6FAAA,MAAMA,EAAeC,GACVA,EAAIC,cAAcC,QAAQ,IAAK,MAAMA,QAAQ,IAAK,MAAMA,QAAQ,IAAK,MAGzEC,eAAeC,EAAeC,EA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