1var component=function(){"use strict";var t={exports:{}};return function(t){class e{constructor(t){this.container=t,this.subscriptionContainer=t.querySelector(".shopify_subscriptions_app_container"),this.lastUpdateTime=0,this.updateDebounceDelay=100,this.subscriptionContainer&&this.init()}init(){this.storeOriginalPrices(),this.listenForVariantChanges(),this.waitForWidget().then((()=>{this.attachEventListeners(),this.observeSellingPlanInputChanges();const t=this.getSelectedPurchaseOption();t&&this.handleSellingPlanChange(t)}))}storeOriginalPrices(){const t=this.container.querySelector("[data-form-wrapper]");if(!t)return this.originalPrice=0,this.originalCompareAtPrice=0,void(this.isProductOnSale=!1);const e=t.dataset.variantPrice;this.originalPrice=e?parseInt(e,10):0;const i=t.dataset.variantComparePrice;this.originalCompareAtPrice=i?parseInt(i,10):0,this.isProductOnSale=this.originalCompareAtPrice&&this.originalCompareAtPrice>this.originalPrice}listenForVariantChanges(){this.container.querySelectorAll("form[data-product-form]").forEach((t=>{t.addEventListener("change",(t=>{t.target.closest(".shopify_subscriptions_app_container")||setTimeout((()=>{this.storeOriginalPrices(),this.reInitializeWidget()}),400)}))}));this.container.querySelectorAll('input[name="id"]').forEach((t=>{new MutationObserver((()=>{setTimeout((()=>{this.storeOriginalPrices(),this.reInitializeWidget()}),400)})).observe(t,{attributes:!0,attributeFilter:["value"]})})),"undefined"!=typeof subscribe&&subscribe("theme:variant:change",(()=>{setTimeout((()=>{this.storeOriginalPrices(),this.reInitializeWidget()}),400)}))}reInitializeWidget(){this.waitForWidget().then((()=>{this.attachEventListeners(),this.observeSellingPlanInputChanges();const t=this.getSelectedPurchaseOption();t&&this.handleSellingPlanChange(t)}))}extractPrice(t){if(!t)return 0;const e=t.toString().replace(/[^0-9.,]/g,"").replace(",","."),i=parseFloat(e);return isNaN(i)?0:Math.round(100*i)}waitForWidget(){return new Promise((t=>{if(this.getSellingPlanRadioButtons().length>0)return void t();const e=new MutationObserver((()=>{this.getSellingPlanRadioButtons().length>0&&(e.disconnect(),t())}));e.observe(this.container,{childList:!0,subtree:!0}),setTimeout((()=>{e.disconnect(),t()}),5e3)}))}getSellingPlanRadioButtons(){return this.container.querySelectorAll('.shopify_subscriptions_app_block input[type="radio"]')}getSelectedPurchaseOption(){return this.container.querySelector('.shopify_subscriptions_app_block:not(.shopify_subscriptions_app_block--hidden) input[type="radio"]:checked')}attachEventListeners(){this.getSellingPlanRadioButtons().forEach((t=>{t.addEventListener("change",(t=>{this.handleSellingPlanChange(t.target)}))}))}observeSellingPlanInputChanges(){this.container.querySelectorAll(".selected-selling-plan-id").forEach((t=>{new MutationObserver((()=>{const t=this.getSelectedPurchaseOption();t&&this.updatePrices(t)})).observe(t,{attributes:!0,attributeFilter:["value"]})}))}handleSellingPlanChange(t){this.updatePrices(t),this.dispatchCustomEvent(t)}updatePrices(t){const e=Date.now(),i=t.dataset.sellingPlanId;if(e-this.lastUpdateTime<this.updateDebounceDelay&&this.lastPlanId===i)return;this.lastUpdateTime=e,this.lastPlanId=i;const r=t.dataset.variantPrice,n=t.dataset.variantCompareAtPrice,a=t.dataset.sellingPlanId,s=t.dataset.sellingPlanAdjustment;if(!r)return;let o,l=null;if("string"==typeof r&&r.includes("$")?(o=this.extractPrice(r),n&&(l=this.extractPrice(n))):(o=parseInt(r,10),l=n?parseInt(n,10):null),isNaN(o)||0===o)return;let c=o,d=null,h=!1;const u=o!==this.originalPrice;this.isProductOnSale?o<this.originalPrice?(c=o,d=this.originalPrice,h=!0):u?(c=o,d=this.originalCompareAtPrice,h=c<this.originalCompareAtPrice):(c=this.originalPrice,d=this.originalCompareAtPrice,h=!0):o<this.originalPrice?(c=o,d=this.originalPrice,h=!0):u?(c=o,d=null,h=!1):(c=this.originalPrice,d=null,h=!1);const p=this.formatMoney(c),g=d?this.formatMoney(d):null;this.updatePriceElements(p,g,h);this.container.querySelectorAll("[data-add-to-cart]").forEach((t=>{t.dataset.subscriptionPrice=o.toString(),t.dataset.subscriptionCompareAtPrice=l?l.toString():"",t.dataset.sellingPlanId=a||"",t.dataset.sellingPlanAdjustment=s||""}))}updatePriceElements(t,e,i){this.container.querySelectorAll("[data-price-wrapper]").forEach((r=>{r.querySelectorAll("[data-product-price]").forEach((r=>{r.innerHTML=t,i&&e?r.classList.add("product__price--sale"):r.classList.remove("product__price--sale")}));const n=r.querySelectorAll("[data-compare-price]");
1i&&e?n.forEach((t=>{t.innerHTML=e,t.classList.remove("hidden"),t.style.display=""})):n.forEach((t=>{t.classList.add("hidden")}))}))}dispatchCustomEvent(t){const e=new CustomEvent("subscription:planChanged",{bubbles:!0,detail:{price:t.dataset.variantPrice,compareAtPrice:t.dataset.variantCompareAtPrice,sellingPlanId:t.dataset.sellingPlanId,sellingPlanAdjustment:t.dataset.sellingPlanAdjustment,isProductOnSale:this.isProductOnSale,originalPrice:this.originalPrice,originalCompareAtPrice:this.originalCompareAtPrice,radioButton:t}});this.container.dispatchEvent(e)}formatMoney(t){if("number"!=typeof t||isNaN(t))return console.error("formatMoney received invalid value:",t),"$0.00";if("undefined"!=typeof Shopify&&Shopify.formatMoney)return Shopify.formatMoney(t,theme.moneyFormat||"${{amount}}");return`$${(t/100).toFixed(2)}`}}function i(){document.querySelectorAll('[data-section-type*="product"]').forEach((t=>{t.dataset.subscriptionPriceUpdaterInitialized||(t.dataset.subscriptionPriceUpdaterInitialized="true",new e(t))}))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",i):i(),document.addEventListener("shopify:section:load",(()=>{i()})),t.exports&&(t.exports=e)}(t),t.exports}();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.