1import{r as d,j as e,L as F}from"./vendor-react-CnqPvWtE.js";import{a as de,u as ie,c as ce,b as me,x as H,e as ue,k as K,S as p,C as xe,E as ge,B as G,r as be,A as he,t as fe,s as i,m as R,o as W,F as pe,l as je,y as ye}from"./index-4OJGohLf.js";import{B as we}from"./Breadcrumb-BL5iM2hO.js";import{S as U,f as Q,V as Ne,C as _e,d as ve,e as ke}from"./vendor-icons-CD64bo--.js";import"./vendor-radix-DmpERO9M.js";import"./vendor-supabase-DwTFzKkW.js";import"./vendor-query-BHo95kTe.js";const Ee=({parentBrandId:c,parentBrand:t}={})=>{const[j,V]=d.useState([]),[Ce,Y]=d.useState([]),[M,O]=d.useState(!0);de(!M);const[C,J]=d.useState("all"),{language:r,t:y}=ie(),{serverTime:w}=ce(),z=me(),[o,S]=d.useState(null),[$,u]=d.useState(!1),[X,x]=d.useState(!1),[N,P]=d.useState(5),[m,E]=d.useState(0),[L,Z]=d.useState([]),[g,B]=d.useState(null),[D,ee]=d.useState(new Map),se=s=>H(s,w),re=s=>pe(s,7,w),_=s=>r==="ru"&&s.description_ru?s.description_ru:s.description,T=s=>r==="ru"&&s.discount_ru?s.discount_ru:s.discount;d.useEffect(()=>{(async()=>{O(!0);let a=i.from("brands").select("id, parent_brand_id, store_category_id").not("parent_brand_id","is",null).eq("is_active",!0);c&&(a=a.eq("parent_brand_id",c));const{data:n}=await a,l=n?.map(k=>k.id)||[],b=new Map;n?.forEach(k=>b.set(k.id,k.store_category_id)),ee(b);const[h,f,q]=await Promise.all([i.from("promo_codes").select("id,code,discount,discount_ru,description,description_ru,expiry_date,youtube_url,website_url,is_hot,is_active,promo_type,button_text,button_text_ru,badge_text,badge_emoji,badge_color,slug,created_at,category_id,brand:brands(id,name,logo_url,slug,website_url),category:categories(name,name_ru)").eq("is_active",!0).in("brand_id",l.length>0?l:["00000000-0000-0000-0000-000000000000"]).order("display_order",{ascending:!0}),i.from("categories").select("id, name, name_ru, slug").order("display_order",{ascending:!0}),i.from("store_categories").select("id, name, name_ru, slug, icon").order("display_order",{ascending:!0})]);h.data&&V(h.data),f.data&&Y(f.data),q.data&&Z(q.data),O(!1)})()},[c]),d.useEffect(()=>{if(!c)return;(async()=>{const{data:a,error:n}=await i.rpc("brand_rating_summary",{p_brand_id:c});if(n){console.error("brand_rating_summary:",n);return}const l=a?.[0];l&&Number(l.rating_count)>0&&(P(Number(l.avg_rating)),E(Number(l.rating_count)))})()},[c]);const v=d.useMemo(()=>j.filter(s=>{const a=H(s.expiry_date,w);if(g&&s.brand&&D.get(s.brand.id)!==g)return!1;switch(C){case"chegirma":return!a&&s.promo_type==="link";case"kupon":return!a&&s.promo_type==="code";case"aksiya":return!a&&s.is_hot;case"expired":return a;default:return!a}}),[j,C,g,D,w]),I=d.useMemo(()=>{const s=new Map;return j.forEach(a=>{a.brand&&!s.has(a.brand.id)&&s.set(a.brand.id,{name:a.brand.name,logo_url:a.brand.logo_url,slug:a.brand.slug})}),Array.from(s.values()).slice(0,18)},[j]),te=async(s,a,n)=>{const l=n?n.target.getBoundingClientRect():null;try{await je(s)}catch{R.error(y("copyError"));return}R.success(r==="ru"?"Ðод ÑкопиÑован!":"Kod nusxalandi!"),i.rpc("increment_copy_count",{promo_id:a}).then(()=>{},()=>{}),u(!0),setTimeout(()=>u(!1),2e3),l&&ye({particleCount:80,spread:60,origin:{x:(l.left+l.width/2)/window.innerWidth,y:(l.top+l.height/2)/window.innerHeight}}),setTimeout(()=>x(!0),1500)},A=(s,a)=>{W(a),i.rpc("increment_copy_count",{promo_id:s}).then(()=>{},()=>{})},ae=[{key:"all",label:"Hammasi",labelRu:"ÐÑе",icon:"ð·ï¸"},{key:"chegirma",label:"Chegirmalar",labelRu:"Скидки",icon:"ð·"},{key:"kupon",label:"Kuponlar",labelRu:"ÐÑпонÑ",icon:"âï¸"},{key:"aksiya",label:"Aksiyalar",labelRu:"ÐкÑии",icon:"ð¥"},{key:"expired",label:"Muddati tugagan",labelRu:"ÐÑÑÑк ÑÑок",icon:"â°"}],ne=s=>{switch(s){case"green":return"bg-gradient-to-r from-green-500 to-green-600";case"blue":return"bg-gradient-to-r from-blue-500 to-blue-600";case"purple":return"bg-gradient-to-r from-purple-500 to-purple-600";case"red":return"bg-gradient-to-r from-red-500 to-red-600";case"gray":return"bg-gradient-to-r from-gray-500 to-gray-600";default:return"gradient-hero"}},oe=t?r==="ru"?`${t.name} Ð¼Ð°Ð³Ð°Ð·Ð¸Ð½Ñ - пÑÐ¾Ð¼Ð¾ÐºÐ¾Ð´Ñ | Promokod.uz`:`${t.name} do'konlari - promokodlar | Promokod.uz`:r==="ru"?"ÐаÑкеÑÐ¿Ð»ÐµÐ¹Ñ - ÐÑÑÑие пÑÐ¾Ð¼Ð¾ÐºÐ¾Ð´Ñ | Promokod.uz":"Marketpleys - Eng yaxshi promokodlar | Promokod.uz",le=t?r==="ru"?`ÐÑе пÑомокодÑ, Ñкидки и акÑии магазинов маÑкеÑплейÑа ${t.name} в одном меÑÑе.`:`${t.name} marketplace do'konlarining barcha promokodlari, chegirmalari va aksiyalari b
1ir joyda.`:r==="ru"?"ÐÑе пÑомокодÑ, Ñкидки и акÑии бÑендов маÑкеÑплейÑа в одном меÑÑе. ÐокÑпайÑе по лÑÑÑим Ñенам.":"Marketpleys brendlarining barcha promokodlari, chegirmalari va aksiyalari bir joyda. Eng yaxshi narxlarda xarid qiling.";return e.jsxs(e.Fragment,{children:[e.jsx(ue,{pageTitle:t?.meta_title||oe,pageDescription:t?.meta_description||le}),e.jsx("div",{className:"bg-background",children:e.jsxs("main",{className:"container py-8",children:[e.jsx(we,{items:t?[{label:r==="ru"?"ÐÑендÑ":"Brendlar",href:"/dokonlar"},{label:t.name}]:[{label:r==="ru"?"ÐÑендÑ":"Brendlar"}]}),e.jsxs("div",{className:"flex gap-8 mt-6",children:[e.jsxs("aside",{className:"hidden lg:block w-72 flex-shrink-0 space-y-6",children:[t&&e.jsx("div",{className:"rounded-sm border border-border bg-card p-6",children:e.jsxs("div",{className:"flex flex-col items-center text-center mb-4",children:[e.jsx("div",{className:"w-24 h-24 rounded-sm bg-secondary/50 overflow-hidden mb-3",children:t.logo_url?e.jsx("img",{src:t.logo_url,alt:t.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-3xl font-bold text-muted-foreground",children:t.name.charAt(0)})}),e.jsx("div",{className:"flex items-center gap-1 text-sm text-muted-foreground mb-2",children:e.jsx("span",{children:r==="ru"?`РейÑинг ${N.toFixed(2)} (${m||v.length} ${m?"оÑенок":"пÑедл."})`:`Baho ${N.toFixed(2)} (${m||v.length} ${m?"ta baho":"ta taklif"})`})}),e.jsx("div",{className:"flex gap-0.5 mb-3",children:[1,2,3,4,5].map(s=>e.jsx(U,{className:`w-4 h-4 ${s<=Math.round(N)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},s))}),K(t.website_url)&&e.jsxs("a",{href:K(t.website_url)??void 0,target:"_blank",rel:"noopener noreferrer",className:"w-full py-2.5 px-4 rounded-sm bg-green-500 hover:bg-green-600 text-white font-semibold text-sm transition-colors flex items-center justify-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),r==="ru"?"Ð ÐÐÐÐÐÐÐ":"DO'KONGA"]})]})}),L.length>0&&e.jsxs("div",{className:"rounded-sm border border-border bg-card p-5",children:[e.jsx("h3",{className:"text-lg font-bold text-foreground mb-1",children:y("categories")}),e.jsx("div",{className:"w-12 h-0.5 bg-primary mb-4"}),e.jsx("ul",{className:"space-y-2.5",children:L.map(s=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>B(g===s.id?null:s.id),className:`flex items-center gap-2 text-sm transition-colors w-full text-left ${g===s.id?"text-foreground font-semibold":"text-muted-foreground hover:text-foreground"}`,children:[s.icon?e.jsx("span",{className:"text-base",children:s.icon}):e.jsx("span",{className:"w-3 h-3 rounded-full border border-muted-foreground/40"}),r==="ru"&&s.name_ru?s.name_ru:s.name]})},s.id))})]}),I.length>0&&e.jsxs("div",{className:"rounded-sm border border-border bg-card p-5",children:[e.jsx("h3",{className:"text-lg font-bold text-foreground mb-1",children:r==="ru"?"ÐÑÑгие магазинÑ":"Boshqa do'konlar"}),e.jsx("div",{className:"w-12 h-0.5 bg-primary mb-4"}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:I.map((s,a)=>e.jsx(F,{to:s.slug?z(`/promokod/${s.slug}`):"#",className:"group",children:e.jsx("div",{className:"w-full aspect-square rounded-sm border border-border bg-background overflow-hidden hover:shadow-md transition-all",children:s.logo_url?e.jsx("img",{src:s.logo_url,alt:s.name,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-xl font-bold text-muted-foreground",children:s.name.charAt(0)})})},a))})]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold text-foreground flex items-center gap-3",children:[t?.logo_url&&e.jsx("img",{src:t.logo_url,alt:t.name,className:"w-8 h-8 md:w-10 md:h-10 rounded-sm object-cover"}),t?r==="ru"?`${t.name} â магазинÑ`:`${t.name} â do'konlar`:r==="ru"?"ÐаÑкеÑплейÑ":"Marketpleys"]}),e.jsx("p",{className:"text-muted-foreground mt-2 leading-relaxed",children:t?r==="ru"?`ÐÑе пÑÐ¾Ð¼Ð¾ÐºÐ¾Ð´Ñ Ð¸ Ñкидки магазинов маÑкеÑплейÑа ${t.name}.`:`${t.name}
1 marketplace do'konlarining barcha promokodlari va chegirmalari.`:r==="ru"?"ÐÑÐ¾Ð¼Ð¾ÐºÐ¾Ð´Ñ Ð¼Ð°ÑкеÑплейÑ-бÑендов Ñ ÑиÑоким аÑÑоÑÑименÑом и доÑÑавкой по вÑей ÑÑÑане.":"Keng assortimentga ega va buyurtmani butun mamlakat bo'ylab yetkazib beriladigan marketpleys brendlarining promokodlari."})]}),e.jsx("div",{className:"flex gap-2 mb-8 overflow-x-auto pb-2 scrollbar-hide flex-nowrap md:flex-wrap",children:ae.map(s=>e.jsxs("button",{onClick:()=>J(s.key),className:`px-4 py-2 rounded-full text-sm font-medium transition-colors flex items-center gap-1.5 whitespace-nowrap shrink-0 ${C===s.key?"bg-foreground text-background":"bg-muted text-muted-foreground hover:bg-muted/80"}`,children:[e.jsx("span",{children:s.icon}),r==="ru"?s.labelRu:s.label]},s.key))}),M?e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx("div",{className:"rounded-sm p-6 border border-border",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(p,{className:"w-16 h-16 rounded-sm shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(p,{className:"h-5 w-48 mb-2"}),e.jsx(p,{className:"h-4 w-72 mb-2"}),e.jsx(p,{className:"h-4 w-40"})]}),e.jsx(p,{className:"h-10 w-36 rounded-sm"})]})},s))}):v.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"text-5xl mb-4",children:"ð¦"}),e.jsx("h3",{className:"text-xl font-semibold text-foreground mb-2",children:y("noPromosFound")}),e.jsx("p",{className:"text-muted-foreground",children:y("noPromosInSection")})]}):e.jsx("div",{className:"space-y-4",children:v.map(s=>{const a=s.badge_text||s.badge_emoji,n=se(s.expiry_date),l=s.brand?.name||"",b=s.brand?.logo_url,h=s.brand?.slug,f=s.brand?.website_url;return e.jsxs("div",{className:`rounded-sm p-5 md:p-6 relative border border-border bg-card transition-shadow hover:shadow-md overflow-hidden ${n?"grayscale":""}`,children:[n&&e.jsx("div",{className:"absolute inset-0 z-[1] pointer-events-none opacity-20",style:{backgroundImage:"repeating-linear-gradient(135deg, transparent, transparent 10px, hsl(var(--muted-foreground)) 10px, hsl(var(--muted-foreground)) 11px)"}}),n&&e.jsxs("div",{className:"flex items-center gap-3 mb-3 relative z-[2]",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["â³ ",r==="ru"?"СÑок иÑÑÑк":"Muddati tugagan"]}),re(s.created_at)&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"â
Yangi taklif â¨"})]}),a&&!n&&e.jsxs("div",{className:`absolute -top-2 left-4 ${ne(s.badge_color)} text-white text-xs font-bold px-3 py-1 rounded-full shadow-md z-10`,children:[s.badge_emoji," ",s.badge_text]}),e.jsxs("div",{className:`relative ${n?"z-[2]":""}`,children:[e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx("div",{className:"flex flex-col items-center gap-1 shrink-0",children:e.jsx(F,{to:h?z(`/promokod/${h}`):"#",className:"w-16 h-16 md:w-20 md:h-20 rounded-sm bg-secondary/50 overflow-hidden border border-border",children:b?e.jsx("img",{src:b,alt:l,className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-xl font-bold text-muted-foreground",children:l.charAt(0)})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h2",{className:"text-sm md:text-base font-semibold text-foreground mb-1 leading-snug",children:[n&&e.jsx("span",{className:"inline-block bg-red-500 text-white text-[10px] font-bold uppercase px-2 py-0.5 rounded-sm mr-2 align-middle",children:r==="ru"?"ÐÑÑÑк ÑÑок":"Muddati tugagan"}),t&&s.brand?.name?r==="ru"?`ÐÑомокод Ð´Ð»Ñ Ð¼Ð°Ð³Ð°Ð·Ð¸Ð½Ð° "${s.brand.name}" на ${t.name}`:`${t.name} - "${s.brand.name}" do'koni uchun promokod`:s.brand?.name||T(s)]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1 hidden lg:block",children:_(s)}),s.expiry_date&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mt-1",children:[e.jsx(Ne,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:s.expiry_date})]})]}),e.jsx("div",{className:"hidden lg:flex shrink-0",children:n?e.jsx("button",{disabled:!0,className:"px-6 py-2.5 rounded-sm bg-muted text-muted-foreground font-bold text-sm cursor-not-allowed",children:r==="ru"?"ÐУÐÐТЬ":"SOTIB OLISH"}):s.promo_type==="code"?e.jsx("button",{onClick:()=>{u(!1),x(!1),S(s)},className:"px-6 py-2.5 rounded-sm bg-green-500 hover:bg-green-600 text-white font-bold text-sm transition-colors",children:r==="ru"?"ÐÐ ÐÐÐÐÐÐ":"PROMOKOD"}):e.jsx("button",{onClick:()=>A(s.id,s.website_url||f||""),className:"px-6 py-2.5 rounded-sm bg-green-500 hover:bg-green-600 text-white font-bold text-sm transition-colors",children:r==="ru"?"ÐУÐÐТЬ":"SOTIB OLISH"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3 line-clamp-2 lg:hidden",children:_(s)}),e.jsx("div",{className:"lg:hidden mt-3",children:n?e.jsx("button",{disabled:!0,className:"w-full py-2 rounded-lg bg-muted text-muted-foreground font-bold text-sm cursor-not-allowed",children:r==="ru"?"ÐУÐÐТЬ":"SOTIB OLISH"}):s.promo_type==="code"?e.jsx("button",{onClick:()=>{u(!1),x(!1),S(s)},className:"w-full py-2 rounded-lg bg-green-500 hover:bg-green-600 text-white font-bold text-sm transition-colors",children:r==="ru"?"ÐÐ ÐÐÐÐÐÐ":"PROMOKOD"}):e.jsx("button",{onClick:()=>A(s.id,s.website_url||f||""),className:"w-full py-2 rounded-lg bg-green-500 hover:bg-green-600 text-white font-bold text-sm transition-colors",children:r==="ru"?"ÐУÐÐТЬ":"SOTIB OLISH"})})]})]},s.id)})})]})]})]})}),e.jsx(xe,{open:!!o,onOpenChange:s=>{s||(S(null),x(!1),u(!1))},children:e.jsx(ge,{className:"max-w-[calc(100vw-2rem)] sm:max-w-md p-0 overflow-hidden max-h-[90vh] overflow-y-auto",children:o&&e.jsxs("div",{className:"bg-background",children:[e.jsxs("div",{className:"bg-secondary/30 pt-6 sm:pt-8 pb-4 sm:pb-6 px-4 sm:px-6 text-center border-b border-dashed border-border",children:[e.jsx("div",{className:"flex justify-center mb-3 sm:mb-4",children:e.jsx("img",{src:o.brand?.logo_url||`https://ui-avatars.c
1om/api/?name=${encodeURIComponent(o.brand?.name||"")}&background=random&size=80`,alt:o.brand?.name||"",className:"w-16 h-16 sm:w-20 sm:h-20 rounded-2xl object-cover border-2 border-border shadow-md"})}),e.jsx("h3",{className:"text-lg sm:text-xl font-bold text-foreground mb-1 sm:mb-2 px-2 leading-tight",children:T(o)}),o.expiry_date&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsx(_e,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 flex-shrink-0"}),e.jsxs("span",{children:[r==="ru"?"ÐейÑÑвÑÐµÑ Ð´Ð¾":"Amal qilish muddati"," ",o.expiry_date]})]})]}),e.jsxs("div",{className:"p-4 sm:p-6 space-y-4 sm:space-y-5",children:[e.jsx("p",{className:"text-center text-sm sm:text-base text-muted-foreground leading-relaxed",children:r==="ru"?e.jsxs(e.Fragment,{children:["ÐеÑейдиÑе на ÑÐ°Ð¹Ñ Â«",e.jsx("span",{className:"text-primary font-semibold",children:o.brand?.name}),"» и иÑполÑзÑйÑе пÑомокод"]}):e.jsxs(e.Fragment,{children:["«",e.jsx("span",{className:"text-primary font-semibold",children:o.brand?.name}),"» saytiga o'ting va promokodni kiriting"]})}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex-1 bg-secondary rounded-xl px-3 sm:px-4 py-3 sm:py-4 font-mono text-base sm:text-xl font-bold text-foreground tracking-wider border-2 border-dashed border-primary/30 text-center uppercase break-all",children:o.code}),e.jsx(G,{variant:$?"default":"outline",size:"icon",className:`h-12 w-12 sm:h-14 sm:w-14 shrink-0 rounded-xl transition-all ${$?"bg-primary hover:bg-primary/90 text-primary-foreground":"border-2 border-dashed border-primary/30 hover:bg-primary hover:text-primary-foreground"}`,onClick:s=>te(o.code,o.id,s),children:$?e.jsx(ve,{className:"w-5 h-5 sm:w-6 sm:h-6"}):e.jsx(ke,{className:"w-5 h-5 sm:w-6 sm:h-6"})})]}),_(o)&&e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground text-center leading-relaxed",children:_(o)}),X&&e.jsxs("div",{className:"text-center space-y-2 animate-in fade-in slide-in-from-bottom-2 duration-300",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:r==="ru"?"ÐÑомокод ÑÑабоÑал?":"Promokod ishladimi?"}),e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(s=>e.jsx("button",{onClick:async()=>{if(o){const a=be("visitor_id")||he();fe("visitor_id",a),await i.rpc("rate_promo_stars",{_promo:o.id,_brand:o.brand?.id||c||null,_visitor:a,_stars:s,_comment:null});const n=m+1,l=(N*m+s)/n;P(Math.round(l*100)/100),E(n)}R.success(r==="ru"?"СпаÑибо за оÑенкÑ!":"Bahoyingiz uchun rahmat!"),x(!1)},className:"p-1 hover:scale-125 transition-transform",children:e.jsx(U,{className:"w-7 h-7 text-yellow-400 hover:fill-yellow-400 transition-colors"})},s))})]}),e.jsxs(G,{className:"w-full h-11 sm:h-12 text-sm sm:text-base font-bold gap-2 bg-primary hover:bg-primary/90",onClick:()=>{W(o.website_url||o.brand?.website_url||t?.website_url)},children:[e.jsx(Q,{className:"w-4 h-4 sm:w-5 sm:h-5"}),r==="ru"?"ÐеÑейÑи на ÑайÑ":"Saytga o'tish"]})]})]})})})]})};export{Ee 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.