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D,KAAKiD,QACtB,CAEOlB,KAAAA,GACHqB,aAAapD,KAAKiD,SAClBjD,KAAKgD,WAAaK,KAAKC,KAAI,IAAIZ,MAAOC,UAAY3C,KAAKyC,MAAME,UACjE,CAEOV,MAAAA,GACHjC,KAAKyC,MAAQ,IAAIC,KACjBU,aAAapD,KAAKiD,SAClBjD,KAAKiD,QAAUC,OAAOC,WAAWnD,KAAK6C,SAAU7C,KAAKgD,UACzD,E,iBCxCE,SAAU3C,EAAiDkD,EAAgBC,EAAY,IACzF,OAAO,IAAIC,SAASC,IAChB,GAAmC,oBAAxBC,qBAAqC,CAC5C,MAAMC,EAAU,CACZJ,UAAWA,GAGTK,EAAW,IAAIF,sBAAqB,CAACG,EAASD,KAChDC,EACKC,QAAQC,GAAUA,EAAMC,gBAAkBD,EAAME,mBAAqBV,IACrEW,SAASH,IACNN,EAAIM,GACJH,EAASO,UAAUJ,EAAMK,OAAO,GAClC,GACPT,GAEHC,EAASS,QAAQf,EACrB,MACIG,EAAI,KACR,GAER,C","sources":["webpack://@sazka/web/./js/app/casino/widgets/_hero-carousel.ts","webpack://@sazka/web/../../libs/utils/timer.ts","webpack://@sazka/web/../../libs/utils/viewport-enter.ts"],"sourcesContent":["import { ResponsiveUtils } from \"@sazka/utils/responsive-utils\";\r\nimport { onViewportEnter } from \"@sazka/utils/viewport-enter\";\r\nimport { TimeoutTimer } from \"@sazka/utils/timer\";\r\n\r\nexport class HeroCarousel {\r\n    private $carousel: JQuery<HTMLElement>;\r\n    private $slides: JQuery<HTMLElement>;\r\n    private timer: TimeoutTimer;\r\n    private slideTimeout: number;\r\n    private codeName: string;\r\n\r\n    constructor($carousel: JQuery<HTMLElement>) {\r\n        this.init($carousel);\r\n    }\r\n\r\n    private async init($carousel: JQuery<HTMLElement>) {\r\n        if (!$carousel || $carousel.length === 0) return;\r\n\r\n        this.$carousel = $carousel;\r\n        this.$slides = this.$carousel.find(\".hero-carousel__slide\");\r\n\r\n        if (this.$slides.length <= 1) {\r\n            return;\r\n        }\r\n\r\n        await onViewportEnter($carousel[0], 0);\r\n\r\n        this.slideTimeout = this.$carousel.data(\"slidetimeout\") * 1000;\r\n        this.codeName = this.$carousel.data(\"codename\");\r\n\r\n        this.timer = new TimeoutTimer(() => {\r\n            this.goToNextSlide();\r\n        }, this.slideTimeout);\r\n\r\n        if (ResponsiveUtils.breakpointUp(\"sm\")) {\r\n            this.$carousel.on(\"mouseenter\", () => this.mouseIn(this.$carousel, this.timer));\r\n            this.$carousel.on(\"mouseleave\", () => this.mouseOut(this.$carousel, this.timer));\r\n\r\n            this.$carousel.find(\".hero-carousel__menu--item\").click((e) => {\r\n                const $elem = $(e.currentTarget);\r\n                if ($elem.hasClass(\"active\")) {\r\n                    return;\r\n                }\r\n\r\n                const slideId = $elem.data(\"slide-id\");\r\n                this.changeActiveElements(slideId);\r\n            });\r\n        }\r\n    }\r\n\r\n    private goToNextSlide(): void {\r\n        const $currentSlide = this.$carousel.find(\".hero-carousel__slide.active\");\r\n        if ($currentSlide.length) {\r\n            let $nextSlide = $currentSlide.next();\r\n            if (!$nextSlide.length) {\r\n                $nextSlide = this.$carousel.find(\".hero-carousel__slide\").first();\r\n            }\r\n\r\n            const nextSlideId = $nextSlide.data(\"slide-id\");\r\n            this.changeActiveElements(nextSlideId);\r\n        }\r\n    }\r\n\r\n    private mouseIn($carousel: JQuery<HTMLElement>, timer: TimeoutTimer): void {\r\n        $carousel.addClass(\"hover\");\r\n        timer.pause();\r\n    }\r\n\r\n    private mouseOut($carousel: JQuery<HTMLElement>, timer: TimeoutTimer): void {\r\n        $carousel.removeClass(\"hover\");\r\n        timer.resume();\r\n    }\r\n\r\n    private changeActiveElements(slideId: number): void {\r\n        this.$carousel.find(\".hero-carousel__menu--item, .hero-carousel__slide\").removeClass(\"active\");\r\n\r\n        // change active slide\r\n        this.$carousel.find(`.hero-carousel__slide[data-slide-id=${slideId}]`).addClass(\"active\");\r\n\r\n        // change active slide in menu\r\n        this.$carousel.find(`.hero-carousel__menu--item[data-slide-id=${slideId}]`).addClass(\"active\");\r\n\r\n        this.resetTimer();\r\n    }\r\n\r\n    private resetTimer(): void {\r\n        if (this.timer) {\r\n            this.timer.clear();\r\n\r\n            this.timer = new TimeoutTimer(() => {\r\n                this.goToNextSlide();\r\n            }, this.slideTimeout);\r\n\r\n            if (this.$carousel.hasClass(\"hover\")) {\r\n                this.timer.pause();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n$(() => {\r\n    const $root = $(\".hero-carousel\");\r\n    if (!$root.length) {\r\n        return;\r\n    }\r\n\r\n    $root.each((_, item) => {\r\n        const $carousel = $(item);\r\n        new HeroCarousel($carousel);\r\n    });\r\n});\r\n","export class Timer {\r\n    start: Date;\r\n\r\n    constructor() {\r\n        this.start = new Date();\r\n    }\r\n\r\n    public getTime(): number {\r\n        return new Date().getTime() - this.start.getTime();\r\n    }\r\n\r\n    public reset(): void {\r\n        this.start = new Date();\r\n    }\r\n}\r\n\r\n/**\r\n *\r\n * @param {Function} callback to call when complete\r\n * @param {Number} delay in milliseconds\r\n */\r\nexport class TimeoutTimer extends Timer {\r\n    timerId: number;\r\n    remaining: number;\r\n    callback: () => void;\r\n\r\n    constructor(callback: () => void, delay: number) {\r\n        super();\r\n        this.remaining = delay;\r\n        this.callback = callback;\r\n\r\n        this.timerId = window.setTimeout(this.callback, this.remaining);\r\n    }\r\n\r\n    public clear(): void {\r\n        clearTimeout(this.timerId);\r\n    }\r\n\r\n    public pause(): void {\r\n        clearTimeout(this.timerId);\r\n        this.remaining -= Math.abs(new Date().getTime() - this.start.getTime());\r\n    }\r\n\r\n    public resume(): void {\r\n        this.start = new Date();\r\n        clearTimeout(this.timerId);\r\n        this.timerId = window.setTimeout(this.callback, this.remaining);\r\n    }\r\n}\r\n","/**\r\n * Returns a Promise that resolves when the given HTML element enters the viewport.\r\n *\r\n * @param {HTMLElement | Element} htmlElement - The HTML element to observe.\r\n * @param {number} [threshold=0.7] - The threshold for intersection.\r\n * @return {Promise<IntersectionObserverEntry | null>} A Promise that resolves with the intersection entry or null if IntersectionObserver is not supported.\r\n */\r\nexport function onViewportEnter<T extends HTMLElement | Element>(htmlElement: T, threshold = 0.7) {\r\n    return new Promise((res) => {\r\n        if (typeof IntersectionObserver != \"undefined\") {\r\n            const options = {\r\n                threshold: threshold,\r\n            };\r\n\r\n            const observer = new IntersectionObserver((entries, observer) => {\r\n                entries\r\n                    .filter((entry) => entry.isIntersecting && entry.intersectionRatio >= threshold)\r\n                    .forEach((entry) => {\r\n                        res(entry);\r\n                        observer.unobserve(entry.target);\r\n                    });\r\n            }, options);\r\n\r\n            observer.observe(htmlElement as HTMLElement);\r\n        } else {\r\n            res(null);\r\n        }\r\n    });\r\n}\r\n"],"names":["HeroCarousel","constructor","$carousel","_defineProperty","this","init","length","$slides","find","onViewportEnter","slideTimeout","data","codeName","timer","TimeoutTimer","goToNextSlide","ResponsiveUtils","breakpointUp","on","mouseIn","mouseOut","click","e","$elem","$","currentTarget","hasClass","slideId","changeActiveElements","$currentSlide","$nextSlide","next","first","nextSlideId","addClass","pause","removeClass","resume","resetTimer","clear","$root","each","_","item","Timer","start","Date","getTime","reset","callback","delay","super","remaining","timerId","window","setTimeout","clearTimeout","Math","abs","htmlElement","threshold","Promise","res","IntersectionObserver","options","observer","entries","filter","entry","isIntersecting","intersectionRatio","forEach","unobserve","target","observe"],"sourceRoot":""}