{
  "version": 3,
  "sources": ["/cdn/shop/t/226/assets/btk-cart-count.js?cb=5"],
  "sourcesContent": ["/**\n * btk-cart-count.js - header basket badge\n * ----------------------------------------------------------------\n * Keeps the header's cart-icon badge in step with the basket.\n *\n * Lifted out of btk-cart-drawer.js when the slide-over drawer was retired\n * (2026-08-17) in favour of navigating straight to /cart. The badge never had\n * anything to do with the drawer UI - it only lived there because that file\n * happened to be loaded on every page - and btk-cart-advanced.js calls\n * window.btkRefreshCartCount() in two places, so it had to survive the removal.\n *\n * WHY A SECTION RE-RENDER, NOT textContent: the badge element is absent\n * entirely when the basket is empty, so there is no node to write a number\n * into. Re-rendering the header section server-side gets the correct markup\n * for both states - empty and populated - without duplicating that logic here.\n */\nwindow.btkRefreshCartCount = function () {\n  return fetch('/?sections=header')\n    .then(function (r) { return r.json(); })\n    .then(function (s) {\n      if (!s || !s.header) return;\n      var tmp = document.createElement('div');\n      tmp.innerHTML = s.header;\n      var ng = tmp.querySelector('#cart-icon .header__icon-graphic');\n      if (!ng) return;\n      document.querySelectorAll('#cart-icon .header__icon-graphic').forEach(function (cg) {\n        cg.innerHTML = ng.innerHTML;\n      });\n      // The basket total under the icon (Arden, 2026-10-11): the server sends it\n      // inc VAT - show it the way the VAT switch says. The basket's own\n      // Today's Price wins where it is known (btkApplyHeaderTotal).\n      var total = document.getElementById('header-cart-total');\n      var raw = total ? parseInt(total.getAttribute('data-btk-raw'), 10) : NaN;\n      if (total && window.BTKVat && !isNaN(raw)) total.textContent = window.BTKVat.formatPrice(raw);\n      // The redrawn header arrives with its \"ex VAT\" mark hidden.\n      if (window.BTKVat && window.BTKVat.updateToggleUI) window.BTKVat.updateToggleUI();\n      window.btkApplyHeaderTotal();\n    })\n    .catch(function () { /* a stale badge is not worth surfacing */ });\n};\n\n// Any surface that adds or changes items announces it; keep the badge honest.\ndocument.addEventListener('btk:item-added', function () {\n  window.btkRefreshCartCount();\n});\n\n// THE HEADER SHOWS THE BASKET'S TODAY'S PRICE (Arden, 2026-10-27), delivery\n// included, not Shopify's cart total - which leaves delivery out and, in staff\n// mode, is the salesperson's own cart (a customer's staff FREE- code cannot\n// apply there). The cart page publishes it (btk-cart-advanced.js\n// publishHeaderTotal) with the basket, its save (updatedAt) and its item count;\n// on other pages it is used only while the cart holds THAT save of THAT basket\n// (the cart's _btk_basket_id / _btk_basket_rev, on #header-cart-total), else\n// the server's total stands. Matching on the item count alone showed an older\n// Today's Price - \u00A369.73 with the standard delivery estimate, over \u00A33.90 with\n// \"Deliver with your main order\" (Sales bugs row 63).\nwindow.btkApplyHeaderTotal = function () {\n  var el = document.getElementById('header-cart-total');\n  if (!el || !window.BTKVat) return;\n  var held = window.__btkHeaderTotal || null;\n  if (!held) {\n    try { held = JSON.parse(localStorage.getItem('btk_header_cart_total') || 'null'); } catch (e) { held = null; }\n    var badge = document.querySelector('#cart-icon .header__cart-count-number');\n    var count = badge ? parseInt(badge.textContent, 10) : NaN;\n    if (!held || typeof held.pence !== 'number' || held.count !== count || !held.basket\n        || held.basket !== el.getAttribute('data-btk-basket')\n        || held.rev !== el.getAttribute('data-btk-rev')) {\n      // Not this basket's: the server's figure, the way the VAT switch says.\n      var raw = parseInt(el.getAttribute('data-btk-raw'), 10);\n      if (!isNaN(raw)) el.textContent = window.BTKVat.formatPrice(raw);\n      return;\n    }\n  }\n  el.setAttribute('data-btk-raw', held.pence);\n  el.textContent = window.BTKVat.formatPrice(held.pence);\n};\nif (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', window.btkApplyHeaderTotal);\nelse window.btkApplyHeaderTotal();\n"],
  "mappings": "AAgBA,OAAO,oBAAsB,UAAY,CACvC,OAAO,MAAM,mBAAmB,EAC7B,KAAK,SAAU,EAAG,CAAE,OAAO,EAAE,KAAK,CAAG,CAAC,EACtC,KAAK,SAAU,EAAG,CACjB,GAAI,GAAC,GAAK,CAAC,EAAE,QACb,KAAI,IAAM,SAAS,cAAc,KAAK,EACtC,IAAI,UAAY,EAAE,OAClB,IAAI,GAAK,I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