{
  "version": 3,
  "sources": ["/cdn/shop/t/30/assets/pdp-variant-price.js"],
  "sourcesContent": ["/* PDP variant price update \u2014 defensive patch\n   Project: Veryplants CRO fixes (Apr 2026)\n\n   Theme uses pubsub.js + constants.js with PUB_SUB_EVENTS.variantChange.\n   product-info.js renders the section on variant change, which should already update\n   the price. This patch is defensive: subscribes to the same event and force-updates\n   the price elements + Seal Subscriptions price if present.\n\n   Safe to remove if QA confirms the underlying behaviour is working.\n*/\n\n(function () {\n  if (window.__veryplantsPdpPricePatchLoaded) return;\n  window.__veryplantsPdpPricePatchLoaded = true;\n\n  function init() {\n    if (typeof window.subscribe !== 'function' || !window.PUB_SUB_EVENTS) {\n      // pubsub not loaded yet, retry shortly.\n      return setTimeout(init, 200);\n    }\n\n    window.subscribe(window.PUB_SUB_EVENTS.variantChange, (data) => {\n      const variant = data && (data.data?.variant || data.variant);\n      if (!variant) return;\n      updatePrices(variant);\n    });\n\n    // Also catch the option-change event for snappier updates before section render completes.\n    window.subscribe(window.PUB_SUB_EVENTS.optionValueSelectionChange, () => {\n      const idInput = document.querySelector('product-info form[action*=\"/cart/add\"] input[name=\"id\"]');\n      if (!idInput) return;\n      const id = Number(idInput.value);\n      if (!id) return;\n      // Look up product JSON if the form has handle data.\n      const form = idInput.closest('form');\n      const productInfo = form?.closest('product-info');\n      const handle = productInfo?.dataset.url?.split('/').pop()?.split('?')[0];\n      if (!handle) return;\n      fetch(`/products/${handle}.js`)\n        .then((r) => r.json())\n        .then((p) => {\n          const variant = p.variants.find((v) => v.id === id);\n          if (variant) updatePrices(variant);\n        })\n        .catch(() => {});\n    });\n  }\n\n  function updatePrices(variant) {\n    const priceCents = variant.price;\n    const compareCents = variant.compare_at_price;\n\n    // Main displayed price.\n    document.querySelectorAll(\n      '.price-item--regular, .price__regular .price-item, [data-product-price]'\n    ).forEach((el) => {\n      el.textContent = formatMoney(priceCents);\n    });\n\n    // Compare-at price.\n    document.querySelectorAll(\n      '.price-item--sale, .price__sale .price-item, [data-compare-price]'\n    ).forEach((el) => {\n      if (compareCents && compareCents > priceCents) {\n        el.textContent = formatMoney(compareCents);\n      }\n    });\n\n    // Seal Subscriptions widget price (defensive \u2014 class name may vary by version).\n    document.querySelectorAll(\n      '.seal-subscriptions-widget .seal-subscriptions-product-price, .seal-subscriptions-price, [data-subscription-price]'\n    ).forEach((el) => {\n      // Don't know the discount% reliably from JS \u2014 best effort: re-fetch widget render.\n      // If the widget is rendering stale, the simplest fix is to re-call its render method.\n      if (window.sealSubscriptions && typeof window.sealSubscriptions.refresh === 'function') {\n        try { window.sealSubscriptions.refresh(); } catch (e) {}\n      }\n    });\n\n    document.dispatchEvent(\n      new CustomEvent('veryplants:price-updated', { detail: { variant, priceCents } })\n    );\n  }\n\n  function formatMoney(cents) {\n    if (window.Shopify && Shopify.formatMoney) {\n      try {\n        return Shopify.formatMoney(cents, window.theme?.moneyFormat || '${{amount}}');\n      } catch (e) {}\n    }\n    return '$' + (cents / 100).toFixed(2);\n  }\n\n  if (document.readyState === 'loading') {\n    document.addEventListener('DOMContentLoaded', init);\n  } else {\n    init();\n  }\n})();\n"],
  "mappings": "CAWC,UAAY,CACX,GAAI,OAAO,gCAAiC,OAC5C,OAAO,gCAAkC,GAEzC,SAAS,MAAO,CACd,GAAI,OAAO,OAAO,WAAc,YAAc,CAAC,OAAO,eAEpD,OAAO,WAAW,KAAM,GAAG,EAG7B,OAAO,UAAU,OAAO,eAAe,cAAgB,MAAS,CAC9D,MAAM,QAAU,OAAS,KAAK,MAAM,SAAW,KAAK,SAC/C,SACL,aAAa,OAAO,CACtB,CAAC,EAGD,OAAO,UAAU,OAAO,eAAe,2BAA4B,IAAM,CACvE,MAAM,QAAU,SAAS,cAAc,yDAAyD,EAChG,GAAI,CAAC,QAAS,OACd,MAAM,GAAK,OAAO,QAAQ,KAAK,EAC/B,GAAI,CAAC,GAAI,OAIT,MAAM,OAFO,QAAQ,QAAQ,MAAM,GACT,QAAQ,cAAc,GACpB,QAAQ,KAAK,MA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