{"config": "/*\r\n// Change this selectors below for your theme\r\nconst itemsSelector = \".line-item\";\r\nconst itemsQtySelector = \".quantity-selector\";\r\n// Change this selectors for your theme\r\n\r\nsetInterval(() => {\r\n\r\nlet gifts = document.querySelectorAll(`${itemsSelector} a[href*=\"gratis-geschenk\"]`);\r\n\r\ngifts.forEach((gift) => {\r\n\r\n    let giftWrapper = gift.closest(itemsSelector);\r\n\r\n    if(!giftWrapper) return;\r\n\r\nlet qtyInputs = giftWrapper?.querySelectorAll(`${itemsQtySelector}, ${itemsQtySelector} *`);\r\n\r\nqtyInputs.forEach((el) => {\r\n\r\nel.style[\"pointer-events\"] = \"none\";\r\n\r\nel.style[\"opacity\"] = \"0.25\";\r\n\r\n});\r\n\r\n});\r\n\r\n}, 100);\r\n\r\n\r\n\r\nconst CONFIG = {\r\n  selectors: {\r\n    cartItem: '.line-item',\r\n    qtySelector: '.quantity-selector',\r\n    qtyInput: '.quantity-selector__input',\r\n    qtyButtons: '.quantity-selector__button',\r\n    qtyContainer: '.line-item__quantity',\r\n    removeButton: '.line-item__remove-button',\r\n    imageLink: '.line-item__image-wrapper',\r\n    productTitle: '.product-item-meta__title',\r\n    freeGiftIdentifiers: ['[href*=\"gratis\"]', '[href*=\"free-gift\"]']\r\n  },\r\n  styles: {\r\n    disabled: {\r\n      opacity: '0.25',\r\n      pointerEvents: 'none',\r\n      userSelect: 'none'\r\n    },\r\n    noClick: {\r\n      pointerEvents: 'none',\r\n      userSelect: 'none',\r\n      cursor: 'default'\r\n    },\r\n    hidden: {\r\n      display: 'none'\r\n    }\r\n  },\r\n  defaultQty: 1\r\n};\r\n\r\nfunction applyStyles(element, styles) {\r\n  Object.assign(element.style, styles);\r\n}\r\n\r\nfunction lockFreeGiftItem(item) {\r\n  let isFreeGift = CONFIG.selectors.freeGiftIdentifiers.some(selector => item.querySelector(selector));\r\n  const productTitle = item.querySelector(CONFIG.selectors.productTitle);\r\n  if (!isFreeGift && productTitle && productTitle.textContent.toUpperCase().includes(\"GRATIS\")) {\r\n    isFreeGift = true;\r\n  }\r\n  if (!isFreeGift) return;\r\n\r\n  const qtyContainer = item.querySelector(CONFIG.selectors.qtyContainer);\r\n  if (qtyContainer) applyStyles(qtyContainer, CONFIG.styles.hidden);\r\n\r\n  const removeButton = item.querySelector(CONFIG.selectors.removeButton);\r\n  if (removeButton) applyStyles(removeButton, CONFIG.styles.disabled);\r\n\r\n  const imageLink = item.querySelector(CONFIG.selectors.imageLink);\r\n  if (imageLink) {\r\n    applyStyles(imageLink, CONFIG.styles.noClick);\r\n    imageLink.removeAttribute('href');\r\n    imageLink.onclick = e => e.preventDefault();\r\n  }\r\n\r\n  if (productTitle) {\r\n    applyStyles(productTitle, CONFIG.styles.noClick);\r\n    productTitle.onclick = e => e.preventDefault();\r\n  }\r\n\r\n  const qtyInput = item.querySelector(CONFIG.selectors.qtyInput);\r\n  if (qtyInput) {\r\n    qtyInput.value = CONFIG.defaultQty;\r\n    qtyInput.setAttribute('readonly', true);\r\n    qtyInput.setAttribute('disabled', true);\r\n    qtyInput.style.pointerEvents = 'none';\r\n  }\r\n}\r\n\r\nfunction handleFreeGiftQuantities() {\r\n  const cartItems = document.querySelectorAll(CONFIG.selectors.cartItem);\r\n  cartItems.forEach(item => lockFreeGiftItem(item));\r\n}\r\n\r\nconst observer = new MutationObserver(() => {\r\n  handleFreeGiftQuantities();\r\n});\r\nconst targetNode = document.body || document.documentElement;\r\nobserver.observe(targetNode, { childList: true, subtree: true });\r\n\r\nhandleFreeGiftQuantities();\r\n\r\n// Disable Checkout Btn\r\n\r\nconst DELAY = 4000;\r\n\r\nfunction toggleCheckoutBtn(show) {\r\n    document.querySelectorAll(`.checkout-button`).forEach(btn => {\r\n        show ? btn.removeAttribute(\"disabled\") : btn.setAttribute(\"disabled\", \"true\");\r\n    })\r\n}\r\n\r\ndocument.addEventListener(\"click\", (e) => {\r\n\r\n\r\nif(!e.target.closest(\".quantity-selector__button\")) return;\r\n\r\n\r\n\r\ntoggleCheckoutBtn(false);\r\n\r\n\r\nsetTimeout(() => toggleCheckoutBtn(true), DELAY);\r\n\r\n\r\n})\r\n\r\n\r\n\r\n\r\ndocument.addEventListener(\"change\", (e) => {\r\n\r\n\r\nif(!e.target.closest(\".quantity-selector__input\")) return;\r\n\r\n\r\n\r\ntoggleCheckoutBtn(false);\r\n\r\n\r\nsetTimeout(() => toggleCheckoutBtn(true), DELAY);\r\n\r\n\r\n})\r\n\r\nwindow.GIFTBOX_CUSTOM_UPDATE_CART = () => {\r\n\r\n\r\n// focal theme cart refresh v2\r\n\r\n\r\nfetch(`${window.themeVariables.routes.cartUrl}.js`).then(async (response) => {\r\n\r\n\r\nconst cartContent = await response.json();\r\n\r\n\r\ndocument.documentElement.dispatchEvent(new CustomEvent(\"cart:refresh\", {\r\n\r\n\r\nbubbles: true,\r\n\r\n\r\ndetail: {\r\n\r\n\r\ncart: cartContent\r\n\r\n\r\n}\r\n\r\n\r\n}));\r\n\r\n\r\n});\r\n\r\n\r\n}\r\n\r\nwindow.GIFTBOX_CUSTOM_CART_ITEMS_SELECTORS = [\".qsc2-product-item\"]\r\nwindow.GIFTBOX_CUSTOM_CART_REMOVE_LINK_SELECTORS= [\".qsc2-product-item__product-title a\"]\r\nwindow.GIFTBOX_CUSTOM_CART_REMOVE_INPUTS_SELECTORS = [\".qsc2-product-item__quantity\"]\r\n*/\r\n\r\n\r\nconst itemsSelector = \".qsc2-product-item\";\r\nconst itemsQtySelector = \".qsc2-product-item .qsc2-product-item__quantity\";\r\n\r\nsetInterval(() => {\r\n\r\nlet gifts = document.querySelectorAll(`${itemsSelector} a[href*=\"gratis-geschenk\"]:not(:has(img))`);\r\n\tgifts.forEach((gift) => {\r\n\t\r\n\t    let giftWrapper = gift.closest(itemsSelector);\r\n\t\r\n\t    if(!giftWrapper) return;\r\n\t\r\n\t\t\tlet qtyInputs = giftWrapper?.querySelectorAll(`${itemsQtySelector}, ${itemsQtySelector} *`);\r\n\t\t\t\r\n\t\t\tqtyInputs.forEach((el) => {\r\n\t\t\t\r\n\t\t\tel.style[\"pointer-events\"] = \"none\";\r\n\t\t\t\r\n\t\t\tel.style[\"opacity\"] = \"0.25\";\r\n\t\t\r\n\t\t});\r\n\t\r\n\t});\r\n}, 100);", "gp_handle_pairs": null, "injection_method": "app_extension", "gp_hiding_in_collections_disabled": false, "storefront_access_token": "c714c409a3b4d0bee4e23a9f75cb5fe4"}