{
  "version": 3,
  "sources": ["/cdn/shop/t/3/assets/gpo-cart-drawer.js"],
  "sourcesContent": ["/**\n *  Globo Product Options: open cart drawer after add to cart\n *\n *  When an option with add-on prices is chosen (e.g. \"Eigen bedrukking\"),\n *  Globo intercepts the add to cart button and posts the product plus its\n *  add-ons to /cart/add.js itself. Its own after-add callback does not\n *  support this theme: depending on script load order it either throws\n *  (drawer stays closed, cart count not updated) or redirects to /cart.\n *  This keeps the customer on the product page and re-renders the cart\n *  sections and opens the drawer the same way ProductForm does for a\n *  regular add to cart.\n */\n(function () {\n  if (window.gpoCartDrawerSync) {\n    return;\n  }\n  window.gpoCartDrawerSync = true;\n\n  const nativeFetch = window.fetch;\n  const editWindow = 10000;\n  let lastCartUpdate = 0;\n\n  const requestUrl = (input) => {\n    return typeof input === 'string' ? input : (input && input.url) || '';\n  };\n\n  const isPost = (init) => {\n    return Boolean(init) && String(init.method || 'GET').toUpperCase() === 'POST';\n  };\n\n  // The theme posts FormData; Globo posts JSON with _gpo properties.\n  const isGloboAdd = (url, init) => {\n    return /\\/cart\\/add(\\.js)?(\\?|$)/.test(url) &&\n      typeof init.body === 'string' &&\n      init.body.indexOf('\"_gpo') !== -1;\n  };\n\n  // When options are edited in the cart, Globo first clears the old lines via\n  // /cart/update.js, then re-adds them and reloads the page. Skip that case.\n  const isCartUpdate = (url) => {\n    return /\\/cart\\/update(\\.js)?(\\?|$)/.test(url);\n  };\n\n  const findProductForm = () => {\n    const form = window.GPOConfigs && window.GPOConfigs.form;\n    const productForm = form instanceof Element ? form.closest('product-form') : null;\n    return productForm || document.querySelector('product-form');\n  };\n\n  const renderCart = (cart) => {\n    const productForm = findProductForm();\n    if (!productForm || typeof productForm.renderContents !== 'function') {\n      return;\n    }\n    const sections = productForm.getSectionsToRender().map((section) => section.section);\n\n    return nativeFetch(`${window.location.pathname}?sections=${sections.join(',')}`)\n      .then((response) => response.json())\n      .then((sectionsHtml) => {\n        productForm.renderContents({\n          sections: sectionsHtml\n        });\n\n        if (typeof dispatchCustomEvent === 'function') {\n          dispatchCustomEvent('cart:item-added', {\n            product: cart.hasOwnProperty('items') ? cart.items[0] : cart\n          });\n        }\n      });\n  };\n\n  window.fetch = function (input, init) {\n    const request = nativeFetch.apply(this, arguments);\n\n    try {\n      const url = requestUrl(input);\n\n      if (isPost(init) && isCartUpdate(url)) {\n        lastCartUpdate = Date.now();\n      } else if (isPost(init) && isGloboAdd(url, init) && Date.now() - lastCartUpdate > editWindow) {\n        // Globo settings read by its after-add callback: update this cart\n        // count and stay on the product page instead of redirecting to /cart.\n        if (window.GPOConfigs) {\n          window.GPOConfigs.stayOnPdp = true;\n          window.GPOConfigs.customCartCountSelector = '#cart-drawer-toggle .thb-item-count';\n        }\n\n        request\n          .then((response) => (response.ok ? response.clone().json() : null))\n          .then((cart) => cart && renderCart(cart))\n          .catch((e) => {\n            console.error(e);\n          });\n      }\n    } catch (e) {\n      console.error(e);\n    }\n\n    return request;\n  };\n})();\n"],
  "mappings": "CAYC,UAAY,CACX,GAAI,OAAO,kBACT,OAEF,OAAO,kBAAoB,GAE3B,MAAM,YAAc,OAAO,MACrB,WAAa,IACnB,IAAI,eAAiB,EAErB,MAAM,WAAc,OACX,OAAO,OAAU,SAAW,MAAS,OAAS,MAAM,KAAQ,GAG/D,OAAU,MACP,EAAQ,MAAS,OAAO,KAAK,QAAU,KAAK,EAAE,YAAY,IAAM,OAInE,WAAa,CAAC,IAAK,OAChB,2BAA2B,KAAK,GAAG,GACxC,OAAO,KAAK,MAAS,UACrB,KAAK,KAAK,QAAQ,OAAO,IAAM,GAK7B,aAAgB,KACb,8BAA8B,KAAK,GAAG,EAGzC,gBAAkB,IAAM,CAC5B,MAAM,KAAO,OAAO,YAAc,OAAO,WAAW,KAEpD,OADoB,gBAAgB,QAAU,KAAK,QAAQ,cAAc,EAAI,OACvD,SAAS,cAAc,cAAc,CAC7D,EAEM,WAAc,MAAS,CAC3B,MAAM,YAAc,gBAAgB,EACpC,GAAI,CAAC,aAAe,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