1(function(){"use strict";if(window.SellmerBundleBuilder)return;function routes(){return window.theme&&window.theme.routes||{}}function formatMoney(cents){if(window.Shopify&&typeof window.Shopify.formatMoney=="function"&&window.theme&&window.theme.moneyFormat)return window.Shopify.formatMoney(cents,window.theme.moneyFormat);var locale=window.theme&&window.theme.language||document.documentElement.lang||"de-DE",currency=document.documentElement.getAttribute("data-currency")||"EUR";return new Intl.NumberFormat(locale,{style:"currency",currency:currency}).format(cents/100)}function parseLocalizedPriceCents(text){var matches=String(text||"").match(/\d[\d\s.,]*/g);if(!matches||!matches.length)return 0;var value=matches[matches.length-1].replace(/\s/g,""),comma=value.lastIndexOf(","),dot=value.lastIndexOf("."),separator=comma>dot?",":".",separatorIndex=value.lastIndexOf(separator);if(separatorIndex!==-1&&value.length-separatorIndex-1<=2){var whole=value.slice(0,separatorIndex).replace(/[.,]/g,""),decimals=value.slice(separatorIndex+1).replace(/[.,]/g,"");value=whole+"."+decimals}else value=value.replace(/[.,]/g,"");var amount=Number(value);return Number.isFinite(amount)?Math.round(amount*100):0}function uniqueBundleId(){return window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():"bundle-"+Date.now()+"-"+Math.random().toString(16).slice(2)}function storePendingBundle(pending){var value=JSON.stringify(pending);window.localStorage.setItem("sellmer_pending_bundle",value),window.sessionStorage.setItem("sellmer_pending_bundle",value)}function clearPendingBundle(){window.localStorage.removeItem("sellmer_pending_bundle"),window.sessionStorage.removeItem("sellmer_pending_bundle")}function storedBundleDiscountCodes(){try{var raw=window.localStorage.getItem("sellmer_bundle_discount_codes"),parsed=raw?JSON.parse(raw):{};return parsed&&typeof parsed=="object"&&!Array.isArray(parsed)?parsed:{}}catch(error){return{}}}function saveBundleDiscountCodes(codes){window.localStorage.setItem("sellmer_bundle_discount_codes",JSON.stringify(codes||{}))}function activeAppBundleIds(cart){var ids=[];return(cart&&cart.items||[]).forEach(function(item){var id=item&&item.properties?String(item.properties._app_bundle_id||""):"";id&&ids.indexOf(id)===-1&&ids.push(id)}),ids}function pruneBundleDiscountCodes(cart){var activeIds=activeAppBundleIds(cart),stored=storedBundleDiscountCodes(),pruned={};return activeIds.forEach(function(id){stored[id]&&(pruned[id]=stored[id])}),saveBundleDiscountCodes(pruned),pruned}function wait(milliseconds){return new Promise(function(resolve){window.setTimeout(resolve,milliseconds)})}function waitFor(test,timeout){var started=Date.now();return new Promise(function(resolve,reject){function check(){var result=test();if(result){resolve(result);return}if(Date.now()-started>=timeout){reject(new Error("Die Bundle-App konnte nicht vollst\xE4ndig geladen werden. Bitte laden Sie die Seite neu."));return}window.setTimeout(check,100)}check()})}function productSection(builder){return builder.closest("section[data-product-id]")||document}function appProductButtonVariantId(button){if(!button)return"";var directId=String(button.dataset.variantId||"");if(directId)return directId;var productCard=button.closest(".child-product-card[data-variant-id]"),cardId=productCard?String(productCard.dataset.variantId||""):"";if(cardId)return cardId;var values=button.closest(".child-card-values")||button.parentElement,variantInput=values&&values.querySelector(".bundle-varint-id, .bundle-variant-id, #pageBundleChildVariantId");return variantInput?String(variantInput.value||""):""}function appProductButtonInRoot(root,variantId){var expectedId=String(variantId||"");return!root||!expectedId?null:Array.prototype.find.call(root.querySelectorAll(".page-bundle-add-item-btn"),function(button){return appProductButtonVariantId(button)===expectedId})||null}function appContext(builder){var section=productSection(builder),checkoutButtons=Array.prototype.slice.call(section.querySelectorAll("#pageBundleCheckoutButton[data-bundle-id]"));if(!checkoutButtons.length&§ion!==document&&(checkoutButtons=Array.prototype.slice.call(document.querySelectorAll("#pageBundleCheckoutButton[data-bundle-id]"))),!checkoutButtons.length)return null;var variantIds=builderVariantIds(builder),checkout=checkoutButtons.find(function(candidate){var root=candidate.closest('.shopify-app-block, [id^
1="shopify-block-"]')||candidate.parentElement;return root&&variantIds.length>0&&variantIds.every(function(variantId){return appProductButtonInRoot(root,variantId)})})||checkoutButtons[0],appBlock=checkout.closest('.shopify-app-block, [id^="shopify-block-"]')||checkout.parentElement,appBundleId=String(checkout.dataset.bundleId||"");return appBundleId&&(builder.dataset.appBundleId=appBundleId),{root:appBlock,checkout:checkout,bundleId:appBundleId}}function appSelectedVariantIds(builder){var ids=[],context=appContext(builder),root=context&&context.root?context.root:productSection(builder);return root.querySelectorAll(".selected-prod-img [data-variant-id]").forEach(function(element){var id=String(element.dataset.variantId||"");id&&ids.indexOf(id)===-1&&ids.push(id)}),ids}function appProductButton(builder,variantId){var context=appContext(builder),root=context&&context.root?context.root:productSection(builder);return appProductButtonInRoot(root,variantId)}function appCheckoutButton(builder){var context=appContext(builder);return context?context.checkout:null}function appFixedPriceCents(builder){var context=appContext(builder),appCard=context&&context.root?context.root.querySelector("#pageBundleCard"):null;if(!appCard||appCard.dataset.discountType!=="fixed_price")return 0;var offer=context.root.querySelector(".page-offer-text");return offer?parseLocalizedPriceCents(offer.textContent):0}function builderVariantIds(builder){var ids=[];return builder.querySelectorAll("[data-bundle-select] option[value]").forEach(function(option){var id=String(option.value||"");id&&ids.indexOf(id)===-1&&ids.push(id)}),ids}function hideBridgedApp(builder){var checkout=appCheckoutButton(builder),variantIds=builderVariantIds(builder),productsReady=variantIds.length>0&&variantIds.every(function(id){return appProductButton(builder,id)});if(!checkout||!productsReady)return!1;var appBlock=checkout.closest('.shopify-app-block, [id^="shopify-block-"]');return appBlock&&appBlock.classList.add("sellmer-bundle-app-bridge"),!0}function revealBridgedApp(builder){var checkout=appCheckoutButton(builder);if(checkout){var appBlock=checkout.closest('.shopify-app-block, [id^="shopify-block-"]');appBlock&&appBlock.classList.remove("sellmer-bundle-app-bridge"),window.dispatchEvent(new Event("resize"))}}function syncAppSelections(builder,options){var desired=options.map(function(option){return String(option.value)});return revealBridgedApp(builder),wait(300).then(function(){return waitFor(function(){return desired.every(function(id){return appProductButton(builder,id)})&&appCheckoutButton(builder)},15e3)}).then(function(){var sequence=Promise.resolve();return appSelectedVariantIds(builder).forEach(function(id){desired.indexOf(id)===-1&&(sequence=sequence.then(function(){var button=appProductButton(builder,id);if(button)return button.click(),waitFor(function(){return appSelectedVariantIds(builder).indexOf(id)===-1},5e3)}))}),desired.forEach(function(id){sequence=sequence.then(function(){if(appSelectedVariantIds(builder).indexOf(id)===-1){var button=appProductButton(builder,id);if(!button)throw new Error("Ein ausgew\xE4hltes Motiv ist in der Bundle-App nicht verf\xFCgbar.");return button.click(),waitFor(function(){return appSelectedVariantIds(builder).indexOf(id)!==-1},5e3)}})}),sequence.then(function(){var selected=appSelectedVariantIds(builder);if(selected.length!==desired.length||!desired.every(function(id){return selected.indexOf(id)!==-1}))throw new Error("Die Motivauswahl konnte nicht vollst\xE4ndig an die Bundle-App \xFCbertragen werden.");hideBridgedApp(builder)})})}function selectedOption(select){return select&&select.value?select.options[select.selectedIndex]:null}function getPicker(builder){return builder&&builder._bundlePicker?builder._bundlePicker:null}function updateTrigger(select){var selector=select.closest(".bundle-builder__selector");if(selector){var option=selectedOption(select),trigger=selector.querySelector("[data-bundle-trigger]"),image=selector.querySelector("[data-bundle-trigger-image]"),placeholder=selector.querySelector(".bundle-builder__trigger-placeholder"),title=selector.querySelector("[data-bundle-trigger-title]"),price=selector.querySelector("[data-bundle-trigger-price]");if(!(!trigger||!image||!placeholder||!title||!price))if(option)title.textContent=option.dataset.productTitle||option.textContent.trim(),price.textContent=formatMoney(Number(option.dataset.price||0)),price.hidden=!1,trigger.classList.add("is-selected"),option.dataset.image?(image.src=option.dataset.image,image.alt=option.dataset.productTitle||"",image.hidden=!1,placeholder.hidden=!0):(image.removeAttribute("src"),image.alt="",image.hidden=!0,placeholder.hidden=!1);else{var builder=select.closest("[data-bundle-builder]");title.textContent=builder&&builder.dataset.placeholder||"Motiv ausw\xE4hlen",price.textContent="",price.hidden=!0,image.removeAttribute("src"),image.alt="",image.hidden=!0,placeholder.hidden=!1,trigger.classList.remove("is-selected")}}}function updateGallery(builder,selects){var gallery=document.querySelector('[data-bundle-gallery="'+builder.dataset.sectionId+'"]');
1gallery&&selects.forEach(function(select,index){var slot=gallery.querySelector('[data-bundle-gallery-slot="'+index+'"]');if(slot){var option=selectedOption(select),image=slot.querySelector("[data-bundle-gallery-image]"),placeholder=slot.querySelector("[data-bundle-gallery-placeholder]"),caption=slot.querySelector(".bundle-gallery__caption");if(option&&option.dataset.image)image.src=option.dataset.image,image.alt=option.dataset.productTitle||"",image.classList.remove("hidden"),placeholder.classList.add("hidden"),caption.textContent=option.dataset.productTitle||"";else{var selector=select.closest(".bundle-builder__selector"),label=selector&&selector.querySelector(".bundle-builder__selector-label");image.removeAttribute("src"),image.alt="",image.classList.add("hidden"),placeholder.classList.remove("hidden"),caption.textContent=label?label.textContent.trim():"Kalender "+(index+1)}}})}function updateDistinctOptions(selects,requireDistinct){var selectedProducts=selects.map(function(select){var option=selectedOption(select);return option?option.dataset.productId:""});selects.forEach(function(select,selectIndex){Array.prototype.forEach.call(select.options,function(option){if(option.value){var usedElsewhere=requireDistinct&&selectedProducts.some(function(productId,index){return index!==selectIndex&&productId&&productId===option.dataset.productId});option.disabled=option.hasAttribute("data-unavailable")||usedElsewhere}})})}function updatePickerChoices(builder,select){var picker=getPicker(builder);if(!(!picker||!select)){var selects=Array.prototype.slice.call(builder.querySelectorAll("[data-bundle-select]")),activeIndex=selects.indexOf(select),requireDistinct=builder.dataset.requireDistinct==="true",selectedProducts=selects.map(function(item){var option=selectedOption(item);return option?option.dataset.productId:""});picker.querySelectorAll("[data-bundle-choice]").forEach(function(choice){var unavailable=choice.hasAttribute("data-unavailable"),usedElsewhere=requireDistinct&&selectedProducts.some(function(productId,index){return index!==activeIndex&&productId&&productId===choice.dataset.productId});choice.disabled=unavailable||usedElsewhere,choice.classList.toggle("is-selected",String(choice.dataset.variantId)===String(select.value)),choice.classList.toggle("is-used",usedElsewhere),choice.setAttribute("aria-pressed",String(choice.dataset.variantId)===String(select.value)?"true":"false");var usedLabel=choice.querySelector("[data-bundle-choice-used]");usedLabel&&(usedLabel.hidden=!usedElsewhere)})}}function openPicker(builder,trigger){var picker=getPicker(builder),panel=picker&&picker.querySelector("[data-bundle-picker-panel]"),grid=picker&&picker.querySelector(".bundle-picker__grid"),title=picker&&picker.querySelector("[data-bundle-picker-title]"),select=builder.querySelector('[data-bundle-select][data-slot-index="'+trigger.dataset.slotIndex+'"]');if(!(!picker||!panel||!select)){if(builder._bundleActiveSelect=select,builder._bundleReturnFocus=trigger,title){var label=trigger.closest(".bundle-builder__selector").querySelector(".bundle-builder__selector-label");title.textContent=(label?label.textContent.trim()+": ":"")+(builder.dataset.placeholder||"Motiv ausw\xE4hlen")}updatePickerChoices(builder,select),window.clearTimeout(builder._bundleCloseTimer),trigger.setAttribute("aria-expanded","true"),grid&&(grid.scrollTop=0),picker.hidden=!1,document.body.classList.add("bundle-picker-open"),window.requestAnimationFrame(function(){picker.classList.add("is-open");var selected=picker.querySelector("[data-bundle-choice].is-selected:not([disabled])");selected?(selected.focus({preventScroll:!0}),selected.scrollIntoView({block:"nearest"})):(panel.focus({preventScroll:!0}),grid&&(grid.scrollTop=0))})}}function closePicker(builder){var picker=getPicker(builder);!picker||picker.hidden||(picker.classList.remove("is-open"),document.body.classList.remove("bundle-picker-open"),builder._bundleCloseTimer=window.setTimeout(function(){picker.hidden=!0},180),builder._bundleReturnFocus&&(builder._bundleReturnFocus.setAttribute("aria-expanded","false"),builder._bundleReturnFocus.focus()),builder._bundleActiveSelect=null,builder._bundleReturnFocus=null)}function chooseProduct(builder,choice){var select=builder._bundleActiveSelect;!select||choice.disabled||(select.value=choice.dataset.variantId,select.dispatchEvent(new Event("change",{bubbles:!0})),closePicker(builder))}function updateBuilder(builder){var selects=Array.prototype.slice.call(builder.querySelectorAll("[data-bundle-select]")),requireDistinct=builder.dataset.requireDistinct==="true",options=selects.map(selectedOption).filter(
1Boolean),complete=options.length===Number(builder.dataset.bundleSize),productIds=options.map(function(option){return option.dataset.productId}),distinct=!requireDistinct||new Set(productIds).size===productIds.length,original=options.reduce(function(total2,option){return total2+Number(option.dataset.price||0)},0),discount=Number(builder.dataset.discountPercent||0),calculatedTotal=original-Math.round(original*discount/100),appFixedPrice=appFixedPriceCents(builder),parentPrice=Number(builder.dataset.bundleParentPrice||0),total=appFixedPrice>0?appFixedPrice:parentPrice>0?parentPrice:calculatedTotal,saving=Math.max(0,original-total);updateDistinctOptions(selects,requireDistinct),selects.forEach(updateTrigger),updateGallery(builder,selects);var prices=builder.querySelector("[data-bundle-prices]");prices&&(prices.hidden=options.length===0,builder.querySelector("[data-bundle-original-price]").textContent=formatMoney(original),builder.querySelector("[data-bundle-savings]").textContent="-"+formatMoney(saving),builder.querySelector("[data-bundle-total]").textContent=formatMoney(total));var button=builder.querySelector("[data-bundle-add]");button&&(button.disabled=!(complete&&distinct))}function removeAddedBundleItems(addedItems){var updates={};return(addedItems||[]).forEach(function(item){item&&item.key&&(updates[item.key]=0)}),Object.keys(updates).length?fetch((routes().cart_update_url||"/cart/update")+".js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({updates:updates})}).catch(function(){return null}):Promise.resolve()}function preparedAppDetails(options,appBundleId){var cartItems=[],discountItems=[];return options.forEach(function(option){var variantId=String(option.value||""),productId=String(option.dataset.productId||""),productName=option.dataset.productTitle||option.textContent.trim(),quantity="1";if(!variantId||!productId)throw new Error("Ein ausgew\xE4hltes Motiv enth\xE4lt keine vollst\xE4ndigen Shopify-Produktdaten.");cartItems.push({id:variantId,quantity:Number(quantity),product_name:productName,properties:{_page_bundle_id:String(appBundleId),"_essenifyBundles:OfferId":String(appBundleId),"_essenifyBundles:prodQty":quantity}}),discountItems.push({product_id:productId,bundle_id:String(appBundleId),variant_id:variantId,quantity:quantity,product_name:productName})}),{cartItems:cartItems,discountItems:discountItems}}function preparedSingleBundleLine(options,appBundleId,parentVariantId,bundle){var selections=[],originalTotal=options.reduce(function(sum,option){return sum+Number(option.dataset.price||0)},0),savings=Math.max(0,originalTotal-Number(bundle.price||0)),properties={_essenify_byb_main_line:"true",_page_bundle_id:String(appBundleId),_bundle_id:bundle.id,_app_bundle_id:String(appBundleId),_bundle_name:bundle.name,_bundle_size:String(bundle.size),_bundle_original_total_cents:String(originalTotal),_bundle_savings_cents:String(savings)};return options.forEach(function(option,index){var variantId=String(option.value||""),productId=String(option.dataset.productId||""),productName=option.dataset.productTitle||option.textContent.trim();if(!variantId||!productId)throw new Error("Ein ausgew\xE4hltes Motiv enth\xE4lt keine vollst\xE4ndigen Shopify-Produktdaten.");selections.push({product_id:productId,variant_id:variantId,quantity:"1"}),properties[productName]="x1",properties["_bundle_motif_"+String(index+1)]=productName}),properties._essenify_build_box_items=JSON.stringify(selections),{id:Number(parentVariantId),quantity:1,properties:properties}}function addSingleAppBundleAndOpenCart(cartItem,appBundleId,bundleId){return window.localStorage.setItem("bundle_id",String(appBundleId)),window.localStorage.setItem("bundle_type","page_bundle"),fetch((routes().cart_add_url||"/cart/add")+".js?ignorecheck=true",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[cartItem]})}).then(function(response){return response.ok?response.json():response.json().then(function(body){throw new Error(body.description||body.message||"Das Bundle konnte nicht hinzugef\xFCgt werden.")})}).then(function(result){var addedItems=result&&Array.isArray(result.items)?result.items:[],added=addedItems.some(function(item){return item&&item.properties&&String(item.properties._bundle_id||"")===String(bundleId)});if(!added)throw new Error("Shopify hat das Bundle nicht best\xE4tigt. Bitte versuchen Sie es erneut.");clearPendingBundle(),window.location.assign(routes().cart_url||"/cart")})}function applyBundleDiscountCodes(codes){var uniqueCodes=[];
1return(codes||[]).forEach(function(code){code=String(code||"").trim(),code&&uniqueCodes.indexOf(code)===-1&&uniqueCodes.push(code)}),fetch((routes().cart_update_url||"/cart/update")+".js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({discount:uniqueCodes.join(",")})}).then(function(response){return response.ok?response.json():response.json().then(function(body){throw new Error(body.description||body.message||"Die Bundle-Rabatte konnten nicht angewendet werden.")})})}function bundleItemsAreDiscounted(cart){var bundleItems=(cart&&cart.items||[]).filter(function(item){return item&&item.properties&&item.properties._bundle_id});return bundleItems.length?bundleItems.every(function(item){var originalPrice=Number(item.original_price||item.original_line_price||0),finalPrice=Number(item.final_price||item.discounted_price||item.final_line_price||item.line_price||0),allocations=item.line_level_discount_allocations||[];return allocations.length>0||originalPrice>0&&finalPrice<originalPrice}):!1}function bundleDiscountUrl(appBundleId){var bundleHostUrl=window.bundleHost||"/apps/bundle-host",endpoint=window.bundleDispoint||"/api/bundle_theme/:bundle_theme_id/discount_request",encodedId=encodeURIComponent(String(appBundleId));return endpoint=endpoint.replace(":bundle_theme_id",encodedId),endpoint=endpoint.replace(/(\/bundle_theme\/)[^/]+(\/discount_request)/,"$1"+encodedId+"$2"),bundleHostUrl+endpoint}function addAppBundleAndOpenCart(cartItems,discountItems,appBundleId){var addedItems=[],previousCodes=storedBundleDiscountCodes(),shopDomain=window.Shopify&&window.Shopify.shop||window.location.hostname,discountUrl=bundleDiscountUrl(appBundleId)+"?shop_domain="+encodeURIComponent(shopDomain);return window.localStorage.setItem("bundle_id",String(appBundleId)),window.localStorage.setItem("bundle_type","page_bundle"),fetch((routes().cart_add_url||"/cart/add")+".js?ignorecheck=true",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:cartItems})}).then(function(response){return response.ok?response.json():response.json().then(function(body){throw new Error(body.description||body.message||"Die Bundle-Artikel konnten nicht hinzugef\xFCgt werden.")})}).then(function(result){return addedItems=result&&Array.isArray(result.items)?result.items:[],fetch(discountUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({data:{prod_id_arr:discountItems,bundle_id:String(appBundleId),customer_id:window.customerId||null,bundle_type:"page_bundle"}})})}).then(function(response){if(!response.ok)throw new Error("Der Bundle-Rabatt konnte nicht erstellt werden.");return response.json()}).then(function(discountResponse){var code=discountResponse&&discountResponse.code;if(!code)throw new Error("Die Bundle-App hat keinen Rabattcode zur\xFCckgegeben.");typeof window.setCookie=="function"&&window.setCookie("pageBundleCode",code);var nextCodes=Object.assign({},previousCodes);return nextCodes[String(appBundleId)]=String(code),applyBundleDiscountCodes(Object.keys(nextCodes).map(function(id){return nextCodes[id]})).then(function(cart){if(!bundleItemsAreDiscounted(cart))throw new Error("Die Bundle-Rabatte konnten nicht sicher kombiniert werden. Der Warenkorb wurde nicht ver\xE4ndert.");saveBundleDiscountCodes(nextCodes),window.location.assign(routes().cart_url||"/cart")})}).catch(function(error){return removeAddedBundleItems(addedItems).then(function(){clearPendingBundle();var codes=Object.keys(previousCodes).map(function(id){return previousCodes[id]});return applyBundleDiscountCodes(codes).catch(function(){return null})}).then(function(){throw error})})}function addBundle(builder){var button=builder.querySelector("[data-bundle-add]"),message=builder.querySelector("[data-bundle-message]"),options=Array.prototype.slice.call(builder.querySelectorAll("[data-bundle-select]")).map(selectedOption),bundleId=uniqueBundleId(),bundleName=builder.dataset.bundleName||"Bundle",bundleSize=builder.dataset.bundleSize||String(options.length),parentVariantId=Number(builder.dataset.bundleParent
1VariantId||0),parentPrice=Number(builder.dataset.bundleParentPrice||0),appBundleId=String(builder.dataset.appBundleId||"").trim();if(!options.some(function(option){return!option})){if(!/^\d+$/.test(appBundleId)){message.textContent="Das Bundle ist derzeit nicht verf\xFCgbar. Bitte versuchen Sie es sp\xE4ter erneut.",message.classList.add("is-error");return}if(!parentVariantId){message.textContent="Das Bundle-Hauptprodukt ist derzeit nicht verf\xFCgbar. Bitte versuchen Sie es sp\xE4ter erneut.",message.classList.add("is-error");return}if(options.some(function(option){return!(option.dataset.sku||"").trim()})){message.textContent="Mindestens ein ausgew\xE4hltes Motiv hat keine SKU. Bitte hinterlegen Sie die SKU in Shopify, bevor das Bundle verkauft wird.",message.classList.add("is-error");return}button.disabled=!0,button.setAttribute("aria-busy","true"),message.textContent="Bundle wird in den Warenkorb gelegt \u2026",message.classList.remove("is-error"),Promise.resolve().then(function(){return fetch((routes().cart_url||"/cart")+".js",{headers:{Accept:"application/json"}})}).then(function(response){return response.ok?response.json():response.json().then(function(body){throw new Error(body.description||body.message)})}).then(function(cart){var selectedVariantIds=options.map(function(option){return Number(option.value)}),selectedProductAlreadyInCart=cart.items.some(function(item){return selectedVariantIds.indexOf(Number(item.variant_id))!==-1});if(selectedProductAlreadyInCart)throw new Error("Mindestens eines der ausgew\xE4hlten Motive liegt bereits einzeln im Warenkorb. Bitte entfernen Sie es dort und versuchen Sie es erneut.");pruneBundleDiscountCodes(cart)}).then(function(){var pending={parentVariantId:parentVariantId,appBundleId:appBundleId,bundleId:bundleId,bundleName:bundleName,bundleSize:bundleSize,items:options.map(function(option){return{variantId:Number(option.value),title:option.dataset.productTitle||option.textContent.trim(),sku:option.dataset.sku||""}})};storePendingBundle(pending);var appDetails=preparedAppDetails(options,appBundleId),cartItems=appDetails.cartItems,discountItems=appDetails.discountItems,expectedIds=pending.items.map(function(item){return Number(item.variantId)}),originalTotal=options.reduce(function(sum,option){return sum+Number(option.dataset.price||0)},0),savings=Math.max(0,originalTotal-parentPrice);return cartItems.forEach(function(item){var position=expectedIds.indexOf(Number(item.id));item.properties=Object.assign({},item.properties||{},{_bundle_id:pending.bundleId,_app_bundle_id:pending.appBundleId,_bundle_name:pending.bundleName,_bundle_component:"true",_bundle_position:String(position+1),_bundle_original_total_cents:String(originalTotal),_bundle_savings_cents:String(savings)})}),message.textContent="Bundle und Rabatt werden vorbereitet \u2026",addAppBundleAndOpenCart(cartItems,discountItems,appBundleId)}).catch(function(error){hideBridgedApp(builder),message.textContent=error.message||"Das Bundle konnte nicht hinzugef\xFCgt werden. Bitte versuchen Sie es erneut.",message.classList.add("is-error"),button.disabled=!1,button.removeAttribute("aria-busy")})}}function pendingBundle(){try{var raw=window.localStorage.getItem("sellmer_pending_bundle")||window.sessionStorage.getItem("sellmer_pending_bundle");return raw?JSON.parse(raw):null}catch(error){return clearPendingBundle(),null}}function enrichPendingBundle(){var pending=pendingBundle();return!pending||!Array.isArray(pending.items)||!pending.items.length?Promise.resolve(!1):fetch((routes().cart_url||"/cart")+".js",{headers:{Accept:"application/json"}}).then(function(response){if(!response.ok)throw new Error("Der Warenkorb konnte nicht gelesen werden.");return response.json()}).then(function(cart){var taggedItems=cart.items.filter(function(cartItem){return cartItem.properties&&cartItem.properties._bundle_id===pending.bundleId});if(taggedItems.length===pending.items.length)return clearPendingBundle(),!1;var claimedKeys={},componentItems=pending.items.map(function(selectedItem){var match=cart.items.find(function(cartItem){return!claimedKeys[cartItem.key]&&Number(cartItem.variant_id)===Number(selectedItem.variantId)&&!(cartItem.properties&&cartItem.properties._bundle_id)});return match&&(claimedKeys[match.key]=!0),match});return componentItems.some(function(item){return!item})?!1:componentItems.reduce(function(request,item,index){return request.then(function(){var properties=Object.assign({},item.properties||{},{_bundle_id:pending.bundleId,_app_bundle_id:pending.appBundleId,_bundle_name:pending.bundleName,_bundle_component:"true",_bundle_position:String(index+1)});
1return fetch((routes().cart_change_url||"/cart/change")+".js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({id:item.key,quantity:item.quantity,properties:properties})}).then(function(response){if(!response.ok)throw new Error("Die Bundle-Artikel konnten nicht gruppiert werden.")})})},Promise.resolve()).then(function(){return clearPendingBundle(),!0})})}function initBuilder(builder){if(builder.dataset.bundleInitialized!=="true"){builder.dataset.bundleInitialized="true";var picker=builder.querySelector("[data-bundle-picker]");if(picker){var duplicate=document.body.querySelector("#"+picker.id);duplicate&&duplicate!==picker&&duplicate.remove(),builder._bundlePicker=picker,document.body.appendChild(picker)}builder.addEventListener("change",function(event){event.target.matches("[data-bundle-select]")&&updateBuilder(builder)}),builder.addEventListener("click",function(event){var trigger=event.target.closest("[data-bundle-trigger]");if(trigger){openPicker(builder,trigger);return}}),picker&&(picker.addEventListener("click",function(event){var choice=event.target.closest("[data-bundle-choice]");if(choice){chooseProduct(builder,choice);return}event.target.closest("[data-bundle-picker-close]")&&closePicker(builder)}),picker.addEventListener("keydown",function(event){if(event.key==="Escape"){closePicker(builder);return}if(event.key==="Tab"){var focusable=Array.prototype.slice.call(picker.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(function(element){return element.offsetParent!==null});if(focusable.length){var first=focusable[0],last=focusable[focusable.length-1];event.shiftKey&&document.activeElement===first?(event.preventDefault(),last.focus()):!event.shiftKey&&document.activeElement===last&&(event.preventDefault(),first.focus())}}}));var button=builder.querySelector("[data-bundle-add]");if(button&&button.addEventListener("click",function(){addBundle(builder)}),updateBuilder(builder),hideBridgedApp(builder))updateBuilder(builder);else{var observer=new MutationObserver(function(){hideBridgedApp(builder)&&(updateBuilder(builder),observer.disconnect())});observer.observe(document.body,{childList:!0,subtree:!0}),window.setTimeout(function(){observer.disconnect()},3e4)}}}function decorateCart(root){(root||document).querySelectorAll("[data-cart-items]").forEach(function(container){var seen={};container.querySelectorAll("[data-bundle-id]").forEach(function(item){var id=item.dataset.bundleId;item.dataset.bundleFirst=seen[id]?"false":"true",seen[id]=!0})})}function removeBundle(button){var firstItem=button.closest("[data-bundle-id]"),container=button.closest("[data-cart-items]");if(!(!firstItem||!container)){var id=firstItem.dataset.bundleId,updates={};container.querySelectorAll("[data-bundle-id]").forEach(function(item){item.dataset.bundleId===id&&(updates[item.dataset.cartItem]=0)}),button.disabled=!0,button.setAttribute("aria-busy","true"),fetch((routes().cart_update_url||"/cart/update")+".js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({updates:updates})}).then(function(response){if(!response.ok)throw new Error("Bundle konnte nicht entfernt werden.");return response.json()}).then(function(cart){var remainingCodes=pruneBundleDiscountCodes(cart);return Object.keys(remainingCodes).length?applyBundleDiscountCodes(Object.keys(remainingCodes).map(function(appBundleId){return remainingCodes[appBundleId]})):cart}).then(function(){window.Cart&&typeof window.Cart.update=="function"?window.Cart.update():window.location.reload()}).catch(function(){button.disabled=!1,button.removeAttribute("aria-busy")})}}function init(root){(root||document).querySelectorAll("[data-bundle-builder]").forEach(initBuilder),decorateCart(root||document)}document.addEventListener("click",function(event){var button=event.target.closest("[data-bundle-remove]");button&&removeBundle(button)}),document.addEventListener("cartItems",function(){window.setTimeout(function(){decorateCart(document)},0)}),document.addEventListener("shopify:section:load",function(event){init(event.target)}),document.addEventListener("shopify:section:unload",function(event){var builder=event.target.querySelector("[data-bundle-builder]");builder&&builder._bundlePicker&&builder._bundlePicker.remove(),document.body.classList.remove("bundle-picker-open")});var pageInitialized=!1;function initializePage(){pageInitialized||(pageInitialized=!0,enrichPendingBundle().then(function(ch
1anged){changed&&window.location.reload()}).catch(function(error){window.console.error("Bundle-Daten konnten nicht erg\xE4nzt werden:",error)}),init(document))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initializePage):initializePage(),window.addEventListener("pageshow",initializePage),window.SellmerBundleBuilder={init:init,decorateCart:decorateCart}})(); 2//# sourceMappingURL=/cdn/shop/t/75/assets/script.bundle-builder.js.map?v=54508358821343171371788784510
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.