import{d as e,f as t,h as n,l as r,r as i,s as a,t as o,u as s}from"./src-C0xjWfnx.js";import{t as c}from"./useNavigate-VRicZWJI.js";import{t as l}from"./arrow-left-9Wn53Zfu.js";import{t as u}from"./shopping-cart-BBNoSjWE.js";import{t as d}from"./index-BXnbw4dQ.js";import{n as f}from"./cart-query-hooks-BCr0eax3.js";import{t as p}from"./central-product-store-DGoerB5U.js";var m=n(t()),h=e();function g(){let{productId:e,storeId:t}=d.useParams(),n=Number(e),g=c(),[_,v]=(0,m.useState)(1),y=p(e=>e.productsById)[n],b=f(`regular`),x=()=>{y&&b.mutate({productId:y.id,quantity:_,storeId:y.storeId},{onSuccess:()=>g({to:`/cart`})})};if(!y)return(0,h.jsx)(o,{children:(0,h.jsx)(s,{children:`Product not found`})});let S=y.discountedPrice??y.price,C=y.images?.[0];return(0,h.jsxs)(o,{children:[(0,h.jsx)(a,{onClick:()=>g({to:`/stores/$storeId`,params:{storeId:t}}),className:`mb-4 flex items-center gap-2`,children:(0,h.jsx)(l,{className:`h-5 w-5`})}),C&&(0,h.jsx)(`div`,{className:`mb-4 aspect-square w-full overflow-hidden rounded-xl bg-gray-100`,children:(0,h.jsx)(`img`,{src:C,alt:y.name,className:`h-full w-full object-cover`})}),(0,h.jsx)(s,{weight:`bold`,className:`mb-1 text-xl`,children:y.name}),(0,h.jsxs)(s,{className:`mb-2 text-sm text-gray-500`,children:[y.unitValue,y.unit]}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-baseline gap-2`,children:[(0,h.jsxs)(s,{weight:`bold`,className:`text-2xl text-brand-600`,children:[`₹`,S]}),y.discountedPrice&&(0,h.jsxs)(s,{className:`text-sm text-gray-400 line-through`,children:[`₹`,y.price]})]}),y.description&&(0,h.jsx)(s,{className:`mb-4 text-gray-600`,children:y.description}),(0,h.jsx)(`div`,{className:`mb-6`,children:(0,h.jsx)(i,{value:_,setValue:v,max:10})}),(0,h.jsxs)(r,{fullWidth:!0,onClick:x,disabled:b.isPending,className:`flex items-center justify-center gap-2 bg-brand-500 text-white`,children:[(0,h.jsx)(u,{className:`h-4 w-4`}),b.isPending?`Adding...`:`Add to Cart`]})]})}export{g as component};