{"version":3,"file":"js/scripts_libraries__utilities_lib_js.js?_t=57f572d90e01429159bb","mappings":";;;;;;;;;;;;;;AAAA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAGA;AACA;AAAA;AAEA;;;;;;;;;;;;;;;;AC5BA;AAEA;AAAA;AAEA;AACA;AAAA;AACA;AAAA;AACA;AAGA;AACA;AAEA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AACA;AAAA;AACA;AACA;AAGA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AAAA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxFA;AAGA;AAGA;AAKA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AAGA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAEA;AAEA;AACA;AAKA;AAIA;AACA;AAEA;AACA;AACA;AAyBA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AAIA;AAEA;AACA;AACA;AAAA;AAEA;AAAA;AAGA;AACA;AAYA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AACA;AACA;AAkBA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAWA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AAEA;AACA;;;;;;;;;;;;;;;;;;;AC3RA;AACA;AACA;AAEA;AAAA;AAEA;AAEA;AACA;AAAA;AACA;AACA;AAGA;AAAA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AAAA;AACA;AACA;AAGA;AAAA;AACA;AAEA;AAAA;AACA;AAGA;AAAA;AACA;AAGA;AAAA;AACA;AAEA;AAAA;AACA;AAEA;AAAA;AACA;AAEA;AAGA;AACA;AAKA;AACA;AAAA;AAIA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAIA;AAEA;AACA;AAAA;AACA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AAAA;AACA;AACA;AAGA;AAAA;AAEA;;;;;;;;;;;;;;;;;;;AC7HA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA","sources":["webpack://@mlssoccer/netcore/./scripts/libraries/_components/03-organisms/dateTimeConverter/dateTimeConverter.js","webpack://@mlssoccer/netcore/./scripts/libraries/_components/03-organisms/search-dropdown/search.js","webpack://@mlssoccer/netcore/./scripts/libraries/_helpers/index.js","webpack://@mlssoccer/netcore/./scripts/libraries/_modules/carousels.js","webpack://@mlssoccer/netcore/./scripts/libraries/_utilities/lib.js"],"sourcesContent":["import { x0, x } from '../../../_helpers';\nexport default class DateTimeConverter {\n constructor() {\n this.el = x0('article');\n if (!this.el) return;\n this.init();\n }\n\n convertUtcToLocal() {\n if (this.dateTimeElements.length > 0) {\n this.dateTimeElements.forEach((element) => {\n const dateValue = element.getAttribute('data-datetime');\n if (!dateValue) {\n return;\n }\n const utcDateTime = dateValue.concat(' UTC');\n const parsedDateTime = new Date(Date.parse(utcDateTime));\n const options = { weekday: 'long', month: 'short', day: 'numeric', year: 'numeric', hour: '2-digit', minute: '2-digit' }; //Format: Thursday, Apr 16, 2020 03:52 AM\n const dateTimeLocal = parsedDateTime.toLocaleDateString('en-US', options);\n element.innerHTML = dateTimeLocal;\n });\n }\n }\n\n init() {\n this.dateTimeElements = x('[js-date-time-to-convert]');\n this.convertUtcToLocal();\n }\n}\n","import { x0, x } from \"../../../_helpers\";\n\nexport default class Search {\n constructor() {\n this.el = x0(\".fo-search-btn\");\n if (!this.el) return;\n this.init();\n }\n\n toggleSearch(e, isSearchOpen) {\n e.preventDefault();\n this.searchField = x0(\"[js-search]\");\n\n if (!this.searchField) {\n return;\n }\n\n if (isSearchOpen) {\n const searchClose = this.searchField.querySelector(\".fo-search__close\"); // Sostituisci 'selettore' con il selettore dell'elemento\n if (searchClose) {\n searchClose.removeAttribute('aria-label');\n searchClose.setAttribute(\"aria-hidden\", \"true\");\n }\n\n this.searchField.classList.remove(\"-is-active\");\n this.searchField.setAttribute('aria-hidden', 'true');\n document.body.classList.remove('-search-is-open');\n\n const accessibleElements = this.searchField.querySelectorAll('[tabindex=\"0\"]');\n if (accessibleElements?.length) {\n accessibleElements.forEach(element => {\n element.setAttribute('tabindex', '-1');\n element.setAttribute('aria-hidden', 'true')\n });\n }\n } else {\n const searchClose = this.searchField.querySelector(\".fo-search__close\"); // Sostituisci 'selettore' con il selettore dell'elemento\n if (searchClose) {\n searchClose.setAttribute(\"aria-label\", \"Close search panel\");\n searchClose.setAttribute(\"aria-hidden\", \"false\");\n }\n\n this.searchField.classList.add(\"-is-active\");\n this.searchField.setAttribute('aria-hidden', 'false');\n document.body.classList.add('-search-is-open');\n\n const accessibleElements = this.searchField.querySelectorAll('[tabindex=\"-1\"]');\n if (accessibleElements?.length) {\n accessibleElements.forEach(element => {\n element.setAttribute('tabindex', '0');\n element.setAttribute('aria-hidden', 'false')\n });\n }\n }\n\n const input = x0(\"input\", this.searchField);\n if (input) {\n input.focus();\n }\n }\n\n attachEvents() {\n const that = this;\n //open search\n\n if (this.searchOpener.length > 0) {\n this.searchOpener.forEach((el) => {\n el.addEventListener(\"click\", function (e) {\n that.toggleSearch(e, false);\n });\n });\n }\n\n if (this.searchCloser.length > 0) {\n this.searchCloser.forEach((el) => {\n el.addEventListener(\"click\", function (e) {\n that.toggleSearch(e, true);\n });\n });\n }\n }\n\n init() {\n this.searchOpener = x(\"[js-search-open]\");\n this.searchCloser = x(\"[js-menu-close]\");\n\n this.attachEvents();\n }\n}\n","export const x = (selector, context = document) =>\n context.querySelectorAll(selector);\n\nexport const x0 = (selector, context = document) =>\n context.querySelector(selector);\n\nexport const isTouch = (() =>\n \"ontouchstart\" in window ||\n navigator.MaxTouchPoints > 0 ||\n navigator.msMaxTouchPoints > 0)();\n\nexport const doubleDigitIntDisplay = (count) => {\n return count < 10 ? \"0\" + count : count;\n};\n\nexport function parseCSSText(cssText) {\n const cssTxt = cssText.replace(/\\/\\*(.|\\s)*?\\*\\//g, \" \").replace(/\\s+/g, \" \");\n const style = {};\n const rule = (cssTxt.match(/ ?(.*?) ?{([^}]*)}/) || [])[2] || cssTxt;\n const cssToJs = (s) =>\n s.replace(/\\W+\\w/g, (match) => match.slice(-1).toUpperCase());\n const properties = rule\n .split(\";\")\n .map((o) => o.split(\":\").map((x) => x && x.trim()));\n for (const [property, value] of properties) style[cssToJs(property)] = value;\n return style;\n}\n\nexport function truncateString(str, length = 7) {\n if (!str) {\n return null;\n }\n\n return str.length > length ? `${str.slice(0, length)}...` : str;\n}\n\nexport const callAll = (...fns) => (...args) =>\n fns.forEach((fn) => fn?.(...args));\n\nexport const mediaQueries = {\n screenSmallMin: \"(min-width: 375px)\",\n screenSmall: \"(min-width: 375px) and (max-width: 767px)\",\n screenSmallMax: \"(max-width: 767px)\",\n screenMediumMin: \"(min-width: 768px)\",\n screenMedium: \"(min-width: 768px) and (max-width: 1079px)\",\n screenMediumMax: \"(max-width: 1079px)\",\n screenMediumLargeMin: \"(min-width: 1080px)\",\n screenMediumLarge: \"(min-width: 1080px) and (max-width: 1439px)\",\n screenMediumLargeMax: \"(min-width: 1439px)\",\n screenLargeMin: \"(min-width: 1440px)\",\n screenLarge: \"(min-width: 1440px) and (max-width: 1647px)\",\n screenLargeMax: \"(max-width: 1647px)\",\n screenXLargeMin: \"(min-width: 1648px)\",\n screenXLarge: \"(min-width: 1648px) and (max-width: 1919px)\",\n screenXLargeMax: \"(max-width: 1919px)\",\n screenXXLargeMin: \"(min-width: 1920px)\",\n};\n\nexport function formatMillisecondToHumanMinute(ms) {\n if (!ms || ms < 1000) {\n return null;\n }\n const date = new Date(1000 * Math.round(ms / 1000)); // round to nearest second\n\n if (date.getUTCHours() !== 0) {\n return (\n date.getUTCHours() +\n \":\" +\n pad(date.getUTCMinutes()) +\n \":\" +\n pad(date.getUTCSeconds(), true)\n );\n }\n\n return pad(date.getUTCMinutes()) + \":\" + pad(date.getUTCSeconds(), true);\n}\n\nfunction pad(i, includeZeroPrefix = false) {\n return (`${includeZeroPrefix ? \"0\" : \"\"}` + i).slice(-2);\n}\n\n// export const getOffsetTop = (elem) => {\n// let offsetTop = 0;\n// do {\n// if (!isNaN(elem.offsetTop)) {\n// offsetTop += elem.offsetTop;\n// }\n// } while ((elem = elem.offsetParent));\n// return offsetTop;\n// };\n//\n// export const getScrollTop = () => {\n// if (typeof pageYOffset != 'undefined') {\n// return pageYOffset;\n// } else {\n// let doc = document,\n// B = doc.body,\n// D = doc.documentElement;\n//\n// D = D.clientHeight ? D : B;\n// return D.scrollTop;\n// }\n// };\n\nexport const encodeURLComponent = (str) => {\n return encodeURIComponent(str).replace(/[!'()*]/g, escape);\n};\n\nexport const getFirstCharacter = (str) => {\n if (!str) {\n return \"\";\n }\n\n return str.charAt(0);\n};\n\nexport const getParametersFromURL = () => {\n const re = /(?:\\?|&(?:amp;)?)([^=&#]+)(?:=?([^&#]*))/g,\n params = {},\n url = document.location.href,\n decode = (s) => decodeURIComponent(s.replace(/\\+/g, \" \"));\n let match;\n\n while ((match = re.exec(url))) {\n if (!params[decode(match[1])]) {\n params[decode(match[1])] = [];\n }\n params[decode(match[1])].push(decode(match[2]));\n }\n\n return params;\n};\n\n// export const closest = (el, parentClass) => {\n// do {\n// if (el.classList && el.classList.contains(parentClass)) {\n// return el;\n// }\n// } while ((el = el.parentNode));\n//\n// return null;\n// };\n\nexport const minmax = (value, min, max) => {\n const valueInt = parseInt(value, 10);\n if (isNaN(valueInt) || valueInt < min) return min;\n else if (valueInt > max) return max;\n else return value;\n};\n\n// export const setScrollTop = (offset = 0) => {\n// document.documentElement.scrollTop = document.body.scrollTop = offset;\n// };\n//\n// export const getSiblings = (elem) => {\n// const siblings = [];\n// let sibling = elem.parentNode.firstChild;\n// while (sibling) {\n// if (sibling.nodeType === 1) {\n// siblings.push(sibling);\n// }\n// sibling = sibling.nextSibling;\n// }\n// return siblings;\n// };\n\nexport function checkIfObject(obj) {\n return obj != null && obj.constructor.name === \"Object\";\n}\n\nexport function calculateDistanceBetweenTwoNumbers(firstValue, secondValue) {\n if (firstValue === secondValue) {\n return 50;\n }\n const sum = firstValue + secondValue;\n const percentageDifference = (firstValue * 100) / sum;\n\n return !percentageDifference ? 1 : percentageDifference;\n}\n\nexport function calculateDistanceBetweenTwoDecimals(firstValue, secondValue) {\n if (firstValue === secondValue) {\n return 50;\n }\n\n const sum = Number(firstValue) + Number(secondValue);\n const percentageDifference = (Number(firstValue) * 100) / sum;\n\n return !percentageDifference ? 1 : percentageDifference;\n}\n\nexport function percentDiff(first, second, isRounded = false) {\n if (first == null || isNaN(first) || second == null || isNaN(second)) {\n return 0;\n }\n\n const sum = first + second;\n const percentageDifference = (first * 100) / sum;\n\n let value;\n value = percentageDifference;\n\n return isRounded ? round(value, 1) : value;\n}\n\nexport function round(number, decimalSpot = 2) {\n if (typeof number !== \"number\") {\n return number;\n }\n\n return Number(number.toFixed(decimalSpot));\n}\n\nexport function decimalRound(number, decimalSpot = 2) {\n if (typeof number !== \"number\") {\n return number;\n }\n\n return eval((Math.round(number * 100) / 100).toFixed(decimalSpot));\n}\n\nexport function calculatePercentage(partialValue, totalValue) {\n if (!partialValue || !totalValue) {\n return decimalRound(0, 1);\n }\n\n return decimalRound((100 * partialValue) / totalValue, 1);\n}\n\nexport function calculateSubtractedValues(firstValue = 0, secondValue = 0) {\n if ((firstValue || firstValue === 0) && (secondValue || secondValue === 0)) {\n return firstValue - secondValue;\n }\n\n return 0;\n}\n\nexport function calculateSum(firstValue = 0, secondValue = 0) {\n if ((firstValue || firstValue === 0) && (secondValue || secondValue === 0)) {\n return firstValue + secondValue;\n }\n\n return 0;\n}\n\nexport function titleCase(str) {\n const splitStr = str.toLowerCase().split(\" \");\n for (let i = 0; i < splitStr.length; i++) {\n splitStr[i] =\n splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);\n }\n return splitStr.join(\" \");\n}\n\nexport function getPercentageFromDecimal(decimal) {\n return decimal * 100;\n}\n\n//\n// export const isDesktop = () => window.outerWidth >= 1440;\n// export const isTablet = () => window.outerWidth >= 768 && window.outerWidth < 1440;\n// export const isMobile = () => window.outerWidth < 768;\n// export const isIOS = (() => /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)();\n// export const isIE11 = !!(\n// navigator.userAgent.match(/Trident/) && navigator.userAgent.match(/rv[ :]11/)\n// );\n\nexport function replaceAmpersand(str) {\n return String(str).replace(/&/g, \"&\");\n}\n\nexport function splitAndTrimStr(str) {\n if (str == null) {\n return [];\n }\n\n return str.split(\",\").map((word) => word.trim());\n}\n\nexport function IsMlsCompetition(compettionId) {\n const mlsIds =\n window.forgeVariables?.match?.competitionsWithFirstSecondAssists ?? \"\";\n return mlsIds.includes(compettionId);\n}\n","import { each } from 'lodash';\nimport Swiper from 'swiper/bundle';\nimport { x } from '../_helpers';\n\nexport default class Carousels {\n constructor() {\n this.carousels = x(\"[js-carousel]\");\n\n if (this.carousels) {\n this.init();\n }\n }\n\n initCarousel(el) {\n const carousel = new Swiper(el, {\n speed: 600,\n slidesPerView: el.hasAttribute(\"js-carousel-gallery\") ? 1 : \"auto\",\n autoplay: el.hasAttribute('js-carousel-autoplay')\n ? {\n delay: 4000,\n }\n : false,\n navigation: {\n nextEl: el.querySelector('[js-carousel-trigger-next]'),\n prevEl: el.querySelector('[js-carousel-trigger-prev]'),\n },\n pagination: {\n el: el.querySelector(\"[js-carousel-pagination]\"),\n type: el.hasAttribute(\"js-carousel-fraction-pagination\")\n ? \"fraction\"\n : \"bullets\",\n },\n });\n if (el.hasAttribute(\"js-carousel-gallery\")) {\n this.createGallery(el, carousel);\n }\n }\n createGallery(el, carousel) {\n // ELEMENTS\n const paginationWrapper = el.parentNode.parentNode.querySelector(\n \".swiper-info__pagination\"\n );\n const photoWrapper = el.parentNode.parentNode.querySelector(\n \".swiper-wrapper-info .swiper-info__photo\"\n );\n\n const photoWrapperCaption = el.parentNode.parentNode.querySelector(\n \".swiper-wrapper-info-caption .swiper-info__photo-caption\"\n );\n\n const fullscreenWrapper = el.parentNode.parentNode.querySelector(\n \".swiper-info__fullscreen\"\n );\n const paginationCurrent = paginationWrapper.querySelector(\n \".swiper-info__pagination--current\"\n );\n const paginationTotal = paginationWrapper.querySelector(\n \".swiper-info__pagination--total\"\n );\n let photoCaption = photoWrapper\n ? photoWrapper.querySelector(\".swiper-info__photo h1\")\n : undefined;\n photoCaption = photoCaption ? photoCaption : photoWrapper.querySelector(\".swiper-info__photo div\");\n const photoDescription = photoWrapperCaption\n ? photoWrapperCaption.querySelector(\".swiper-info__photo-caption span\")\n : undefined;\n\n // FULLSCREEN\n fullscreenWrapper.addEventListener(\"click\", () => {\n el.querySelector(\".swiper-slide-active a\").click();\n });\n\n // PAGINATION && TEXT\n carousel.on(\"paginationUpdate\", (swiper, paginationEl) => {\n this.setPagination(paginationCurrent, paginationTotal, paginationEl);\n });\n carousel.on(\"slideChangeTransitionEnd\", (swiper) => {\n const target = el.querySelector(\".swiper-slide-active a\");\n this.setInfo(photoCaption, photoDescription, target);\n });\n\n // INITIALIZE\n const target = el.querySelector(\".swiper-slide-active a\");\n\n this.setInfo(photoCaption, photoDescription, target);\n carousel.pagination.update();\n }\n\n setPagination(paginationCurrent, paginationTotal, paginationEl) {\n if (paginationCurrent) {\n paginationCurrent.innerHTML = (\n paginationEl.querySelector(\".swiper-pagination-current\") || {\n innerText: \"\",\n }\n ).innerText;\n }\n if (paginationTotal) {\n paginationTotal.innerHTML = (\n paginationEl.querySelector(\".swiper-pagination-total\") || {\n innerText: \"\",\n }\n ).innerText;\n }\n }\n\n setInfo(photoCaption, photoDescription, target) {\n if (photoCaption) {\n const caption = target.getAttribute(\"data-caption\");\n photoCaption.innerHTML = caption;\n }\n if (photoDescription) {\n const desc = target.getAttribute(\"data-desc\");\n photoDescription.innerHTML = desc;\n }\n }\n\n handleEvents() {\n each(this.carousels, (el) => {\n this.initCarousel(el);\n });\n }\n\n init() {\n this.handleEvents();\n }\n}\n","import vhCheck from 'vh-check';\nimport { isTouch } from '../_helpers';\nimport { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';\n\nimport Carousels from '../_modules/carousels';\nimport Search from '../_components/03-organisms/search-dropdown/search';\nimport DateTimeConverter from '../_components/03-organisms/dateTimeConverter/dateTimeConverter';\n\nvhCheck();\n\nwindow.disableBodyScroll = disableBodyScroll;\nwindow.enableBodyScroll = enableBodyScroll;\nwindow.clearAllBodyScrollLocks = clearAllBodyScrollLocks;\n\n!isTouch && document.body.classList.add('no-touch');\nisTouch && document.body.classList.add('is-touch');\n\nconst CAROUSELS = new Carousels();\nconst SEARCH = new Search();\nconst DATETIMECONVERTER = new DateTimeConverter();\n"],"names":[],"sourceRoot":""}