(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,46395,e=>{e.v({actionsBar:"reviews-module__ngcMdq__actionsBar",analyticsCard:"reviews-module__ngcMdq__analyticsCard",analyticsGrid:"reviews-module__ngcMdq__analyticsGrid",cardTitle:"reviews-module__ngcMdq__cardTitle",cardValue:"reviews-module__ngcMdq__cardValue",container:"reviews-module__ngcMdq__container",customerName:"reviews-module__ngcMdq__customerName",emptyState:"reviews-module__ngcMdq__emptyState",errorText:"reviews-module__ngcMdq__errorText",header:"reviews-module__ngcMdq__header",pageButton:"reviews-module__ngcMdq__pageButton",pageControls:"reviews-module__ngcMdq__pageControls",pagination:"reviews-module__ngcMdq__pagination",productName:"reviews-module__ngcMdq__productName",reviewCard:"reviews-module__ngcMdq__reviewCard",reviewComment:"reviews-module__ngcMdq__reviewComment",reviewDate:"reviews-module__ngcMdq__reviewDate",reviewHeader:"reviews-module__ngcMdq__reviewHeader",reviewsGrid:"reviews-module__ngcMdq__reviewsGrid",searchInput:"reviews-module__ngcMdq__searchInput",selectInput:"reviews-module__ngcMdq__selectInput",stars:"reviews-module__ngcMdq__stars",title:"reviews-module__ngcMdq__title"})},67403,e=>{"use strict";var a=e.i(43476),t=e.i(71645),s=e.i(66595),r=e.i(86563);let i=(0,e.i(56420).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var l=e.i(65464);let d=new class{async fetchVendorReviews(e){let{data:a,error:t}=await l.supabase.from("reviews").select(`
        *,
        products!inner (
          id,
          product_name,
          vendor_id
        ),
        users!left (
          id,
          email,
          name
        )
      `).eq("products.vendor_id",e).order("created_at",{ascending:!1});if(t)throw console.error("Error fetching reviews:",t),t;return a||[]}};var n=e.i(46395),c=e.i(44824);function o(){return(0,a.jsx)(c.default,{text:"Loading Reviews..."})}e.s(["default",0,function(){let[e,c]=(0,t.useState)(!1);(0,t.useEffect)(()=>{c(!0)},[]);let{data:u,analytics:m,loading:v,error:g,filters:_,pagination:h}=function(){let[e,a]=(0,t.useState)([]),[s,r]=(0,t.useState)(!0),[i,n]=(0,t.useState)(null),[c,o]=(0,t.useState)("all"),[u,m]=(0,t.useState)(""),[v,g]=(0,t.useState)(1);(0,t.useEffect)(()=>{_()},[]);let _=async()=>{try{r(!0),n(null);let{data:{user:e}}=await l.supabase.auth.getUser();if(!e)throw Error("Not authenticated");let{data:t,error:s}=await l.supabase.from("vendor_profiles").select("id").eq("user_id",e.id).single();if(s)throw s;if(!t)throw Error("Vendor profile not found");let i=await d.fetchVendorReviews(t.id);a(i)}catch(e){console.warn("Failed to load reviews:",e.message),n(`Failed to load reviews: ${e.message}`)}finally{r(!1)}},h=(0,t.useMemo)(()=>e.filter(e=>{let a=e.products?.product_name?.toLowerCase().includes(u.toLowerCase())||e.comment?.toLowerCase().includes(u.toLowerCase()),t=!0;return"all"!==c&&(t=e.rating===parseInt(c,10)),a&&t}),[e,u,c]),f=Math.ceil(h.length/10);return{data:h.slice((v-1)*10,10*v),analytics:(0,t.useMemo)(()=>{let a=e.length,t=0,s=0,r=0,i=0,l=0,d=0;e.forEach(e=>{t+=e.rating,5===e.rating&&s++,4===e.rating&&r++,3===e.rating&&i++,2===e.rating&&l++,1===e.rating&&d++});let n=a>0?(t/a).toFixed(1):0;return{total:a,averageRating:n,distribution:{5:s,4:r,3:i,2:l,1:d}}},[e]),loading:s,error:i,filters:{searchQuery:u,setSearchQuery:m,ratingFilter:c,setRatingFilter:o},pagination:{currentPage:v,setCurrentPage:g,totalPages:f},actions:{refresh:_}}}();return e?v&&0===u.length?(0,a.jsx)(o,{}):(0,a.jsxs)("div",{className:n.default.container,children:[(0,a.jsx)("div",{className:n.default.header,children:(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:n.default.title,children:"Customer Reviews"}),(0,a.jsx)("p",{style:{color:"var(--color-text-secondary)",marginTop:"4px"},children:"Monitor and manage customer feedback on your products."})]})}),g&&(0,a.jsx)("div",{className:n.default.errorText,children:g}),(0,a.jsxs)("div",{className:n.default.analyticsGrid,children:[(0,a.jsxs)("div",{className:n.default.analyticsCard,children:[(0,a.jsxs)("div",{className:n.default.cardTitle,children:[(0,a.jsx)(i,{size:16,style:{display:"inline",marginRight:8,verticalAlign:"middle"}}),"Total Reviews"]}),(0,a.jsx)("div",{className:n.default.cardValue,children:m.total})]}),(0,a.jsxs)("div",{className:n.default.analyticsCard,children:[(0,a.jsxs)("div",{className:n.default.cardTitle,children:[(0,a.jsx)(r.Star,{size:16,style:{display:"inline",marginRight:8,verticalAlign:"middle",color:"#fbbf24"}}),"Average Rating"]}),(0,a.jsxs)("div",{className:n.default.cardValue,children:[m.averageRating," / 5.0"]})]}),(0,a.jsx)("div",{className:n.default.analyticsCard,style:{flex:2,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:(0,a.jsxs)("div",{style:{flex:1},children:[(0,a.jsx)("div",{className:n.default.cardTitle,children:"Rating Distribution"}),(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:[5,4,3,2,1].map(e=>(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,a.jsxs)("span",{children:[e," ★"]}),(0,a.jsx)("div",{style:{flex:1,height:6,background:"var(--color-border)",borderRadius:3,overflow:"hidden"},children:(0,a.jsx)("div",{style:{width:`${m.total>0?m.distribution[e]/m.total*100:0}%`,height:"100%",background:"#fbbf24"}})}),(0,a.jsx)("span",{style:{width:24,textAlign:"right"},children:m.distribution[e]})]},e))})]})})]}),(0,a.jsxs)("div",{className:n.default.actionsBar,children:[(0,a.jsxs)("div",{style:{position:"relative",flex:1,minWidth:"250px"},children:[(0,a.jsx)(s.Search,{size:18,style:{position:"absolute",left:12,top:12,color:"var(--color-text-secondary)"}}),(0,a.jsx)("input",{type:"text",placeholder:"Search reviews or products...",className:n.default.searchInput,style:{paddingLeft:40,width:"100%"},value:_.searchQuery,onChange:e=>_.setSearchQuery(e.target.value)})]}),(0,a.jsxs)("select",{className:n.default.selectInput,value:_.ratingFilter,onChange:e=>_.setRatingFilter(e.target.value),children:[(0,a.jsx)("option",{value:"all",children:"All Ratings"}),(0,a.jsx)("option",{value:"5",children:"5 Stars"}),(0,a.jsx)("option",{value:"4",children:"4 Stars"}),(0,a.jsx)("option",{value:"3",children:"3 Stars"}),(0,a.jsx)("option",{value:"2",children:"2 Stars"}),(0,a.jsx)("option",{value:"1",children:"1 Star"})]})]}),0===u.length?(0,a.jsx)("div",{className:n.default.emptyState,children:"No reviews found matching your criteria."}):(0,a.jsx)("div",{className:n.default.reviewsGrid,children:u.map(e=>(0,a.jsxs)("div",{className:n.default.reviewCard,children:[(0,a.jsxs)("div",{className:n.default.reviewHeader,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:n.default.productName,children:e.products?.product_name||"Unknown Product"}),(0,a.jsxs)("div",{className:n.default.customerName,children:["By ",e.users?.name||e.users?.email||"Anonymous Customer"]})]}),(0,a.jsx)("div",{className:n.default.reviewDate,children:new Date(e.created_at).toLocaleDateString()})]}),(0,a.jsx)("div",{className:n.default.stars,children:[1,2,3,4,5].map(t=>(0,a.jsx)(r.Star,{size:16,fill:t<=e.rating?"#fbbf24":"none",color:t<=e.rating?"#fbbf24":"var(--color-border)"},t))}),e.comment&&(0,a.jsxs)("div",{className:n.default.reviewComment,children:['"',e.comment,'"']})]},e.id))}),h.totalPages>1&&(0,a.jsxs)("div",{className:n.default.pagination,children:[(0,a.jsxs)("span",{style:{color:"var(--color-text-secondary)",fontSize:14},children:["Showing Page ",h.currentPage," of ",h.totalPages]}),(0,a.jsxs)("div",{className:n.default.pageControls,children:[(0,a.jsx)("button",{className:n.default.pageButton,disabled:1===h.currentPage,onClick:()=>h.setCurrentPage(e=>e-1),children:"Previous"}),(0,a.jsx)("button",{className:n.default.pageButton,disabled:h.currentPage===h.totalPages,onClick:()=>h.setCurrentPage(e=>e+1),children:"Next"})]})]})]}):null}],67403)}]);