WebFontConfig = {
    google: {
        families: ['Open+Sans:400italic,400,600,700&display=swap'],
        timeout: 2000
    },
    custom: {
        families: ['Tiempo,Lufga&display=swap'],
        urls: ['/Themes/Gerdmans2.0/Content/fonts/fonts.css'],
        timeout: 2000
    },
};


(function (d) {
    var wf = d.createElement('script'), s = d.scripts[0];
    wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
    wf.async = true;
    s.parentNode.insertBefore(wf, s);
})(document);

var LazyLoad = /** @class */ (function () {
    function LazyLoad() {
        this.constants = new Constants();
        this.browserSupportLazyLoad = 'loading' in HTMLImageElement.prototype;
        this.browserSupportLazyLoad = false;
        if (this.browserSupportLazyLoad) {
            this.initBrowserLazyLoading();
        }
        else {
            this.initFallbackLazyLoading();
        }
    }
    LazyLoad.prototype.initFallbackLazyLoading = function () {
        var script = document.createElement('script');
        script.src = "/Themes/" + Constants.themeName() + "/content/dist/common.blocks/lazyload/lazysizes.min.js";
        document.body.appendChild(script);
    };
    LazyLoad.prototype.initBrowserLazyLoading = function () {
        var images = document.querySelectorAll('img[loading="lazy"]');
        images.forEach(function (img) {
            img.src = img.dataset.src;
        });
    };
    return LazyLoad;
}());
window.addEventListener("load", function () {
    var menu = new LazyLoad();
});
//# sourceMappingURL=lazyload.js.map
var Constants = /** @class */ (function () {
    function Constants() {
    }
    Constants.themeName = function () {
        return 'Gerdmans2.0';
    };
    return Constants;
}());
//# sourceMappingURL=Constants.js.map
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
/// <reference path="../../../../../typings/globals/underscore/index.d.ts" />
var cart;
(function (cart) {
    var MiniCartController = /** @class */ (function () {
        function MiniCartController(container) {
            this.container = container;
            this.miniCartSService = new MiniCartService();
        }
        MiniCartController.prototype.initEvents = function () {
            var _this = this;
            document.querySelectorAll(".quantityInput-js").forEach(function (item) {
                item.addEventListener('input', function (event) {
                    var containerElm = event.currentTarget.parentElement.querySelector('.quantityInput-js');
                    if (parseInt(containerElm.value) > 0 && event.currentTarget.parentElement.querySelector('.quantityInput-js').value != '') {
                        event.currentTarget.parentElement.querySelector('.quantity-js').value = event.currentTarget.parentElement.querySelector('.quantityInput-js').value;
                        _this.quantityChanged(event);
                    }
                    else {
                        event.currentTarget.parentElement.querySelector('.quantityInput-js').value = event.currentTarget.parentElement.querySelector('.quantity-js').value;
                    }
                });
            });
            document.querySelectorAll(".cart-product-substractQuantity-js").forEach(function (item) {
                item.addEventListener('click', function (event) {
                    var newValue = (parseInt(event.currentTarget.parentElement.querySelector('.quantityInput-js').value) < 1 ? '0' : parseInt(event.currentTarget.parentElement.querySelector('.quantity-js').value) - 1);
                    event.currentTarget.parentElement.querySelector('.quantityInput-js').value = newValue.toString();
                    event.currentTarget.parentElement.querySelector('.quantity-js').value = newValue.toString();
                    _this.quantityChanged(event);
                });
            });
            document.querySelectorAll(".cart-product-addQuantity-js").forEach(function (item) {
                item.addEventListener('click', function (event) {
                    var newValue = 1 + parseInt(event.currentTarget.parentElement.querySelector('.quantity-js').value);
                    event.currentTarget.parentElement.querySelector('.quantityInput-js').value = newValue.toString();
                    event.currentTarget.parentElement.querySelector('.quantity-js').value = newValue.toString();
                    _this.quantityChanged(event);
                });
            });
            document.querySelectorAll(MiniCartController.Selectors.miniCartClose).forEach(function (item) {
                item.addEventListener('click', function (event) {
                    _this.closeMiniCart();
                });
            });
            document.querySelectorAll(MiniCartController.Selectors.itemRemove).forEach(function (item) {
                item.addEventListener('click', function (event) {
                    _this.removeItem(event);
                });
            });
            document.querySelectorAll(MiniCartController.Selectors.selectQuantity).forEach(function (item) {
                item.addEventListener('change', function (event) {
                    _this.quantityChanged(event);
                });
            });
            var hdnCountElement = document.querySelector(".hdnTotalCartItems");
            if (hdnCountElement != null) {
                document.querySelectorAll(".badge__content").forEach(function (item) {
                    item.dataset.label = document.querySelector(".hdnTotalCartItems").value;
                });
            }
            else {
                document.querySelectorAll(".badge__content").forEach(function (item) {
                    item.dataset.label = '0';
                });
            }
            this.initTouchCartLink();
        };
        MiniCartController.prototype.is = function (elem, selector) {
            if (selector.nodeType) {
                return elem === selector;
            }
            var qa = (typeof (selector) === 'string' ? document.querySelectorAll(selector) : selector), length = qa.length, returnArr = [];
            while (length--) {
                if (qa[length] === elem) {
                    return true;
                }
            }
            return false;
        };
        MiniCartController.prototype.oneTimeEvent = function (element, eventType, callback) {
            element.addEventListener(eventType, function (e) {
                e.target.removeEventListener(e.type, arguments.callee);
                return callback(e);
            });
        };
        MiniCartController.prototype.initTouchCartLink = function () {
            var _this = this;
            document.querySelectorAll(MiniCartController.Selectors.touchCartLink).forEach(function (item) {
                item.addEventListener('click', function (event) {
                    _this.oneTimeEvent(item, 'click', _this.showMiniCart());
                });
            });
        };
        MiniCartController.prototype.navigateToCart = function () {
            var button = document.querySelector(MiniCartController.Selectors.checkoutButton);
            button.click();
        };
        MiniCartController.prototype.reloadMiniCart = function () {
            this.miniCartSService.setMinicartQuantity(0, 0, this);
        };
        MiniCartController.prototype.isMiniCartVisible = function () {
            return !(document.querySelectorAll(MiniCartController.Selectors.miniCartHidden).length > 0);
        };
        MiniCartController.prototype.resetToPreviousQuantity = function (event) {
            var eventElement = event.target;
            if (eventElement.value === '') {
                eventElement.value = "1";
            }
        };
        MiniCartController.prototype.quantityChanged = function (event) {
            var currentElement = event.target.parentElement.querySelector('.quantity-js');
            var productId = this.getProductId(event);
            var quantity = parseInt(currentElement.value);
            var test = event.currentTarget;
            if (!this.isQuantityValid(currentElement, quantity))
                return;
            MiniCartController.isLastQuantityEdited = false;
            this.miniCartSService.setMinicartQuantity(productId, quantity, this);
        };
        MiniCartController.prototype.isQuantityValid = function (element, quantity) {
            var quantityContainer = element.closest(MiniCartController.Selectors.quantityContainer);
            var orderMinQuantity = quantityContainer.dataset.orderMinQuantity;
            var orderMaxQuantity = quantityContainer.dataset.orderMaxQuantity;
            var isScaledProduct = quantityContainer.dataset.isScaledProduct;
            if (!isScaledProduct && quantity < parseInt(orderMinQuantity) || quantity > parseInt(orderMaxQuantity)) {
                this.showQuantityError(element, true);
                return false;
            }
            this.showQuantityError(element, false);
            return true;
        };
        MiniCartController.prototype.showQuantityError = function (element, show) {
            var errorElement = element.closest(MiniCartController.Selectors.quantityContainer).querySelector('.quantity-error');
            if (show)
                errorElement.classList.remove('hidden');
            else
                errorElement.classList.add('hidden');
        };
        MiniCartController.prototype.closeMiniCartOnClickOutside = function (event) {
            if (!event.target.closest(MiniCartController.Selectors.miniCart) != null) {
                if (this.isMiniCartVisible()) {
                    this.closeMiniCart();
                    this.initTouchCartLink();
                    /*$(document).off("click", MiniCartController.Selectors.touchPage);*/
                }
            }
        };
        MiniCartController.prototype.showMiniCart = function () {
            var _this = this;
            document.querySelector(MiniCartController.Selectors.miniCart).classList.remove("hidden");
            if (document.querySelector(MiniCartController.Selectors.touchPage) != null) {
                document.querySelector(MiniCartController.Selectors.touchPage).addEventListener('click', function (event) {
                    _this.closeMiniCartOnClickOutside(event);
                });
            }
        };
        MiniCartController.prototype.mouseOut = function (e) {
            this.closeMiniCart();
        };
        MiniCartController.prototype.closeMiniCart = function () {
            document.querySelector(MiniCartController.Selectors.miniCart).classList.add('hidden');
        };
        MiniCartController.prototype.removeItem = function (event) {
            var productId = this.getProductId(event);
            this.miniCartSService.setMinicartQuantity(productId, 0, this);
        };
        MiniCartController.prototype.getProductId = function (e) {
            return Number(e.currentTarget.closest('.item-container-js').getAttribute("data-productid"));
        };
        MiniCartController.prototype.miniCartChangeDone = function (response) {
            document.getElementById("minicart__body").innerHTML = response.updateflyoutcartsectionhtml;
            document.querySelectorAll(".badge__content").forEach(function (item) {
                item.dataset.label = response.updatetopcartsectionhtml;
            });
            initiateMiniCartEvents();
            /*document.querySelector("#mob-cart-link .badge").setAttribute('data-cart-items-count', response.updatetopcartsectionhtml);*/
            if (response.updatetopcartsectionhtml > 0) {
                var elm = document.querySelector('[data-productid="' + response.productId + '"]');
                if (elm != null) {
                    var currentField = document.querySelector('[data-productid="' + response.productId + '"]').querySelector('input.quantity-js');
                    if (currentField != null) {
                        var value = currentField.value;
                        document.querySelector(MiniCartController.Selectors.miniCart).classList.remove('hidden');
                        if (MiniCartController.isLastQuantityEdited) {
                            currentField.focus();
                            currentField.value = '';
                            currentField.value = value;
                            currentField.focus();
                        }
                    }
                }
            }
        };
        MiniCartController.prototype.miniCartChangeComplete = function (productId) {
            if (productId > 0) {
                // Dispatch cart updated event
                var evt = new CustomEvent("minicart-updated", { detail: "From Minicart" });
                window.dispatchEvent(evt);
            }
        };
        MiniCartController.isLastQuantityEdited = false;
        MiniCartController.Selectors = {
            miniCartContainer: '#minicart-container',
            desktopCartLink: '.header__icons #minicart-container',
            touchPage: '.master-wrapper-page.touch',
            touchCartLink: '.master-wrapper-page.touch #mob-cart-link',
            miniCart: '#minicart-box',
            miniCartHidden: '#minicart-box.hidden',
            miniCartClose: '#mini-cart-close',
            itemRemove: '.modal-removeproduct-js svg',
            editQuantity: 'input.quantity',
            selectQuantity: '.minicart__quantity-container select',
            quantityContainer: '.minicart__quantity-container',
            checkoutButton: '.checkout-button'
        };
        return MiniCartController;
    }());
    var MiniCartService = /** @class */ (function () {
        function MiniCartService() {
        }
        MiniCartService.prototype.fetchWithTimeout = function (request, timeoutInMillis) {
            return __awaiter(this, void 0, void 0, function () {
                var abortController, timeout, response;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            abortController = new AbortController();
                            timeout = setTimeout(function () { return abortController.abort(); }, timeoutInMillis);
                            return [4 /*yield*/, fetch(request, { signal: abortController.signal })];
                        case 1:
                            response = _a.sent();
                            clearTimeout(timeout);
                            return [2 /*return*/, response.json()];
                    }
                });
            });
        };
        MiniCartService.prototype.getRequest = function (endpointUrl, data) {
            var headers = new Headers();
            headers.append('Accept', 'application/json');
            headers.append('Content-Type', 'application/json');
            var request = new Request(endpointUrl, {
                method: 'POST',
                headers: headers,
                mode: 'cors',
                cache: 'no-cache',
                body: data,
                credentials: 'include',
            });
            return request;
        };
        MiniCartService.prototype.setMinicartQuantity = function (productId, quantity, miniCartChangedCallBack) {
            var setCart = this.fetchWithTimeout(this.getRequest(MiniCartService.urls.setQuantity, JSON.stringify({ productId: productId, quantity: quantity })), 3000);
            setCart.then(function (response) {
                miniCartChangedCallBack.miniCartChangeDone(response);
            })
                .then(function (response) {
                miniCartChangedCallBack.miniCartChangeComplete(productId);
                TriggerDataLayerEvent();
            });
        };
        MiniCartService.urls = {
            setQuantity: '/ShoppingCart/MiniCartSetQuantity',
        };
        return MiniCartService;
    }());
    function TriggerDataLayerEvent() {
        var event = new CustomEvent("cart-update-datalayer", {});
        document.dispatchEvent(event);
    }
    function initiateMiniCartEvents() {
        var miniCartContainer = document.getElementById('minicart-container');
        if (miniCartContainer != null) {
            var controller = new MiniCartController(miniCartContainer);
            controller.initEvents();
        }
    }
    function loadMiniCart() {
        var miniCartContainer = document.getElementById('minicart-container');
        if (miniCartContainer != null) {
            var controller = new MiniCartController(miniCartContainer);
            controller.reloadMiniCart();
        }
    }
    function ready(callback) {
        // in case the document is already rendered
        if (document.readyState != 'loading')
            callback();
        // modern browsers
        else if (document.addEventListener)
            document.addEventListener('DOMContentLoaded', callback);
        // IE <= 8
        else
            document.attachEvent('onreadystatechange', function () {
                if (document.readyState == 'complete')
                    callback();
            });
    }
    ready(function () {
        loadMiniCart();
        initiateMiniCartEvents();
        //Initialize cart modal
        new Modal({
            modalIdSelector: 'minicart-box',
            modalOpenClassSelector: '.shoppingcart__icon',
            modalCloseClassSelector: '.modal-showmore-close-js'
        });
        //Listen for the cart updated event
        window.addEventListener("cart-updated", function (evt) {
            loadMiniCart();
            initiateMiniCartEvents();
            var cEvent = evt;
            if (cEvent.detail != "fromcheckoutpageJS") {
                document.querySelector(".shoppingcart__icon").click();
            }
        }, false);
    });
})(cart || (cart = {}));
//# sourceMappingURL=cart.js.map
var SearchBox = /** @class */ (function () {
    function SearchBox() {
        this.activateMobileSelector = '.show-search-mobile-js';
        this.activateTabletSelector = '.show-search-tablet-js';
        this.classes = {
            showOnMobile: 'action-bar-mobile__search-container--active',
            showOnTablet: 'header__search--active',
        };
        this.searchBoxMobileContainerElement = document.getElementById('action-bar-search-field-js');
        this.searchBoxTabletContainerElement = document.getElementById('header-search-field-js');
        this.initEvents();
    }
    SearchBox.prototype.initEvents = function () {
        var _this = this;
        document.querySelectorAll(this.activateMobileSelector).forEach(function (element) {
            element.addEventListener('click', function (evt) { return _this.showSearchMobile(); });
        });
        document.querySelectorAll(this.activateTabletSelector).forEach(function (element) {
            element.addEventListener('click', function (evt) { return _this.showSearchTablet(); });
        });
    };
    SearchBox.prototype.showSearchMobile = function () {
        this.searchBoxMobileContainerElement.classList.add(this.classes.showOnMobile);
        var searchField = this.searchBoxMobileContainerElement.getElementsByClassName('search-input-js')[0];
        searchField.focus();
        this.initCloseButton();
    };
    SearchBox.prototype.showSearchTablet = function () {
        var _this = this;
        if (MediaQueries.IsTabletLandscapeUp()) {
            window.scroll({ top: 0, left: 0, behavior: 'smooth' });
        }
        else {
            this.searchBoxTabletContainerElement.classList.add(this.classes.showOnTablet);
            this.initCloseButton();
        }
        setTimeout(function () {
            var searchField = _this.searchBoxTabletContainerElement.querySelector('.search-input-js');
            searchField.focus();
        }, 1000);
    };
    SearchBox.prototype.initCloseButton = function () {
        var _this = this;
        var mobileClose = document.getElementById('search-close-mobile-js');
        mobileClose.addEventListener('click', function () { return _this.hideSearch(); }, { once: true });
        var tabletClose = document.getElementById('search-close-tablet-js');
        tabletClose.addEventListener('click', function () { return _this.hideSearchTablet(); }, { once: true });
    };
    SearchBox.prototype.hideSearch = function () {
        this.searchBoxMobileContainerElement.classList.remove(this.classes.showOnMobile);
    };
    SearchBox.prototype.hideSearchTablet = function () {
        this.searchBoxTabletContainerElement.classList.remove(this.classes.showOnTablet);
    };
    return SearchBox;
}());
window.addEventListener("load", function () {
    var header = new SearchBox();
});
//# sourceMappingURL=searchbox.js.map
var DataLayer;
(function (DataLayer_1) {
    var DataLayer = /** @class */ (function () {
        function DataLayer() {
            this.dataLayer = window.dataLayer;
            this.init();
        }
        DataLayer.prototype.init = function () {
            this.observer = this.createObserver();
            this.listenForProductsLoadedEvent();
            this.observeLoadedElements();
            this.ListenBuyButtonClickEvent();
        };
        DataLayer.prototype.createObserver = function () {
            var options = {
                root: null,
                rootMargin: "0px",
                threshold: 1.0
            };
            return new IntersectionObserver(this.viewportEntered.bind(this), options);
        };
        DataLayer.prototype.observeLoadedElements = function () {
            var _this_1 = this;
            var productCards = document.querySelectorAll("article.product-card,.scaled-prices__table-row");
            productCards.forEach(function (card) { return _this_1.observer.observe(card); });
            var searchResults = document.querySelectorAll('.search-result__item-container');
            searchResults.forEach(function (result) { return _this_1.observer.observe(result); });
        };
        DataLayer.prototype.listenForProductsLoadedEvent = function () {
            var _this_1 = this;
            var productListContainers = document.querySelectorAll('[data-product-list]');
            productListContainers.forEach(function (pl) {
                pl.addEventListener("products-loaded", function (e) {
                    var currentElement = e.currentTarget;
                    var productCards = currentElement.querySelectorAll("article.product-card");
                    productCards.forEach(function (card) { return _this_1.observer.observe(card); });
                    var searchResults = currentElement.querySelectorAll(".search-result__item-container");
                    searchResults.forEach(function (result) { return _this_1.observer.observe(result); });
                });
            });
        };
        DataLayer.prototype.GetListname = function (element) {
            var productList = '';
            var parent = element.closest('.dal-product-list');
            if (parent != null)
                productList = parent.getAttribute('data-product-list');
            return productList;
        };
        DataLayer.prototype.viewportEntered = function (entries, observer) {
            var _this_1 = this;
            var impressions = [];
            entries.forEach(function (entry) {
                if (entry.isIntersecting) {
                    var element = entry.target;
                    var productList = _this_1.GetListname(element);
                    var obj = _this_1.GetAttributeValues(element, productList);
                    impressions.push(obj);
                }
            });
            if (impressions.length > 0) {
                this.dataLayer.push({
                    "ecommerce": {
                        "impressions": impressions
                    },
                    "event": "EEC-productImpression",
                });
            }
        };
        DataLayer.prototype.GetAttributeValues = function (element, list) {
            var productsku = element.getAttribute('data-productSku');
            var price = element.getAttribute('data-price');
            var variant = element.getAttribute('data-variant');
            var categoryName = element.getAttribute('data-categoryName');
            var name = element.getAttribute('data-name');
            var position = element.getAttribute('data-position');
            return {
                "id": productsku,
                "name": name,
                "price": price,
                "variant": variant,
                "position": position,
                "quantity": 1,
                "list": list,
                "category": categoryName,
            };
        };
        DataLayer.prototype.ListenBuyButtonClickEvent = function () {
            var _this = this;
            this.AddProductClickEvent(document, "click", "article, .search-result__item-container", function (event) {
                var target = event.target;
                var article = target.closest('article');
                if (article == null) {
                    article = target.closest('.search-result__item-container');
                }
                if (article == null) {
                    return;
                }
                var isButton = target.className.indexOf('button') >= 0;
                var isVariant = article.className.indexOf('is-variant') >= 0;
                if (isVariant && isButton) {
                    return;
                }
                var productList = _this.GetListname(article);
                var obj = _this.GetAttributeValues(article, productList);
                _this.dataLayer.push({
                    "ecommerce": {
                        "click": {
                            "actionField": {
                                "list": "Special shops - sale",
                                "action": "click"
                            },
                            "products": [
                                obj
                            ]
                        }
                    },
                    "event": "EEC-productClick",
                });
            });
        };
        DataLayer.prototype.AddProductClickEvent = function (el, evt, sel, handler) {
            el.addEventListener(evt, function (event) {
                var t = event.target;
                while (t && t !== this) {
                    if (t.matches(sel)) {
                        handler.call(t, event);
                    }
                    t = t.parentNode;
                }
            });
        };
        return DataLayer;
    }());
    window.addEventListener("load", function () {
        var dataLayer = new DataLayer();
    });
})(DataLayer || (DataLayer = {}));
//# sourceMappingURL=datalayer.js.map
var Header = /** @class */ (function () {
    function Header() {
        this.headerCollapseThreshold = 100;
        this.isCollapsed = false;
        this.headerElement = document.getElementById(Header.jsIdentifiers.headerWrapperId);
        this.createObserver();
    }
    Header.prototype.createObserver = function () {
        var observerOptions = {
            root: null,
            rootMargin: '0px',
            threshold: 0
        };
        var observer = new IntersectionObserver(this.observerCallback, observerOptions);
        var target = document.getElementById(Header.jsIdentifiers.layoutTargetId);
        observer.observe(target);
    };
    Header.prototype.observerCallback = function (entries, observer) {
        if (!MediaQueries.IsDesktop())
            return;
        var headerElement = document.getElementById(Header.jsIdentifiers.headerWrapperId);
        var pageElement = document.querySelector(".page");
        if (document.body.clientHeight - window.innerHeight < 200)
            return;
        var collapse = true;
        entries.forEach(function (entry) {
            collapse = !entry.isIntersecting;
        });
        if (collapse) {
            headerElement.classList.add(Header.classes.headerCollapsed);
            pageElement.classList.add(Header.classes.headerCollapsedPage);
        }
        else {
            headerElement.classList.remove(Header.classes.headerCollapsed);
            pageElement.classList.remove(Header.classes.headerCollapsedPage);
        }
    };
    Header.classes = {
        headerCollapsed: 'header-wrapper--collapsed',
        headerCollapsedPage: 'header--collapsed'
    };
    Header.jsIdentifiers = {
        headerWrapperId: 'header-wrapper-js',
        layoutTargetId: 'header-layout-breakpoint-js'
    };
    return Header;
}());
window.addEventListener("load", function () {
    var header = new Header();
});
//# sourceMappingURL=header.js.map
/// <reference path="../../../../../typings/globals/underscore/index.d.ts" />
/// <reference path="../../../../../typings/globals/jquery/index.d.ts" />
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var cookieConsent;
(function (cookieConsent) {
    var CookieConsentSettings = /** @class */ (function () {
        function CookieConsentSettings() {
            this.Essential = true;
        }
        return CookieConsentSettings;
    }());
    var CookieConsentSettingsParser = /** @class */ (function () {
        function CookieConsentSettingsParser() {
        }
        CookieConsentSettingsParser.fromString = function (cookieConsentString) {
            var settings = new CookieConsentSettings();
            var jsSettings = JSON.parse(cookieConsentString);
            settings.Adoption = jsSettings.Adoption;
            settings.Performance = jsSettings.Performance;
            settings.Marketing = jsSettings.Marketing;
            settings.IsAccepted = jsSettings.IsAccepted;
            return settings;
            //let settings = Object.assign(new CookieConsentSettings(),
            //    JSON.parse(cookieConsentString));
            //return settings;
        };
        CookieConsentSettingsParser.toString = function (cookieConsentSettings) {
            return JSON.stringify(cookieConsentSettings);
        };
        return CookieConsentSettingsParser;
    }());
    var CookieConsentController = /** @class */ (function () {
        function CookieConsentController(container, cookieService) {
            this.consentContainer = container;
            this.detailedConsentContainer = document.getElementById(CookieConsentController.Selectors.detailedConsentContainer);
            this.cookieConsentService = new CookieConsentService();
            this.cookieService = cookieService;
            this.initEvents();
            this.init();
            this.initState();
        }
        // IControllerCallback methods
        CookieConsentController.prototype.onSaveSuccess = function () {
            this.saveConsentCookie();
            document.getElementById(CookieConsentController.Selectors.consentContainer).style.display = "none";
            document.getElementById(CookieConsentController.Selectors.detailedConsentContainer).style.display = "none";
            window.location.reload(false);
        };
        CookieConsentController.prototype.onOpenDetailedSettings = function (html) {
            document.getElementById(CookieConsentController.Selectors.detailedConsentContainer).innerHTML += html;
            if (!CookieConsentController.consentCookieSettings.IsAccepted) {
                this.setPerformance(true);
                this.setAdoption(true);
                this.setMarketing(true);
            }
            this.initDetailedSettingsEvents();
            this.initDetailedSettingsState();
            this.disableModalBackground(true);
            this.consentContainer.style.display = "none";
        };
        // End IControllerCallback
        CookieConsentController.prototype.initEvents = function () {
            var _this = this;
            var acceptAllButton = document.getElementById(CookieConsentController.Selectors.buttonAcceptAll);
            if (acceptAllButton != null) {
                acceptAllButton.addEventListener('click', function (evt) {
                    _this.setIsAccepted(true);
                    _this.cookieConsentService
                        .saveCookieConsent(_this, CookieConsentController.consentCookieSettings);
                });
            }
            var cookieSettingsButton = document.getElementById(CookieConsentController.Selectors.buttonCookieSettings);
            if (cookieSettingsButton != null) {
                cookieSettingsButton.addEventListener('click', function (evt) {
                    _this.openCookieConsentDialog();
                });
            }
            var openDetailedConsentDialogLink = document.getElementById(CookieConsentController.Selectors.openDetailedConsentDialogLink);
            openDetailedConsentDialogLink.addEventListener('click', function (evt) {
                _this.openCookieConsentDialog();
            });
        };
        CookieConsentController.prototype.openCookieConsentDialog = function () {
            if (this.isCookieConsentDialogLoaded()) {
                this.disableModalBackground(true);
                this.consentContainer.style.display = "none";
                document.getElementById(CookieConsentController.Selectors.detailedConsentContainer).style.display = "block";
            }
            else {
                this.cookieConsentService.openDetailedCookieSettingsDialog(this, CookieConsentController.consentCookieSettings);
            }
        };
        CookieConsentController.prototype.isCookieConsentDialogLoaded = function () {
            return document.getElementById(CookieConsentController.Selectors.detailedConsentContainer).children.length > 0;
        };
        CookieConsentController.prototype.disableModalBackground = function (deactivateBackground) {
            if (deactivateBackground) {
                document.getElementById("modal-backdrop").classList.add("modal-backdrop");
                document.body.classList.add("no-scroll");
                document.getElementsByClassName("master-wrapper-content")[0].classList.add("no-pointer-events");
            }
            else {
                document.getElementById("modal-backdrop").classList.remove("modal-backdrop");
                document.body.className = document.body.className.replace("no-scroll", "");
                document.getElementsByClassName("master-wrapper-content")[0].classList.remove("no-pointer-events");
            }
        };
        CookieConsentController.prototype.initDetailedSettingsState = function () {
            if (CookieConsentController.consentCookieSettings.Performance) {
                var perfomanceButton = document.getElementById(CookieConsentController.Selectors.performanceButton);
                perfomanceButton.checked = true;
            }
            if (CookieConsentController.consentCookieSettings.Adoption) {
                var adoptionButton = document.getElementById(CookieConsentController.Selectors.adoptionButton);
                adoptionButton.checked = true;
            }
            if (CookieConsentController.consentCookieSettings.Marketing) {
                var marketingButton = document.getElementById(CookieConsentController.Selectors.marketingButton);
                marketingButton.checked = true;
            }
        };
        CookieConsentController.prototype.initDetailedSettingsEvents = function () {
            var _this = this;
            var performanceButton = document.getElementById(CookieConsentController.Selectors.performanceButton);
            performanceButton.addEventListener('click', function (evt) {
                _this.setPerformance(_this.isConsentGiven(evt));
            });
            var adoptionButton = document.getElementById(CookieConsentController.Selectors.adoptionButton);
            adoptionButton.addEventListener('click', function (evt) {
                _this.setAdoption(_this.isConsentGiven(event));
            });
            var marketingButton = document.getElementById(CookieConsentController.Selectors.marketingButton);
            marketingButton.addEventListener('click', function (evt) {
                _this.setMarketing(_this.isConsentGiven(event));
            });
            document.querySelectorAll(CookieConsentController.Selectors.saveButton).forEach(function (item) {
                item.addEventListener('click', function (event) {
                    _this.setIsAccepted(true);
                    _this.saveConsentCookie();
                    _this.cookieConsentService.saveCookieConsent(_this, CookieConsentController.consentCookieSettings);
                });
            });
            document.querySelectorAll(CookieConsentController.Selectors.closeButton).forEach(function (item) {
                item.addEventListener('click', function (event) {
                    if (!CookieConsentController.consentCookieSettings.IsAccepted) {
                        _this.initState();
                        _this.consentContainer.style.display = "block";
                    }
                    document.getElementById(CookieConsentController.Selectors.detailedConsentContainer).style.display = "none";
                    _this.disableModalBackground(false);
                });
            });
        };
        CookieConsentController.prototype.init = function () {
            var _this = this;
            var loadTime = Number(this.consentContainer.dataset.loadtime);
            if (this.isConsentNeeded()) {
                setTimeout(function () {
                    _this.consentContainer.style.display = "block";
                }, loadTime);
            }
        };
        CookieConsentController.prototype.isConsentNeeded = function () {
            return !this.cookieService.cookieExists();
        };
        CookieConsentController.prototype.initState = function () {
            var currentCookieString = this.cookieService.readCookie();
            if (currentCookieString !== undefined) {
                CookieConsentController.consentCookieSettings = CookieConsentSettingsParser.fromString(currentCookieString);
                return;
            }
            CookieConsentController.consentCookieSettings = new CookieConsentSettings();
            CookieConsentController.consentCookieSettings.IsAccepted = false;
            CookieConsentController.consentCookieSettings.Performance = true;
            CookieConsentController.consentCookieSettings.Adoption = true;
            CookieConsentController.consentCookieSettings.Marketing = true;
        };
        CookieConsentController.prototype.isConsentGiven = function (event) {
            var element = event.target;
            if (element.checked) {
                return true;
            }
            else {
                return false;
            }
        };
        CookieConsentController.prototype.setIsAccepted = function (isConsentGiven) {
            CookieConsentController.consentCookieSettings.IsAccepted = isConsentGiven;
        };
        CookieConsentController.prototype.setPerformance = function (isConsentGiven) {
            CookieConsentController.consentCookieSettings.Performance = isConsentGiven;
        };
        CookieConsentController.prototype.setAdoption = function (isConsentGiven) {
            CookieConsentController.consentCookieSettings.Adoption = isConsentGiven;
        };
        CookieConsentController.prototype.setMarketing = function (isConsentGiven) {
            CookieConsentController.consentCookieSettings.Marketing = isConsentGiven;
        };
        CookieConsentController.prototype.saveConsentCookie = function () {
            this.cookieService
                .saveCookie(JSON.stringify(CookieConsentController.consentCookieSettings));
        };
        CookieConsentController.Selectors = {
            consentContainer: 'dialog-eu-cookie-law',
            detailedConsentContainer: 'dialog-eu-cookie-law-detailed-container',
            detailedConsentDialog: 'dialog-eu-cookie-law-detailed',
            buttonAcceptAll: 'accept-all',
            buttonCookieSettings: "open-cookie-settings",
            performanceButton: 'performance-button',
            adoptionButton: 'adoption-button',
            marketingButton: 'marketing-button',
            saveButton: '.save-button',
            closeButton: '.close-button',
            openDetailedConsentDialogLink: 'open-consent-dialog',
            footerWrap: '.footer'
        };
        return CookieConsentController;
    }());
    //
    // Class responsible for communication with backend
    //
    var CookieConsentService = /** @class */ (function () {
        function CookieConsentService() {
        }
        CookieConsentService.prototype.fetchWithTimeout = function (request, timeoutInMillis) {
            return __awaiter(this, void 0, void 0, function () {
                var abortController, timeout, response;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            abortController = new AbortController();
                            timeout = setTimeout(function () { return abortController.abort(); }, timeoutInMillis);
                            return [4 /*yield*/, fetch(request, { signal: abortController.signal })];
                        case 1:
                            response = _a.sent();
                            clearTimeout(timeout);
                            return [2 /*return*/, response];
                    }
                });
            });
        };
        CookieConsentService.prototype.getRequest = function (endpointUrl, data) {
            var headers = new Headers();
            headers.append('Accept', 'application/json');
            headers.append('Content-Type', 'application/json');
            var request = new Request(endpointUrl, {
                method: 'POST',
                headers: headers,
                mode: 'cors',
                cache: 'no-cache',
                body: data,
                credentials: 'include',
            });
            return request;
        };
        CookieConsentService.prototype.saveCookieConsent = function (callback, cookieConsentSettings) {
            var responseSaveCookieConsent = this.fetchWithTimeout(this.getRequest('/Common/GDMEuCookieLawAccept', JSON.stringify(cookieConsentSettings)), 3000);
            responseSaveCookieConsent.then(function (response) { return callback.onSaveSuccess(); });
        };
        CookieConsentService.prototype.openDetailedCookieSettingsDialog = function (callback, cookieConsentSettings) {
            var responseOfAjax = this.fetchWithTimeout(this.getRequest('/Common/GDMEuCookieLawDetailedSettings', JSON.stringify(cookieConsentSettings)), 3000);
            responseOfAjax.then(function (response) { return response.text(); }).then(function (data) {
                callback.onOpenDetailedSettings(data);
            });
        };
        return CookieConsentService;
    }());
    //
    // Class  responsible for handling cookie on client 
    //
    var CookieService = /** @class */ (function () {
        function CookieService(cookieName, expirationHours) {
            CookieService.cookieName = cookieName;
            this.expirationHours = expirationHours;
        }
        CookieService.prototype.cookieExists = function () {
            if (document.cookie.split(';').some(function (item) {
                return item.trim().indexOf(CookieService.cookieName + '=') === 0;
            })) {
                return true;
            }
            return false;
        };
        CookieService.prototype.saveCookie = function (cookieValue) {
            document.cookie = CookieService.cookieName + "=" +
                encodeURIComponent(cookieValue) + ";max-age=" +
                this.getExpiresDate() +
                ";path=/;SameSite=None;Secure";
        };
        CookieService.prototype.readCookie = function () {
            var value = "; " + document.cookie;
            var parts = value.split("; " + CookieService.cookieName + "=");
            if (parts.length === 2) {
                return decodeURIComponent(parts.pop().split(";").shift());
            }
        };
        CookieService.prototype.getExpiresDate = function () {
            return this.expirationHours * 60 * 60;
        };
        return CookieService;
    }());
    window.addEventListener("load", function () {
        var cookieService = new CookieService('consentCookie', 24 * 365);
        var container = document.getElementById(CookieConsentController.Selectors.consentContainer);
        if (container != null) {
            var controller = new CookieConsentController(container, cookieService);
        }
    });
})(cookieConsent || (cookieConsent = {}));
//# sourceMappingURL=CookieConsent.js.map
var MediaQueries = /** @class */ (function () {
    function MediaQueries() {
    }
    MediaQueries.IsPhone = function () {
        return window.matchMedia("only screen and (max-width: " + (MediaQueries.tabletPortraitMin - 1) + "px)").matches;
    };
    MediaQueries.IsTabletPortrait = function () {
        return window.matchMedia("only screen and (min-width: " + MediaQueries.tabletPortraitMin + "px ) and (max-width: " + (MediaQueries.tabletLandscapeMin - 1) + "px )").matches;
    };
    MediaQueries.IsTabletPortraitUp = function () {
        return window.matchMedia("only screen and (min-width: " + MediaQueries.tabletPortraitMin + "px )").matches;
    };
    MediaQueries.IsTabletLandscape = function () {
        return window.matchMedia("only screen and (min-width: " + MediaQueries.tabletLandscapeMin + "px ) and (max-width: " + (MediaQueries.desktopMin - 1) + "px )").matches;
    };
    MediaQueries.IsTabletLandscapeUp = function () {
        return window.matchMedia("only screen and (min-width: " + MediaQueries.tabletLandscapeMin + "px )").matches;
    };
    MediaQueries.IsDesktop = function () {
        return window.matchMedia("only screen and (min-width: " + MediaQueries.desktopMin + "px)").matches;
    };
    // Thresholds must match values in _media-queries.less
    MediaQueries.tabletPortraitMin = 768;
    MediaQueries.tabletLandscapeMin = 1024;
    MediaQueries.desktopMin = 1340;
    return MediaQueries;
}());
//# sourceMappingURL=mediaqueries.js.map
var Modal = /** @class */ (function () {
    function Modal(props) {
        this.classOpen = 'modal--open';
        this.modalBackgroundId = 'modal-background-js';
        this.modalElement = document.getElementById(props.modalIdSelector);
        this.modalBackgroundElement = document.getElementById(this.modalBackgroundId);
        this.bodyElement = document.getElementsByTagName('body')[0];
        this.props = props;
        this.initEvents();
        this.body = new Body();
    }
    Modal.prototype.initEvents = function () {
        var _this = this;
        Array.from(document.querySelectorAll(this.props.modalOpenClassSelector))
            .forEach(function (element) { return element.addEventListener("click", function (event) { return _this.openModal(event); }); });
        Array.from(document.querySelectorAll(this.props.modalCloseClassSelector))
            .forEach(function (element) { return element.addEventListener("click", function (event) { return _this.closeModal(event); }); });
    };
    Modal.prototype.closeModal = function (event) {
        this.modalElement.classList.remove(this.classOpen);
        this.modalBackgroundElement.classList.remove(this.classOpen);
        this.body.enableScroll();
        //this.body.toggleNoScroll();
        event.stopPropagation();
        var imbox = document.getElementById('imbox-container');
        this.toggleImbox(true);
    };
    Modal.prototype.openModal = function (event) {
        event.stopPropagation();
        if (!this.modalElement.classList.contains(this.classOpen)) {
            this.modalElement.classList.add(this.classOpen);
            this.modalBackgroundElement.classList.add(this.classOpen);
        }
        else {
            this.modalElement.classList.remove(this.classOpen);
            this.modalBackgroundElement.classList.remove(this.classOpen);
        }
        this.body.disableScroll();
        /*this.body.toggleNoScroll();*/
        this.toggleImbox(false);
    };
    Modal.prototype.toggleImbox = function (show) {
        var imbox = document.getElementById('imbox-container');
        if (imbox == null)
            return;
        if (show) {
            imbox.style.display = 'block';
        }
        else {
            imbox.style.display = 'none';
        }
    };
    return Modal;
}());
//# sourceMappingURL=modal.js.map
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var ProductPageSlider = /** @class */ (function () {
    function ProductPageSlider() {
        this.initSlider();
    }
    ProductPageSlider.prototype.initSlider = function () {
        var _this = this;
        (function () { return __awaiter(_this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                this.loadRelatedProductSlider().then(function () { new ProductSlider('swiper'); });
                this.loadYouMightLikeProductSlider().then(function () { new ProductSlider('swiper'); });
                return [2 /*return*/];
            });
        }); })();
    };
    ProductPageSlider.prototype.loadRelatedProductSlider = function () {
        return __awaiter(this, void 0, void 0, function () {
            var container;
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        container = document.getElementById('related-product-slider');
                        return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 500); })
                                .then(function () { return _this.loadSliderData(container, 'Product', 'GDMRelatedProductSlider'); })
                                .then(function () { return container.dispatchEvent(new Event('products-loaded')); })];
                    case 1:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    ProductPageSlider.prototype.loadYouMightLikeProductSlider = function () {
        return __awaiter(this, void 0, void 0, function () {
            var container;
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        container = document.getElementById('you-might-like-product-slider');
                        return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 500); })
                                .then(function () { return _this.loadSliderData(container, 'Loop54RelatedProducts', 'GDMRelatedProductSlider'); })
                                .then(function () { return container.dispatchEvent(new Event('products-loaded')); })];
                    case 1:
                        _a.sent();
                        ;
                        return [2 /*return*/];
                }
            });
        });
    };
    ProductPageSlider.prototype.loadSliderData = function (container, controller, action) {
        return __awaiter(this, void 0, void 0, function () {
            var modelId, productData;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        modelId = container.getAttribute('data-id');
                        return [4 /*yield*/, this.getSliderData('/' + controller + '/' + action + '?productId=' + modelId)];
                    case 1:
                        productData = _a.sent();
                        container.insertAdjacentHTML('beforeend', productData);
                        return [2 /*return*/];
                }
            });
        });
    };
    ProductPageSlider.prototype.getSliderData = function (url) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, fetch(url)
                            .then(function (response) { return response.text(); })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    return ProductPageSlider;
}());
window.addEventListener("load", function () {
    new ProductPageSlider();
});
//# sourceMappingURL=productpageslider.js.map
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var CartService = /** @class */ (function () {
    function CartService() {
    }
    CartService.prototype.fetchWithTimeout = function (request, timeoutInMillis) {
        return __awaiter(this, void 0, void 0, function () {
            var abortController, timeout, response;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        abortController = new AbortController();
                        timeout = setTimeout(function () { return abortController.abort(); }, timeoutInMillis);
                        return [4 /*yield*/, fetch(request, { signal: abortController.signal })];
                    case 1:
                        response = _a.sent();
                        clearTimeout(timeout);
                        return [2 /*return*/, response.json()];
                }
            });
        });
    };
    CartService.prototype.getRequest = function (endpointUrl, data) {
        var headers = new Headers();
        headers.append('Accept', 'application/json');
        /*headers.append('Content-Type', 'application/json');*/
        var request = new Request(endpointUrl, {
            method: 'POST',
            headers: headers,
            mode: 'cors',
            cache: 'no-cache',
            body: data,
            credentials: 'include',
        });
        return request;
    };
    CartService.prototype.getRequestStringData = function (endpointUrl, data) {
        var headers = new Headers();
        headers.append('Accept', 'application/json');
        headers.append('Content-Type', 'application/json');
        var request = new Request(endpointUrl, {
            method: 'POST',
            headers: headers,
            mode: 'cors',
            cache: 'no-cache',
            body: data,
            credentials: 'include',
        });
        return request;
    };
    CartService.prototype.setCartQuantity = function (productId, quantity) {
        var _this = this;
        if (isNaN(quantity)) {
            quantity = 1;
        }
        var formData = new FormData();
        formData.append('addtocart_' + productId + '.EnteredQuantity', quantity.toString());
        var setCart = this.fetchWithTimeout(this.getRequest(CartService.urls.setQuantity + productId + '/1', formData), 3000);
        setCart.then(function (response) { return _this.afterAdding(response); });
    };
    CartService.prototype.addToCart = function (productId, quantity) {
        if (isNaN(quantity)) {
            quantity = 1;
        }
        var formData = new FormData();
        formData.append('addtocart_' + productId + '.EnteredQuantity', quantity.toString());
        return this.fetchWithTimeout(this.getRequest(CartService.urls.setQuantity + productId + '/1', formData), 10000);
    };
    CartService.prototype.afterAdding = function (response) {
        // Dispatch cart updated event
        var evt = new CustomEvent("cart-updated", { detail: "From ProductDetailsPage" });
        window.dispatchEvent(evt);
    };
    CartService.urls = {
        setQuantity: '/addproducttocart/details/',
    };
    return CartService;
}());
//# sourceMappingURL=cartService.js.map
//import AddToCart from "../../../../../src/components/configurator/AddToCart";
window.addEventListener("DOMContentLoaded", function () {
    // Variant Selector Modal
    new Modal({
        modalIdSelector: 'modal-variant-js',
        modalOpenClassSelector: '.modal-variants-js',
        modalCloseClassSelector: '.modal-showmore-close-js'
    });
    // Variant list click
    window.document.querySelectorAll(".variant-container-js").forEach(function (item) {
        item.addEventListener('click', function (event) {
            document.location.href = event.currentTarget.dataset.url;
        });
    });
});
var VariantPage = /** @class */ (function () {
    function VariantPage() {
        this.intEvents();
        this.cartService = new CartService();
    }
    VariantPage.prototype.intEvents = function () {
        var _this = this;
        var buyButton = document.querySelectorAll(".product-page .button--buy-default").forEach(function (btn) {
            return btn.addEventListener('click', function (event) { return _this.addToCart(event); });
        });
        var subtractQuantityButtons = document.querySelectorAll(".product-substractQuantity");
        subtractQuantityButtons.forEach(function (btn) { return btn.addEventListener('click', function (event) { return _this.decreaseQuantity(event); }); });
        var addQuantityButtons = document.querySelectorAll(".product-addQuantity");
        addQuantityButtons.forEach(function (btn) { return btn.addEventListener('click', function (event) { return _this.increaseQuantity(event); }); });
        document.querySelectorAll(".variantpage-header__quantityinput")
            .forEach(function (input) { return input.addEventListener('input', function (event) { return _this.triggerQuantityChangeEvent(); }); });
        var scrollToLinks = document.querySelectorAll('.scroll-to-js');
        scrollToLinks.forEach(function (link) { return link.addEventListener('click', function (event) { return _this.scrollToId(event); }); });
        var productInfoButton = document.querySelector("#product-info");
        if (productInfoButton != null) {
            productInfoButton.addEventListener('click', function (event) {
                document.querySelector("#product-specifications").style.display = "none";
                document.querySelector("#product-information").style.display = "block";
            });
        }
        var productSpecButton = document.querySelector("#product-spec");
        if (productSpecButton != null) {
            productSpecButton.addEventListener('click', function (event) {
                document.querySelector("#product-information").style.display = "none";
                document.querySelector("#product-specifications").style.display = "block";
            });
        }
        var prodInfoLink = document.querySelector("#prodInfoLink");
        if (prodInfoLink != null) {
            prodInfoLink.addEventListener('click', function (event) {
                document.querySelector("#product-info").click();
            });
        }
        var prodSpecLink = document.querySelector("#prodSpecLink");
        if (prodSpecLink != null) {
            prodSpecLink.addEventListener('click', function (event) {
                document.querySelector("#product-spec").click();
            });
        }
    };
    VariantPage.prototype.scrollToId = function (event) {
        event.preventDefault();
        var clickedElement = event.currentTarget;
        var scrollToId = clickedElement.dataset.scrollToId;
        var scrollToElement = document.getElementById(scrollToId);
        window.scrollTo(0, scrollToElement.getBoundingClientRect().top - 60);
    };
    VariantPage.prototype.addToCart = function (event) {
        var quantity = Number(this.getQuantityInput(event).value);
        var productId = Number(event.currentTarget.closest('.product-page').getAttribute("data-productid"));
        this.cartService.setCartQuantity(productId, quantity);
    };
    VariantPage.prototype.increaseQuantity = function (event) {
        var quantityInput = this.getQuantityInput(event);
        var newValue = 1 + parseInt(quantityInput.value);
        quantityInput.value = newValue.toString();
        this.triggerQuantityChangeEvent();
    };
    VariantPage.prototype.decreaseQuantity = function (event) {
        var quantityInput = this.getQuantityInput(event);
        var quantityValue = Number(quantityInput.value);
        var newValue = quantityValue == 1 ? 1 : quantityValue - 1;
        quantityInput.value = newValue.toString();
        this.triggerQuantityChangeEvent();
    };
    VariantPage.prototype.triggerQuantityChangeEvent = function () {
        var quantityInput = this.getQuantityInput(event);
        var quantityValue = Number(quantityInput.value);
        var productId = quantityInput.dataset.productId;
        var quantityChangedEvent = new CustomEvent("quantity-changed", { detail: { quantity: quantityValue, productId: productId } });
        quantityInput.dispatchEvent(quantityChangedEvent);
    };
    VariantPage.prototype.getQuantityInput = function (event) {
        var button = event.currentTarget;
        return button.parentElement.querySelector('.quantityInput');
    };
    return VariantPage;
}());
window.addEventListener("load", function () {
    var variantPage = new VariantPage();
});
//# sourceMappingURL=variantpage.js.map
var ProductPage = /** @class */ (function () {
    function ProductPage() {
        this.cartService = new CartService();
        new Modal({
            modalIdSelector: 'modal-specification-js',
            modalOpenClassSelector: '.modal-specifications-js ',
            modalCloseClassSelector: '.modal-showmore-close-js'
        });
        this.initVariantGrid();
    }
    ProductPage.prototype.initVariantGrid = function () {
        var _this = this;
        var productVariantsGrid = document.getElementById('product-variants-js');
        if (productVariantsGrid)
            productVariantsGrid.addEventListener('click', (function (event) { return _this.handleVariantCardClick(event); }));
    };
    ProductPage.prototype.handleVariantCardClick = function (event) {
        var clickedElement = event.target;
        if (clickedElement.classList.contains('add-to-cart-js')) {
            event.preventDefault();
            var productId = Number.parseInt(clickedElement.dataset.productId);
            var minOrderQuantity = Number.parseInt(clickedElement.dataset.minimumOrderQuantity);
            if (Number.isNaN(minOrderQuantity))
                minOrderQuantity = 1;
            this.cartService.setCartQuantity(productId, minOrderQuantity);
        }
    };
    return ProductPage;
}());
window.addEventListener("load", function () {
    var header = new ProductPage();
});
//# sourceMappingURL=productpage.js.map
var GDM;
(function (GDM) {
    var Helper;
    (function (Helper) {
        var EventHandler = /** @class */ (function () {
            function EventHandler() {
            }
            EventHandler.prototype.loadObjectOnScrollEvent = function (event, object, scrollOffset, unbindNamespace, callback, backendUrl, postingData) {
                if (scrollOffset === void 0) { scrollOffset = 150; }
                var objectOffset = object.offset();
                if (objectOffset == null) {
                    return;
                }
                var objectOffsetTop = objectOffset.top;
                if (!objectOffsetTop || objectOffsetTop <= 0) {
                    console.log("Object offsett not set");
                }
                if ($(window).scrollTop() > (objectOffsetTop - $(window).height() - scrollOffset)) {
                    if (unbindNamespace) {
                        $(window).off(unbindNamespace);
                    }
                    $.post(backendUrl, postingData, function (data) {
                        callback(data, object);
                    })
                        .fail(function (data, textStatus, jqXHR) {
                        console.log("ajax fail: " + textStatus + "; " + jqXHR);
                    });
                }
            };
            return EventHandler;
        }());
        Helper.EventHandler = EventHandler;
    })(Helper = GDM.Helper || (GDM.Helper = {}));
})(GDM || (GDM = {}));
//# sourceMappingURL=EventHandler.js.map
