1import{r as Q,j as e}from"./vendor-react-B2sh9_cl.js";import{u as U}from"./vendor-query-CZYL2sef.js";import{S as W}from"./SEO-vC6DPYD0.js";import{r as G,Q as V,T as _,U as H,f as J,k as K,s as X,D as Y,S as Z,L as D,B as h,M as tt,I as et,W as st,x as rt,J as at,A as ot}from"./index-Dg39wuFL.js";import{N as ct}from"./Navbar-B2tq9eQm.js";import{F as nt}from"./Footer-BvdDoUET.js";import{AuthModal as it}from"./AuthModal-BjmgCDMG.js";import{C as v}from"./card-Bg7tsvG3.js";import{P as dt}from"./progress-B0FPt7Ay.js";import{C as lt}from"./circle-alert-DSJ_OaJq.js";import{P as ut}from"./percent-BZkwywzu.js";import{G as pt}from"./gift-CssK0T18.js";import"./vendor-ui-CJgNfAeu.js";import"./vendor-utils-DeRmtv56.js";import"./vendor-zod-DyDMQjHO.js";import"./trending-up-D5GMRR4n.js";import"./use-favorites-C9kPtNJm.js";import"./dropdown-menu-24PawOwO.js";import"./chevron-right-DIU9h5iI.js";import"./check-nepLHhG4.js";import"./circle-Bh99Nj0y.js";import"./navbar-settings-fPhhTT96.js";import"./arrow-left-sLItQuDU.js";import"./heart-GCNTOg-V.js";import"./user-DK79JTbh.js";import"./briefcase-kSjT6zcd.js";import"./shirt-DLm0Scht.js";import"./music-CBrhMkJV.js";import"./push-wyTrO4kF.js";import"./bell-Ja8LodWO.js";import"./index-BvF2DRZ9.js";import"./footer-settings-O_1dpJij.js";import"./dialog-5lXfI5Sv.js";import"./input-D1kPcCH9.js";import"./label-CfI855z_.js";import"./circle-check-big-Dii8TUeG.js";import"./mail-FUIkQOqG.js";import"./lock-m6F5Cnl4.js";import"./eye-off-B1gGK5P0.js";import"./eye-CtyCd1X4.js";import"./building-2-B8KMqZux.js";import"./handshake-c5BNYoJZ.js";const q=5e5;function se(){const{data:d,isLoading:$}=G(),M=V(),l=_(),L=H(),[,T]=J(),{isWholesale:r,getWholesalePrice:w}=K(),{data:u}=X(),f=!!u?.user,[A,z]=Q.useState(!1),B=U({queryKey:["/api/loyalty-tiers"],queryFn:async()=>{const t=await fetch("/api/loyalty-tiers");return t.ok?t.json():[]},enabled:f&&!r});if($)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(Y,{size:"lg"})});const a=t=>new Intl.NumberFormat("ru-RU",{style:"currency",currency:"RUB",minimumFractionDigits:0}).format(t/100),j=d?.reduce((t,s)=>{const c=s.product.salePrice;if(c&&c>0&&c<s.product.price)return t+c*s.quantity;const x=s.product.discountPercent,y=s.product.sizeDiscounts,i=(y&&s.size?y[s.size]:null)??x,N=i&&i>0?Math.round(s.product.price*(1-i/100)):s.product.price;return t+N*s.quantity},0)||0,k=d?.reduce((t,s)=>{const c=r&&w(s.product.price,s.product.wholesalePrice,s.product.wholesaleDiscountPercent)||s.product.price;return t+c*s.quantity},0)||0,p=r?k:j,P=j-k,I=!r||p>=q,S=(B.data||[]).slice().sort((t,s)=>t.minSpent-s.minSpent),g=u?.user?.totalSpent||0,o=S.find(t=>g<t.minSpent),O=o?Math.min(100,Math.round(g/o.minSpent*100)):100,R=o?o.minSpent-g:0;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(W,{title:"ÐоÑзина",description:"ÐаÑа коÑзина покÑпок BMGBRAND.",noindex:!0}),e.jsx(ct,{}),e.jsxs("div",{className:"pt-32 pb-24 max-w-8xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-semibold mb-8 text-foreground",children:"ÐоÑзина"}),!d||d.length===0?e.jsxs(v,{className:"text-center py-16 px-6","data-testid":"status-cart-empty",children:[e.jsx(Z,{className:"w-16 h-16 mx-auto mb-6 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground mb-8 text-lg",children:"ÐаÑа коÑзина пÑÑÑа"}),e.jsx(D,{href:"/products",children:e.jsx(h,{size:"lg","data-testid":"button-go-shopping",children:"ÐеÑейÑи к покÑпкам"})})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[d.map(t=>{const s=t.product.salePrice,c=t.product.discountPercent,x=t.product.sizeDiscounts,n=(x&&t.size?x[t.size]:null)??c;!r&&(s&&s>0&&s<t.product.price||n&&n>0);const i=s&&s>0&&s<t.product.price&&!r?s:n&&n>0&&!r?Math.round(t.product.price*(1-n/100)):t.product.price,N=w(t.product.price,t.product.wholesalePrice,t.product.wholesaleDiscountPercent)||t.product.price,F=(r?N:i)*t.quantity,E=i*t.quantity;return e.jsxs(v,{className:"flex gap-4 p-4","data-testid":`card-cart-item-${t.productId}-${t.size}`,children:[e.jsx("div",{className:"w-24 h-28 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:e.jsx("img",{src:t.product.imageUrl,alt:t.product.name,className:"w-full h-full object-cover","data-testid":`img-cart-item-${t.id}`})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-between min-w-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-start gap-2 mb-1",children:[e.jsx("h3",{className:"font-medium text-foreground line-clamp-2 text-sm sm:text-base","data-testid":`text-cart-item-name-${t.id}`,children:t.product.name}),e.jsxs("div",{className:"text-right whitespace-nowrap",children:[e.jsx("p",{className:`font-semibold ${r?"text-primary":"text-foreground"}`,"data-testid":`text-cart-item-total-${t.id}`,children:a(F)}),r&&e.jsx("p",{className:"text-xs text-muted-foreground line-through",children:a(E)})]})]}),e.jsxs("p",{className:"text-muted-foreground text-sm","data-testid":`text-cart-item-variants-${t.id}`,children:[t.size,t.color&&t.color!=="Default"?` / ${t.color}`:""]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"outline",size:"icon",className:"h-7 w-7","data-testid":`button-decrease-quantity-${t.id}`,disabled:t.quantity<=(r&&t.product?.category==="socks"?2:1)||l.isPending,onClick:()=>l.mutate({id:t.id,sessionId:t.sessionId||"",productId:t.productId,size:t.size,color:t.color,quantity:t.quantity-1}),children:e.jsx(tt,{className:"w-3 h-3"})}),e.jsx("span",{className:"text-sm font-medium w-8 text-center tabular-nums","data-testid":`text-cart-item-quantity-${t.id}`,children:t.quantity}),e.jsx(h,{variant:"outline",size:"icon",className:"h-7 w-7","data-testid":`button-increase-quantity-${t.id}`,disabled:l.isPending||(()=>{const C=t.size||"One Size",b=t.product?.sizeStock;let m;return b&&b[C]!==void 0?m=b[C]:t.product?.stock!==void 0&&t.product?.stock!==null?m=t.product.stock:m=999,t.quantity>=m})(),onClick:()=>l.mutate({id:t.id,sessionId:t.sessionId||"",productId:t.productId,size:t.size,color:t.color,quantity:t.quantity+1}),children:e.jsx(et,{className:"w-3 h-3"})})]}),e.jsx("button",{onClick:()=>M.mutate({id:t.id,sessionId:t.sessionId||"",productId:t.productId,size:t.size,color:t.color,productName:t.product?.name,ecommerce:{id:t.productId,name:t.product?.name||"",priceCents:t.product?.price||0,variant:rt(t.size,t.color),quantity:t.quantity}}),"data-testid":`button-remove-cart-item-${t.id}`,className:"text-muted-foreground hover:text-destructive transition-colors p-1",children:e.jsx(st,{className:"w-4 h-4"})})]})]})]},`${t.productId}-${t.size}-${t.color}`)}),e.jsx("button",{onClick:()=>L.mutate(),"data-testid":"button-clear-cart",className:"text-sm text-muted-foreground hover:text-foreground underline",children:"ÐÑиÑÑиÑÑ ÐºÐ¾Ñзин
1Ñ"})]}),e.jsx("div",{className:"lg:col-span-1",children:e.jsxs(v,{className:"p-6 sticky top-24",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground",children:"ÐÑого"}),r&&e.jsx(at,{variant:"secondary",children:"ÐÐТ"})]}),e.jsxs("div",{className:"space-y-3 mb-6 text-sm",children:[r&&e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:"РозниÑÐ½Ð°Ñ Ñена"}),e.jsx("span",{className:"line-through",children:a(j)})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:r?"ÐпÑÐ¾Ð²Ð°Ñ Ñена":"СÑмма"}),e.jsx("span",{"data-testid":"text-cart-subtotal",children:a(p)})]}),r&&P>0&&e.jsxs("div",{className:"flex justify-between text-primary",children:[e.jsx("span",{children:"ÐаÑа ÑкономиÑ"}),e.jsx("span",{"data-testid":"text-cart-savings",children:a(P)})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:"ÐоÑÑавка"}),e.jsx("span",{"data-testid":"text-shipping-cost",children:"РаÑÑÑиÑаеÑÑÑ Ð¿Ñи оÑоÑмлении"})]}),e.jsxs("div",{className:"border-t pt-3 flex justify-between text-foreground text-lg font-semibold",children:[e.jsx("span",{children:"ÐÑего"}),e.jsx("span",{"data-testid":"text-cart-total",children:a(p)})]})]}),r&&!I&&e.jsxs("div",{className:"flex items-start gap-2 p-3 mb-4 rounded-lg bg-destructive/10 text-destructive text-sm",children:[e.jsx(lt,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"ÐинималÑнÑй заказ Ð´Ð»Ñ Ð¾Ð¿Ñа"}),e.jsxs("p",{children:["ÐобавÑÑе ÑоваÑов еÑÑ Ð½Ð° ",a(q-p)]})]})]}),!f&&e.jsxs("div",{className:"flex items-start gap-3 p-3 mb-4 rounded-lg bg-primary/10 border border-primary/20",children:[e.jsx(ut,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-primary"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:"ÐаÑегиÑÑÑиÑÑйÑÑ Ð¸ полÑÑи ÑкидкÑ"}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:"Чем болÑÑе покÑпаеÑÑ â Ñем вÑÑе ÑÐ²Ð¾Ñ Ð¿ÐµÑÑоналÑÐ½Ð°Ñ Ñкидка. Скидка пÑименÑеÑÑÑ Ð°Ð²ÑомаÑиÑеÑки к ÐºÐ°Ð¶Ð´Ð¾Ð¼Ñ Ð·Ð°ÐºÐ°Ð·Ñ."}),e.jsx("button",{onClick:()=>z(!0),className:"text-primary text-xs font-medium hover:underline mt-1 inline-block","data-testid":"link-loyalty-register",children:"СоздаÑÑ Ð°ÐºÐºÐ°ÑÐ½Ñ â"})]})]}),f&&!r&&S.length>0&&e.jsxs("div",{className:"p-3 mb-4 rounded-lg bg-primary/5 border border-primary/20","data-testid":"cart-loyalty-progress",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm mb-2",children:[e.jsx(pt,{className:"w-4 h-4 text-primary flex-shrink-0"}),o?e.jsxs("span",{className:"font-medium text-foreground",children:["Ðо «",o.name||"ÑледÑÑÑего ÑÑовнÑ","» (",o.discountPercent,"%) оÑÑалоÑÑ ",a(R)]}):e.jsxs("span",{className:"font-medium text-foreground",children:["ÐакÑималÑнÑй ÑÑÐ¾Ð²ÐµÐ½Ñ â ваÑа Ñкидка ",u?.user?.loyaltyDiscount||0,"%"]})]}),e.jsx(dt,{value:O,className:"h-2"}),e.jsx("p",{className:"text-muted-foreground text-xs mt-1.5",children:o?`СейÑÐ°Ñ Ð²Ð°Ñа Ñкидка ${u?.user?.loyaltyDiscount||0}%. ÐокÑпки ÑÑиÑÑваÑÑÑÑ Ð½Ð°ÐºÐ¾Ð¿Ð¸ÑелÑно â ÑÑмма заказа пÑибавиÑÑÑ Ð¿Ð¾Ñле оплаÑÑ.`:"ÐаÑа накопиÑелÑÐ½Ð°Ñ Ñкидка пÑименÑеÑÑÑ Ð°Ð²ÑомаÑиÑеÑки к ÐºÐ°Ð¶Ð´Ð¾Ð¼Ñ Ð·Ð°ÐºÐ°Ð·Ñ."})]}),e.jsxs(h,{size:"lg",className:"w-full","data-testid":"button-checkout",onClick:()=>T("/checkout"),disabled:!I,children:["ÐÑоÑмиÑÑ Ð·Ð°ÐºÐ°Ð· ",e.jsx(ot,{className:"w-4 h-4 ml-2"})]}),e.jsx(D,{href:"/products",className:"block text-center mt-4 text-sm text-muted-foreground hover:text-foreground",children:"ÐÑодолжиÑÑ Ð¿Ð¾ÐºÑпки"})]})})]})]}),e.jsx(nt,{}),e.jsx(it,{open:A,onOpenChange:z,initialView:"register"})]})}
1export{se as default};
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.