1const BUNDLE_LINK_PREFIX="/a/loop_subscriptions/bundle",LOOP_BUNDLE_URL="https://api-service.loopwork.co/bundleTransaction/getBundleCartDetails",LOOP_API_SERVICE_URL="https://api-service.loopwork.co";let BUNDLE_CONTAINER_CLASS="BUNDLE_CONTAINER_CLASS",CART_SUBTOTAL_CLASS="CART_SUBTOTAL_CLASS";const getItemsHtmlLoop=(item,bundleQuantityMapping)=>{let quantity=item.quantity;if(bundleQuantityMapping){let variant=bundleQuantityMapping.find(v=>v.childProductId===item.id);variant&&(quantity=variant.quantity)}return`<p><span style="display:block;" class="data-cart-item-selling-plan-name">${item.title||""} x ${quantity||""}</span></p>`},getEditCartButton=(bundleTransactionId,editBtnText="Edit")=>`<button onclick="event.preventDefault(); changeBundleCartItems('${bundleTransactionId}');" style="background:none;border:none;display:flex;align-items:center;gap:3px;cursor:pointer;padding:0; text-decoration:underline;"> 2 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pen" viewBox="0 0 17 17"> 3 <path fill-rule="evenodd" d="M15.655 4.344a2.695 2.695 0 0 0-3.81 0l-.599.599-.009-.009-1.06 1.06.008.01-5.88 5.88a2.75 2.75 0 0 0-.805 1.944v1.922a.75.75 0 0 0 .75.75h1.922a2.75 2.75 0 0 0 1.944-.806l7.54-7.539a2.695 2.695 0 0 0 0-3.81Zm-4.409 2.72-5.88 5.88a1.25 1.25 0 0 0-.366.884v1.172h1.172c.331 0 .65-.132.883-.366l5.88-5.88-1.689-1.69Zm2.75.629.599-.599a1.195 1.195 0 1 0-1.69-1.689l-.598.599 1.69 1.689Z"></path> 4 </svg> 5 <p style="padding:0px;margin:0px;margin-top:5px">${editBtnText??"Edit"}</p> 6 </button>`,getBundleCartTableTemplateLoop=(bundleItem,index,bundleLink)=>` 7 <tr> 8 <td> 9 <line-item class="line-item"> 10 <div class="line-item__media-wrapper"> 11 <img src="${bundleItem.image||""}" alt="${bundleItem.label}" width="2400" height="2000" loading="lazy" sizes="(max-width: 740px) 80px, 96px" class="line-item__media rounded-xs"> 12 <pill-loader class="pill-loader"> 13 <div class="loader-dots"> 14 <span></span> 15 <span></span> 16 <span></span> 17 </div> 18 <svg class="loader-checkmark" fill="none" width="9" height="8" viewBox="0 0 9 8"> 19 <path d="M1 3.5 3.3 6 8 1" stroke="currentColor" stroke-width="2"></path> 20 </svg> 21 </pill-loader> 22 </div> 23 <div class="line-item__info "> 24 <div class="v-stack gap-1 "> 25 <a href="${bundleLink}" class="bold"> 26 <span class="reversed-link hover:show">${bundleItem.label||""}</span> 27 </a> 28 <price-list class="price-list "> 29 <sale-price class="text-on-sale"> 30 <span class="sr-only">Angebot</span>${bundleItem.price} 31 </sale-price> 32 <compare-at-price class="text-subdued line-through"> 33 <span class="sr-only">Regul\xE4rer Preis</span>${bundleItem.priceWithoutDiscount} 34 </compare-at-price> 35 <unit-price class="text-subdued text-sm"> 36 </unit-price> 37 </price-list> 38 </div> 39 <p class="text-sm text-subdued"> 40 ${bundleItem.items.map(item=>getItemsHtmlLoop(item)).join("")} 41 ${getEditCartButton(bundleItem.bundleId,bundleItem.editBtnText)} 42 </p> 43 <p class="text-sm text-subdued">${bundleItem.sellingPlan||""}</p> 44 <div class="text-sm text-subdued sm:hidden"> 45 <line-item-quantity class="h-stack justify-center gap-3"> 46 <div class="qty_wrapper"> 47 <input disabled class="quantity-input" type="text" inputmode="numeric" max="763" value="${bundleItem.quantity}"> 48 </div>
49 <span class="text-xs" style="cursor: pointer;"> 50 <a onclick="removeBundleLoop('${bundleItem.bundleId}')" class=" link">Entfernen</a> 51 </span> 52 </line-item-quantity> 53 </div> 54 </div> 55 </line-item> 56 </td> 57 <td class="hidden align-center text-center text-subdued sm:table-cell"> 58 <line-item-quantity class="v-stack justify-center gap-2"> 59 <div class="qty_wrapper"> 60 <input disabled class="quantity-input" type="text" inputmode="numeric" max="763" value="${bundleItem.quantity}"> 61 </div> 62 <span class="text-xs text-center" style="cursor: pointer;"> 63 <a onclick="removeBundleLoop('${bundleItem.bundleId}')" class="link ">Entfernen</a> 64 </span> 65 </line-item-quantity> 66 </td> 67 <td class="hidden align-center text-subdued text-end sm:table-cell">${bundleItem.price}</td> 68 </tr> 69 `,getBundleCartDrawerTemplateLoop=(bundleItem,index,bundleLink)=>` 70 <line-item class="line-item"> 71 <div class="line-item__media-wrapper"> 72 <img src="${bundleItem.image||""}" alt="${bundleItem.label}" width="2400" height="2000" loading="lazy" sizes="(max-width: 740px) 80px, 96px" class="line-item__media rounded-xs"> 73 <pill-loader class="pill-loader"> 74 <div class="loader-dots"> 75 <span></span> 76 <span></span> 77 <span></span> 78 </div> 79 <svg class="loader-checkmark" fill="none" width="9" height="8" viewBox="0 0 9 8"> 80 <path d="M1 3.5 3.3 6 8 1" stroke="currentColor" stroke-width="2"></path> 81 </svg> 82 </pill-loader> 83 </div> 84 <div class="line-item__info "> 85 <div class="v-stack gap-1 "> 86 <a href="${bundleLink}" class="bold"> 87 <span class="reversed-link hover:show">${bundleItem.label||""}</span> 88 </a> 89 <price-list class="price-list"> 90 <sale-price class="text-on-sale"> 91 <span class="sr-only">Angebot</span>${bundleItem.price} 92 </sale-price> 93 <unit-price class="text-subdued text-sm"> 94 </unit-price> 95 </price-list> 96 </div> 97 <p class="text-sm text-subdued">${bundleItem.items.map(item=>getItemsHtmlLoop(item)).join("")} 98 ${getEditCartButton(bundleItem.bundleId,bundleItem.editBtnText)} 99 </p> 100 <p class="text-sm text-subdued">${bundleItem.sellingPlan||""}</p> 101 <div class="text-sm text-subdued sm:hidden"> 102 <line-item-quantity class="h-stack justify-center gap-3"> 103 <div class="qty_wrapper"> 104 <input disabled class="quantity-input" type="text" inputmode="numeric" max="763" value="${bundleItem.quantity}"> 105 </div> 106 <span class="text-xs" style="cursor: pointer;"> 107 <a onclick="removeBundleLoop('${bundleItem.bundleId}')" class=" link">Entfernen</a> 108 </span> 109 </line-item-quantity> 110 </div> 111 </div> 112 <div class="line-item__actions text-subdued hidden sm:block"> 113 <line-item-quantity class="v-stack gap-2"> 114 <div class="qty_wrapper"> 115 <input disabled class="quantity-input" type="text" inputmode="numeric" max="763" value="${bundleItem.quantity}"> 116 </div> 117 <span class="text-xs text-center" style="cursor: pointer;"> 118 <a onclick="removeBundleLoop('${bundleItem.bundleId}')" class="link ">Entfernen</a> 119 </span> 120 </line-item-quantity> 121 </div> 122 </line-item> 123 `,getBundleCartItemsDivTemplateLoop=(bundleItem,index,bundleLink)=>` 124 <div style="display:flex; gap:20px; justify-content: space-between;
124" id="CartBundleItem-${index}"> 125 <div style="display:flex; gap:20px;"> 126 <div style="text-align:center;"> 127 <img 128 src="${bundleItem.image||""}" 129 alt="${bundleItem.label}" loading="lazy" width="75" height="75"> 130 </div> 131 <div> 132 <a href="${bundleLink}" 133 style="font-weight:600"> 134 ${bundleItem.label||""} 135 </a> 136 <div> 137 ${bundleItem.items.map(item=>getItemsHtmlLoop(item)).join("")} 138 <br/> 139 <p><span>${bundleItem.sellingPlan||""}</span></p> 140 </div> 141 </div> 142 </div> 143 <div> 144 ${bundleItem.quantity} 145 </div> 146 <div> 147 <div style="display: flex; gap: 10px;"> 148 ${bundleItem.priceWithoutDiscount!==bundleItem.price?`<span style="text-decoration:line-through;"> 149 ${bundleItem.priceWithoutDiscount} 150 </span>`:""} 151 <span style="font-weight: 600;">${bundleItem.price}</span> 152 </div> 153 ${getEditCartButton(bundleItem.bundleId,bundleItem.editBtnText)} 154 <div onclick="removeBundleLoop('${bundleItem.bundleId}')" style="cursor:pointer; vertical-align: text-top; width: fit-content;height: 15px;display: inline-flex;flex-direction: row-reverse;"> 155 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" style="width: 1em; height: 1em;" aria-hidden="true" focusable="false" role="presentation" class="icon icon-remove"> 156 <path d="M14 3h-3.53a3.07 3.07 0 00-.6-1.65C9.44.82 8.8.5 8 .5s-1.44.32-1.87.85A3.06 3.06 0 005.53 3H2a.5.5 0 000 1h1.25v10c0 .28.22.5.5.5h8.5a.5.5 0 00.5-.5V4H14a.5.5 0 000-1zM6.91 1.98c.23-.29.58-.48 1.09-.48s.85.19 1.09.48c.2.24.3.6.36 1.02h-2.9c.05-.42.17-.78.36-1.02zm4.84 11.52h-7.5V4h7.5v9.5z" fill="currentColor"></path> 157 <path d="M6.55 5.25a.5.5 0 00-.5.5v6a.5.5 0 001 0v-6a.5.5 0 00-.5-.5zM9.45 5.25a.5.5 0 00-.5.5v6a.5.5 0 001 0v-6a.5.5 0 00-.5-.5z" fill="currentColor"></path> 158 </svg> 159 </div> 160 </div> 161 </div> 162 `,getPresetBundleCartTemplateLoop=(bundleItem,index,bundleLink)=>` 163 <tr class="cart-item" id="CartBundleItem-${index}"> 164 <td class="cart-item__media"> 165 <a href="${bundleLink}" class="cart-item__link" aria-hidden="true" tabindex="-1"> </a> 166 <div class="cart-item__image-container gradient global-media-settings"> 167 <img src="${bundleItem.image||""}" class="cart-item__image" alt="" loading="lazy" width="150" height="94"> 168 </div> 169 </td> 170 171 <td class="cart-item__details"><a href="${bundleLink}" class="cart-item__name h4 break">${bundleItem.label}</a> 172 <div class="product-option"> 173 ${bundleItem.items.map(item=>getItemsHtmlLoop(item,bundleItem.bundleQuantityMapping)).join("")} 174 <br/> 175 </div> 176 <div class="product-option"> 177 ${bundleItem.eachBundleAmount} 178 </div><dl></dl> 179 180 <p class="product-option">${bundleItem.sellingPlan||""}</p> 181 ${bundleItem.discountTitle?`<ul class="discounts list-unstyled" role="list" aria-label="Discount"> 182 <li class="discounts__discount"> 183 <svg aria-hidden="true" focusable="false" role="presentation" class="icon icon-discount color-foreground-text" viewBox="0 0 12 12"> 184 <path fill-rule="evenodd" clip-rule="evenodd" d="M7 0h3a2 2 0 012 2v3a1 1 0 01-.3.7l-6 6a1 1 0 01-1.4 0l-4-4a1 1 0 010-1.4l6-6A1 1 0 017 0zm2 2a1 1 0 102 0 1 1 0 00-2 0z" fill="currentColor"> 185 </path> 186 </svg> 187 ${bundleItem.discountTitle} 188 </li> 189 </ul>`:""} 190 </td> 191 192 <td class="cart-item__totals right medium-hide large-up-hide"> 193 <div class="cart-item__price-wrapper"><span class="price price--end"> 194 ${bundleItem.final_line_price} 195 </span></div> 196 </td> 197 198 <td class="cart-item__quantity"> 199 <div class="cart-item__quantity-wrapper"> 200 <quantity-input class="quantity"> 201 <input disabled class="quantity__input" type="number" value="${bundleItem.bundleProductQuantity}" min="0"> 202 </quantity-input> 203 <cart-remove-button> 204 <a onclick="removeBundleLoop('${bundleItem.bundleId}')" class="button button--tertiary" aria-label="${bundleItem.label}" style="cursor : pointer"> 205 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" aria-hidden="true" role="presentation" class="icon icon-remove"> 206 <path d="M14 3h-3.53a3.07 3.07 0 00-.6-1.65C9.44.82 8.8.5 8 .5s-1.44.32-1.87.85A3.06 3.06 0 005.53 3H2a.5.5 0 000 1h1.25v10c0 .28.22.5.5.5h8.5a.5.5 0 00.5-.5V4H14a.5.5 0 000-1zM6.91 1.98c.23-.29.58-.48 1.09-.48s.85.19 1.09.48c.2.24.3.6.36 1.02h-2.9c.05-.42.17-.78.36-1.02zm4.84 11.52h-7.5V4h7.5v9.5z" fill="currentColor"></path> 207 <path d="M6.55 5.25a.5.5 0 00-.5.5v6a.5.5 0 001 0v-6a.5.5 0 00-.5-.5zM9.45 5.25a.5.5 0 00-.5.5v6a.5.5 0 001 0v-6a.5.5 0 00-.5-.5z" fill="currentColor"></path> 208 </svg> 209 </a> 210 </cart-remove-button> 211 </div> 212 </td> 213 214 <td class="cart-item__totals right small-hide"> 215 <div class="cart-item__price-wrapper"><span class="price price--end"> 216 ${bundleItem.final_line_price_currency} 217 </span></div> 218 </td> 219 </tr> 220 `,getPresetBundleCartDrawerTemplateLoop=(bundleItem,index,bundleLink)=>`
221 <tr class="cart-item" id="CartBundleItem-${index}"> 222 <td class="cart-item__media"> 223 <a href="${bundleLink}" class="cart-item__link" aria-hidden="true" tabindex="-1"> </a> 224 <div class="cart-item__image-container gradient global-media-settings"> 225 <img src="${bundleItem.image||""}" class="cart-item__image" alt="" loading="lazy" width="150" height="94"> 226 </div> 227 </td> 228 229 <td class="cart-item__details"><a href="${bundleLink}" class="cart-item__name h4 break">${bundleItem.label}</a> 230 <div class="product-option"> 231 ${bundleItem.items.map(item=>getItemsHtmlLoop(item,bundleItem.bundleQuantityMapping)).join("")} 232 <br/> 233 </div> 234 <div class="product-option"> 235 ${bundleItem.eachBundleAmount} 236 </div><dl></dl> 237 238 <p class="product-option">${bundleItem.sellingPlan||""}</p> 239 ${bundleItem.discountTitle?`<ul class="discounts list-unstyled" role="list" aria-label="Discount"> 240 <li class="discounts__discount"> 241 <svg aria-hidden="true" focusable="false" role="presentation" class="icon icon-discount color-foreground-text" viewBox="0 0 12 12"> 242 <path fill-rule="evenodd" clip-rule="evenodd" d="M7 0h3a2 2 0 012 2v3a1 1 0 01-.3.7l-6 6a1 1 0 01-1.4 0l-4-4a1 1 0 010-1.4l6-6A1 1 0 017 0zm2 2a1 1 0 102 0 1 1 0 00-2 0z" fill="currentColor"> 243 </path> 244 </svg> 245 ${bundleItem.discountTitle} 246 </li> 247 </ul>`:""} 248 </td> 249 250 <td class="cart-item__totals right medium-hide large-up-hide"> 251 <div class="cart-item__price-wrapper"><span class="price price--end"> 252 ${bundleItem.final_line_price} 253 </span></div> 254 </td> 255 256 <td class="cart-item__quantity"> 257 <div class="cart-item__quantity-wrapper"> 258 <quantity-input class="quantity"> 259 <input disabled class="quantity__input" type="number" value="${bundleItem.bundleProductQuantity}" min="0"> 260 </quantity-input> 261 <cart-remove-button> 262 <a onclick="removeBundleLoop('${bundleItem.bundleId}')" class="button button--tertiary" aria-label="${bundleItem.label}" style="cursor : pointer"> 263 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" aria-hidden="true" role="presentation" class="icon icon-remove"> 264 <path d="M14 3h-3.53a3.07 3.07 0 00-.6-1.65C9.44.82 8.8.5 8 .5s-1.44.32-1.87.85A3.06 3.06 0 005.53 3H2a.5.5 0 000 1h1.25v10c0 .28.22.5.5.5h8.5a.5.5 0 00.5-.5V4H14a.5.5 0 000-1zM6.91 1.98c.23-.29.58-.48 1.09-.48s.85.19 1.09.48c.2.24.3.6.36 1.02h-2.9c.05-.42.17-.78.36-1.02zm4.84 11.52h-7.5V4h7.5v9.5z" fill="currentColor"></path> 265 <path d="M6.55 5.25a.5.5 0 00-.5.5v6a.5.5 0 001 0v-6a.5.5 0 00-.5-.5zM9.45 5.25a.5.5 0 00-.5.5v6a.5.5 0 001 0v-6a.5.5 0 00-.5-.5z" fill="currentColor"></path> 266 </svg> 267 </a> 268 </cart-remove-button> 269 </div> 270 </td> 271 272 <td class="cart-item__totals right small-hide"> 273 <div class="cart-item__price-wrapper"><span class="price price--end"> 274 ${bundleItem.final_line_price_currency} 275 </span></div> 276 </td> 277 </tr> 278 `,getItemKeysByBundleIdLoop=bundleId=>{const cartItems=window.Loop.bundleCartAllItems,data={updates:{}};for(const item of cartItems){const _bundleId=item?.properties?._bundleId??item?.properties?.bundleId;!_bundleId||_bundleId!==bundleId||(data.updates[item.key]=0)}return data},removeBundleLoop=async bundleId=>{const data=getItemKeysByBundleIdLoop(bundleId),endpoint=`${window.Shopify.routes.root}cart/update.js`;await fetch(endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(data)}),window.location.href=window.location.href},changeBundleCartItems=async bundleTransactionId=>{disableEditButton();const currentLocale=window?.Shopify?.locale,root=window?.Shopify?.routes?.root??"/";if(bundleTransactionId){const _editBundleRef=`${BUNDLE_LINK_PREFIX}/change/${bundleTransactionId}`;currentLocale&&root!=="/"?window.location.href=`/${currentLocale}${_editBundleRef}`:window.location.href=_editBundleRef}},disableEditButton=bundleId=>{console.log(`disabling bundle edit button: ${bundleId}`);const editButttons=document.querySelectorAll(`loop-edit-bundle-${bundleId}`);for(const button of editButttons)button.disabled=!0}
278,fetchLoopBundleTransactionCartDetails=async loopBundleGuid=>{const{locale}=window.Shopify,_locale=locale.split("-")[0],_endpoint=`${LOOP_BUNDLE_URL}/${loopBundleGuid}?locale=${_locale}`;return await(await fetch(_endpoint)).json()},addExtraDetailsToBundleItemsLoop=async bundleItems=>{let totalDiscount=0,currencySymbol="",currency="";const fetchDetailsPromises=bundleItems.map(bundleItem=>fetchLoopBundleTransactionCartDetails(bundleItem.bundleId)),allExtraDetails=await Promise.all(fetchDetailsPromises);for(let i=0;i<allExtraDetails.length;++i){const extraDetails=allExtraDetails[i],bundleItem=bundleItems[i],quantityMapping=extraDetails?.variantMap?.[bundleItem.bundleId]??[],isPresetBundleProduct=bundleItem.isPresetBundleProduct,totalBundleItemsQuantity=bundleItem.items.reduce((acc,item)=>acc+item.quantity,0);let price=isPresetBundleProduct?bundleItem.discounted_price:bundleItem.price;bundleItem.label=extraDetails?.label,bundleItem.image=extraDetails?.image,bundleItem.sellingPlan=extraDetails?.name,bundleItem.editBtnText=extraDetails.editBtnText??"Edit",bundleItem.priceWithoutDiscount=`${extraDetails.currencySymbol}${price.toFixed(2)}`,bundleItem.final_line_price_currency=`${extraDetails.currencySymbol}${parseFloat(bundleItem.final_line_price).toFixed(2)}`,bundleItem.loopBundleId=extraDetails.loopBundleId,currencySymbol=extraDetails.currencySymbol,currency=extraDetails.currency,extraDetails.discountType&&extraDetails.discountValue&&!isPresetBundleProduct&&(extraDetails.discountType==="PERCENTAGE"?extraDetails.appliesOnEachItem?(totalDiscount+=price*(parseFloat(extraDetails.discountValue)/100)*totalBundleItemsQuantity,price=price-price*(parseFloat(extraDetails.discountValue)/100)*totalBundleItemsQuantity):(totalDiscount+=price*(parseFloat(extraDetails.discountValue)/100),price=price-price*(parseFloat(extraDetails.discountValue)/100)):extraDetails.appliesOnEachItem?(totalDiscount+=parseFloat(extraDetails.discountValue)*totalBundleItemsQuantity,price=price-parseFloat(extraDetails.discountValue)*totalBundleItemsQuantity):(totalDiscount+=parseFloat(extraDetails.discountValue),price=price-parseFloat(extraDetails.discountValue))),bundleItem.price=`${extraDetails.currencySymbol}${parseFloat(price).toFixed(2)}`,extraDetails?.productsQuantity?(bundleItems[i].bundleProductQuantity=extraDetails.productsQuantity,bundleItems[i].eachBundleAmount=`${extraDetails.currencySymbol}${parseFloat(bundleItems[i].final_line_price/extraDetails.productsQuantity).toFixed(2)}`):(bundleItems[i].bundleProductQuantity=1,bundleItems[i].eachBundleAmount=`${extraDetails.currencySymbol}${parseFloat(price/1).toFixed(2)}`),quantityMapping.length&&(bundleItem.bundleQuantityMapping=quantityMapping),isPresetBundleProduct&&(bundleItem.productHandle=extraDetails.product_handle)}removeDiscountFromSubtotalInCartLoop(totalDiscount,currencySymbol,currency)},removeDiscountFromSubtotalInCartLoop=(totalDiscount,currencySymbol,currency)=>{let targetNode=null;targetNode=document.querySelector(".totals__subtotal-value"),targetNode&&applyDiscountByCartLineItemsLoop(targetNode,totalDiscount,currencySymbol,currency)};function applyDiscountByCartLineItemsLoop(element,discount,currencySymbol,currency){const discountedPrice=((window.Loop.bundleCartAllItems.reduce((acc,item)=>acc+(item.properties._isPresetBundleProduct?item.discounted_price:item.price)*item.quantity,0)/100).toFixed(2)-discount).toFixed(2);isNaN(discountedPrice)||(element.innerHTML=`${currencySymbol??""}${discountedPrice} ${currency??""}`)}const getBundleItemsLoop=items=>{const bundleItemsMap={};for(const item of items){const bundleId=item?.properties?._bundleId??item?.properties?.bundleId;bundleId&&(Object.hasOwn(bundleItemsMap,bundleId)?(bundleItemsMap[bundleId].price+=Number(item.price)*Number(item.quantity)/100,bundleItemsMap[bundleId].discounted_price+=Number(item.discounted_price)*Number(item.quantity)/100,bundleItemsMap[bundleId].amount+=Number(item.price)*Number(item.quantity)/100,bundleItemsMap[bundleId].final_line_price+=Number(item.final_line_price)/100,bundleItemsMap[bundleId].items.push(item)):bundleItemsMap[bundleId]={bundleId,quantity:1,price:Number(item.price)*Number(item.quantity)/100,amount:Number(item.price)*Number(item.quantity)/100,items:[item],discounted_price:Number(item.discounted_price)*Number(item.quantity)/100,isPresetBundleProduct:item?.properties?._isPresetBundleProduct,discountTitle:item?.discounts?.[0]?.title??"",final_line_price:Number(item.final_line_price)/100})}
278return sortItemsByTitleLoop(Object.values(bundleItemsMap))},sortItemsByTitleLoop=bundles=>bundles.map(bundle=>(bundle.items.sort((a,b)=>{let titleA=a.title.toUpperCase(),titleB=b.title.toUpperCase();return titleA<titleB?-1:titleA>titleB?1:0}),bundle)),renderBundleItemsLoop=(bundleItems,clientId)=>{let _parent=document.querySelector(`.${clientId}`);if(_parent||(_parent=document.querySelector(`.${BUNDLE_CONTAINER_CLASS}`)),!!_parent)for(let i=0;i<bundleItems.length;++i){let bundleItem=bundleItems[i];const _bundleLink=bundleItem.isPresetBundleProduct?`https://${window.Shopify.shop}/products/${bundleItem.productHandle}`:`${BUNDLE_LINK_PREFIX}/${bundleItem.loopBundleId}`;let _template,hasTable=document.getElementsByTagName("table");bundleItem.isPresetBundleProduct&&window.location.pathname.includes("cart")?_template=getPresetBundleCartTemplateLoop(bundleItem,i+1,_bundleLink):bundleItem.isPresetBundleProduct&&!window.location.pathname.includes("cart")?_template=getPresetBundleCartDrawerTemplateLoop(bundleItem,i+1,_bundleLink):window.location.pathname.includes("cart")?window.location.pathname.includes("cart")?_template=getBundleCartTableTemplateLoop(bundleItem,i+1,_bundleLink):_template=getBundleCartItemsDivTemplateLoop(bundleItem,i+1,_bundleLink):_template=getBundleCartDrawerTemplateLoop(bundleItem,i+1,_bundleLink),_parent.insertAdjacentHTML("afterbegin",_template)}};async function getCartItemsLoop(){const url=`https://${Shopify.cdnHost.split("/cdn")[0]}/cart.json`;return(await(await fetch(url)).json())?.items??[]}function setupMutationLoop(_bundleItems){if(!_bundleItems?.length||window.location.pathname.includes("/a/loop_subscriptions/bundle"))return;let previousQuantity=window.Loop.bundleCartAllItems.reduce((acc,curr)=>acc+curr.quantity,0),timeoutId;const handleChanges=async()=>{(await getCartItemsLoop()).reduce((acc,curr)=>acc+curr.quantity,0)!==previousQuantity&&window.location.reload()};let targetNodes=document.querySelectorAll("form");const config={childList:!0,subtree:!0};targetNodes.forEach(targetNode=>{new MutationObserver(()=>{clearTimeout(timeoutId),timeoutId=setTimeout(handleChanges,500)}).observe(targetNode,config)})}function setupMutationIfElementDelete(){let firstChange=!0,timeoutId;const handleChanges=()=>{firstChange?firstChange=!1:window.location.pathname.includes("/a/loop_subscriptions/bundle")||(firstChange=!0,window.location.reload())};let targetNode=document.querySelector(".cart-container");if(targetNode||(targetNode=document.querySelector(".cart__blocks")),!targetNode)return;const observer=new MutationObserver(()=>{clearTimeout(timeoutId),timeoutId=setTimeout(handleChanges,1e3)}),config={childList:!0,subtree:!0};observer.observe(targetNode,config)}function setupMutationOldLoop(){var firstChange=!0;let targetNode=null,observerNode=null;if(targetNode=document.querySelectorAll("[data-cart-subtotal]"),targetNode&&targetNode.length>1||!targetNode.length?observerNode=document.querySelector(`.${CART_SUBTOTAL_CLASS}`):observerNode=targetNode[0],!observerNode)return;const config={attributes:!0,childList:!0,subtree:!0},callback=(mutationList,observer2)=>{if(firstChange){firstChange=!1;return}else firstChange=!0,setTimeout(window.location.reload(),1e3)};new MutationObserver(callback).observe(observerNode,config)}const initLoopBundle=async clientId=>{console.log(`Loop Bundle Initialized for ${clientId}`);const _cartItems=window.Loop.bundleCartAllItems,_bundleItems=getBundleItemsLoop(_cartItems);await addExtraDetailsToBundleItemsLoop(_bundleItems),setupMutationLoop(_bundleItems),renderBundleItemsLoop(_bundleItems,clientId)}; 279//# sourceMappingURL=/cdn/shop/t/259/assets/loop_bundle.js.map?v=26374851427665724491758106289
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.