PageSourceSearch

https://invizi.com/cdn/shop/t/3/assets/cart-checkout.js?v=181247248162659387241791422734

js invizi.com collected 2026-10-09 23:49:21 UTC 28,631 bytes, 158 lines download raw bytes

1import{CartAddPendingEvent,ThemeEvents}from"@theme/events";import{sectionRenderer}from"@theme/section-renderer";import{prefersReducedMotion,fetchCartJsonWithMeta}from"@theme/utilities";let pendingCount=0;const pendingOptimisticIds=[];function consumeOptimisticId(preferredId=""){if(preferredId){const index=pendingOptimisticIds.indexOf(preferredId);if(index!==-1)return pendingOptimisticIds.splice(index,1),preferredId}return pendingOptimisticIds.shift()||""}function setAddingState(adding){document.querySelector("cart-drawer-component")?.toggleAttribute("cart-adding",adding);const btn=document.getElementById("checkout")||document.querySelector(".cart__checkout-button");btn&&(btn.classList.toggle("is-loading",adding),btn.setAttribute("aria-busy",adding?"true":"false"),btn.disabled=adding)}function animateOptimisticRowAdd(row){if(!(row instanceof HTMLElement)||prefersReducedMotion())return;const startAnimation=()=>{const measuredHeight=row.clientHeight;if(measuredHeight<=0)return;const cleanup=()=>{row.classList.remove("adding"),row.style.removeProperty("--row-height"),row.style.removeProperty("overflow"),row.style.removeProperty("height"),row.style.removeProperty("opacity"),row.style.removeProperty("margin-bottom"),row.style.removeProperty("padding-bottom")};row.style.setProperty("--row-height",`${measuredHeight}px`),row.style.overflow="hidden",row.style.height="0",row.style.opacity="0",row.style.marginBottom="0",row.style.paddingBottom="0",row.offsetHeight,row.style.height="",row.style.opacity="",row.addEventListener("animationend",event=>{event.target!==row||event.animationName!=="addRow"||cleanup()},{once:!0}),row.classList.add("adding")};requestAnimationFrame(()=>{requestAnimationFrame(startAnimation)})}function findOptimisticRow(optimisticId){if(optimisticId){const match=document.querySelector(`.cart-items__table-row[data-optimistic-id="${CSS.escape(optimisticId)}"]`);if(match instanceof HTMLElement)return match}const fallback=document.querySelector('.cart-items__table-row[data-optimistic="true"]');return fallback instanceof HTMLElement?fallback:null}function decodeHtmlEntities(str){if(!str||!str.includes("&"))return String(str);const el=document.createElement("textarea");return el.innerHTML=String(str),el.value}function esc(str){return decodeHtmlEntities(str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function getThemeTranslations(){return window.Theme?.translations||{}}function getThemeCartConfig(){const cart=window.Theme?.cart||{};return{totalPriceCents:Number(cart.totalPriceCents)||0,freeShippingThresholdCents:Number(cart.freeShippingThresholdCents)||0,moneyFormat:cart.moneyFormat||"{{amount}}"}}function formatMoneyFromCents(moneyValueCents){const template=getThemeCartConfig().moneyFormat||"{{amount}}",placeholderMatch=template.match(/\{\{\s*(\w+)\s*\}\}/),placeholder=placeholderMatch?placeholderMatch[1]:"amount";let precision=2,thousandsSeparator=",",decimalSeparator=".";switch(placeholder){case"amount_no_decimals":precision=0;break;case"amount_with_comma_separator":thousandsSeparator=".",decimalSeparator=",";break;case"amount_no_decimals_with_comma_separator":precision=0,thousandsSeparator=".",decimalSeparator=",";break;case"amount_with_space_separator":thousandsSeparator=" ";break;case"amount_no_decimals_with_space_separator":precision=0,thousandsSeparator=" ";break;case"amount_with_apostrophe_separator":thousandsSeparator="'";break;default:break}const roundedNumber=(moneyValueCents/100).toFixed(precision),[intPart,decPart]=roundedNumber.split("."),formattedInt=intPart.replace(/\B(?=(\d{3})+(?!\d))/g,thousandsSeparator),formattedValue=decPart?`${formattedInt}${decimalSeparator}${decPart}`:formattedInt;return template.replace(placeholderMatch?placeholderMatch[0]:"{{amount}}",formattedValue)}function getShippingProgressState(projectedTotalCents){const translations=getThemeTranslations(),{freeShippingThresholdCents:threshold}=getThemeCartConfig(),goalMarkup=translations.shipping_progress_goal_markup||translations.shipping_progress_goal||"";if(threshold<=0)return{copyHtml:"",percent:0,unlocked:!1};const remainingCents=Math.max(0,threshold-projectedTotalCents),percent=Math.min(100,Math.round(projectedTotalCents/threshold*100));if(remainingCents===0){let successText=translations.shipping_progress_success||"";return successText.includes("[goal]")?successText=successText.replace("[goal]",goalMarkup):goalMarkup&&(successText=`${successText} ${goalMarkup}`.trim()),{copyHtml:successText,percent,unlocked:!0}}const remainingMoney=formatMoneyFromCents(remainingCents);let pendingText=translations.shipping_progress_pending||"";return pendingText.includes("[amount]")&&(pendingText=pendingText.replace("[amount]",remainingMoney)),pendingText.includes("[goal]")?pendingText=pendingText.replace("[goal]",goalMarkup):goalMarkup&&(pendingText=`${pendingText} ${goalMarkup}`.trim()),{copyHtml:pendingText,percent,unlocked:!1}}function updateOptimisticShippingProgress(addedLineCents){const{totalPriceCents,freeShippingThresholdCents:threshold}=getThemeCartConfig();if(threshold<=0)return;const projectedTotal=totalPriceCents+(Number(addedLineCents)||0),{copyHtml,percent,unlocked}=getShippingProgressState(projectedTotal),translations=getThemeTranslations(),truckIcon=(window.Theme?.icons||{}).truck||"",ariaLabel=esc(translations.shipping_progress_aria_label||translations.shipping_progress_goal||"");document.querySelectorAll(".cart-drawer__shipping-progress").forEach(block=>{if(!(block instanceof HTMLElement))return;const copyEl=block.querySelector(".cart-drawer__shipping-progress-copy");copyEl instanceof HTMLElement&&(copyEl.innerHTML=copyHtml);let iconEl=block.querySelector(".cart-drawer__shipping-progress-icon");unlocked&&truckIcon?(iconEl instanceof HTMLElement||(block.querySelector(".cart-drawer__shipping-progress-text")?.insertAdjacentHTML("beforeend",`<span class="cart-drawer__shipping-progress-icon svg-wrapper" aria-hidden="true">${truckIcon}</span>`),iconEl=block.querySelector(".cart-drawer__shipping-progress-icon")),iconEl instanceof HTMLElement&&(iconEl.hidden=!1)):iconEl instanceof HTMLElement&&(iconEl.hidden=!0);const track=block.querySelector(".cart-drawer__shipping-progress-track");track instanceof HTMLElement&&(track.setAttribute("aria-valuenow",String(percent)),track.setAttribute("aria-label",ariaLabel));const fill=block.querySelector(".cart-drawer__shipping-progress-fill");fill instanceof HTMLElement&&(fill.style.width=`${percent}%`)})}function parseMoneyNumber(value){const raw=(value||"").trim().replace(/[^\d.,-]/g,"");if(!raw)return null;const hasComma=raw.includes(","),hasDot=raw.includes(".");let normalized=raw;hasComma&&hasDot?raw.lastIndexOf(",")>raw.lastIndexOf(".")?normalized=raw.replace(/\./g,"").replace(",","."):normalized=raw.replace(/,/g,""):
1hasComma&&(normalized=raw.replace(",","."));const parsed=Number.parseFloat(normalized);return Number.isFinite(parsed)?parsed:null}function normalizeInlineText(value){return String(value||"").replace(/\s+/g," ").trim()}function buildOptimisticRow({imageUrl,productTitle,price,productUrl,optimisticId="",qty=1,variantSummary="",variantId="",comparePrice="",priceEach="",hasNro=!1,isNroSelected=!1,subscriptionDiscountPercent="",subscriptionReceive="",nroDiscountLabel=""}){const translations=getThemeTranslations(),discountedLabel=esc(translations.cart_pending_discounted||""),neverRunOutLabel=esc(translations.cart_pending_never_run_out||""),neverRunOutSubtitle=esc(translations.cart_pending_never_run_out_subtitle||""),decreaseQuantityLabel=esc(translations.cart_pending_decrease_quantity||""),increaseQuantityLabel=esc(translations.cart_pending_increase_quantity||""),quantityLabel=esc(translations.cart_pending_quantity||""),removeLabel=esc(translations.cart_pending_remove||""),href=esc(productUrl||"#"),title=esc((productTitle||"").trim()||" "),summary=esc((variantSummary||"").trim()),displayPrice=normalizeInlineText(price||"")||" ",rawComparePrice=normalizeInlineText(comparePrice||""),priceAmount=parseMoneyNumber(displayPrice),compareAmount=parseMoneyNumber(rawComparePrice),displayComparePrice=(isNroSelected?/\d/.test(rawComparePrice):!!rawComparePrice&&compareAmount!=null&&(priceAmount==null||compareAmount>priceAmount))?esc(rawComparePrice):"",displayPriceEach=esc(normalizeInlineText(priceEach||"")),displaySubscriptionDiscountPercent=esc((subscriptionDiscountPercent||"").trim()),displaySubscriptionReceive=esc((subscriptionReceive||"").trim()),displayNroDiscountLabel=esc(normalizeInlineText(nroDiscountLabel||"")),displayQty=Number.isFinite(qty)&&qty>0?Math.floor(qty):1,imgHtml=imageUrl?`<a href="${href}" class="cart-items__media-container" style="--ratio:1;" tabindex="-1">
2         <img src="${esc(imageUrl)}" class="cart-items__media-image border-style" alt="${title}" loading="eager">
3       </a>`:'<div class="cart-items__media-container" style="--ratio:1;"></div>';return`
4    <tr role="row" class="cart-items__table-row" data-optimistic="true" data-optimistic-id="${esc(optimisticId)}">
5      <td class="cart-items__media" role="cell" headers="productImage">
6        ${imgHtml}
7      </td>
8      <td class="cart-items__details cart-primary-typography" role="cell" headers="productInformation">
9        <p><a href="${href}" class="cart-items__title">${title}</a></p>
10        ${summary?`<dl class="cart-items__variants">
11          <div class="cart-items__variant"><dd>${summary}</dd></div>
12        </dl>`:""}
13        ${isNroSelected&&displaySubscriptionReceive?`<div class="cart-items__subscription">
14          <span class="cart-items__subscription-receive-wrap">
15            <span class="cart-items__subscription-label cart-items__subscription-icon">
16              <svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
17                <g id="icon-arrows-clock-wise" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
18                  <path d="M13.766 7.79h3.75V4.04"></path>
19                  <path d="M5.14 5.14a6.867 6.867 0 0 1 9.72 0l2.656 2.65M6.234 12.21h-3.75v3.75"></path>
20                  <path d="M14.86 14.86a6.869 6.869 0 0 1-9.72 0l-2.656-2.65"></path>
21                </g>
22              </svg>
23            </span>
24            <span class="cart-items__subscription-receive">${displaySubscriptionReceive}</span>
25          </span>
26        </div>`:""}
27      </td>
28      <td class="cart-items__price" role="cell" headers="productTotal">
29        <div class="cart-items__price-content">
30          <div class="cart-items__price-row${isNroSelected?" cart-items__price-row--subscription":""}">
31            ${displayComparePrice?`<span class="cart-items__price-compare compare-at-price">${displayComparePrice}</span>`:""}
32            <text-component class="cart-items__price-total${displayComparePrice?" cart-items__price-total--discounted":""}" value="${esc(displayPrice)}">${esc(displayPrice)}</text-component>
33          </div>
34          ${displayPriceEach?`<span class="cart-items__price-each cart-secondary-typography">${displayPriceEach}</span>`:""}
35        </div>
36      </td>
37      <td class="cart-items__quantity" role="cell" headers="quantity">
38        <div class="cart-items__quantity-controls${isNroSelected?" cart-items__quantity-controls--subscription":""}" aria-disabled="true">
39          ${isNroSelected?`${displaySubscriptionDiscountPercent?`<sp
39an class="cart-items__subscription-discount">
40                <span class="cart-items__subscription-discount-percent">${displaySubscriptionDiscountPercent}</span>
41                <span class="cart-items__subscription-discount-text">${discountedLabel}</span>
42                <span class="cart-items__subscription-discount-icon"><svg viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
43                  <path id="icon-check" d="m10.125 3.375-5.25 5.25L2.25 6" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"></path>
44                </svg></span>
45              </span>`:""}`:`<div class="quantity-selector-wrapper">
46            <cart-quantity-selector-component class="quantity-selector cart-primary-typography" data-variant-id="${esc(variantId)}">
47              <button class="button quantity-minus button-unstyled" type="button" name="minus" ref="minusButton" disabled>
48                <span class="visually-hidden">${decreaseQuantityLabel}</span><span class="svg-wrapper icon-plus">
49                  <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
50                    <path d="M2.75 7H11.25" stroke="currentColor" stroke-width="var(--icon-stroke-width)" stroke-linecap="round"></path>
51                  </svg>
52                </span>
53              </button>
54              <input type="number" value="${displayQty}" min="1" step="1" readonly aria-label="${quantityLabel}" ref="quantityInput" data-cart-quantity="${displayQty}" data-min="1">
55              <button class="button quantity-plus button-unstyled" type="button" name="plus" ref="plusButton" disabled>
56                <span class="visually-hidden">${increaseQuantityLabel}</span><span class="svg-wrapper icon-plus">
57                  <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
58                    <path class="vertical" d="M2.75 7H11.25" stroke="currentColor" stroke-width="var(--icon-stroke-width)" stroke-linecap="round"></path>
59                    <path class="horizontal" d="M7 2.75L7 11.25" stroke="currentColor" stroke-width="var(--icon-stroke-width)" stroke-linecap="round"></path>
60                  </svg>
61                </span>
62              </button>
63            </cart-quantity-selector-component>
64          </div>`}
65          <button class="button button--tertiary cart-items__remove" type="button" disabled>
66            <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
67              <path class="remove-icon-bottom" d="M11.5 9v4.25M8.5 9v4.25M5.75 12.2V6h8.5c0 2.421 0 3.779 0 6.2 0 .853 0 1.447-.038 1.91-.037.453-.106.714-.207.911a2.498 2.498 0 0 1-.983 1.017c-.197.1-.458.17-.911.207-.463.037-1.057.038-1.91.038h-.4c-.853 0-1.447 0-1.91-.038-.453-.037-.714-.106-.911-.207a2.498 2.498 0 0 1-.984-1.017c-.1-.197-.17-.458-.207-.911C5.75 13.647 5.75 13.053 5.75 12.2z" stroke="currentColor" stroke-width="var(--icon-stroke-width)" stroke-linecap="round"></path>
68              <path class="remove-icon-top" d="M4.25 6h11.5M8 5.25a2 2 0 1 1 4 0" stroke="currentColor" stroke-width="var(--icon-stroke-width)" stroke-linecap="round" stroke-linejoin="round"></path>
69            </svg>
70            <span class="visually-hidden">${removeLabel}</span>
71          </button>
72        </div>
73      </td>
74      <td class="cart-items__error hidden" role="cell" headers="quantity">
75        <div class="cart-item__error" role="alert">
76          <span class="svg-wrapper">
77            <svg class="icon icon-error" viewBox="0 0 13 13">
78              <circle cx="6.5" cy="6.5" r="5.5" stroke="#fff" stroke-width="var(--icon-stroke-width)"></circle>
79              <circle cx="6.5" cy="6.5" r="5.5" fill="#EB001B" stroke="#EB001B" stroke-width=".7"></circle>
80              <path fill="#fff" d="m5.874 3.528.1 4.044h1.053l.1-4.044zm.627 6.133c.38 0 .68-.288.68-.656s-.3-.656-.68-.656-.681.288-.681.656.3.656.68.656"></path>
81            </svg>
82          </span>
83          <small class="cart-item__error-text cart-primary-typography"></small>
84        </div>
85      </td>
86      ${hasNro&&!isNroSelected?`<td class="cart-items__nro-cell" role="cell" headers="productInformation">
87        <div class="cart-items__nro" data-optimistic-nro="true">
88          <button type="button" class="cart-items__nro-toggle button-unstyled" aria-expanded="false" disabled>
89            <span class="cart-items__nro-toggle-main">
90              <span class="cart-items__nro-toggle-checkbox" aria-hidden="true"></span>
91              <span class="cart-items__nro-toggle-copy">
92                <span class="cart-items__nro-toggle-text">${neverRunOutLabel}</span>
93                <span class="cart-items__nro-toggle-subtitle">${neverRunOutSubtitle}</span>
94              </span>
95            </span>
96            <span class="cart-items__nro-toggle-discount${displayNroDiscountLabel?"":" cart-optimistic-skeleton"}">${displayNroDiscountLabel||"\xA0"}</span>
97          </button>
98        </div>
99      </td>`:""}
100    </tr>`}function ensureTaxNoteInSummary(summaryEl){const container=summaryEl.querySelector(".cart__total-container");if(!(container instanceof HTMLElement)||container.querySelector(".tax-note"))return;const taxNote=esc(getThemeTranslations().tax_note||"");taxNote&&container.insertAdjacentHTML("beforeend",`<div class="cart__summary-item tax-note cart-primary-typography"><small>${taxNote}</small></div>`)}function ensureDrawerHasSummary(projectedTotalCents){const drawerDialog=document.querySelector("cart-drawer-component .cart-drawer__dialog");drawerDialog instanceof HTMLElement&&drawerDialog.classList.remove("cart-drawer--empty");const emptyHeading=document.querySelector(".cart-drawer__heading--empty");emptyHeading instanceof HTMLElement&&emptyHeading.remove();const content=document.querySelector("cart-drawer-component .cart-drawer__content");if(!(content instanceof HTMLElement))return;const formattedTotal=projectedTotalCents!=null&&Number.isFinite(projectedTotalCents)?formatMoneyFromCents(projectedTotalCents):null,existingSummary=content.querySelector(".cart-drawer__summary");if(existingSummary instanceof HTMLElement){const totalEl=existingSummary.querySelector(".cart__total-value");totalEl instanceof HTMLElement&&(formattedTotal?(totalEl.textContent=formattedTotal,totalEl.setAttribute("value",formattedTotal),totalEl.removeAttribute("shimmer"),totalEl.classList.remove("cart-optimistic-skeleton")):(totalEl.textContent="\u2026",totalEl.setAttribute("value","\u2026"),totalEl.setAttribute("shimmer",""),totalEl.classList.add("cart-optimistic-skeleton"))),ensureTaxNoteInSummary(existingSummary);return}const translations=getThemeTranslations(),estimatedTotal=esc(translations.cart_estimated_total||""),taxNote=esc(translations.tax_note||""),checkoutLabel=esc(translations.checkout||""),totalMarkup=formattedTotal?`<text-component class="cart__total-value cart-secondary-typography" value="${esc(formattedTotal)}">${esc(formattedTotal)}</text-component>`:'<text-component class="cart__total-value cart-secondary-typography cart-optimistic-skeleton" value="\u2026" shimmer>\u2026</text-component>',checkoutTemplate=document.getElementById("cart-drawer-checkout-cta-template"),checkoutMarkup=checkoutTemplate instanceof HTMLTemplateElement?checkoutTemplate.innerHTML:`<button
101          type="submit"
102          id="checkout"
103          class="cart__checkout-button button"
104          name="checkout"
105          form="cart-form"
106        >
107          <span class="cart__checkout-text">${checkoutLabel}</span>
108          <span class="cart__checkout-spinner" aria-hidden="true"></span>
109        </button>`;content.insertAdjacentHTML("beforeend",`<div class="cart-drawer__summary" data-optimistic-summary="true">
110      <div class="cart__summary-totals">
111        <div class="cart__total-container">
112          <span class="cart__summary-item cart__total" role="status">
113            <span class="cart__total-label cart-primary-typography">${estimatedTotal}</span>
114            ${totalMarkup}
115          </span>
116          <div class="cart__summary-item tax-note cart-primary-typography">
117            <small>${taxNote}</small>
118          </div>
119        </div>
120      </div>
121      <div class="cart__ctas">
122        ${checkoutMarkup}
123      </div>
124    </div>`)}function ensureDrawerHeaderPlaceholder(addedLineCents=0){const header=document.querySelector("cart-drawer-component .cart-drawer__header");if(!(header instanceof HTMLElement))return;const{totalPriceCents,freeShippingThresholdCents:threshold}=getThemeCartConfig();if(threshold<=0)return;const projectedTotal=totalPriceCents+(Number(addedLineCents)||0),{copyHtml,percent,unlocked}=getShippingProgressState(projectedTotal),translations=getThemeTranslations(),truckIcon=(window.Theme?.icons||{}).truck||"",shippingAriaLabel=esc(translations.shipping_progress_aria_label||translations.shipping_progress_goal||"");if(header.querySelector(".cart-drawer__heading"))updateOptimisticShippingProgress(addedLineCents);else{const cartTitle=esc(translations.cart_title||"");header.insertAdjacentHTML("afterbegin",`<div class="cart-drawer__header-main">
125        <h2 class="cart-drawer__heading" id="cart-drawer-heading">${cartTitle}</h2>
126        <div class="cart-drawer__shipping-progress">
127          <p class="cart-drawer__shipping-progress-text">
128            <span class="cart-drawer__shipping-progress-copy">${copyHtml}</span>
129            ${unlocked&&truckIcon?`<span class="cart-drawer__shipping-progress-icon svg-wrapper" aria-hidden="true">${truckIcon}</span>`:`<span class="cart-drawer__shipping-progress-icon svg-wrapper" aria-hidden="true" hidden>${truckIcon}</span>`}
130          </p>
131          <div
132            class="cart-drawer__shipping-progress-track"
133            role="progressbar"
134            aria-label="${shippingAriaLabel}"
135            aria-valuemin="0"
136            aria-valuemax="100"
137            aria-valuenow="${percent}"
138          >
139            <span class="cart-drawer__shipping-progress-fill" style="width: ${percent}%;"></span>
140          </div>
141        </div>
142      </div>`)}}function clearEmptyDrawerUI(addedLineCents=0){const emptyHeading=document.querySelector(".cart-drawer__heading--empty");emptyHeading instanceof HTMLElement&&emptyHeading.remove();const emptyButton=document.querySelector(".cart-items__empty-button");emptyButton instanceof HTMLElement&&emptyButton.remove();const drawerDialog=document.querySelector("cart-drawer-component .cart-drawer__dialog");drawerDialog instanceof HTMLElement&&drawerDialog.classList.remove("cart-drawer--empty"),ensureDrawerHeaderPlaceholder(addedLineCents)}function findOptimisticRowForRollback(optimisticId){if(optimisticId){const match=Array.from(document.querySelectorAll(".cart-items__table-row[data-optimistic-id]")).find(el=>el instanceof HTMLElement&&el.getAttribute("data-optimistic-id")===optimisticId);if(match instanceof HTMLElement)return match}const fallback=document.querySelector('.cart-items__table-row[data-optimistic="true"]');return fallback instanceof HTMLElement?fallback:null}function clearOptimisticMarkers(row){row.removeAttribute("data-optimistic"),row.removeAttribute("data-optimistic-id"),row.removeAttribute("data-pre-merge-qty")}function restoreMergedOptimisticRow(row){const preMergeQty=row.getAttribute("data-pre-merge-qty");if(preMergeQty==null)return!1;const input=row.querySelector('input[ref="quantityInput"], input[data-cart-quantity]');return input instanceof HTMLInputElement&&(input.value=preMergeQty,input.setAttribute("data-cart-quantity",preMergeQty)),clearOptimisticMarkers(row),!0}function rollbackOptimisticItem(optimisticId){const row=findOptimisticRowForRollback(optimisticId);row instanceof HTMLElement&&(restoreMergedOptimisticRow(row)||row.remove())}async function getCartVariantQtyMeta(variantId){if(!variantId)return{qty:0,rateLimited:!1};const{cart,rateLimited}=await fetchCartJsonWithMeta();return rateLimited||!cart?{qty:0,rateLimited}:{qty:cart.items?.find(line=>String(line.variant_id)===String(variantId))?.quantity??0,rateLimited:!1}}async function shouldSkipRollbackForPartialAdd(optimisticId,variantId){const row=findOptimisticRowForRollback(optimisticId),{qty:cartQty,rateLimited}=await getCartVariantQtyMeta(variantId);if(rateLimited)return!1;if(row instanceof HTMLElement&&row.hasAttribute("data-pre-merge-qty")){const preMergeQty=parseInt(row.getAttribute("data-pre-merge-qty")||"0",10)||0;return cartQty>preMergeQty}return cartQty>0}async function refreshCartItemsSection(){const sectionId=document.querySelector("cart-items-component")?.dataset?.sectionId;sectionId&&await sectionRenderer.renderSection(sectionId,{cache:!1})}function findCartRowForVariant(variantId){if(!variantId)return null;const qtySelector=document.querySelector(`.cart-items__table-row [data-variant-id="${CSS.escape(String(variantId))}"]`);return qtySelector instanceof HTMLElement?qtySelector.closest(".cart-items__table-row"):null}function mergeOptimisticIntoExistingRow(row,qtyToAdd,optimisticId){const input=row.querySelector('input[ref="quantityInput"], input[data-cart-quantity]');if(input instanceof HTMLInputElement){const current=parseInt(input.value,10)||parseInt(input.getAttribute("data-cart-quantity")||"0",10)||0;row.setAttribute("data-pre-merge-qty",String(current));const newQty=current+qtyToAdd;input.value=String(newQty),input.setAttribute("data-cart-quantity",String(newQty))}row.setAttribute("data-optimistic","true"),optimisticId&&row.setAttribute("data-optimistic-id",optimisticId);const tbody=row.closest("tbody");tbody instanceof HTMLElement&&tbody.prepend(row)}function injectOptimisticItem(detail){const wrapper=document.querySelector(".cart-items__wrapper");if(!wrapper)return;const variantId=detail.variantId||"",qtyToAdd=detail.qty||1,optimisticId=detail.optimisticId||"",linePriceCents=detail.linePriceCents!=null?Number(detail.linePriceCents):null,{totalPriceCents}=getThemeCartConfig(),projectedTotalCents=linePriceCents!=null?totalPriceCents+linePriceCents:null,existingRow=findCartRowForVariant(variantId),isSubscriptionRow=existingRow?.querySelector(".cart-items__subscription, .cart
142-items__quantity-controls--subscription");if(existingRow instanceof HTMLElement&&!detail.isNroSelected&&!isSubscriptionRow){mergeOptimisticIntoExistingRow(existingRow,qtyToAdd,optimisticId),ensureDrawerHasSummary(projectedTotalCents),updateOptimisticShippingProgress(linePriceCents||0);return}const row=buildOptimisticRow({optimisticId:detail.optimisticId||"",imageUrl:detail.imageUrl||"",productTitle:detail.productTitle||"",price:detail.price||"",productUrl:detail.productUrl||"",qty:detail.qty||1,variantSummary:detail.variantSummary||"",variantId:detail.variantId||"",comparePrice:detail.comparePrice||"",priceEach:detail.priceEach||"",hasNro:detail.hasNro===!0,isNroSelected:detail.isNroSelected===!0,subscriptionDiscountPercent:detail.subscriptionDiscountPercent||"",subscriptionReceive:detail.subscriptionReceive||"",nroDiscountLabel:detail.nroDiscountLabel||""}),existingTbody=wrapper.querySelector(".cart-items__table tbody");if(existingTbody){existingTbody.insertAdjacentHTML("afterbegin",row);const insertedRow=findOptimisticRow(optimisticId);insertedRow&&animateOptimisticRowAdd(insertedRow)}else{wrapper.innerHTML=`
143      <form action="/cart" class="cart-form" id="cart-form" method="post">
144        <div class="cart-items spacing-style">
145          <table class="cart-items__table" role="table">
146            <thead class="visually-hidden" role="rowgroup">
147              <tr role="row" class="cart-items__table-row">
148                <th id="productImage" scope="col" role="columnheader"></th>
149                <th id="productInformation" scope="col" role="columnheader"></th>
150                <th id="quantity" scope="col" role="columnheader"></th>
151                <th id="productTotal" scope="col" role="columnheader"></th>
152              </tr>
153            </thead>
154            <tbody role="rowgroup">${row}</tbody>
155          </table>
156        </div>
157      </form>`;const insertedRow=findOptimisticRow(optimisticId);insertedRow&&animateOptimisticRowAdd(insertedRow)}ensureDrawerHasSummary(projectedTotalCents),updateOptimisticShippingProgress(linePriceCents||0)}document.addEventListener(CartAddPendingEvent.eventName,event=>{const detail=event.detail||{},addedLineCents=detail.linePriceCents!=null?Number(detail.linePriceCents):0;pendingCount++,pendingOptimisticIds.push(detail.optimisticId||""),clearEmptyDrawerUI(addedLineCents),injectOptimisticItem(detail),setAddingState(!0);const drawer=document.querySelector("cart-drawer-component");drawer?.hasAttribute("auto-open")&&typeof drawer.showDialog=="function"&&drawer.showDialog({immediate:!0})},{capture:!0}),document.addEventListener(ThemeEvents.cartUpdate,event=>{const detail=event.detail?.data;if(detail?.source!=="product-form-component")return;const optimisticId=consumeOptimisticId(detail.optimisticId||"");(async()=>{if(detail.didError){const variantId=String(detail.variantId||"");await shouldSkipRollbackForPartialAdd(optimisticId,variantId)?await refreshCartItemsSection():rollbackOptimisticItem(optimisticId)}pendingCount=Math.max(0,pendingCount-1),pendingCount===0&&setAddingState(!1)})()});
158//# sourceMappingURL=/cdn/shop/t/3/assets/cart-checkout.js.map?v=181247248162659387241791422734

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.