1(function(){"use strict";function setText(el,fn){if(el){for(var n=el.firstChild;n;n=n.nextSibling)if(!(n.nodeType!==3||!n.nodeValue.trim())){var next=fn(n.nodeValue);next!==n.nodeValue&&(n.nodeValue=next)}}}var TRUCK='<span class="sa-ship-msg__icon" aria-hidden="true">\uD83D\uDE9A</span>',STORE_KEY="sa_free_ship_reached";function readStore(){try{return sessionStorage.getItem(STORE_KEY)}catch(e){return null}}function writeStore(v){try{sessionStorage.setItem(STORE_KEY,v)}catch(e){}}function shipping(root){var pb=root.querySelector('[data-rebuy-component="progress-bar"]');if(pb){var wrap=pb.querySelector(".rebuy-cart__progress-bar-wrapper"),prompt=pb.querySelector(".rebuy-cart__progress-bar-prompt"),fill=pb.querySelector(".rebuy-cart__progress-bar-meter-fill");if(!(!wrap||!prompt)){var raw=prompt.textContent||"",pct=fill?parseFloat(fill.getAttribute("aria-valuenow")):NaN,missing=raw.match(/aggiungi ancora\s+(.+?)\s+e ricevi/i),reached=!missing&&(pct>=100||/gratuit/i.test(raw)),key,html;missing?(key="m:"+missing[1],html=TRUCK+'<span class="sa-ship-msg__text">Mancano <strong class="sa-ship-msg__amount">'+missing[1].replace(/</g,"")+"</strong> alla spedizione gratuita</span>"):reached?(key="ok",html=TRUCK+'<span class="sa-ship-msg__text"><strong>Congratulazioni</strong>, hai ottenuto la spedizione gratuita.</span>'):(key="t:"+raw,html=TRUCK+'<span class="sa-ship-msg__text"></span>');var msg=wrap.querySelector(".sa-ship-msg");msg||(msg=document.createElement("div"),msg.className="sa-ship-msg",msg.setAttribute("aria-live","polite"),wrap.insertBefore(msg,wrap.firstChild)),msg.dataset.key!==key&&(msg.innerHTML=html,key.charAt(0)==="t"&&(msg.querySelector(".sa-ship-msg__text").textContent=raw.replace(/^\s*\uD83D\uDE9A\s*/,"")),msg.dataset.key=key,msg.dataset.fitW=""),fitShip(msg,reached),pb.classList.toggle("sa-ship-done",reached);var visible=root.classList.contains("is-visible");reached?readStore()!=="1"&&visible&&(writeStore("1"),celebrate(root,pb)):missing&&writeStore("0")}}}function fitShip(msg,reached){var t=msg.querySelector(".sa-ship-msg__text");if(!(!t||!msg.offsetWidth)){var w=String(msg.offsetWidth);if(msg.dataset.fitW!==w){msg.dataset.fitW=w;var amt=t.querySelector(".sa-ship-msg__amount");if(t.style.removeProperty("font-size"),t.style.removeProperty("white-space"),amt&&amt.style.removeProperty("font-size"),!reached){for(var fs=14;t.scrollWidth>t.clientWidth&&fs>12;)fs-=.5,t.style.setProperty("font-size",fs+"px","important"),amt&&amt.style.setProperty("font-size",fs+1+"px","important");t.scrollWidth>t.clientWidth&&t.style.setProperty("white-space","normal","important")}}}}function celebrate(root,pb){if(pb.classList.remove("sa-ship-pop"),pb.offsetWidth,pb.classList.add("sa-ship-pop"),!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)){var host=root.querySelector(".rebuy-cart__flyout")||root,box=document.createElement("div");box.className="sa-confetti",box.setAttribute("aria-hidden","true");for(var colors=["#21542B","#F39200","#B51F1F","#E8C547","#6FA36B","#F7B955"],r=pb.getBoundingClientRect(),h=
1host.getBoundingClientRect(),ox=r.left-h.left+r.width/2,oy=r.top-h.top+r.height/2,i=0;i<70;i++){var p=document.createElement("i"),ang=Math.random()*Math.PI*2,dist=80+Math.random()*170;p.style.left=ox+"px",p.style.top=oy+"px",p.style.background=colors[i%colors.length],p.style.setProperty("--dx",Math.round(Math.cos(ang)*dist)+"px"),p.style.setProperty("--dy",Math.round(Math.sin(ang)*dist*.6-40)+"px"),p.style.setProperty("--fall",Math.round(160+Math.random()*260)+"px"),p.style.setProperty("--rot",Math.round(Math.random()*720-360)+"deg"),p.style.animationDelay=Math.round(Math.random()*120)+"ms",i%3===0&&(p.style.borderRadius="50%"),box.appendChild(p)}host.appendChild(box),setTimeout(function(){box.parentNode&&box.parentNode.removeChild(box)},2600)}}function subtotalText(t){var m=t.match(/numero articoli\s*\((\d+)\)/i)||t.match(/^\s*totale\s*\((\d+)\s*articol[oi]\)/i);if(!m)return t;var n=parseInt(m[1],10);return"Subtotale ("+n+(n===1?" articolo)":" articoli)")}function discount(root){var box=root.querySelector(".rebuy-cart__discount-container");if(!(!box||box.querySelector(".sa-cart-discount-toggle"))){var form=box.querySelector(".rebuy-cart__discount-form");if(form){var input=form.querySelector("input"),btn=document.createElement("button");btn.type="button",btn.className="sa-cart-discount-toggle",btn.setAttribute("aria-expanded","false"),btn.textContent="Hai un codice sconto?",btn.addEventListener("click",function(){var open=box.classList.toggle("sa-collapsed")===!1;btn.setAttribute("aria-expanded",open?"true":"false"),open&&input&&input.focus()}),box.insertBefore(btn,box.firstChild);var applied=box.children.length>2||input&&input.value;applied?btn.setAttribute("aria-expanded","true"):box.classList.add("sa-collapsed")}}}function apply(){var root=document.getElementById("rebuy-cart");if(root){shipping(root),setText(root.querySelector(".rebuy-cart__flyout-subtotal-label span"),subtotalText),setText(root.querySelector(".rebuy-cart__checkout-button span"),function(t){return/vai alla cassa/i.test(t)?"Vai alla cassa":t}),root.querySelectorAll('[data-rebuy-component="cross-sell-widget"] .rebuy-product-actions .rebuy-button span').forEach(function(s){setText(s,function(t){return/^\s*aggiungi al carrello\s*$/i.test(t)?"Aggiungi":t})});var xsTitle=root.querySelector('[data-rebuy-component="cross-sell-widget"] .primary-title');setText(xsTitle,function(t){return/completa la tua cena siciliana/i.test(t)?"Spesso acquistati insieme":t}),discount(root),klarna(root)}}function money(cents){var S=window.Rebuy&&window.Rebuy.SmartCart;try{if(S&&typeof S.formatMoney=="function")return S.formatMoney(cents)}catch(e){}return"\u20AC"+(cents/100).toFixed(2).replace(".",",")}function esc(t){return String(t).replace(/[&<>"]/g,function(c){return{"&":"&","<":"<",">":">",'"':"""}[c]})}function klarna(root){var cfg=window.saKlarna,area=root.querySelector('[data-rebuy-component="checkout-area"]'),btn=area&&area.querySelector(".rebuy-cart__checkout-button");if(btn){var row=area.querySelector(".sa-cart-klarna"),total=0;try{var C=window.Rebuy.Cart,cart=C.getCart&&C.getCart();total=cart&&typeof cart.total_price=="number"?cart.total_price:C.subtotal()}catch(e){total=0}var n=cfg&&parseInt(cfg.n,10)||0,min=cfg?Math.round((parseFloat(cfg.min)||0)*100):0,show=cfg&&cfg.enabled&&n>1&&total>0&&total>=min;if(!show){row&&row.parentNode.removeChild(row);return}var amount=Math.ceil(total/n),key=n+":"+amount;row||(row=document.createElement("p"),row.className="sa-cart-klarna"),row.nextSibling!==btn&&area.insertBefore(row,btn),row.dataset.key!==key&&(row.innerHTML='<span class="sa-cart-klarna__badge" aria-hidden="true">Klarna</span><span class="sa-cart-klarna__txt">'+esc(cfg.prefix)+" <strong>"+n+" "+esc(cfg.word)+" "+esc(money(amount))+"</strong> "+esc(cfg.suffix)+"</span>",row.dataset.key=key)}}var pending=!1;function schedule(){pending||(pending=!0,requestAnimationFrame(function(){pending=!1,apply()}))}var watched=null;function watch(){var root=document.getElementById("rebuy-cart");!root||root===watched||(watched=root,new MutationObserver(schedule).observe(root,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["class","aria-valuenow"]}),schedule())}var pbar=null;function previewBar(){var w=document.getElementById("PBarNextFrameWrapper"),h=w&&getComputedStyle(w).display!=="none"?w.offsetHeight:0;document.documentElement.style.setProperty("--sa-pbar-h",h+"px"),w&&w!==pbar&&window.ResizeObserver&&(pbar=w,new ResizeObserver(previewBar).observe(w))}var busyTimer=null;function digitsNode(label){for(var n=label&&label.firstChild;n;n=n.nextSibling)if(n.nodeType===3&&/\d/.test(n.nodeValue))return n;return null}function endBusy(){if(!Object.keys(qtyTimers).length){clearTimeout(busyTimer);var root=document.getElementById("rebuy-cart");!root||!root.classList.contains("sa-cart-busy")||(root.classList.remove("sa-cart-busy"),root.querySelectorAll(".sa-removing").forEach(function(li){li.classList.remove("sa-removing")}),resyncQty(root))}}function resyncQty(root){fetch("/cart.js",{credentials:"same-origin",headers:{"Cache-Control":"no-cache"}}).then(function(r){return r.json()}).then(function(cart){root.classList.contains("sa-cart-busy")||root.querySelectorAll(".rebuy-cart__flyout-item").forEach(function(li){var handle="";li.classList.forEach(function(c){!handle&&c.indexOf("product-")===0&&(handle=c.slice(8))});var variant=(li.querySelector(".rebuy-cart__flyout-item-variant-title")||{}).textContent||"",matches=cart.items.filter(function(it){return it.handle===handle});if(matches.length>1&&(matches=matches.filter(function(it){return(it.variant_title||"").trim()===variant.trim()})),matches.length===1){var node=digitsNode(li.querySelector(".rebuy-cart__flyout-item-quantity-widget-label")),want=String(matches[0].quantity);node&&node.nodeValue.replace(/\D/g,"")!==want&&(node.nodeValue=" "+want+" ")}})}).catch(function(){})}function liHandle(li){var handle="";return li.classList.forEach(function(c){!handle&&c.indexOf("product-")===0&&(handle=c.slice(8))}),handle}function rebuyItem(li){var Cart=window.Rebuy&&window.Rebuy.Cart;if(!Cart||typeof Cart.items!="function"||typeof Cart.setItemQuantity!="function")return null;var handle=liHandle(li),variant=((li.querySelector(".rebuy-cart__flyout-item-variant-title")||{}).textContent||"").trim(),list;
1try{list=Cart.items()||[]}catch(err){return null}return list=list.filter(function(it){return it.handle===handle}),list.length>1&&(list=list.filter(function(it){return(it.variant_title||"").trim()===variant})),list.length===1?list[0]:null}var qtyTimers={};function startBusy(root){root.classList.add("sa-cart-busy"),clearTimeout(busyTimer),busyTimer=setTimeout(endBusy,8e3)}document.addEventListener("click",function(e){var btn=e.target.closest&&e.target.closest("#rebuy-cart .rebuy-cart__flyout-item-quantity-widget-button");if(btn){var root=document.getElementById("rebuy-cart"),li=btn.closest(".rebuy-cart__flyout-item"),widget=btn.closest(".rebuy-cart__flyout-item-quantity-widget"),node=digitsNode(widget&&widget.querySelector(".rebuy-cart__flyout-item-quantity-widget-label")),item=li&&rebuyItem(li);if(!(!node||!item)){e.preventDefault(),e.stopImmediatePropagation();var buttons=widget.querySelectorAll(".rebuy-cart__flyout-item-quantity-widget-button"),step=item.quantity_rule&&item.quantity_rule.increment||1,delta=btn===buttons[0]?-step:step,next=Math.max(0,(parseInt(node.nodeValue.replace(/\D/g,""),10)||0)+delta);node.nodeValue=" "+next+" ",li.classList.toggle("sa-removing",next===0),startBusy(root);var key=item.key||item.id;clearTimeout(qtyTimers[key]),qtyTimers[key]=setTimeout(function(){delete qtyTimers[key];var fresh=rebuyItem(li)||item;if(fresh.quantity===next){endBusy();return}try{window.Rebuy.Cart.setItemQuantity(fresh,next,{error:function(){endBusy()}})}catch(err){endBusy()}},400)}}},!0),document.addEventListener("rebuy:cart.change",function(){setTimeout(endBusy,60),setTimeout(headerCount,60)});function headerCount(){var S=window.Rebuy&&window.Rebuy.SmartCart;if(!(!S||typeof S.itemCount!="function")){var n;try{n=S.itemCount()}catch(err){return}typeof n=="number"&&document.querySelectorAll(".header__cart-count").forEach(function(el){el.textContent.trim()!==String(n)&&(el.textContent=n)})}}document.addEventListener("click",function(e){if(e.target.closest&&e.target.closest("#rebuy-cart .rebuy-cart__flyout-item-remove")){var root=document.getElementById("rebuy-cart"),li=e.target.closest(".rebuy-cart__flyout-item");li&&li.classList.add("sa-removing"),root.classList.add("sa-cart-busy"),clearTimeout(busyTimer),busyTimer=setTimeout(endBusy,6e3)}},!0);function init(){watch(),previewBar(),new MutationObserver(function(){watch(),previewBar()}).observe(document.body,{childList:!0})}["rebuy:smartcart.ready","rebuy:smartcart.show","rebuy:cart.change"].forEach(function(e){document.addEventListener(e,function(){watch(),schedule()})}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})(); 2//# sourceMappingURL=/cdn/shop/t/85/assets/sa-cart.js.map?v=59931971849144939961791150503
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.