1import{c as S}from"./lucide-C63VmYQq.js";import{i as B}from"./iconsAndAliases-CInoBnLm.js";document.addEventListener("DOMContentLoaded",()=>{try{S({icons:B})}catch(e){console.warn("Lucide init failed:",e)}const c=document.getElementById("cartflow-horizontal"),y=c?[...c.querySelectorAll(".subcard")]:[],I=document.querySelectorAll(".progress-step"),L=document.getElementById("progressCount");if(!c||y.length===0){console.error("CartFlow: Missing structure.");return}let b=0,p=0;function d(e){const t=Math.max(0,Math.min(e-1,y.length-1));c.scrollTo({left:t*c.clientWidth,behavior:"smooth"})}window.scrollToStep=d,I.forEach((e,t)=>{e.addEventListener("click",()=>{t<=p&&d(t+1)})});function j(e){I.forEach((t,n)=>t.classList.toggle("active",n===e)),L&&(L.textContent=`Krok ${e+1} z ${y.length}`)}c.addEventListener("scroll",()=>{const e=Math.round(c.scrollLeft/c.clientWidth);e!==b&&(b=e,j(e),S({icons:B}))}),document.querySelectorAll("[data-next]").forEach(e=>{e.addEventListener("click",t=>{const n=parseInt(t.target.dataset.next,10);d(n),n-1>p&&(p=n-1)})}),document.querySelectorAll("[data-prev]").forEach(e=>{e.addEventListener("click",t=>{const n=parseInt(t.target.dataset.prev,10);d(n)})});const C=document.querySelectorAll("#deliveryOptions .option-card"),q=document.querySelectorAll("#paymentOptions .option-card"),f=document.getElementById("toDetailsBtn");let s=null,h=null;const w=document.getElementById("packetaSelector"),P=document.getElementById("packetaSelected"),T=document.getElementById("packetaName"),i=document.getElementById("packetaPointId"),v=document.getElementById("packetaPointName"),O=document.getElementById("openPacketa"),_=document.getElementById("deliveryPacketa"),R=document.querySelectorAll("input[name='delivery_method']"),x=()=>{w.style.display="none",P.style.display="none",T.textContent="",i.value="",v.value=""},A=()=>{w.style.display="block"};R.forEach(e=>{e.addEventListener("change",()=>{_.checked?A():x()})}),C.forEach(e=>{e.addEventListener("click",()=>{C.forEach(t=>t.classList.remove("active")),e.classList.add("active"),s=e.dataset.method,s==="packeta"?A():x(),E()})}),q.forEach(e=>{e.addEventListener("click",()=>{q.forEach(t=>t.classList.remove("active")),e.classList.add("active"),h=e.dataset.payment,E()})}),O&&O.addEventListener("click",()=>{const e=document.querySelector('meta[name="packeta-api-key"]')?.content;if(!e){alert("API klÃÄ Zásilkovny nebyl nalezen.");return}if(typeof Packeta?.Widget?.pick!="function"){alert("NepodaÅilo se naÄÃst widget Zásilkovny.");return}Packeta.Widget.pick(e,t=>{t&&(i.value=t.id,v.value=t.name,T.textContent=t.name,P.style.display="block",E())},{appIdentity:"lektor-milky-eshop",language:"cs"})});function E(){if(!s||!h){f.disabled=!0;return}if(s==="packeta"&&!i.value){f.disabled=!0;return}f.disabled=!1}const k=document.getElementById("checkoutForm"),g=document.getElementById("agreeTerms"),N=document.getElementById("toFinalBtn"),o=document.getElementById("submitOrderBtn");if(k){const e=k.querySelectorAll("input[required]"),t=()=>{const n=Array.from(e).every(a=>a.value.trim()!==""),u=g&&g.checked;N.disabled=!(n&&u)};k.addEventListener("input",t),g?.addEventListener("change",t)}N?.addEventListener("click",()=>{o.disabled=!1}),o&&o.addEventListener("click",async e=>{if(e.preventDefault(),o.disabled)return;o.disabled=!0,o.textContent="OdesÃlám...";const t={first_name:document.getElementById("first_name")?.value??"",last_name:document.getElementById("last_name")?.value??"",email:document.getElementById("email")?.value??"",phone:document.getElementById("phone")?.value??"",address:document.getElementById("address")?.value??"",city:document.getElementById("city")?.value??"",zip:document.getElementById("zip")?.value??"",shipping:s,payment:h,packeta_id:i.value||null,packeta_name:v.value||null};try{const n=document.querySelector('meta[name="csrf-token"]').content,a=await(await fetch("/cart/submit",{method:"POST",headers:{"X-CSRF-TOKEN":n,"Content-Type":"application/json"},body:JSON.stringify(t)})).json();if(!a.success){alert(a.message||"Chyba pÅi vytváÅenà objednávky."),o.disabled=!1,o.textContent="Odeslat objednávku";return}window.location.href=a.redirect_url}catch(n){console.error("â Submit failed:",n),alert("NepodaÅilo se odeslat objednávku."),o.disabled=!1,o.textContent="Odeslat objednávku"}});
1const m=document.getElementById("cartSummary");if(m){let u=function(){m.querySelectorAll(".qty-btn").forEach(a=>{a.addEventListener("click",async()=>{const r=a.closest(".cart-item");if(!r)return;const l=r.dataset.id,z=a.dataset.action,K=r.querySelector(".quantity"),F=parseInt(K.textContent||"1",10),M=z==="increase"?F+1:F-1;try{M<=0?await fetch(`/cart/remove/${l}`,{method:"DELETE",headers:{"X-CSRF-TOKEN":t}}):await fetch(`/cart/update/${l}`,{method:"POST",headers:{"X-CSRF-TOKEN":t,"Content-Type":"application/json"},body:JSON.stringify({quantity:M})}),await n()}catch(D){console.error("â Qty update failed:",D)}})})};const e=m.dataset.refreshUrl,t=document.querySelector('meta[name="csrf-token"]').content;async function n(){try{const r=await(await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}})).json();m.innerHTML=r.html,S({icons:B}),u();const l=document.getElementById("summaryTotal");l&&(l.textContent=`${r.total} KÄ`)}catch(a){console.error("â Failed to refresh cart:",a)}}window.refreshCartSummary=n,n()}console.log("â
CartFlow Ready")});
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.