1var component=function(){"use strict";var e={exports:{}};return function(e){class t{constructor(e){this.container=e,this.subscriptionContainer=e.querySelector(".shopify_subscriptions_app_container"),this.lastUpdateTime=0,this.updateDebounceDelay=100,this.sellingPlanObservers=[],this.cachedPriceElements=null,this.subscriptionContainer&&this.init()}init(){this.storeOriginalPrices(),this._onVariantPricesUpdated=this._onVariantPricesUpdated.bind(this),this.container.addEventListener("theme:variant:prices-updated",this._onVariantPricesUpdated),this.waitForWidget().then((()=>{this.attachEventListeners(),this.observeSellingPlanInputChanges();const e=this.getSelectedPurchaseOption();e&&this.handleSellingPlanChange(e)}))}storeOriginalPrices(){const e=this.container.querySelector("[data-form-wrapper]");if(!e)return this.originalPrice=0,this.originalCompareAtPrice=0,void(this.isProductOnSale=!1);const t=e.dataset.variantPrice;this.originalPrice=t?parseInt(t,10):0;const i=e.dataset.variantComparePrice;this.originalCompareAtPrice=i?parseInt(i,10):0,this.isProductOnSale=this.originalCompareAtPrice&&this.originalCompareAtPrice>this.originalPrice}_onVariantPricesUpdated(){this.invalidatePriceElementsCache(),this.storeOriginalPrices(),this.reInitializeWidget()}reInitializeWidget(){this.waitForWidget().then((()=>{this.attachEventListeners(),this.observeSellingPlanInputChanges();const e=this.getSelectedPurchaseOption();e&&this.handleSellingPlanChange(e)}))}extractPrice(e){if(!e)return 0;let t=e.toString().trim().replace(/[A-Z]{3}/g,"").replace(/[$â¬Â£Â¥â¹â½Â¢â©âªâ¦â¨]/g,"").trim();let i,n;t.lastIndexOf(",")>t.lastIndexOf(".")?(i=",",n="."):(i=".",n=","),t=t.replace(new RegExp("\\"+n,"g"),"").replace(i,"."),t=t.replace(/[^0-9.]/g,"");const r=parseFloat(t);return isNaN(r)?0:Math.round(100*r)}waitForWidget(){return new Promise((e=>{if(this.getSellingPlanRadioButtons().length>0)return void e();const t=new MutationObserver((()=>{this.getSellingPlanRadioButtons().length>0&&(t.disconnect(),e())}));t.observe(this.container,{childList:!0,subtree:!0}),setTimeout((()=>{t.disconnect(),e()}),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((e=>{e.addEventListener("change",(e=>{this.handleSellingPlanChange(e.target)}))}))}observeSellingPlanInputChanges(){this.disconnectSellingPlanObservers();this.container.querySelectorAll(".selected-selling-plan-id").forEach((e=>{const t=new MutationObserver((()=>{const e=this.getSelectedPurchaseOption();e&&this.updatePrices(e)}));t.observe(e,{attributes:!0,attributeFilter:["value"]}),this.sellingPlanObservers.push(t)}))}handleSellingPlanChange(e){this.updatePrices(e),this.dispatchCustomEvent(e)}updatePrices(e){const t=Date.now(),i=e.dataset.sellingPlanId;if(t-this.lastUpdateTime<this.updateDebounceDelay&&this.lastPlanId===i)return;this.lastUpdateTime=t,this.lastPlanId=i;const n=e.dataset.variantPrice,r=e.dataset.variantCompareAtPrice,a=e.dataset.sellingPlanId,s=e.dataset.sellingPlanAdjustment;if(!n)return;let l;if("string"==typeof n&&/[^0-9]/.test(n)?(l=this.extractPrice(n),r&&this.extractPrice(r)):l=parseInt(n,10),isNaN(l))return;let o=l,c=null,d=!1;const h=l!==this.originalPrice;this.isProductOnSale?l<this.originalPrice?(o=l,c=this.originalPrice,d=!0):h?(o=l,c=this.originalCompareAtPrice,d=o<this.originalCompareAtPrice):(o=this.originalPrice,c=this.originalCompareAtPrice,d=!0):l<this.originalPrice?(o=l,c=this.originalPrice,d=!0):h?(o=l,c=null,d=!1):(o=this.originalPrice,c=null,d=!1),this.updatePriceElements(o,c,d);this.container.querySelectorAll("[data-add-to-cart]").forEach((e=>{a?(e.dataset.subscriptionPrice=o.toString(),e.dataset.subscriptionCompareAtPrice=c?c.toString():"",e.dataset.sellingPlanId=a,e.dataset.sellingPlanAdjustment=s||""):(delete e.dataset.subscriptionPrice,delete e.dataset.subscriptionCompareAtPrice,delete e.dataset.sellingPlanId,delete e.dataset.sellingPlanAdjustment)}))}getQuantity(){const e=this.container.querySelector("[data-quantity-field]");return e&&parseInt(e.value||"1",10)||1}getCachedPriceElements(){if(!this.cachedPriceElements){const e=this.container.querySelectorAll("[data-price-wrapper]"),t=[];e.forEach((e=>{const i=e.querySelectorAll("[data-product-price]"),n=e.querySelectorAll("[data-compare-price]");t.push({wrapper:e,priceElements:Array.from(i),comparePriceElements:Array.from(n)})})),this.cachedPriceElements=t}return this.cachedPriceElements}invalidatePriceElementsCache(){this.cachedPriceElements=null}updatePriceElements(e,t,i){const n=this.getCachedPriceElements(),r=this.getQuantity(),a=window.theme?.strings?.free;
1n.forEach((({wrapper:n,priceElements:s,comparePriceElements:l})=>{const o=n.hasAttribute("data-atc-button"),c=o?e*r:e,d=null!=t?o?t*r:t:null,h=0===c&&a?a:this.formatMoney(c),u=null!=d?this.formatMoney(d):null;s.forEach((e=>{e.innerHTML=h,i&&u?e.classList.add("product__price--sale"):e.classList.remove("product__price--sale")})),i&&u?l.forEach((e=>{e.innerHTML=u,e.classList.remove("hidden"),e.style.display=""})):l.forEach((e=>{e.classList.add("hidden")}))}))}dispatchCustomEvent(e){const t=new CustomEvent("subscription:planChanged",{bubbles:!0,detail:{price:e.dataset.variantPrice,compareAtPrice:e.dataset.variantCompareAtPrice,sellingPlanId:e.dataset.sellingPlanId,sellingPlanAdjustment:e.dataset.sellingPlanAdjustment,isProductOnSale:this.isProductOnSale,originalPrice:this.originalPrice,originalCompareAtPrice:this.originalCompareAtPrice,radioButton:e}});this.container.dispatchEvent(t)}disconnectSellingPlanObservers(){this.sellingPlanObservers.forEach((e=>{e.disconnect()})),this.sellingPlanObservers=[]}destroy(){this.container.removeEventListener("theme:variant:prices-updated",this._onVariantPricesUpdated),this.disconnectSellingPlanObservers(),this.invalidatePriceElementsCache()}formatMoney(e){if("number"!=typeof e||isNaN(e))return console.error("formatMoney received invalid value:",e),"$0.00";if("undefined"!=typeof Shopify&&Shopify.formatMoney)return Shopify.formatMoney(e,theme.moneyFormat||"${{amount}}");try{return new Intl.NumberFormat("en-US",{style:"currency",currency:theme.current_iso_code}).format(e/100)}catch(t){console.error("Intl.NumberFormat error:",t);return`$${(e/100).toFixed(2)}`}}}const i=new WeakMap;function n(){document.querySelectorAll('[data-section-type*="product"]').forEach((e=>{if(e.dataset.subscriptionPriceUpdaterInitialized)return;e.dataset.subscriptionPriceUpdaterInitialized="true";const n=new t(e);i.set(e,n)}))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n(),document.addEventListener("shopify:section:load",(()=>{n()})),document.addEventListener("shopify:section:unload",(e=>{const t=e.target,n=i.get(t);n&&(n.destroy(),i.delete(t),delete t.dataset.subscriptionPriceUpdaterInitialized)})),e.exports&&(e.exports=t)}(e),e.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.