{
  "version": 3,
  "sources": ["/cdn/shop/t/52/assets/cart-notification.js?section_id=cart-notification"],
  "sourcesContent": ["if (!customElements.get('cart-notification')) {\n  class TG_CartNotification extends HTMLElement {\n    constructor() {\n      super();\n    }\n\n    connectedCallback() {\n      this.cartNotificationInstance = themegoal.components.Toast.getOrCreateInstance(this);\n      this.cartNotificationLinks = this.querySelector(\".CartNotification__Links\");\n      this.cartNotificationProduct = this.querySelector(\".CartNotification__Product\");\n\n      this.onBodyClick = this.handleBodyClick.bind(this);\n      this.onProductAdded = this._onProductAdded.bind(this);\n      this._bindEventsListeners();\n    }\n\n    disconnectedCallback(){\n      document.removeEventListener('product:added', this.onProductAdded);\n    }\n\n    _bindEventsListeners() {\n      var _this = this;\n      document.addEventListener('product:added', this.onProductAdded);\n\n      this.addEventListener('shown.tg.Toast', () => {\n        document.body.addEventListener('click', _this.onBodyClick);\n      });\n      this.addEventListener('hidden.tg.Toast', () => {\n        document.body.removeEventListener('click', _this.onBodyClick);\n      })\n    }\n    \n    _onProductAdded(event){\n      var _this = this;\n      return fetch(window.routes.cartUrl + '?section_id=cart-notification' + '&timestamp=' + Date.now(), {\n        credentials: 'same-origin',\n        method: 'GET'\n      }).then(function (content) {\n        \n        content.text().then(function (html) {\n          _this._replaceContent(html, event.detail.cartItemKey)\n        });\n\n      });\n    }\n\n    _replaceContent(html,itemKey) {\n      let _this = this;\n\n      let tempElement = document.createElement('div');\n      tempElement.innerHTML = html;\n\n      this.cartNotificationLinks.innerHTML = tempElement.querySelector(\".CartNotification__Links\").innerHTML;\n      this.querySelector(\".CartNotification__Product\").innerHTML = tempElement.querySelector(`[id=\"cart-notification-product-${itemKey}\"]`).innerHTML;\n\n      let cartResult = JSON.parse(tempElement.querySelector('.CartNotification').getAttribute('data-section-settings'));\n\n      let cartCount = themegoal.helpers.Dom.nodeListToArray(document.querySelectorAll('.CartCountBubble')),\n      cartText = themegoal.helpers.Dom.nodeListToArray(document.querySelectorAll('.CartCountText')),\n      cartQuantity = themegoal.helpers.Dom.nodeListToArray(document.querySelectorAll('.CartCountBubble__Count'));\n\n      this.itemCount = cartResult['itemCount'];\n\n      cartCount.forEach(function (item) {\n        if (_this.itemCount === 0) {\n          item.classList.remove('Visible'); \n        } else {\n          item.classList.add('Visible');\n        }\n      });\n\n      cartText.forEach(function (item) {\n        if (_this.itemCount === 0) {\n          item.classList.add('Visible'); \n        } else {\n          item.classList.remove('Visible');\n        }\n      });\n\n      cartQuantity.forEach(function (item) {\n        item.textContent = _this.itemCount;\n      });\n\n      this.cartNotificationInstance.show();\n\n      this.scrollIntoView({ behavior: 'smooth', block:\"start\"}); \n    }\n\n    handleBodyClick(evt) {\n      const target = evt.target;\n      if (target !== this && !target.closest('cart-notification')) {\n        this.cartNotificationInstance.hide();\n      }\n    }\n\n  }\n\n  customElements.define('cart-notification', TG_CartNotification);\n}\n"],
  "mappings": "AAAA,GAAI,CAAC,eAAe,IAAI,mBAAmB,EAAG,CAC5C,MAAM,4BAA4B,WAAY,CAC5C,aAAc,CACZ,MAAM,CACR,CAEA,mBAAoB,CAClB,KAAK,yBAA2B,UAAU,WAAW,MAAM,oBAAoB,IAAI,EACnF,KAAK,sBAAwB,KAAK,cAAc,0BAA0B,EAC1E,KAAK,wBAA0B,KAAK,cAAc,4BAA4B,EAE9E,KAAK,YAAc,KAAK,gBAAgB,KAAK,IAAI,EACjD,KAAK,eAAiB,KAAK,gBAAgB,KAAK,IAAI,EACpD,KAAK,qBAAqB,CAC5B,CAEA,sBAAsB,CACpB,SAAS,oBAAoB,gBAAiB,KAAK,cAAc,CACnE,CAEA,sBAAuB,CACrB,IAAI,MAAQ,KACZ,SAAS,iBAAiB,gBAAiB,KAAK,cAAc,EAE9D,KAAK,iBAAiB,iBAAkB,IAAM,CAC5C,SAAS,KAAK,iBAAiB,QAAS,MAAM,WAAW,CAC3D,CAAC,EACD,KAAK,iBAAiB,kBAAmB,IAAM,CAC7C,SAAS,KAAK,oBAAoB,QAAS,MAAM,WAAW,CAC9D,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