import{af as h,a as P,j as e,c$ as f,U as j,ar as R,ao as b,bX as v,M as I,ap as V,Q as d,as as N,d0 as A,Z as D,G as c,aq as $,k as x,c as l,b as m,m as i,bc as M,L as Q,T as C,am as E}from"../index.Crez7j-Y.bundle.js";import{E as L}from"./EmptyContent.BRQ9JwMr.bundle.js";function _(){const t=h(R,n=>n.isLogin),{isMobile:r}=P();return r?e.jsx(e.Fragment,{children:t?e.jsx(S,{}):e.jsx(G,{})}):e.jsx(f,{to:j.MAIN,replace:!0})}function S(){const t=b(),{data:r,isPending:n}=v(),{deleteRecentViewProductAPI:s}=I(),o=V({mutationFn:a=>s(a),onMutate:async a=>{await t.cancelQueries({queryKey:d.memberRecentViewProducts()});const p=t.getQueryData(d.memberRecentViewProducts());return t.setQueryData(d.memberRecentViewProducts(),u=>u.filter(y=>y.productNo!==a)),{previousProducts:p}},onError:(a,p,u)=>{t.setQueryData(d.memberRecentViewProducts(),u==null?void 0:u.previousProducts)},onSettled:()=>{t.invalidateQueries({queryKey:d.memberRecentViewProducts(),stale:!1})}}),w=async a=>{await o.mutateAsync(a)};return e.jsx(g,{recentProducts:r,isPending:n,onDeleteRecentViewProduct:w})}function G(){const{removeItem:t,productNos:r}=h(N,o=>({removeItem:o.removeItem,productNos:o.productNos})),{data:n,isLoading:s}=A(r);return e.jsx(g,{recentProducts:n,isPending:s,onDeleteRecentViewProduct:t})}function g({recentProducts:t,isPending:r,onDeleteRecentViewProduct:n}){return e.jsxs(D,{children:[e.jsx(c,{mobile:12,children:e.jsx($,{title:"최근 본 상품"})}),e.jsxs(c,{mobile:12,sx:{py:3},children:[t&&t.length===0&&e.jsx(L,{height:"50vh",text:"최근 본 상품이 없습니다."}),e.jsxs(c,{container:!0,justifyContent:"center",gap:2,children:[r&&Array.from({length:3}).map((s,o)=>e.jsx(c,{item:!0,mobile:11,position:"relative",sx:{border:"1px solid ".concat(x)},children:e.jsxs(l,{display:"flex",alignItems:"center",gap:4,width:"100%",overflow:"hidden",children:[e.jsx(m,{variant:"rectangular",width:i.최근본상품,height:i.최근본상품}),e.jsxs(l,{width:"calc(100% - ".concat(i.최근본상품,"px)"),children:[e.jsx(m,{variant:"text",width:"80%"}),e.jsx(m,{variant:"text",width:"80%"})]})]})},o)),t&&(t==null?void 0:t.map(s=>e.jsxs(c,{item:!0,mobile:11,position:"relative",sx:{border:"1px solid ".concat(x)},children:[e.jsx(M,{onClick:()=>n(s.productNo),sxProps:{right:0}}),e.jsx(Q,{underline:"none",href:"".concat(j.PRODUCT_DETAIL,"?productNo=").concat(s.productNo),children:e.jsxs(c,{container:!0,alignItems:"center",desktop:12,mobile:12,overflow:"hidden",children:[e.jsx(l,{component:"img",src:"".concat(s.imageUrlInfo[0].url,"?").concat(i.최근본상품,"x").concat(i.최근본상품),alt:s.productName,width:i.최근본상품,height:i.최근본상품}),e.jsxs(l,{pl:1,width:"calc(100% - ".concat(i.최근본상품+40,"px)"),children:[e.jsx(C,{variant:"subtitle1",fontWeight:600,children:s.productName}),e.jsx(E,{salePrice:s.salePrice,immediateDiscountAmt:s.immediateDiscountAmt,contentsIfPausing:s.contentsIfPausing,smallSize:!0})]})]})})]},s.productNo)))]})]})]})}export{_ as default};