1import{r as o,ai as B,j as e,ax as te,a as xe,ac as pe,x as se,as as he,U as fe,L as A,ah as be,b5 as ge,a6 as we,h as ve,b as i,f as je,e as Ne,l as Z}from"./index-DEuermiE.js";import{T as ye}from"./TemplateCard-C-NzCIV9.js";import{U as _e,a as Se,B as Ce,S as Fe,R as ke,A as Te,F as ee}from"./AboutTab-DBf81bGO.js";import{C as Re}from"./CreatorBadges-B5g2KfQ4.js";import{R as Me}from"./ReportDialog-Bqyz6pMB.js";import{S as re}from"./store-DFDp0bVG.js";import{F as Be}from"./flag-DSRkao1J.js";import{P as Ae}from"./package-CiNt8PCe.js";import{A as ae}from"./arrow-up-BBHuwXkL.js";import{P as De}from"./pencil-CH7RtWu7.js";import{e as Ie}from"./cosmetics-D4DXHMAu.js";import{A as $e}from"./arrow-left-DuQ3ZYbW.js";import"./ScoreBadge-D9VRiDSk.js";import"./VerifiedBadge-Co_dDS_I.js";import"./trash-2-DQzmFJSW.js";import"./label-BuiJfjRs.js";import"./collections-jD6br6Ur.js";import"./CollectionCard-DYjZA29Y.js";import"./globe-CeF-OyuZ.js";import"./lock-W8yBDIGk.js";import"./PremiumBadge-Yj8ODSRT.js";function Le({target:a,cosmetics:l={},level:r,me:d,isSelf:N,myFollow:h,onToggleFollow:c,followersCount:F,onFollowersClick:_}){const[k,g]=o.useState(!1),y=B(a);return e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-dc-border bg-dc-panel",children:[e.jsxs("div",{className:"relative h-40 md:h-56",children:[a.banner_url?e.jsx(te,{src:a.banner_url,alt:`${y} store banner`,className:"w-full h-full",fittingType:"fill"}):l.banner?e.jsx("div",{className:"absolute inset-0",style:{background:l.banner.style}}):e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/45 via-primary/15 to-transparent"}),e.jsx("div",{className:"absolute inset-0 opacity-15",style:{backgroundImage:"linear-gradient(hsl(var(--foreground) / 0.14) 1px, transparent 1px), linear-gradient(90deg, hsl(var(--foreground) / 0.14) 1px, transparent 1px)",backgroundSize:"32px 32px"}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-dc-panel via-dc-panel/40 to-transparent"}),e.jsxs("span",{className:"absolute top-4 left-4 inline-flex items-center gap-1.5 rounded-full border border-dc-border bg-dc-rail/80 px-3 py-1 text-xs font-medium text-dc-muted backdrop-blur",children:[e.jsx(re,{className:"w-3.5 h-3.5"})," Creator store"]})]}),e.jsxs("div",{className:"relative px-4 md:px-8 pb-6 -mt-14 md:-mt-16 flex flex-col md:flex-row md:items-end md:justify-between gap-5",children:[e.jsxs("div",{className:"flex items-end gap-4 min-w-0",children:[e.jsx(xe,{user:a,className:"w-24 h-24 md:w-28 md:h-28 rounded-2xl ring-4 ring-dc-panel",textClassName:"text-3xl"}),e.jsxs("div",{className:"min-w-0 pb-1",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight truncate",children:e.jsx("span",{style:l.name_color?{color:l.name_color.value}:void 0,children:y})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[e.jsx(Re,{userId:a.id}),r&&e.jsx("span",{className:"rounded-full border border-dc-border bg-dc-card px-2.5 py-0.5 text-xs font-medium text-dc-muted",children:r.name}),a.created_date&&e.jsxs("span",{className:"rounded-full border border-dc-border bg-dc-card px-2.5 py-0.5 text-xs font-medium text-dc-muted",children:["Since ",pe(a.created_date)]})]}),a.bio&&e.jsx("p",{className:"mt-2 max-w-xl text-sm text-dc-muted leading-relaxed",children:a.bio})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 md:pb-2",children:[e.jsxs("button",{type:"button",onClick:_,className:"rounded-full border border-dc-border bg-dc-card px-3.5 py-1.5 text-sm hover:border-primary/40 transition-colors",children:[e.jsx("span",{className:"font-semibold",children:F})," ",e.jsx("span",{className:"text-dc-muted",children:"Followers"})]}),!N&&d&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:c,className:`rounded-full px-5 py-1.5 text-sm font-medium transition-colors ${h?"border border-dc-border bg-dc-card hover:bg-accent":"bg-primary text-white hover:bg-primary/90"}`,children:h?"Following":"Follow"}),e.jsxs("button",{type:"button",onClick:()=>g(!0),className:"inline-flex items-center gap-1.5 rounded-full border border-dc-border bg-dc-card px-3.5 py-1.5 text-sm font-medium text-dc-muted hover:text-foreground hover:border-primary/40 transition-colors",children:[e.jsx(Be,{className:"w-3.5 h-3.5"})," Report"]})]})]})]}),!N&&e.jsx(Me,{open:k,onOpenChange:g,targetType:"user",targetId:a.id,targetName:y})]})}const Ue=[{key:"templates",label:"Templates",icon:Ae},{key:"avgRating",label:"Average rating",icon:se,decimal:!0},{key:"upvotes",label:"Upvotes",icon:ae},{key:"reviews",label:"Reviews",icon:he},{key:"followers",label:"Followers",icon:fe}];function Ee({stats:a={}}
1){return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:Ue.map(({key:l,label:r,icon:d,decimal:N})=>{const h=a[l]||0;return e.jsxs("div",{className:"rounded-xl border border-dc-border bg-dc-panel px-4 py-3.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wider text-dc-muted",children:[e.jsx(d,{className:"w-3.5 h-3.5 text-primary"})," ",r]}),e.jsx("p",{className:"mt-1.5 text-xl font-bold tracking-tight",children:N?Number(h).toFixed(1):Number(h).toLocaleString()})]},l)})})}function Oe({sections:a,active:l,onSelect:r}){return e.jsx("div",{className:"flex gap-2 overflow-x-auto rounded-xl border border-dc-border bg-dc-panel p-2",children:a.map(d=>e.jsxs("button",{type:"button",onClick:()=>r(d.value),className:`whitespace-nowrap rounded-full px-4 py-2 text-sm font-medium transition-colors ${l===d.value?"bg-primary text-white":"text-dc-muted hover:bg-dc-card hover:text-foreground"}`,children:[d.label,typeof d.count=="number"&&e.jsx("span",{className:`ml-1.5 text-xs ${l===d.value?"text-white/75":"text-dc-muted"}`,children:d.count})]},d.value))})}function Pe({template:a,avgRating:l=0,reviewCount:r=0,upvotes:d=0}){return a?e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-dc-border bg-dc-panel md:flex",children:[e.jsx("div",{className:"relative h-44 md:h-auto md:w-2/5 shrink-0 bg-dc-card",children:a.image_url?e.jsx(te,{src:a.image_url,alt:a.name,className:"w-full h-full",fittingType:"fill"}):e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/40 to-transparent"})}),e.jsxs("div",{className:"flex-1 min-w-0 p-5 md:p-7",children:[e.jsx("span",{className:"inline-flex rounded-full border border-primary/30 bg-primary/10 px-2.5 py-0.5 text-xs font-medium text-primary",children:"Featured listing"}),e.jsx("h2",{className:"mt-3 text-xl md:text-2xl font-bold tracking-tight truncate",children:a.name}),e.jsx("p",{className:"mt-2 text-sm text-dc-muted leading-relaxed line-clamp-3",children:a.description}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-4 text-sm text-dc-muted",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(se,{className:"w-4 h-4 text-[#f0b232]"}),l?l.toFixed(1):"New",r>0&&e.jsxs("span",{className:"text-dc-muted/70",children:["(",r,")"]})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ae,{className:"w-4 h-4 text-primary"})," ",d.toLocaleString()]}),e.jsx("span",{className:"rounded-full border border-dc-border bg-dc-card px-2.5 py-0.5 text-xs capitalize",children:a.category})]}),e.jsxs(A,{to:`/template/${a.id}`,className:"mt-5 inline-flex items-center gap-2 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-white hover:bg-primary/90 transition-colors",children:["View template ",e.jsx(be,{className:"w-4 h-4"})]})]})]}):null}function qe(){return e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-primary/25 bg-primary/5 px-4 py-3",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(re,{className:"w-4 h-4 text-primary shrink-0"}),"This is your public storefront, exactly as visitors see it."]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(A,{to:"/profile",className:"inline-flex items-center gap-1.5 rounded-lg border border-border bg-secondary px-3.5 py-1.5 text-xs font-medium hover:bg-accent transition-colors",children:[e.jsx(De,{className:"w-3.5 h-3.5"})," Manage listings"]}),e.jsxs(A,{to:"/creator-dashboard",className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3.5 py-1.5 text-xs font-medium text-white hover:bg-primary/90 transition-colors",children:[e.jsx(ge,{className:"w-3.5 h-3.5"})," Creator Dashboard"]})]})]})}function ct(){var Q;const{username:a}=we(),{user:l}=ve(),[r,d]=o.useState(null),[N,h]=o.useState(!1),[c,F]=o.useState(null),[_,k]=o.useState(null),[g,y]=o.useState([]),[I,$]=o.useState([]),[S,T]=o.useState([]),[oe,L]=o.useState([]),[U,E]=o.useState(0),[O,P]=o.useState(0),[q,H]=o.use
1State(0),[le,z]=o.useState([]),[ne,V]=o.useState([]),[X,Y]=o.useState([]),[w,G]=o.useState("templates"),[J,D]=o.useState(null),n=(r==null?void 0:r.id)||null;o.useEffect(()=>{d(null),h(!1),G("templates"),i.functions.invoke("getPublicProfile",{username:a}).then(async t=>{const s=t.data.user;if(!(await i.entities.Store.filter({user_id:s.id})).length){h(!0);return}d(s)}).catch(()=>h(!0))},[a]),o.useEffect(()=>{n&&(i.functions.invoke("getCreatorStats",{user_id:n}).then(t=>F(t.data)).catch(()=>F({stats:{},xp:0,level:null})),i.entities.Template.filter({created_by_id:n},"-created_date",200).then(k).catch(()=>k([])),i.entities.Review.list("-created_date",500).then(y).catch(()=>y([])),i.entities.Upvote.list("-created_date",1e3).then($).catch(()=>$([])),i.entities.Follow.filter({followee_id:n},"-created_date",500).then(T).catch(()=>T([])),i.entities.Follow.filter({follower_id:n},"-created_date",500).then(L).catch(()=>L([])),i.entities.SavedTemplate.filter({user_id:n,showcased:!0},"-created_date",100).then(t=>E(t.length)).catch(()=>E(0)),i.entities.Bundle.filter({created_by_id:n},"-created_date",50).then(t=>P(t.length)).catch(()=>P(0)),i.entities.Collection.filter({owner_id:n,is_public:!0},"-updated_date",100).then(t=>H(t.length)).catch(()=>H(0)),i.entities.UserCosmetic.filter({user_id:n},"-created_date",100).then(z).catch(()=>z([])),i.entities.ShopItem.filter({active:!0},"-created_date",200).then(V).catch(()=>V([])),i.entities.Boost.filter({creator_id:n},"-created_date",100).then(Y).catch(()=>Y([])))},[n]);const K=l&&n&&l.id===n,R=S.find(t=>t.follower_id===(l==null?void 0:l.id)),ie=async()=>{if(!(!l||!n))if(R)await i.entities.Follow.delete(R.id),T(t=>t.filter(s=>s.id!==R.id));else{const t=await i.entities.Follow.create({follower_id:l.id,followee_id:n});T(s=>[...s,t]),i.functions.invoke("createNotification",{type:"follow",followee_id:n}).catch(()=>null)}},f=o.useMemo(()=>{const t={};return(g||[]).forEach(s=>{t[s.template_id]||(t[s.template_id]={sum:0,count:0}),t[s.template_id].sum+=s.rating||0,t[s.template_id].count+=1}),t},[g]),v=o.useMemo(()=>{const t={};return(I||[]).forEach(s=>{t[s.template_id]=(t[s.template_id]||0)+1}),t},[I]),de=o.useMemo(()=>{const t=new Map,s=Date.now();return(X||[]).forEach(u=>{if(!u.active||!u.expires_date)return;const x=new Date(u.expires_date).getTime()-s;if(x<=0)return;const p=Math.max(1,Math.ceil(x/864e5)),C=t.get(u.template_id);(C===void 0||p>C)&&t.set(u.template_id,p)}),t},[X]),m=o.useMemo(()=>je(_,l).filter(t=>t.status==="published"),[_,l]),j=o.useMemo(()=>{const t=new Set(m.map(s=>s.id));return(g||[]).filter(s=>t.has(s.template_id))},[m,g]),b=o.useMemo(()=>{if(!m.length)return null;const t=[...m].sort((s,u)=>{const x=f[s.id],p=f[u.id],C=x&&x.count?x.sum/x.count:0,W=p&&p.count?p.sum/p.count:0;return W!==C?W-C:(v[u.id]||0)-(v[s.id]||0)});return t.find(s=>s.featured)||t[0]},[m,f,v]),ce=o.useMemo(()=>{const t=c==null?void 0:c.stats;if(t&&Object.keys(t).length)return t;const s=m.reduce((x,p)=>x+(v[p.id]||0),0),u=j.length?j.reduce((x,p)=>x+(p.rating||0),0)/j.length:0;return{templates:m.length,upvotes:s,reviews:j.length,avgRating:u,followers:S.length,joinDate:r==null?void 0:r.created_date}},[c,m,j,v,S,r]),M=r?B(r):"";if(Ne({title:M?`${M}: Discord templates`:"Creator store",description:r!=null&&r.bio?r.bio:M?`Browse Discord server templates, collections and reviews from ${M} on CordFoundry.`:void 0,path:`/creator/${a}`,image:(r==null?void 0:r.avatar_url)||void 0}),N)return e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-28 text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full border border-border bg-card flex items-center justify-center",children:e.jsx(_e,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("h1",{className:"mt-6 text-2xl font-bold tracking-tight",children:"Store not found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This member hasn't opened a store on CordFoundry yet."}),e.jsxs(A,{to:"/templates",className:"mt-7 inline-flex items-center gap-2 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-white hover:bg-primary/90 transition-colors",children:[e.jsx($e,{className:"w-4 h-4"})," Browse Templates"]})]});if(!r)return e.jsx("div",{className:"py-24 flex justify-center",children:e.jsx(Z,{className:"w-8 h-8 text-primary animate-spin"})});const me=Ie(le,ne),ue=[{value:"templates",label:"Templates",count:m.length},...q>0?[{value:"collections",label:"Collections",count:q}]:[],...O>0?[{value:"bundles",label:"Bundles",count:O}]:[],...U>0?[{value:"showcase",label:"Showcase",count:U}]:[],{value:"reviews",label:"Reviews",count:j.length},{value:"about",label:"About"}];return e.jsxs("div",{className:"max-w-6xl mx-auto px-4 md:px-8 py-6 md:py-10",children:[K&&e.jsx(qe,{}),e.jsx(Le,{target:r,cosmetics:me,level:c==null?void 0:c.level,me:l,isSelf:!!K,myFollow:R,onToggleFollow:ie,followersCount:S.length,onFollowersClick:()=>D("followers")}),e.jsx("div",{className:"mt-4",children:e.jsx(Ee,{stats:ce})}),b&&e.jsx("div",{className:"mt-6",children:e.jsx(Pe,{template:b,avgRating:f[b.id]&&f[b.id].count?f[b.id].sum/f[b.id].count:0,reviewCount:((Q=f[b.id])==null?void 0:Q.count)||0,upvotes:v[b.id]||0})}),e.jsx("div",{className:"mt-8",children:e.jsx(Oe,{sections:ue,active:w,onSelect:G})}),e.jsxs("div",{className:"mt-6",children:[w==="templates"&&(_===null?e.jsx("div",{className:"py-16 flex justify-center",children:e.jsx(Z,{className:"w-8 h-8 text-primary animate-spin"})}):m.length===0?e.jsxs("div",{className:"rounded-xl border border-dc-border bg-dc-panel py-16 text-center",children:[e.jsx("p",{className:"font-medium",children:"No listings yet"}),e.jsx("p",{className:"mt-1 text-sm text-dc-muted",children:"This creator hasn't published any templates."})]}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-5",children:m.map(t=>{const s=f[t.id];
1return e.jsx(ye,{template:t,avgRating:s&&s.count?s.sum/s.count:0,reviewCount:s&&s.count||0,upvotes:v[t.id]||0,boostDaysLeft:de.get(t.id)??null},t.id)})})),w==="collections"&&e.jsx(Se,{targetId:n,isSelf:!1},n),w==="bundles"&&e.jsx(Ce,{targetId:n,isSelf:!1},n),w==="showcase"&&e.jsx(Fe,{targetId:n}),w==="reviews"&&e.jsx(ke,{reviews:j,templates:m}),w==="about"&&e.jsx(Te,{target:r,level:c==null?void 0:c.level,stats:c==null?void 0:c.stats})]}),e.jsx(ee,{open:J==="followers",onOpenChange:t=>!t&&D(null),title:`Followers of ${B(r)}`,userIds:S.map(t=>t.follower_id)}),e.jsx(ee,{open:J==="following",onOpenChange:t=>!t&&D(null),title:`${B(r)} follows`,userIds:oe.map(t=>t.followee_id)})]})}export{ct 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.