;(function () {
	if (typeof $ !== "undefined") {
		return init()
	}

	var script = document.createElement("script")
	script.src = "https://code.jquery.com/jquery-3.0.0.min.js"
	script.type = "text/javascript"
	document.getElementsByTagName("head")[0].appendChild(script)
	script.onload = function () {
		init()
	}
})()

function init() {
	const escapeHtml = (text) => {
		if (typeof text !== "string") {
			return text
		}

		return text
			.replace(/&/g, "&amp;")
			.replace(/</g, "&lt;")
			.replace(/>/g, "&gt;")
			.replace(/"/g, "&quot;")
			.replace(/'/g, "&#039;")
	}

	const stripTags = (text) => text.replace(/<\/?[^>]+(>|$)/g, "")

	;(function () {
		var undef
		var decode = decodeURIComponent
		var deparam = ($.deparam = function (text, reviver) {
			var result = {}
			$.each(text.replace(/\+/g, " ").split("&"), function (index, pair) {
				var kv = pair.split("=")
				var key = decode(kv[0])
				if (!key) {
					return
				}
				var value = decode(kv[1] || "")
				var keys = key.split("][")
				var last = keys.length - 1
				var i = 0
				var current = result
				if (keys[0].indexOf("[") >= 0 && /\]$/.test(keys[last])) {
					keys[last] = keys[last].replace(/\]$/, "")
					keys = keys.shift().split("[").concat(keys)
					last++
				} else {
					last = 0
				}

				if ($.isFunction(reviver)) {
					value = reviver(key, value)
				} else if (reviver) {
					value = deparam.reviver(key, value)
				}

				if (last) {
					for (; i <= last; i++) {
						key = keys[i] !== "" ? keys[i] : current.length
						if (i < last) {
							current = current[key] =
								current[key] || (isNaN(keys[i + 1]) ? {} : [])
						} else {
							current[key] = value
						}
					}
				} else {
					if ($.isArray(result[key])) {
						result[key].push(value)
					} else if (key in result) {
						result[key] = [result[key], value]
					} else {
						result[key] = value
					}
				}
			})

			return result
		})
	})()

	;(function () {
		const locales = {
			pl: {
				search: "Szukaj",
				keyword: "Słowo kluczowe",
				location: "Miejscowość",
				clearForm: "Wyczyść formularz",
				advertsFound: "Znaleziono ogłoszeń",
				readMore: "CZYTAJ WIĘCEJ",
				advertsNotFound: "Nie znaleziono ogłoszeń dla zadanych kryteriów.",
			},
			en: {
				search: "Search",
				keyword: "Keyword",
				location: "Location",
				clearForm: "Clear all",
				advertsFound: "Offers found",
				readMore: "READ MORE",
				advertsNotFound: "We did not find any offers with chosen criteria.",
			},
			cs: {
				search: "Hledat",
				keyword: "Klíčové slovo",
				location: "Lokalita",
				clearForm: "Vymazat vše",
				advertsFound: "Nalezené nabídky",
				readMore: "Dozvědět se více",
				advertsNotFound:
					"Na základě vybraných kritérií jsme nenašli žádné nabídky.",
			},
			fi: {
				search: "Haku",
				keyword: "Hakusana",
				location: "Sijainti",
				clearForm: "Tyhjennä kaikki",
				advertsFound: "Tarjoukset löydetty",
				readMore: "Lue lisää",
				advertsNotFound:
					"Emme löytäneet tarjouksia valittujen kriteerien perusteella.",
			},
			fr: {
				search: "Rechercher",
				keyword: "Mot-clé",
				location: "Emplacement",
				clearForm: "Tout effacer",
				advertsFound: "Offres trouvées",
				readMore: "En savoir plus",
				advertsNotFound:
					"Nous n'avons trouvé aucune offre selon les critères choisis.",
			},
			de: {
				search: "Suchen",
				keyword: "Schlüsselwort",
				location: "Ort",
				clearForm: "Alles löschen",
				advertsFound: "Angebote gefunden",
				readMore: "Mehr erfahren",
				advertsNotFound:
					"Wir haben keine Angebote nach den gewählten Kriterien gefunden.",
			},
			hu: {
				search: "Keresés",
				keyword: "Kulcsszó",
				location: "Hely",
				clearForm: "Minden törlése",
				advertsFound: "Ajánlatok találata",
				readMore: "További információk",
				advertsNotFound:
					"Nem találtunk ajánlatot a kiválasztott kritériumok alapján.",
			},
			lt: {
				search: "Ieškoti",
				keyword: "Raktinis žodis",
				location: "Vieta",
				clearForm: "Išvalyti viską",
				advertsFound: "Pasiūlymai rasti",
				readMore: "Sužinokite daugiau",
				advertsNotFound: "Pagal pasirinktus kriterijus pasiūlymų nerasta.",
			},
			pt: {
				search: "Pesquisar",
				keyword: "Palavra-chave",
				location: "Localização",
				clearForm: "Limpar tudo",
				advertsFound: "Ofertas encontradas",
				readMore: "Saiba mais",
				advertsNotFound:
					"Não encontramos nenhuma oferta com os critérios escolhidos.",
			},
			ro: {
				search: "Căutare",
				keyword: "Cuvânt cheie",
				location: "Locație",
				clearForm: "Șterge tot",
				advertsFound: "Oferte găsite",
				readMore: "Află mai multe",
				advertsNotFound: "Nu am găsit nicio ofertă conform criteriilor alese.",
			},
			ru: {
				search: "Поиск",
				keyword: "Ключевое слово",
				location: "Местоположение",
				clearForm: "Очистить всё",
				advertsFound: "Найдено предложений",
				readMore: "Узнать больше",
				advertsNotFound: "Мы не нашли предложений по выбранным критериям.",
			},
			sk: {
				search: "Hľadať",
				keyword: "Kľúčové slovo",
				location: "Lokalita",
				clearForm: "Vymazať všetko",
				advertsFound: "Ponuky nájdené",
				readMore: "Dozvedieť sa viac",
				advertsNotFound:
					"Na základe zvolených kritérií sme nenašli žiadne ponuky.",
			},
			es: {
				search: "Buscar",
				keyword: "Palabra clave",
				location: "Ubicación",
				clearForm: "Limpiar todo",
				advertsFound: "Ofertas encontradas",
				readMore: "Saber más",
				advertsNotFound:
					"No encontramos ninguna oferta con los criterios elegidos.",
			},
			tr: {
				search: "Ara",
				keyword: "Anahtar kelime",
				location: "Konum",
				clearForm: "Tümünü temizle",
				advertsFound: "Teklifler bulundu",
				readMore: "Daha fazla öğren",
				advertsNotFound: "Seçilen kriterlere göre hiçbir teklif bulamadık.",
			},
			uk: {
				search: "Пошук",
				keyword: "Ключове слово",
				location: "Місцезнаходження",
				clearForm: "Очистити все",
				advertsFound: "Знайдено пропозицій",
				readMore: "Дізнатися більше",
				advertsNotFound:
					"Ми не знайшли жодної пропозиції за вибраними критеріями.",
			},
		}

		const settingsString =
			"\u007B\u0022announcement_list_carreer_page\u0022\u003Anull,\u0022announcement_list_css\u0022\u003A\u0022\u0023traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u0020a\u007Bfont\u002Dstretch\u003A100\u0025\u003Bfont\u002Dvariant\u002Dcaps\u003Anormal\u003Bfont\u002Dvariant\u002Deast\u002Dasian\u003Anormal\u003Bfont\u002Dvariant\u002Dligatures\u003Anormal\u003Bfont\u002Dvariant\u002Dnumeric\u003Anormal\u003Bcolor\u003A\u0023fff\u0021important\u003Btext\u002Drendering\u003Aoptimizelegibility\u003Btext\u002Ddecoration\u003Anone\u0021important\u003Bcursor\u003Apointer\u003Bfont\u003A700\u002025px\\/1.2em\u0020Lato,sans\u002Dserif\u003Bdisplay\u003Ablock\u003Bheight\u003A120px\u003Btext\u002Dalign\u003Acenter\u007D.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Ddate\u002Delement\u007Bdisplay\u003Anone\u0021important\u007D\u0023traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u0020div\u003Afirst\u002Dof\u002Dtype\u007Bcolor\u003A\u002329ade3\u007D.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Delement\u007Bflex\u002Ddirection\u003A\u0020column\u003B\u0020padding\u003A16px\u003Bborder\u002Dradius\u003A3px\u003Bborder\u003A1px\u0020solid\u0020\u0023d0d0d0\u003Bcursor\u003Apointer\u003Bbox\u002Dshadow\u003Anone\u003Bfloat\u003Aleft\u003Bwidth\u003Acalc\u002833\u0025\u0020\u002D\u002020px\u0029\u003Bmargin\u003A10px\u003Bheight\u003A220px\u003Bbackground\u003A\u002329ade3\u0021important\u003Bcolor\u003A\u0023fff\u0021important\u003Bborder\u002Dbottom\u003A5px\u0020solid\u0020\u00230f7ca9\u007D\u0023xtxrxaxfxixtx2x0x1x6x\u002Dpagination\u002Ddiv\u007Bclear\u003Aboth\u007D.extra\u002Dwrap\u007Bbackground\u003A\u0023fff\u0021important\u003Bborder\u003Anone\u0021important\u007D\u0023traffit\u002Dan\u002Dfilters\u002Dxtxrxaxfxixtx2x0x1x6x\u0020button\u007Bbackground\u003A\u002329ade3\u0021important\u007D.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Delement\u0020span\u007Bfont\u002Dsize\u003A1.6em\u003Btext\u002Dalign\u003Acenter\u003Bdisplay\u003Ablock\u007D\u0020.traffit\u002Dan\u002Dmoney\u007Bfont\u002Dsize\u003A\u002017px\u003Btext\u002Dalign\u003A\u0020center\u003B\u007D\\n\\n\u0040media\u0020\u0028max\u002Dwidth\u003A\u00201000px\u0029\u007B\\n.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Delement\u007B\\nwidth\u003Acalc\u0028100\u0025\u0020\u002D\u002016px\u0029\\n\u007D\\n\u007D\\n\u0023traffit\u002Dan\u002Dfilters\u002Dxtxrxaxfxixtx2x0x1x6x\u007B\\ndisplay\u003Anone\u003B\\n\u007D\\n\\n\u0023xtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Ddiv\u007B\\n\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\\n\u007D\u0022,\u0022announcement_page\u0022\u003A\u002260\u0022,\u0022custom_traffit_row_string\u0022\u003A\u0022\u003Cdiv\u0020class\u003D\u0027traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Delement\u0020\u007B\u007Bawarded\u007D\u007D\u0027\u0020onclick\u003D\\\u0022location.href\u003D\u0027\u007B\u007Burl\u007D\u007D\u0027\\\u0022\u003E\u0020\u003Cdiv\u003E\u003Ca\u0020href\u003D\u0027\u007B\u007Burl\u007D\u007D\u0027\u003E\u007B\u007Bname\u007D\u007D\u003C\\/a\u003E\u0020\u002D\u0020\u007B\u007BnrRef\u007D\u007D\u003C\\/div\u003E\u003Cdiv\u0020style\u003D\\\u0022\u0020margin\u002Dtop\u003A\u0020\u002D70px\u003B\\\u0022\u003E\u003Cspan\u0020style\u003D\\\u0022font\u002Dsize\u003A\u002026px\u003B\\\u0022\u003E\u007B\u007Bx_location\u007D\u007D\u003C\\/span\u003E\u003Cspan\u0020class\u003D\u0027traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Ddate\u002Delement\u0027\u003E\u007B\u007Bdate\u007D\u007D\u003C\\/span\u003E\u003C\\/div\u003E\u003Cdiv\u0020class\u003D\\\u0022traffit\u002Dan\u002Dmoney\\\u0022\u0020style\u003D\\\u0022margin\u002Dtop\u003A\u002045px\u003B\\\u0022\u003E\u007B\u007Bmoney\u007D\u007D\u003C\\/div\u003E\u003C\\/div\u003E\u0022,\u0022embed_code_config\u0022\u003A\u0022\u007B\\\u0022additionalStyles\\\u0022\u003A\\\u0022\u0023traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u0020a\u007Bfont\u002Dstretch\u003A100\u0025\u003Bfont\u002Dvariant\u002Dcaps\u003Anormal\u003Bfont\u002Dvariant\u002Deast\u002Dasian\u003Anormal\u003Bfont\u002Dvariant\u002Dligatures\u003Anormal\u003Bfont\u002Dvariant\u002Dnumeric\u003Anormal\u003Bcolor\u003A\u0023fff\u0021important\u003Btext\u002Drendering\u003Aoptimizelegibility\u003Btext\u002Ddecoration\u003Anone\u0021important\u003Bcursor\u003Apointer\u003Bfont\u003A700\u002025px\\\\\\/1.2em\u0020Lato,sans\u002Dserif\u003Bdisplay\u003Ablock\u003Bheight\u003A120px\u003Btext\u002Dalign\u003Acenter\u007D.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Ddate\u002Delement\u007Bdisplay\u003Anone\u0021important\u007D\u0023traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u0020div\u003Afirst\u002Dof\u002Dtype\u007Bcolor\u003A\u002329ade3\u007D.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Delement\u007Bflex\u002Ddirection\u003A\u0020column\u003B\u0020padding\u003A16px\u003Bborder\u002Dradius\u003A3px\u003Bborder\u003A1px\u0020solid\u0020\u0023d0d0d0\u003Bcursor\u003Apointer\u003Bbox\u002Dshadow\u003Anone\u003Bfloat\u003Aleft\u003Bwidth\u003Acalc\u002833\u0025\u0020\u002D\u002020px\u0029\u003Bmargin\u003A10px\u003Bheight\u003A220px\u003Bbackground\u003A\u002329ade3\u0021important\u003Bcolor\u003A\u0023fff\u0021important\u003Bborder\u002Dbottom\u003A5px\u0020solid\u0020\u00230f7ca9\u007D\u0023xtxrxaxfxixtx2x0x1x6x\u002Dpagination\u002Ddiv\u007Bclear\u003Aboth\u007D.extra\u002Dwrap\u007Bbackground\u003A\u0023fff\u0021important\u003Bborder\u003Anone\u0021important\u007D\u0023traffit\u002Dan\u002Dfilters\u002Dxtxrxaxfxixtx2x0x1x6x\u0020button\u007Bbackground\u003A\u002329ade3\u0021important\u007D.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Delement\u0020span\u007Bfont\u002Dsize\u003A1.6em\u003Btext\u002Dalign\u003Acenter\u003Bdisplay\u003Ablock\u007D\u0020.traffit\u002Dan\u002Dmoney\u007Bfont\u002Dsize\u003A\u002017px\u003Btext\u002Dalign\u003A\u0020center\u003B\u007D\\\\n\\\\n\u0040media\u0020\u0028max\u002Dwidth\u003A\u00201000px\u0029\u007B\\\\n.traffit\u002Dan\u002Dlist\u002Dxtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Delement\u007B\\\\nwidth\u003Acalc\u0028100\u0025\u0020\u002D\u002016px\u0029\\\\n\u007D\\\\n\u007D\\\\n\u0023traffit\u002Dan\u002Dfilters\u002Dxtxrxaxfxixtx2x0x1x6x\u007B\\\\ndisplay\u003Anone\u003B\\\\n\u007D\\\\n\\\\n\u0023xtxrxaxfxixtx2x0x1x6x\u002Dlist\u002Ddiv\u007B\\\\n\u0020\u0020\u0020\u0020display\u003A\u0020block\u003B\\\\n\u007D\\\u0022,\\\u0022jobPostLimit\\\u0022\u003A60\u007D\u0022\u007D"
		const settings = JSON.parse(settingsString)

		let embedCodeConfig = {}

		if (settings.embed_code_config) {
			try {
				const parsedData = JSON.parse(settings.embed_code_config)
				embedCodeConfig = Object.fromEntries(
					Object.entries(parsedData).map(([key, value]) => [
						key,
						key === "additionalStyles" ? stripTags(value) : escapeHtml(value),
					])
				)
			} catch (e) {
				console.error(e)
			}
		}

		const defaultLimit = 10

		const scriptConfig = {
			...embedCodeConfig,
			customTraffitRowString: settings["custom_traffit_row_string"],
			careerPageJobPostLimit: defaultLimit,
			jobPostLimit: parseInt(embedCodeConfig.jobPostLimit || defaultLimit),
		}

		var browserLang = navigator.language || navigator.userLanguage
		var browserLangShort = browserLang.substr(0, 2)
		const createTranslator = (locales, language) => (message) => {
			const locale = locales[browserLangShort] || locales["en"]
			return locale[message]
		}
		const t = createTranslator(locales, browserLangShort)

		scriptConfig.careerPageJobPostLimit = parseInt("60")

		const isWithinAts = !!document.querySelector('script[data-name="traffit"]')
		const limit = Math.max(
			1,
			isWithinAts
				? scriptConfig.careerPageJobPostLimit
				: scriptConfig.jobPostLimit
		)

		var request = { obj: {}, filter: [], limit, offset: 0, page: 1 }

		var traffitSite = decodeURIComponent("https\u003A//wingedit.traffit.com/")

		const columnCount = scriptConfig.jobListing === "boxes" ? 2 : 1

		const fontColorVar = "--traffit-an-list-font-color"
		const leadingColorVar = "--traffit-an-list-leading-color"
		const backgroundColorVar = "--traffit-an-list-background-color"
		const fontFamilyVar = "--traffit-an-list-font-family"

		const fontPreconnect =
			'<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>'
		let fontUrl =
			fontPreconnect +
			'<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">'

		const root = document.documentElement
		if (scriptConfig.fontColor) {
			root.style.setProperty(fontColorVar, scriptConfig.fontColor)
		}
		if (scriptConfig.leadingColor) {
			root.style.setProperty(leadingColorVar, scriptConfig.leadingColor)
		}
		if (scriptConfig.backgroundColor) {
			root.style.setProperty(backgroundColorVar, scriptConfig.backgroundColor)
		}
		if (scriptConfig.fontFamily) {
			let fontFamilyValue = scriptConfig.fontFamily
			const googleFonts = ["Lato", "Roboto", "Poppins", "Open Sans"].map(
				(font) => font.toLowerCase()
			)

			if (googleFonts.includes(fontFamilyValue.toLowerCase())) {
				const formattedFontFamily = fontFamilyValue.replace(/ /g, "+")
				fontUrl = `${fontPreconnect}<link href="https://fonts.googleapis.com/css2?family=${formattedFontFamily}:wght@300;400;500;700&display=swap" rel="stylesheet">`
				fontFamilyValue = `'${fontFamilyValue}', sans-serif`
			} else {
				fontUrl = undefined
			}
			root.style.setProperty(fontFamilyVar, fontFamilyValue)
		}

		var divId = "traffit-an-list-widget"
		var filterId = "traffit-an-filters-xtxrxaxfxixtx2x0x1x6x"
		// var listId = "xtxrxaxfxixtx2x0x1x6x-list-div"
		var listId = "traffit-list-div"
		var scriptType = "filters"
		var paginationId = "xtxrxaxfxixtx2x0x1x6x-pagination-div"
		var coreDiv,
			listDiv,
			filtersDiv,
			paginationDiv,
			counterSpan,
			infoDiv,
			loader
		var iconsFont =
			'<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">'
		var styles =
			'<link rel="stylesheet" href="https\u003A//cdn3.traffit.com/23S40256/bundles/traffitcareerpage/styles/main.css">'
		var scripts =
			'<script type="text/javascript" src="https\u003A//cdn3.traffit.com/23S40256/bundles/traffitcareerpage/app/careerFront.js"></script>'
		const hoverFilter = "filter: brightness(90%);"
		var outsideStyles =
			"<style>" +
			// `:root { ${fontColorVar}: #0b285b; ${leadingColorVar}: #2862ef; ${backgroundColorVar}: #ffffff; ${fontFamilyVar}: 'Roboto', sans-serif; }` +
			// ".traffit-xx-flex-container{display: -moz-box; display: -webkit-flexbox; display: -ms-flexbox; display: -webkit-flex; display: -moz-flex; display: flex; -moz-flex-flow: row; -ms-flex-flow: row; flex-flow: row; }"+
			// ".traffit-xx-flex-big{ -moz-box-flex: 1 1 auto;-webkit-flex: 1 1 auto;-moz-flex: 1 1 auto;-ms-flex: 1 1 auto;flex: 1 1 auto; }"+
			// ".traffit-xx-flex-no-shrink{ -moz-flex-shrink: 0;-ms-flex-shrink: 0;-webkit-flex-shrink: 0;flex-shrink: 0; }"+
			// "@media screen and (max-width: 800px){ #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x>div>*{width:100% !important; margin-bottom: 16px; margin-right: 0 !important; } } "+
			// `#traffit-an-list-widget, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x{ color: var(${fontColorVar}); font-family: var(${fontFamilyVar}); max-width: 1000px; margin: 0 auto; position:relative; padding: 0 20px;}`+
			// `#traffit-an-list-widget .traffit-xx-input, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x .traffit-xx-input{  font-family: var(${fontFamilyVar});}`+
			// "#traffit-an-list-widget *, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x *{ box-sizing: border-box; }"+
			// "@media screen and (max-width: 800px){ #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x>div{ flex-direction: column; } }"+
			// `#traffit-an-list-widget select, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x select, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x input, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x select{font-family: var(${fontFamilyVar}); width:calc(20% - 36px); font-size:12px; border: none; padding: 12px 8px; background: white; outline: none;margin-right: 16px; box-shadow: 0px 1px 2px #C5C5C5;}`+
			// `#traffit-an-filters-xtxrxaxfxixtx2x0x1x6x button{ font-size:12px;background: var(${fontColorVar});color: var(${backgroundColorVar});border: none;padding: 12px 0;font-family: var(${fontFamilyVar});border-radius: 2px;cursor: pointer; width: 80px;outline: none; box-shadow: 0px 1px 2px #C5C5C5;}`+
			// `#traffit-an-filters-xtxrxaxfxixtx2x0x1x6x button:active, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x button:hover{ ${hoverFilter} }`+
			// `#traffit-an-list-widget a{ color: var(${leadingColorVar}) !important; text-decoration: none !important; cursor: pointer;}`+
			// // "#xtxrxaxfxixtx2x0x1x6x-list-div {display: grid; margin: 12px 0; grid-gap: 12px;}"+
			// // `@media screen and (min-width: 840px) { #xtxrxaxfxixtx2x0x1x6x-list-div {grid-template-columns: repeat(${columnCount}, 1fr);}}`+
			// `.traffit-an-list-widget-list-element{ display: flex; align-items: center; justify-content: space-between; padding: 0 50px; height: 120px; box-shadow: 0 0 25px 2px rgba(137, 187, 219, 0.2); border-radius: 12px; background-color: var(${backgroundColorVar}); cursor: pointer; min-width: 0;}`+
			// `.traffit-an-list-widget-list-element:hover{ ${hoverFilter} }`+
			// "@media screen and (max-width: 1000px) { .traffit-an-list-widget-list-element { height: 120px; padding: 0 30px;}}" +
			// "@media screen and (max-width: 450px) { .traffit-an-list-widget-list-element { flex-direction: column; justify-content: center; align-items: center; height: auto; padding: 30px; }}" +
			// ".traffit-an-list-widget-list-element .info { display: flex; flex-direction: column; overflow: hidden; }" +
			// "@media screen and (max-width: 450px) { .traffit-an-list-widget-list-element .info { align-items: center; margin-bottom: 10px; width: 100%; }}" +
			// `.traffit-an-list-widget-list-element .info .title { color: var(${fontColorVar}); font-size: 18px; font-weight: 700; margin-bottom: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding-right: 8px; width: 100%; }` +
			// `.traffit-an-list-widget-list-element .info .details { display: flex; color: var(${fontColorVar}); font-size: 14px; font-weight: 300; }` +
			// ".traffit-an-list-widget-list-element .info .details > div { display: flex; align-items: center; padding-right: 8px; overflow: hidden;}" +
			// ".traffit-an-list-widget-list-element .info .details > div > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }" +
			// `.traffit-an-list-widget-list-element .info .details > div .material-icons { margin-right: 10px; color: var(${leadingColorVar}); font-size: 18px; }` +
			// ".traffit-an-list-widget-list-element > div:after { content: ''; float: none; clear: both; display: block; }" +
			// `#traffit-an-list-widget #xtxrxaxfxixtx2x0x1x6x-pagination-div > div:not(.xxxseparatorxxxtraffit) { display: inline-block; border-radius: 3px; border: 1px solid #b3b3b3; background-color: var(${backgroundColorVar});color: var(${fontColorVar}); text-align: center; line-height: 30px; width: 30px; height: 30px; cursor: pointer; margin: 4px; }` +
			// `#traffit-an-list-widget #xtxrxaxfxixtx2x0x1x6x-pagination-div > div.xxxactivexxxtraffit { background: var(${fontColorVar}); color: var(${backgroundColorVar}); border-color: var(${fontColorVar}); }` +
			// `#traffit-an-list-widget #xtxrxaxfxixtx2x0x1x6x-pagination-div > div.xxxactivexxxtraffit:hover { ${hoverFilter} }` +
			// "#traffit-an-list-widget #xtxrxaxfxixtx2x0x1x6x-pagination-div > div.xxxseparatorxxxtraffit { display: inline-block; line-height: 30px; width: 30px; height: 30px; cursor: default; margin: 4px; text-align: center; }" +
			// `#traffit-an-list-widget #xtxrxaxfxixtx2x0x1x6x-pagination-div > div:not(.xxxseparatorxxxtraffit):not(.xxxactivexxxtraffit):hover { ${hoverFilter} }` +
			// "#traffit-an-filters-xtxrxaxfxixtx2x0x1x6x .traffit-xx-filter-clear { font-size: 12px; cursor: pointer; }" +
			// `#traffit-pagin-xxx-counter:not(:empty), .traffit-xx-filter-clear { font-size: 12px; background-color: var(${backgroundColorVar}); border-radius: 3px; padding: 2px 8px; }` +
			// ".traffit-xx-pagination-bottom > div { width: 50%; display: inline-block; }" +
			// ".traffit-xx-pagination-bottom > div:last-child { text-align: right; }" +`.traffit-xx-info-box { margin-top: 16px; display: grid; place-items: center; color: var(${fontColorVar}); background-color: var(${backgroundColorVar});  padding: 0 50px; height: 120px; border-radius: 12px; box-shadow: 0 0 25px 2px rgba(137, 187, 219, 0.2); }` +
			//   ".traffit-xx-info-box:empty { display: none;}" +
			// ".traffit-xx-loader { position: fixed; left: 0; top: 0; width: 100%; height: 100%; text-align: center; }" +
			// ".traffit-xx-loader > div { position: absolute; width: 50px; height: 50px; left: 50%; top: 50%; margin: -25px 0 0 -25px; background: white; border-radius: 50%; padding: 5px; box-shadow: 0px 1px 2px #c5c5c5; }" +
			// "#traffit-an-list-widget select, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x select, #traffit-an-list-widget input, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x input, #traffit-an-filters-xtxrxaxfxixtx2x0x1x6x button { border-radius: 5px; }" +
			// `.btn-container__button { display: flex; justify-content: center; align-items: center; cursor: pointer; border-radius: 8px; background-color: var(${leadingColorVar}); color: white; font-size: 14px; font-weight: 400; text-transform: uppercase; padding: 15px 40px;  text-decoration: none; white-space: nowrap; }` +
			// ".btn-container__button:hover, .btn-container__button:active, .btn-container__button:focus, .btn-container__button:visited { text-decoration: none; }" +
			// `.btn-container__button--text-only { background: none; color: var(${leadingColorVar}); padding: 0; }` +
			// `.btn-container__button--text-only span { max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }` +
			// ".btn-container__button .material-icons { transition: transform 0.2s ease-in-out; }"+
			// ".btn-container__button--opened .material-icons { transform: rotate(-90deg); }" +
			// ".btn-container--align-start { justify-content: flex-start;}" +
			"</style>"

		var htmlDiv
		// if(scriptConfig.customTraffitRowString && scriptConfig.customTraffitRowString.length > 0){
		//   htmlDiv = scriptConfig.customTraffitRowString;
		// }else{
		htmlDiv_OLD =
			"<div class='111 job-post-item d-flex justify-content-between align-items-center {{awarded}}'>" +
        "<div class='job-left'>" +
            "<h2><a href='{{url}}' target='_blank'>{{name}}</a></h2>" +
            "<span>{{date}}</span>" +
        "</div>" +
        "<div class='job-left'>" +
          "<a class='theme-btns' href='{{url}}' target='_blank'>Apply Now</a>" +
        "</div>" +
			"</div>"
		htmlDiv =
			"<div class='col-12 col-sm-6 col-md-6 col-lg-4 traffit-single-element {{awarded}}' onclick=\"window.open('{{url}}')\">" +
        "<div class='traffit-single-element-wrapper'>" +
          "<div class='info-title'>" +
            `<h2 class='title'>{{name}}</h2>` +
            // "<div class='details'><div class='traffit-flex-no-shrink'><i class='material-icons'>calendar_today</i><span>{{date}}</span></div>{{geolocationHTML}}</div>" +
          "</div>" +
          "<div class='info-location'>" +
            "<p>{{cityName}}</p>" +
          "</div>" +
          "<div class='info-salary'>" +
            "<p>{{money}}</p>" +
          "</div>" +
          "<div class='btn-container'>" +
          "<div class='btn-container__button btn-container__button--text-only'>" +
						// "<span title='{{readMore}}' >{{readMore}}</span>" +
						"<span title='READ MORE' >READ MORE</span>" +
            "</div>" +
          "</div>" +
        "</div>" +
			"</div>"
		// }

		var filtersInterior =
			`<div class='traffit-xx-flex-container'><input type='text' placeholder='${t(
				"keyword"
			)}' name='query' class='traffit-xx-flex-big traffit-xx-input'/>` +
			`<input type='text' placeholder='${t(
				"location"
			)}' name='geolocation' class='traffit-xx-flex-no-shrink traffit-xx-input'/>` +
			`<button onclick='xxtraffixxlist.search()' class='traffit-xx-flex-no-shrink'>${t(
				"search"
			)}</button></div>` +
			`<div style='margin-top:8px;' class='traffit-xx-pagination-bottom'><div><span class='traffit-xx-filter-clear' onclick='xxtraffixxlist.clear()'>${t(
				"clearForm"
			)}</span></div><div><span id='traffit-pagin-xxx-counter'></span></div></div>`

		var paginationInterior =
			"<div onclick='xxtraffixxlist.changePage({{page}})' class='{{class}} '>{{page}}</div>"
		var paginationInteriorSeparator =
			"<div class='xxxseparatorxxxtraffit'>...</div>"

		String.prototype.template = function (data) {
			var i
			var that = this.toString()
			for (i in data) {
				var regExp = new RegExp("{{" + i + "}}", "g")
				that = that.replace(regExp, data[i] || "")
			}

			var regExpClear = /{{(.+?(?=})}})/gi
			that = that.replace(regExpClear, "")

			return that
		}

		var getUrlParameter = function getUrlParameter(sParam) {
			var sPageURL = decodeURIComponent(window.location.search.substring(1)),
				sURLVariables = sPageURL.split("&"),
				sParameterName,
				i

			for (i = 0; i < sURLVariables.length; i++) {
				sParameterName = sURLVariables[i].split("=")

				if (sParameterName[0] === sParam) {
					return sParameterName[1] === undefined ? true : sParameterName[1]
				}
			}
		}

		var formatDate = function (date) {
			date = new Date(parseInt(date + "000"))

			var month = date.getMonth() + 1
			var day = date.getDate()
			var year = date.getFullYear()
			if (month < 10) {
				month = "0" + month.toString()
			}
			if (day < 10) {
				day = "0" + day.toString()
			}
			return "{{dd}}/{{mm}}/{{rrrr}}".template({
				dd: day,
				mm: month,
				rrrr: year,
			})
		}

		var filtering = function (key, value, type) {
			if (!value || value === "") {
				delete request.obj[key]
			} else {
				type = type || "like"

				if (type === "like") {
					value = "%" + value + "%"
				}

				request.obj[key] = {
					field: key,
					values: value,
					comparision: type,
					type: type,
				}
			}
		}

		var sendRequestAnotherSite = function () {
			var filterObj = {}
			for (var i in request.obj) {
				if (!request.obj.hasOwnProperty(i)) continue
				filterObj[i] = request.obj[i].values.replace(/^%/, "").replace(/%$/, "")
			}
			if (request.query) {
				filterObj.query = request.query
			}
		}

		var sendRequest = function () {
			loader.show()
			var req = {
				limit: request.limit,
				offset: request.offset,
			}

			if (request.filter.length) {
				req.filter = { fields: request.filter }
			}

			if (request.query) {
				req.filter = req.filter || {}
				req.filter.query = request.query
			}

			var isAwarded = ""
			if (isAwarded === "1") {
				req.awarded = 1
			}
			if (isAwarded === "0") {
				req.awarded = 0
			}

			var languageString = "" || ""
			if (languageString !== "") {
				req.language = languageString
			}

			if (scriptType === "filters") {
				sendRequestAnotherSite()
				return
			}

			$.ajax({
				url: traffitSite + "public/an/list/",
				dataType: "jsonp",
				data: req,
				jsonpCallback: "xxtraffixxlist.callback",
			})
		}

		var paginationStandard = function (pages) {
			for (var i = 1; i <= pages; i++) {
				var cls = i === request.page ? "xxxactivexxxtraffit" : ""
				var pageData = {
					page: i,
					class: cls,
				}
				paginationDiv.append(paginationInterior.template(pageData))
			}
		}

		var generatePagination = function (fr, to) {
			for (var i = fr; i <= to; i++) {
				var cls = i === request.page ? "xxxactivexxxtraffit" : ""
				var pageData = {
					page: i,
					class: cls,
				}
				paginationDiv.append(paginationInterior.template(pageData))
			}
		}

		var paginationLeft = function (pages) {
			generatePagination(1, 7)
			paginationDiv.append(paginationInteriorSeparator)
			generatePagination(pages - 2, pages)
		}

		var paginationRight = function (pages) {
			generatePagination(1, 3)
			paginationDiv.append(paginationInteriorSeparator)
			generatePagination(pages - 6, pages)
		}
		var paginationCenter = function (pages) {
			generatePagination(1, 2)
			paginationDiv.append(paginationInteriorSeparator)
			generatePagination(request.page - 2, request.page + 2)
			paginationDiv.append(paginationInteriorSeparator)
			generatePagination(pages - 1, pages)
		}

		var createPagination = function (num) {
			var pages = Math.ceil(num / request.limit)
			paginationDiv.html("")
			if (pages <= 1) return
			if (pages <= 11) {
				paginationStandard(pages)
			} else if (request.page < 7) {
				paginationLeft(pages)
			} else if (pages - request.page <= 5) {
				paginationRight(pages)
			} else {
				paginationCenter(pages)
			}
		}

		var setFilterValues = function (obj, div) {
			for (var i in obj.filter) {
				if (!obj.filter.hasOwnProperty(i)) continue
				div.find('[name="' + i + '"]').val(obj.filter[i])
			}
			window.xxtraffixxlist.search()
		}

		var isJSONString = function (string) {
			try {
				JSON.parse(string)
			} catch (e) {
				return false
			}
			return true
		}

		window.xxtraffixxlist = {
			callback: function (data) {
				var items = data.items

				listDiv.html("")
				infoDiv.text("")
				for (var i = 0; i < items.length; i++) {
					;(function () {
						items[i].name = escapeHtml(items[i].name)
						var fillData = {
							name: items[i].name,
							nrRef: items[i].nrRef,
							date: formatDate(items[i].validStart),
							url: items[i].url,
							location: items[i].location,
							awarded: items[i].awarded
								? "traffit-an-list-widget-awarded"
								: "",
						}
						$.extend(fillData, items[i])
						fillData.date = formatDate(items[i].validStart)
						fillData.awarded = items[i].awarded
							? "traffit-an-list-widget-awarded"
							: ""
						var geo =
							items[i].geolocation && isJSONString(items[i].geolocation)
								? JSON.parse(items[i].geolocation)
								: {}
						fillData.geolocation = geo.hasOwnProperty("locality")
							? geo.locality
							: ""
						fillData.geolocationHTML = fillData.geolocation
							? "<div><i class='material-icons'>room</i><span>" +
							  fillData.geolocation +
							  "</span></div>"
							: ""

						fillData.readMore = t("readMore")
            fillData.cityName = items[i].x_location
            fillData.money = items[i].money

						listDiv.append(htmlDiv.template(fillData))
					})()
				}

				if (data.count === 0) {
					counterSpan.text("")
					infoDiv.text(t("advertsNotFound"))
				} else if (data.count > 0) {
					counterSpan.text(`${t("advertsFound")}: ${data.count}`)
				}

				createPagination(data.count)
				loader.hide()
				changeButtonsColor()
			},
			search: function () {
				$.each(filtersDiv.find("input, select"), function (i, el) {
					var $el = $(el)
					var name = $el.attr("name")
					var value = $el.val()
					var type = $el.attr("data-search")
          var geolocation = $el.attr("geolocation")

					switch (name) {
						case "query":
							request.obj.fields = {
								field: "title",
								values: `%${value}%`,
								comparision: "like",
								type: "like",
							}
							break
						default:
							filtering(name, value, type)
					}
				})

				request.filter.length = 0
				for (var i in request.obj) {
					if (!request.obj.hasOwnProperty(i)) continue
					request.filter.push(request.obj[i])
				}

				request.offset = 0
				request.page = 1
				sendRequest()
			},
			changePage: function (page) {
				request.offset = (page - 1) * request.limit
				request.page = page
				sendRequest()
			},
			clear: function () {
				request.offset = 0
				request.page = 1
				request.filter.length = 0
				delete request.query

				$.each(filtersDiv.find("input, select"), function (i, el) {
					var $el = $(el)
					var name = $el.attr("name")
					$el.val("")
					filtering(name)
				})

				sendRequest()
			},
		}

		var coreFunc = function () {
			coreDiv = $("#" + divId)
			filtersDiv = $("#" + filterId)
			var regExp =
				/(traffit\.com\/.*career.*)|(traffit\.local:1025\/.*career.*)/

			if (!regExp.test(window.location.href)) {
				$("head").append(fontUrl).append(iconsFont).append(outsideStyles)
			}

			const isWithinAts = !!document.querySelector(
				'script[data-name="traffit"]'
			)

			if (!isWithinAts && scriptConfig.additionalStyles) {
				$("head").append("<style>" + scriptConfig.additionalStyles + "</style>")
			}

			paginationDiv = $("<div id={{id}}></div>".template({ id: paginationId }))
			listDiv = $("<div id={{id}} class='job-post-wrapper row'></div>".template({ id: listId }))
			loader = $(
				'<div class="traffit-xx-loader"><div><img src="https\u003A//cdn3.traffit.com/23S40256/bundles/traffitfrontend/images/ajax\u002Dloader.gif" alt/></div></div>'.template(
					{ site: traffitSite.replace("app_dev.php/", "") }
				)
			)
			infoDiv = $('<div class="traffit-xx-info-box"></div>')
			coreDiv.append(loader).append(infoDiv)

			filtersDiv.append(filtersInterior)

			filtersDiv.find("input").keydown(function (e) {
				if (e.keyCode === 13) {
					window.xxtraffixxlist.search()
				}
			})

			counterSpan = filtersDiv.find("#traffit-pagin-xxx-counter")

			if (coreDiv.length > 0) {
				coreDiv.append(listDiv).append(paginationDiv)
				scriptType = "all"

				var filter = $.deparam(
					window.location.search.substring(1, window.location.search.length)
				)

				if (filter.filter && filtersDiv.length > 0) {
					setFilterValues(filter, filtersDiv)
				} else if (filter.filter) {
					for (var i in filter.filter) {
						if (!filter.filter.hasOwnProperty(i)) continue
						switch (i) {
							case "query":
								request.query = filter.filter[i]
								break
							case "advert.values.fieldId":
								request.filter.push({
									field: i,
									values: "location",
									comparision: "=",
									type: "=",
								})
								break
							default:
								request.filter.push({
									field: i,
									values: "%" + filter.filter[i] + "%",
									comparision: "like",
									type: "like",
								})
						}
					}

					sendRequest()
				} else {
					sendRequest()
				}
			}
		}

		function changeButtonsColor() {
			var searchButton = $("#traff-xx-search-button")
			var backgroundColor = searchButton.css("background-color")

			if (searchButton.length) {
				var rgbColor = backgroundColor,
					rgbSeparate = rgbColor
						.substring(rgbColor.indexOf("(") + 1, rgbColor.lastIndexOf(")"))
						.split(/,\s*/),
					rgbRed = rgbSeparate[0],
					rgbGreen = rgbSeparate[1],
					rgbBlue = rgbSeparate[2],
					yiq = (rgbRed * 299 + rgbGreen * 587 + rgbBlue * 114) / 1000

				searchButton.css("color", yiq >= 128 ? "#000000" : "#ffffff")
			}
		}

		try {
			$(coreFunc)
		} catch (e) {
			console.error(e)
		}
	})()
}
