1import{r as i,j as e}from"./vendor-ui-Dew8CZxq.js";import{a as h,cb as ma,d as pa,e as ua,b8 as xa,s as o,cq as ha,al as T,B as n,aU as x,bo as ga,M as Me,br as Le,aP as y,ax as fa,az as De,bx as ja,a$ as va,af as wa,b7 as Na,j as Ie,ai as Y,E as _a,b1 as P,b2 as M,ao as H,ap as J,aq as X,ad as Q,G as ka,c6 as Ee,av as ya,a5 as A,am as ee,D as ba,k as Sa,l as Ca,m as Ra,Z as Pa,_ as Ma,$ as La,a0 as Da,a1 as L,t as f}from"./index-DFuwCptV.js";import{u as Ia}from"./useMarketplaceSettings-BSDyMFPo.js";import{S as Ea}from"./ShareContentDialog-CzSd94dR.js";import za from"./AuthModal-RSIw9f9K.js";import{M as ze,g as Te}from"./marketplaceTypes-Cw4uEtKl.js";import{S as Ta}from"./SellerLocationMap-BHWg4w_f.js";import{V as Aa}from"./VideoEmbed-BA1UMsqH.js";import{Z as qa}from"./zoom-in-DXbhEYRR.js";import{S as Ae}from"./SidebarLayout-D8Rdd3Io.js";import{d as Oa,a as $a}from"./vendor-router-DljXtjbj.js";import{A as Ba}from"./arrow-left-DcrUMmwE.js";import{P as Va}from"./package-Be2d5GwY.js";import{C as Fa}from"./credit-card-C-ERhEFe.js";import{S as Ua}from"./shield-check-Dej69toD.js";import{S as Wa}from"./store-NGfQWV9G.js";import{P as Za}from"./phone-DyjQ11D9.js";import{M as Ga}from"./mail-xGzvri7f.js";import{E as Ka}from"./external-link-zWb_6rlJ.js";import{T as qe}from"./thumbs-up-Cedrz_qJ.js";import{R as Ya}from"./reply-DiDdNzfb.js";import"./vendor-supabase-BOCL3uOH.js";import"./vendor-charts-Da-j9H4-.js";import"./vendor-editor-Ct-iNwJc.js";import"./vendor-query-Cjd1QUxP.js";import"./shareUtils-CYJxVENR.js";import"./auth-register-image-CKw0NjvU.js";import"./checkbox-B5Si2vjD.js";import"./index-9O2INCfF.js";/* empty css */import"./videoThumbnails-BuIqA-YB.js";const Ha=4,Ja=({src:c,alt:q,className:s})=>{const v=i.useRef(null),[r,j]=i.useState(!1),[a,O]=i.useState({x:50,y:50}),[p,D]=i.useState(!1),w=i.useCallback(S=>{if(!v.current)return;const N=v.current.getBoundingClientRect(),C=(S.clientX-N.left)/N.width*100,B=(S.clientY-N.top)/N.height*100;O({x:Math.max(0,Math.min(100,C)),y:Math.max(0,Math.min(100,B))})},[]),b=i.useCallback(()=>j(!0),[]),$=i.useCallback(()=>j(!1),[]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:v,className:h("relative overflow-hidden cursor-crosshair rounded-xl border border-border bg-muted",s),onMouseMove:w,onMouseEnter:b,onMouseLeave:$,onClick:()=>D(!0),children:[e.jsx("img",{src:c,alt:q,className:"w-full h-full object-cover pointer-events-none select-none",draggable:!1,loading:"lazy"}),e.jsx("div",{className:h("absolute inset-0 transition-opacity duration-200 pointer-events-none",r?"opacity-100":"opacity-0"),style:{backgroundImage:`url(${c})`,backgroundSize:`${Ha*100}%`,backgroundPosition:`${a.x}% ${a.y}%`,backgroundRepeat:"no-repeat"}}),r&&e.jsx("div",{className:"absolute w-24 h-24 rounded-full border-2 border-primary/60 pointer-events-none shadow-[0_0_0_2px_rgba(0,0,0,0.1),0_0_20px_rgba(0,0,0,0.15)] -translate-x-1/2 -translate-y-1/2 transition-none",style:{left:`${a.x}%`,top:`${a.y}%`,background:"radial-gradient(circle, transparent 40%, hsl(var(--background) / 0.15) 100%)"}}),e.jsxs("div",{className:h("absolute bottom-3 right-3 bg-background/80 backdrop-blur-sm rounded-lg px-2.5 py-1.5 flex items-center gap-1.5 text-xs text-muted-foreground transition-opacity duration-300 pointer-events-none",r?"opacity-0":"opacity-100"),children:[e.jsx(qa,{className:"w-3.5 h-3.5"}),"Hover to zoom"]})]}),e.jsx(ma,{src:c,alt:q,open:p,onOpenChange:D})]})},Lt=()=>{const{id:c}=Oa(),{isRTL:q,t:s,language:v}=pa(),{user:r}=ua(),j=$a();Ia();const[a,O]=i.useState(null),[p,D]=i.useState(null),[w,b]=i.useState([]),[$,S]=i.useState(!0),[N,C]=i.useState(!1),[B,V]=i.useState(0),[ae,Oe]=i.useState(0),[$e,_]=i.useState(!1),[te,se]=i.useState(5),[re,le]=i.useState(""),[ie,ne]=i.useState(!1),[Be,F]=i.useState(!1),[U,oe]=i.useState(""),[ce,de]=i.useState(""),[me,pe]=i.useState(!1),[Ve,ue]=i.useState(!1),[Xa,Qa]=i.useState(!1),[xe,Fe]=i.useState([]),[he,ge]=i.useState(!1),[I,W]=i.useState(null),[fe,je]=i.useState(""),[ve,we]=i.useState(5),[Ne,Z]=i.useState(null),[E,G]=i.useState(""),[_e,ke]=i.useState(5),ye=r&&a?.user_id===r.id,Ue=async()=>
1{if(!(!r||!a||!ye)&&window.confirm(s("marketplace.confirmDelete")||"Are you sure you want to delete this product?")){ge(!0);try{const{error:t}=await o.from("marketplace_products").delete().eq("id",a.id).eq("user_id",r.id);if(t)throw t;f({title:s("marketplace.productDeleted")||"Product deleted successfully"}),j("/marketplace")}catch(t){f({variant:"destructive",title:t.message||"Error deleting product"})}finally{ge(!1)}}},We=i.useMemo(()=>{if(!a)return;const t=a.image_urls?.[0]||"https://circassianweb.com/og-image.jpg";return{"@context":"https://schema.org","@type":"Product",name:a.title,description:a.description||a.title,image:t,url:`https://circassianweb.com/marketplace/product/${a.id}`,...a.price!=null&&a.price>0?{offers:{"@type":"Offer",price:a.price,priceCurrency:a.currency||"USD",availability:"https://schema.org/InStock",url:`https://circassianweb.com/marketplace/product/${a.id}`}}:{},...a.avg_rating!=null?{aggregateRating:{"@type":"AggregateRating",ratingValue:a.avg_rating.toFixed(1),reviewCount:a.review_count||1}}:{}}},[a]);xa({title:a?`${a.title} | Circassian Marketplace`:"Loading⦠| Circassian Marketplace",description:a?.description?.substring(0,155)||"Browse Circassian marketplace products.",ogImage:a?.image_urls?.[0],ogType:"product",jsonLd:We}),i.useEffect(()=>{c&&R()},[c,r]);const R=async()=>{if(c){S(!0);try{const[t,d,l,u]=await Promise.all([o.from("marketplace_products").select("*").eq("id",c).maybeSingle(),o.from("marketplace_likes").select("id, user_id").eq("product_id",c),o.from("marketplace_ratings").select("*").eq("product_id",c).order("created_at",{ascending:!1}),r?o.from("marketplace_likes").select("id").eq("product_id",c).eq("user_id",r.id):Promise.resolve({data:[]})]);if(t.error)throw t.error;const g=t.data,k=l.data||[],sa=k.length>0?k.reduce((m,da)=>m+da.rating,0)/k.length:void 0,ra={...g,tags:g.tags||[],image_urls:g.image_urls||[],avg_rating:sa,review_count:k.length,like_count:(d.data||[]).length};O(ra),ha(g.id,g.title),Ke({...g,tags:g.tags||[],image_urls:g.image_urls||[],category:g.category,id:g.id}),V((d.data||[]).length),C((u.data||[]).length>0);const{data:la}=await o.from("profiles_public").select("full_name, avatar_url, tribe, bio, country, verification_status").eq("user_id",g.user_id).maybeSingle();D(la);const Re=k.map(m=>m.user_id),z=k.map(m=>m.id),[ia,na,oa]=await Promise.all([Re.length>0?o.from("profiles_public").select("user_id, full_name, avatar_url").in("user_id",Re):Promise.resolve({data:[]}),z.length>0?o.from("marketplace_review_likes").select("review_id").in("review_id",z):Promise.resolve({data:[]}),r&&z.length>0?o.from("marketplace_review_likes").select("review_id").in("review_id",z).eq("user_id",r.id):Promise.resolve({data:[]})]),Pe={};(ia.data||[]).forEach(m=>{Pe[m.user_id]=m});const K={};(na.data||[]).forEach(m=>{K[m.review_id]=(K[m.review_id]||0)+1});const ca=new Set((oa.data||[]).map(m=>m.review_id));b(k.map(m=>({...m,profile:Pe[m.user_id],like_count:K[m.id]||0,user_liked:ca.has(m.id)}))),o.from("marketplace_products").update({view_count:(g.view_count||0)+1}).eq("id",c).then()}catch(t){console.error(t),j("/marketplace")}finally{S(!1)}}},Ze=async()=>{if(!r){_(!0);return}try{N?(await o.from("marketplace_likes").delete().eq("product_id",c).eq("user_id",r.id),C(!1),V(t=>t-1)):(await o.from("marketplace_likes").insert({product_id:c,user_id:r.id}),C(!0),V(t=>t+1))}catch{}},Ge=()=>{ue(!0)},Ke=async t=>{const{data:d}=await o.from("marketplace_products").select("*").eq("category",t.category).eq("status","approved").neq("id",t.id).limit(3);d&&Fe(d)},Ye=async()=>{if(!r){_(!0);return}if(c){ne(!0);try{const{error:t}=await o.from("marketplace_ratings").upsert({product_id:c,user_id:r.id,rating:te,comment:re||null},{onConflict:"product_id,user_id"});if(t)throw t;le(""),se(5),R(),f({title:s("marketplace.reviewSubmitted")||"Review submitted!"})}catch(t){f({variant:"destructive",title:t.message||"Error"})}finally{ne(!1)}}},be=async t=>{if(!r){_(!0);return}const d=w.find(l=>l.id===t);d&&(d.user_liked?(await o.from("marketplace_review_likes").delete().eq("review_id",t).eq("user_id",r.id),b(l=>l.map(u=>u.id===t?{...u,user_liked:!1,like_count:Math.max(0,(u.like_count||0)-1)}:u))):(await o.from("marketplace_review_likes").insert({review_id:t,user_id:r.id}),b(l=>l.map(u=>u.id===t?{...u,user_liked:!0,like_count:(u.like_count||0)+1}:u))))},Se=async t=>{if(r&&window.confirm(s("marketplace.confirmDeleteReview")||"Delete this review?"))try{await o.from("marketplace_ratings").delete().eq("id",t).eq("user_id",r.id),R(),f({title:s("marketplace.reviewDeleted")||"Review deleted"})}catch{f({variant:"destructive",title:"Error"})}},He=async()=>
1{if(!(!r||!I))try{await o.from("marketplace_ratings").update({comment:fe||null,rating:ve}).eq("id",I).eq("user_id",r.id),W(null),R(),f({title:s("marketplace.reviewUpdated")||"Review updated"})}catch{f({variant:"destructive",title:"Error"})}},Je=async t=>{if(!r){_(!0);return}if(!(!c||!E.trim()))try{await o.from("marketplace_ratings").insert({product_id:c,user_id:r.id,rating:_e,comment:E.trim(),parent_id:t}),Z(null),G(""),ke(5),R(),f({title:s("marketplace.replySubmitted")||"Reply submitted"})}catch{f({variant:"destructive",title:"Error"})}};if($)return e.jsx(Ae,{children:e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(T,{className:"w-8 h-8 animate-spin text-primary"})})});if(!a)return null;const Ce=ze[a.category]||"ð¦",Xe=a.shipping_scope==="international"?s("marketplace.shippingInternational")||"ð International":a.shipping_scope==="both"?s("marketplace.shippingBoth")||"ð Local & International":s("marketplace.shippingLocal")||"ð Local Only",Qe={Red:{ar:"Ø£ØÙ
ر",tr:"Kırmızı",ru:"ÐÑаÑнÑй",he:"××××",ady:"ÐлÑÑжÑ"},Blue:{ar:"أزرÙ",tr:"Mavi",ru:"Синий",he:"××××",ady:"ШÑ
ÑÑанÑIÑ"},Green:{ar:"أخضر",tr:"YeÅil",ru:"ÐелÑнÑй",he:"×ר××§",ady:"ЩÑ
ÑÑÑкIаÑÑ"},Black:{ar:"Ø£Ø³ÙØ¯",tr:"Siyah",ru:"ЧÑÑнÑй",he:"ש××ר",ady:"ФIÑÑIÑ"},White:{ar:"Ø£Ø¨ÙØ¶",tr:"Beyaz",ru:"ÐелÑй",he:"×××",ady:"Ð¥ÑжÑ"},Gold:{ar:"Ø°ÙØ¨Ù",tr:"Altın",ru:"ÐолоÑой",he:"×××",ady:"ÐÑÑÑ"},Silver:{ar:"ÙØ¶Ù",tr:"GümüÅ",ru:"СеÑебÑÑнÑй",he:"×סף",ady:"ÐÑжÑÑн"},Brown:{ar:"بÙÙ",tr:"Kahverengi",ru:"ÐоÑиÑневÑй",he:"×××",ady:"Ð¥ÑÑбзаÑIÑ"},Beige:{ar:"Ø¨ÙØ¬",tr:"Bej",ru:"ÐежевÑй",he:"××'",ady:"ÐежевÑй"},"Multi-color":{ar:"Ù
تعدد Ø§ÙØ£ÙÙØ§Ù",tr:"Ãok renkli",ru:"РазноÑвеÑнÑй",he:"×¨× ×¦××¢××",ady:"ÐÑмÑÑÑ
ÑкIаÑÑ"},"All Colors":{ar:"جÙ
ÙØ¹ Ø§ÙØ£ÙÙØ§Ù",tr:"Tüm renkler",ru:"ÐÑе ÑвеÑа",he:"×× ×צ××¢××",ady:"ÐIаÑÑ Ð¿ÑоÑи"},Other:{ar:"أخرÙ",tr:"DiÄer",ru:"ÐÑÑгой",he:"××ר",ady:"ÐÑмÑкI"}},ea={"All Sizes":{ar:"جÙ
ÙØ¹ اÙÙ
ÙØ§Ø³Ø§Øª",tr:"Tüm bedenler",ru:"ÐÑе ÑазмеÑÑ",he:"×× ×××××ת",ady:"ÐÐ½Ð°Ð³Ñ Ð¿ÑоÑи"},"One Size":{ar:"Ù
ÙØ§Ø³ ÙØ§ØØ¯",tr:"Tek beden",ru:"Ðдин ÑазмеÑ",he:"×××× ××ת",ady:"ÐÑ Ð¸Ð½Ð°Ð³Ñ"},Custom:{ar:"Ù
خصص",tr:"Ãzel",ru:"Ðа заказ",he:"××ת××",ady:"Ð¥ÑÑ
аÑÑ"},Other:{ar:"أخرÙ",tr:"DiÄer",ru:"ÐÑÑгой",he:"××ר",ady:"ÐÑмÑкI"}},aa=t=>v==="en"?t:Qe[t]?.[v]??t,ta=t=>v==="en"?t:ea[t]?.[v]??t;return e.jsxs(Ae,{children:[e.jsxs("div",{className:"max-w-5xl mx-auto py-4 sm:py-8 px-2 sm:px-4 md:px-6 overflow-hidden",children:[e.jsxs(n,{variant:"ghost",className:"mb-4 gap-2",onClick:()=>j("/marketplace"),children:[e.jsx(Ba,{className:"w-4 h-4"})," ",s("marketplace.backToMarketplace")||"Back to Marketplace"]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4 sm:gap-8",children:[e.jsxs("div",{className:"space-y-3",children:[a.image_urls.length>0?e.jsx(Ja,{src:a.image_urls[ae],alt:a.title,className:"aspect-square"}):e.jsx("div",{className:"aspect-square rounded-xl overflow-hidden bg-muted border border-border flex items-center justify-center text-6xl",children:Ce}),a.image_urls.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto",children:a.image_urls.map((t,d)=>e.jsx("button",{onClick:()=>Oe(d),className:h("w-16 h-16 rounded-lg overflow-hidden border-2 flex-shrink-0 transition-all",d===ae?"border-primary":"border-transparent opacity-60 hover:opacity-100"),children:e.jsx("img",{src:t,alt:`Product image ${d+1}`,className:"w-full h-full object-cover",loading:"lazy"})},d))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(x,{variant:"outline",className:"gap-1",children:[Ce," ",s(Te(a.category))||a.category.replace(/_/g," ")]}),e.jsxs(x,{variant:a.seller_type==="company"?"default":"secondary",className:"gap-1",children:[a.seller_type==="company"?e.jsx(ga,{className:"w-3 h-3"}):e.jsx(Me,{className:"w-3 h-3"}),a.seller_type==="company"?s("marketplace.company")||"Company":s("marketplace.person")||"Individual"]}),e.jsx(x,{variant:"outline",className:"text-xs",children:Xe}),a.selling_type&&a.selling_type!=="retail"&&e.jsxs(x,{variant:"outline",className:"gap-1 text-xs",children:[e.jsx(Le,{className:"w-3 h-3"}),a.selling_type==="wholesale"?s("marketplace.wholesale")||"Wholesale":
1a.selling_type==="both"?s("marketplace.wholesaleAndRetail")||"Wholesale & Retail":s("marketplace.retail")||"Retail"]}),!a.selling_type||a.selling_type==="retail"?e.jsxs(x,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(Le,{className:"w-3 h-3"}),s("marketplace.retail")||"Retail"]}):null]}),e.jsx("h1",{className:"text-xl sm:text-2xl font-serif font-bold text-foreground break-words",children:a.title}),e.jsxs("div",{className:"text-2xl sm:text-3xl font-bold text-primary",children:[a.currency," ",a.price.toLocaleString()]}),a.min_order_amount>0&&e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Va,{className:"w-4 h-4"}),s("marketplace.minOrder"),": ",a.min_order_amount.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(t=>e.jsx(y,{className:h("w-5 h-5",(a.avg_rating||0)>=t?"fill-yellow-500 text-yellow-500":"text-muted-foreground/30")},t))}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.avg_rating?.toFixed(1)||"0"," (",a.review_count||0," ",s("marketplace.reviews")||"reviews",")"]})]}),(a.color||a.size)&&e.jsxs("div",{className:"flex flex-wrap gap-3",children:[a.color&&e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-3 py-2 border border-border",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:s("marketplace.color")||"Color"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:a.color.split(", ").map(t=>e.jsx(x,{variant:"outline",className:"font-semibold",children:aa(t)},t))})]}),a.size&&e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-3 py-2 border border-border",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:s("marketplace.size")||"Size"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:a.size.split(", ").map(t=>e.jsx(x,{variant:"outline",className:"font-semibold",children:ta(t)},t))})]})]}),(a.location||a.country)&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(fa,{className:"w-4 h-4"}),[a.location,a.country?De(a.country,v):null].filter(Boolean).join(", ")]}),a.expires_at&&e.jsxs("div",{className:h("flex items-center gap-1 text-sm",new Date(a.expires_at)<new Date?"text-destructive":"text-muted-foreground"),children:[e.jsx(ja,{className:"w-4 h-4"}),new Date(a.expires_at)<new Date?s("marketplace.expired")||"Expired":`${s("marketplace.expires")||"Expires"}: ${new Date(a.expires_at).toLocaleDateString()}`]}),e.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none overflow-hidden",children:e.jsx("p",{className:"whitespace-pre-wrap break-words overflow-wrap-anywhere",children:a.description})}),a.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.tags.map(t=>e.jsx(x,{variant:"secondary",className:"text-xs",children:t},t))}),a.payment_methods&&a.payment_methods.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1 mb-1",children:[e.jsx(Fa,{className:"w-4 h-4"})," ",s("marketplace.paymentMethods")||"Payment Methods"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:a.payment_methods.map(t=>e.jsx(x,{variant:"outline",className:"text-xs",children:t},t))})]}),e.jsxs(n,{variant:"outline",size:"sm",className:"gap-2 w-fit",onClick:()=>j("/marketplace/return-policy"),children:[e.jsx(va,{className:"w-4 h-4"})," ",s("marketplace.returnPolicy")||"Return Policy"]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsxs(n,{variant:"outline",className:"gap-2 flex-1",onClick:Ze,children:[e.jsx(wa,{className:h("w-4 h-4",N&&"fill-red-500 text-red-500")})," ",B," ",s("marketplace.likes")||"Likes"]}),e.jsxs(n,{variant:"outline",className:"gap-2 flex-1",onClick:Ge,children:[e.jsx(Na,{className:"w-4 h-4"})," ",s("marketplace.share")||"Share"]})]}),ye&&e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(n,{variant:"outline",className:"gap-2 flex-1",onClick:()=>j(`/marketplace/edit/${a.id}`),children:[e.jsx(Ie,{className:"w-4 h-4"})," ",s("marketplace.editProduct")||"Edit"]}),e.jsxs(n,{variant:"destructive",className:"gap-2 flex-1",onClick:Ue,disabled:he,children:[he?e.jsx(T,{className:"w-4 h-4 animate-spin"}):e.jsx(Y,{className:"w-4 h-4"}),s("marketplace.deleteProduct")||"Delete"]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(_a,{className:"w-3 h-3"})," ",a.view_count||0," ",s("marketplace.views")||"views"]}),e.jsx(P,{className:"bg-muted/30 border-primary/20",children:e.jsxs(M,{className:"p-3 sm:p-5 space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>j(`/marketplace/seller/${a.user_id}
1`),children:[e.jsxs(H,{className:"w-14 h-14 border-2 border-primary/20",children:[e.jsx(J,{src:p?.avatar_url||""}),e.jsx(X,{className:"text-lg",children:p?.full_name?.charAt(0)||"?"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-semibold text-sm hover:text-primary transition-colors",children:a.seller_name||p?.full_name||s("marketplace.anonymousSeller")||"Seller"}),p?.verification_status==="verified"&&e.jsxs(x,{variant:"default",className:"text-[10px] h-5 gap-0.5 bg-green-600 hover:bg-green-600 text-white",children:[e.jsx(Ua,{className:"w-3 h-3"})," ",s("marketplace.verifiedSeller")||"Verified"]}),e.jsx(x,{variant:a.seller_type==="company"?"default":"secondary",className:"text-[10px] h-5",children:a.seller_type==="company"?s("marketplace.company")||"Company":s("marketplace.person")||"Individual"})]}),p?.tribe&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["ðï¸ ",p.tribe]}),(a.country||p?.country)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["ð ",[a.location,De(a.country||p?.country||"",v)].filter(Boolean).join(", ")]}),(a.seller_description||p?.bio)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:a.seller_description||p?.bio})]})]}),(a.brand_name||a.has_shop!=="no")&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.brand_name&&e.jsxs(x,{variant:"outline",className:"text-xs gap-1",children:["ð·ï¸ ",a.brand_name]}),a.has_shop&&a.has_shop!=="no"&&e.jsxs(x,{variant:"outline",className:"text-xs",children:[a.has_shop==="physical"?"ðª":a.has_shop==="online"?"ð":"ð¦"," ",a.has_shop==="physical"?s("marketplace.physicalShop")||"Physical Shop":a.has_shop==="online"?s("marketplace.onlineShop")||"Online Shop":s("marketplace.dropshipping")||"Dropshipping"]})]}),r&&r.id!==a.user_id&&e.jsxs(n,{className:"w-full gap-2",onClick:()=>{window.dispatchEvent(new CustomEvent("lovable:private-chat:start",{detail:{userId:a.user_id,userName:a.seller_name||p?.full_name||"Seller",avatarUrl:p?.avatar_url||null}}))},children:[e.jsx(Q,{className:"w-4 h-4"}),s("marketplace.privateMessage")||"Private Message"]}),!r&&e.jsxs(n,{className:"w-full gap-2",onClick:()=>_(!0),children:[e.jsx(Q,{className:"w-4 h-4"}),s("marketplace.privateMessage")||"Private Message"]}),e.jsxs(n,{variant:"outline",className:"w-full gap-2",onClick:()=>j(`/marketplace/seller/${a.user_id}`),children:[e.jsx(Wa,{className:"w-4 h-4"}),s("seller.viewProfile")||"View Seller Profile"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[a.seller_phone&&e.jsxs("a",{href:`tel:${a.seller_phone}`,className:"flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Za,{className:"w-4 h-4"})," ",a.seller_phone]}),a.seller_whatsapp&&e.jsxs("a",{href:`https://wa.me/${a.seller_whatsapp.replace(/[^0-9]/g,"")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-muted-foreground hover:text-green-600 transition-colors",children:[e.jsx(Q,{className:"w-4 h-4"})," WhatsApp"]}),a.seller_email&&e.jsxs("a",{href:`mailto:${a.seller_email}`,className:"flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Ga,{className:"w-4 h-4"})," ",a.seller_email]}),a.seller_website&&e.jsxs("a",{href:a.seller_website,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(ka,{className:"w-4 h-4"})," ",s("marketplace.sellerWebsite")||"Website"]}),a.contact_info&&e.jsxs("p",{className:"flex items-center gap-2 text-muted-foreground col-span-full",children:[e.jsx(Ka,{className:"w-4 h-4"})," ",a.contact_info]})]}),(a.location||a.country)&&e.jsx(Ta,{address:[a.location,a.country].filter(Boolean).join(", ")}),r&&r.id!==a.user_id&&e.jsxs(n,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground gap-1.5 hover:text-destructive",onClick:()=>F(!0),children:[e.jsx(Ee,{className:"w-3.5 h-3.5"}),s("marketplace.reportSeller")||"Report Seller"]})]})})]})]}),a.youtube_url&&e.jsxs("div",{className:"mt-8",children:[e.jsxs("h3",{className:"text-lg font-semibold mb-3 flex items-center gap-2",children:[e.jsx(ya,{className:"w-5 h-5 text-red-500"}),s("marketplace.productVideo")||"Product Video"]}),e.jsx(Aa,{url:a.youtube_url,className:"max-w-2xl"})]}),e.jsxs("div",{className:"mt-10",children:[e.jsxs("h3",{className:"text-xl font-serif font-bold mb-6",children:[s("marketplace.reviewsTitle")||"Reviews"," (",w.length,")"]}),r?e.jsx(P,{className:"mb-6",children:e.jsxs(M,{className:"p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:s("marketplace.writeReview")||"Write a Review"}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(t=>e.jsx("button",{onClick:()=>se(t),children:e.jsx(y,{className:h("w-6 h-6 transition-colors",te>
1=t?"fill-yellow-500 text-yellow-500":"text-muted-foreground/30 hover:text-yellow-400")})},t))}),e.jsx(A,{placeholder:s("marketplace.reviewPlaceholder")||"Share your experience...",value:re,onChange:t=>le(t.target.value),rows:3}),e.jsxs(n,{onClick:Ye,disabled:ie,className:"gap-2",children:[ie?e.jsx(T,{className:"w-4 h-4 animate-spin"}):e.jsx(ee,{className:"w-4 h-4"}),s("marketplace.submitReview")||"Submit Review"]})]})}):e.jsx(P,{className:"mb-6",children:e.jsxs(M,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:s("marketplace.loginToReview")||"Log in to write a review"}),e.jsxs(n,{variant:"outline",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(Me,{className:"w-4 h-4"})," ",s("auth.login")||"Log In"]})]})}),w.filter(t=>!t.parent_id).length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:s("marketplace.noReviews")||"No reviews yet. Be the first!"}):e.jsx("div",{className:"space-y-4",children:w.filter(t=>!t.parent_id).map(t=>{const d=w.filter(l=>l.parent_id===t.id);return e.jsx(P,{children:e.jsx(M,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs(H,{
1className:"w-8 h-8",children:[e.jsx(J,{src:t.profile?.avatar_url||""}),e.jsx(X,{children:t.profile?.full_name?.charAt(0)||"?"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm",children:t.profile?.full_name||s("marketplace.anonymousSeller")||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t.created_at).toLocaleDateString()})]}),I===t.id?e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(l=>e.jsx("button",{onClick:()=>we(l),children:e.jsx(y,{className:h("w-4 h-4",ve>=l?"fill-yellow-500 text-yellow-500":"text-muted-foreground/30")})},l))}),e.jsx(A,{value:fe,onChange:l=>je(l.target.value),rows:2,className:"text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{size:"sm",onClick:He,className:"gap-1",children:[e.jsx(ee,{className:"w-3 h-3"})," ",s("common.save")||"Save"]}),e.jsx(n,{size:"sm",variant:"ghost",onClick:()=>W(null),children:s("common.cancel")||"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-0.5 my-1",children:[1,2,3,4,5].map(l=>e.jsx(y,{className:h("w-3.5 h-3.5",t.rating>=l?"fill-yellow-500 text-yellow-500":"text-muted-foreground/30")},l))}),t.comment&&e.jsx("p",{className:"text-sm text-foreground mt-1",children:t.comment})]}),I!==t.id&&e.jsxs("div",{className:"flex items-center gap-1 mt-2 -ml-1",children:[e.jsxs(n,{variant:"ghost",size:"sm",className:h("h-7 px-2 gap-1 text-xs",t.user_liked&&"text-primary"),onClick:()=>be(t.id),children:[e.jsx(qe,{className:"w-3.5 h-3.5"})," ",t.like_count||0]}),e.jsxs(n,{variant:"ghost",size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:()=>{Z(Ne===t.id?null:t.id),G("")},children:[e.jsx(Ya,{className:"w-3.5 h-3.5"})," ",s("common.reply")||"Reply"]}),r&&r.id===t.user_id&&e.jsxs(e.Fragment,{children:[e.jsxs(n,{variant:"ghost",size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:()=>{W(t.id),je(t.comment||""),we(t.rating)},children:[e.jsx(Ie,{className:"w-3.5 h-3.5"})," ",s("common.edit")||"Edit"]}),e.jsxs(n,{variant:"ghost",size:"sm",className:"h-7 px-2 gap-1 text-xs text-destructive hover:text-destructive",onClick:()=>Se(t.id),children:[e.jsx(Y,{className:"w-3.5 h-3.5"})," ",s("common.delete")||"Delete"]})]})]}),Ne===t.id&&e.jsxs("div",{className:"mt-3 space-y-2 ps-4 border-s-2 border-primary/20",children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(l=>e.jsx("button",{onClick:()=>ke(l),children:e.jsx(y,{className:h("w-4 h-4",_e>=l?"fill-yellow-500 text-yellow-500":"text-muted-foreground/30")})},l))}),e.jsx(A,{placeholder:s("marketplace.replyPlaceholder")||"Write a reply...",value:E,onChange:l=>G(l.target.value),rows:2,className:"text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{size:"sm",onClick:()=>Je(t.id),disabled:!E.trim(),className:"gap-1",children:[e.jsx(ee,{className:"w-3 h-3"})," ",s("common.reply")||"Reply"]}),e.jsx(n,{size:"sm",variant:"ghost",onClick:()=>Z(null),children:s("common.cancel")||"Cancel"})]})]}),d.length>0&&e.jsx("div",{className:"mt-3 space-y-3 ps-4 border-s-2 border-border",children:d.map(l=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs(H,{
1className:"w-6 h-6",children:[e.jsx(J,{src:l.profile?.avatar_url||""}),e.jsx(X,{className:"text-xs",children:l.profile?.full_name?.charAt(0)||"?"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-xs",children:l.profile?.full_name||"User"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:new Date(l.created_at).toLocaleDateString()})]}),e.jsx("div",{className:"flex gap-0.5 my-0.5",children:[1,2,3,4,5].map(u=>e.jsx(y,{className:h("w-3 h-3",l.rating>=u?"fill-yellow-500 text-yellow-500":"text-muted-foreground/30")},u))}),l.comment&&e.jsx("p",{className:"text-xs text-foreground",children:l.comment}),e.jsxs("div",{className:"flex items-center gap-1 mt-1 -ml-1",children:[e.jsxs(n,{variant:"ghost",size:"sm",className:h("h-6 px-1.5 gap-1 text-[10px]",l.user_liked&&"text-primary"),onClick:()=>be(l.id),children:[e.jsx(qe,{className:"w-3 h-3"})," ",l.like_count||0]}),r&&r.id===l.user_id&&e.jsx(n,{variant:"ghost",size:"sm",className:"h-6 px-1.5 gap-1 text-[10px] text-destructive hover:text-destructive",onClick:()=>Se(l.id),children:e.jsx(Y,{className:"w-3 h-3"})})]})]})]},l.id))})]})]})})},t.id)})})]}),xe.length>0&&e.jsxs("div",{className:"mt-10",children:[e.jsx("h3",{className:"text-xl font-serif font-bold mb-6",children:s("marketplace.relatedProducts")||"Related Products"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:xe.map(t=>{const d=ze[t.category]||"ð¦";return e.jsxs(P,{className:"cursor-pointer hover:border-primary/50 transition-colors overflow-hidden",onClick:()=>j(`/marketplace/${t.id}`),children:[e.jsx("div",{className:"aspect-[4/3] bg-muted overflow-hidden",children:t.image_urls?.[0]?e.jsx("img",{src:t.image_urls[0],alt:t.title,className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-4xl",children:d})}),e.jsxs(M,{className:"p-3 space-y-1",children:[e.jsx("p",{className:"font-medium text-sm line-clamp-1",children:t.title}),e.jsxs("p",{className:"text-primary font-bold text-sm",children:[t.currency," ",t.price.toLocaleString()]}),e.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:e.jsxs(x,{variant:"outline",className:"text-[10px] h-5",children:[d," ",s(Te(t.category))||t.category.replace(/_/g," ")]})})]})]},t.id)})})]})]}),e.jsx(za,{open:$e,onOpenChange:_}),e.jsx(Ea,{open:Ve,onOpenChange:ue,shareTitle:a?.title||s("marketplace.title")||"Marketplace",sharePath:`/marketplace/${c}`,contentLabel:"content"}),e.jsx(ba,{open:Be,onOpenChange:F,children:e.jsxs(Sa,{className:"sm:max-w-md",children:[e.jsx(Ca,{children:e.jsxs(Ra,{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"w-5 h-5 text-destructive"}),s("marketplace.reportSeller")||"Report Seller"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Pa,{value:U,onValueChange:oe,children:[e.jsx(Ma,{children:e.jsx(La,{placeholder:s("marketplace.selectReason")||"Select a reason..."})}),e.jsxs(Da,{children:[e.jsx(L,{value:"fake_product",children:s("marketplace.reportFakeProduct")||"Fake / Misleading product"}),e.jsx(L,{value:"scam",children:s("marketplace.reportScam")||"Scam / Fraud"}),e.jsx(L,{value:"inappropriate",children:s("marketplace.reportInappropriate")||"Inappropriate content"}),e.jsx(L,{value:"not_circassian",children:s("marketplace.reportNotCircassian")||"Not related to Circassian heritage"}),e.jsx(L,{value:"other",children:s("marketplace.reportOther")||"Other"})]})]}),e.jsx(A,{placeholder:s("marketplace.reportDetailsPlaceholder")||"Please provide more details...",value:ce,onChange:t=>de(t.target.value),rows:3}),e.jsx(n,{className:"w-full",variant:"destructive",disabled:!U||me,onClick:async()=>{if(!(!r||!a)){pe(!0);try{const{error:t}=await o.from("seller_reports").insert({reporter_id:r.id,seller_id:a.user_id,product_id:a.id,reason:U,details:ce||null});if(t)throw t;f({title:s("marketplace.reportSubmitted")||"Report submitted. Thank you!"}),F(!1),oe(""),de("")}catch(t){f({variant:"destructive",title:t.message||"Error"})}finally{pe(!1)}}},children:me?e.jsx(T,{className:"w-4 h-4 animate-spin"}):s("marketplace.submitReport")||"Submit Report"})]})]})})]})};export{Lt 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.