1async function initializeSEPACheckout(){if(window._sepa_checkout_initialized)return;window._sepa_checkout_initialized=!0;const apiBaseUrl=window.Shopify.routes.root;let cachedCart=null;const getSellingPlanId=shopifyId=>shopifyId.split("/").pop(),sepaToNative=Object.fromEntries(window.sellingPlanMapping.map(m=>[getSellingPlanId(m.sepa),getSellingPlanId(m.native)])),getCart=async()=>cachedCart??(cachedCart=await fetchCart()),fetchCart=async()=>(await fetch(`${apiBaseUrl}cart.js`)).json(),updateCart=async payload=>(await fetch(`${apiBaseUrl}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(payload)})).json(),clearCart=async()=>fetch(`${apiBaseUrl}cart/clear.js`,{method:"POST"}),addToCart=async payload=>(await fetch(`${apiBaseUrl}cart/add.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(payload)})).json(),updateCheckoutButtonDisabledState=disabled=>{document.querySelectorAll("button.fh-sepa-checkout, shopify-buy-it-now-button>button, button[name='checkout']").forEach(button=>{button.disabled=disabled})},replacePlans=async planMapping2=>{const cart=await fetchCart();if(!cart.items.some(item=>item.selling_plan_allocation&&planMapping2[item.selling_plan_allocation.selling_plan.id]))return!1;const items=cart.items.map(item=>({id:item.variant_id,quantity:item.quantity,...item.selling_plan_allocation?{selling_plan:planMapping2[item.selling_plan_allocation.selling_plan.id]??item.selling_plan_allocation.selling_plan.id}:{},properties:item.properties}));return await clearCart(),await addToCart({items,attributes:cart.attributes}),!0},revertSEPAPlans=async()=>{(await getCart()).items.some(item=>item.selling_plan_allocation&&sepaToNative[item.selling_plan_allocation.selling_plan.id])&&(updateCheckoutButtonDisabledState(!0),await replacePlans(sepaToNative)?window.location.reload():updateCheckoutButtonDisabledState(!1))},observeCartChanges=()=>{new PerformanceObserver(list=>{list.getEntries().forEach(entry=>{(entry.initiatorType==="xmlhttprequest"||entry.initiatorType==="fetch")&&entry.name.includes("/cart/")&&(cachedCart=null,checkCart())})}).observe({entryTypes:["resource"]})},checkCart=async()=>{const cart=await getCart();await revertSEPAPlans()};checkCart(),observeCartChanges();const planMapping=Object.fromEntries(window.sellingPlanMapping.map(m=>
1[getSellingPlanId(m.native),getSellingPlanId(m.sepa)])),getCartInputs=()=>{const attributes=document.querySelectorAll("input[name^='attributes['], textarea[name^='attributes[']"),note=document.querySelector("textarea[name='note'], input[name='note']"),payload={};return note&&(payload.note=note.value),attributes&&(payload.attributes=Object.fromEntries(Array.from(attributes).map(a=>[a.name.replace("attributes[","").replace("]",""),a.value]))),payload},handleClick=async()=>{updateCheckoutButtonDisabledState(!0),await updateCart(getCartInputs()),await replacePlans(planMapping),window.location.href="/checkout"};window.fhSepaCheckout=handleClick}window.addEventListener("pageshow",initializeSEPACheckout); 2//# sourceMappingURL=/cdn/shop/t/9/assets/sepa-checkout.js.map?v=121117070570790537251776367727
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.