import{d as e,l as t,r as n,s as r,t as i,u as a}from"./src-C0xjWfnx.js";import{t as o}from"./useNavigate-VRicZWJI.js";import{t as s}from"./trash-2-B2Qxo_rV.js";import{a as c,i as l,r as u}from"./cart-query-hooks-BCr0eax3.js";import{t as d}from"./prominent-api-hooks-DipwWw0H.js";var f=e();function p(){let e=o(),{data:p}=u(`regular`),{data:m}=d(),h=c(`regular`),g=l(`regular`),_=m?.products||[],v={};_.forEach(e=>{v[e.id]=e});let y=(p?.items||[]).filter(e=>v[e.productId]),b=0;return y.forEach(e=>{let t=v[e.productId];t&&(b+=t.price*e.quantity)}),(0,f.jsxs)(i,{children:[(0,f.jsx)(a,{weight:`bold`,className:`mb-4 text-xl`,children:`Your Cart`}),y.length===0?(0,f.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-20`,children:[(0,f.jsx)(a,{className:`text-gray-500`,children:`Your cart is empty`}),(0,f.jsx)(t,{textContent:`Browse Products`,onClick:()=>e({to:`/home`})})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`flex flex-col gap-3`,children:y.map(e=>{let t=v[e.productId],i=t.price;return(0,f.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-gray-100 bg-white p-3 shadow-sm`,children:[(0,f.jsx)(`img`,{src:t.images?.[0],alt:t.name,className:`h-16 w-16 rounded-lg object-cover`}),(0,f.jsxs)(`div`,{className:`flex-1`,children:[(0,f.jsx)(a,{weight:`semibold`,className:`text-sm`,numberOfLines:1,children:t.name}),(0,f.jsxs)(a,{className:`text-brand-600 text-sm font-bold`,children:[`₹`,i]}),(0,f.jsx)(n,{value:e.quantity,setValue:t=>h.mutate({productId:e.productId,quantity:t})})]}),(0,f.jsx)(r,{onClick:()=>g.mutate(e.productId),children:(0,f.jsx)(s,{className:`h-5 w-5 text-red-500`})})]},e.productId)})}),(0,f.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 border-t border-gray-200 bg-white p-4 shadow-lg`,children:[(0,f.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,f.jsx)(a,{weight:`bold`,children:`Total`}),(0,f.jsxs)(a,{weight:`bold`,className:`text-lg text-brand-600`,children:[`₹`,b]})]}),(0,f.jsx)(t,{fullWidth:!0,textContent:`Proceed to Checkout`,onClick:()=>e({to:`/home/checkout`}),className:`bg-brand-500 text-white`})]})]})]})}export{p as component};