PageSourceSearch

https://top1000league.com/assets/Profile-BS3hhz62.js

js top1000league.com collected 2026-10-09 22:04:18 UTC 29,402 bytes, 29 lines download raw bytes

1import{j as e}from"./ui-vendor-59hLoTKd.js";import{a as x,l as ae,u as re}from"./react-vendor-DHHkWg5p.js";import{C as N,s as h,y as K,p as ie,H as ne,i as q,u as le,q as X,r as J,B as w,a8 as M,a0 as oe,T as A,j as ce,Y as de,w as b,O as Z,Q,z as me,a9 as U,k as xe,l as pe,m as he,f as fe,a as ue,N as G,F,M as ge,_ as je,$ as Ne}from"./index-B712TPBp.js";import{u as _e}from"./useTierInfo-B-q_UOrT.js";import{T as be,a as we,b as V,c as W}from"./tabs-CfZKoYVK.js";import{T as ee}from"./TierBadge-CbcbduPg.js";import{P as Y}from"./progress-Co5KM0T2.js";import{D as ye}from"./dollar-sign-Bay59-Cu.js";import{E as ve,P as ke}from"./elo-info-tooltip-XWxes5kG.js";import{V as Se}from"./VideoGallery-iLs65XvY.js";import{Q as Ce}from"./index-DEa3GikS.js";import{H as qe}from"./hash-J1mEFi8k.js";import{C as Te}from"./copy-DMZXc2aK.js";import{S as se}from"./share-2-yFBYjMlR.js";import{G as Re}from"./gamepad-2-DV_4FN-2.js";import{A as P}from"./award-CoemWDVO.js";import{L as O,R as Ee,W as Pe}from"./lucide-react-633SH4zg.js";import{a as $e}from"./query--LTQ4q54.js";import{A as De}from"./arrow-left-B8HNFMNO.js";import{S as Le}from"./shield-check-DMH0aOw5.js";import{S as Ie}from"./square-pen-atqRZG3D.js";import"./supabase-D_pLX_lr.js";import"./message-circle-Bjlqj5p4.js";import"./pin-ChkCcr3d.js";import"./eye-DWPpD2ha.js";import"./heart-CR-6nv48.js";import"./activity-DGar6fxX.js";import"./ban-CIEQBccY.js";import"./book-open-Dccz-DNt.js";import"./camera-CRizHD1J.js";import"./chart-no-axes-column-increasing-VS9ZXS_e.js";import"./check-check-ttKakJdY.js";import"./chevron-left-jKAwOGJh.js";import"./circle-alert-C2lRW_0g.js";import"./circle-check-DeDMEqWe.js";import"./circle-help-DvRn8e4s.js";import"./circle-plus-BVeF0gM9.js";import"./circle-user-D7ghULx-.js";import"./circle-x-BOGSGYYx.js";import"./compass-DeGoI_2d.js";import"./credit-card--DifNu3I.js";import"./dribbble-Vkl5g5HA.js";import"./link-2-Dw0Rjg3x.js";import"./filter-DvMmz8O9.js";import"./flag-CAg9GUF3.js";import"./flashlight-ZzkPuFZL.js";import"./gift-CZZ6QG2H.js";import"./rocket-_wXknb3L.js";import"./share-BmjikslG.js";import"./handshake-D4w141Tg.js";import"./image-BSz--4st.js";import"./keyboard-fb9tRjQA.js";import"./megaphone-JyRN_IRr.js";import"./list-CCUmyVnE.js";import"./loader-circle-BOlysSMP.js";import"./lock-Dunqbqap.js";import"./map-D0XaYC9A.js";import"./medal-DweR0BlP.js";import"./navigation-BrraGgU1.js";import"./palette-DkQ_7hUx.js";import"./plus-ChWTupcz.js";import"./wifi-x190_Lln.js";import"./send-ACIWYBLZ.js";import"./smartphone-vdH5KPXG.js";import"./sparkles-DlPSAUTh.js";import"./square-B_h7kT6M.js";import"./test-tube-diagonal-D5IDT0Ez.js";import"./thumbs-up-iD2xx3nA.js";import"./trending-down-D4hj4939.js";import"./undo-2-DdtBDKua.js";import"./upload-Cj1hpvJM.js";import"./user-check-BxnN31mk.js";import"./video-Cof76VbV.js";const Be=({tierInfo:a,nextTier:d,currentElo:r})=>{const s=d?d.min_elo-r:0,i=a.max_elo>=9999;return e.jsxs(N,{className:"p-6 bg-gradient-to-br from-primary/10 to-primary/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold mb-2",children:"Your Rank Tier"}),e.jsx(ee,{tierName:a.tier_name,tierIcon:a.tier_icon,tierColor:a.tier_color,size:"lg"})]}),d&&!i&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Next Tier"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:d.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-sm",children:d.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["+",s," needed"]})]})]})]}),i&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:"🏆 MAX TIER"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You've reached the top!"})]})]}),!i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tier Progress"}),e.jsxs("span",{className:"font-bold",children:[a.progress_percentage,"%"]})]}),e.jsx(Y,{value:a.progress_percentage,className:"h-3"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:a.min_elo}),e.jsx("span",{className:"font-bold text-primary",children:r}),e.jsx("span",{children:a.max_elo})]})]}),i&&e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx(Y,{value:100,className:"h-3 mb-2"}),e.jsx("p",{className:"text-sm font-bold text-primary",children:"Legendary Status Achieved"})]})]})},ze=({userId:a,city:d})=>{const[r,s]=x.useState([]),[i,n]=x.useState(!0);x.useEffect(()=>{o()},[a,d]);const o=async()=>{try{const{data:l,error:m}=await h.from("most_wanted_titles").select("title_type").eq("user_id",a).eq("city",d).is("lost_at",null);if(m)throw m;const t=(l||[]).map(c=>{switch(c.title_type){case"kingpin":return{type:"kingpin",title:"THE KINGPIN",icon:ne,color:"text-yellow-500 bg-yellow-500/20 border-yellow-500/50"};case"bounty_magnet":return{type:"bounty_magnet",title:"BOUNTY MAGNET",icon:ie,color:"text-red-500 bg-red-500/20 border-red-500/50"};case"hitman":return{type:"hitman",title:"THE HITMAN",icon:ye,color:"text-green-500 bg-green-500/20 border-green-500/50"};case"untouchable":return{type:"untouchable",title:"UNTOUCHABLE",icon:K,color:"text-blue-500 bg-blue-500/20 border-blue-500/50"};default:return null}}
1).filter(Boolean);s(t)}catch(l){console.error("Error loading titles:",l)}finally{n(!1)}};return i||r.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:r.map(l=>{const m=l.icon;return e.jsxs(q,{variant:"outline",className:`text-sm font-bold px-3 py-1.5 border-2 ${l.color}`,children:[e.jsx(m,{className:"w-4 h-4 mr-1.5"}),"🔥 ",d.toUpperCase(),"'S ",l.title]},l.type)})})},Ae=({qrData:a,qrExpiry:d,playerId:r,username:s,isOwnProfile:i,shortCode:n,onRefresh:o})=>{const{toast:l}=le(),[m,t]=x.useState(!1),[c,v]=x.useState(!1),_=async()=>{t(!0);try{const{data:p,error:u}=await h.rpc("refresh_player_qr_code",{_player_id:r});if(u)throw u;if(l({title:"QR Code Refreshed",description:"Your QR code has been updated with a new expiration time."}),o&&p&&typeof p=="object"){const g=p;o({qr_data:g.qr_data,qr_expiry:g.qr_expiry})}}catch(p){l({title:"Error",description:p.message,variant:"destructive"})}finally{t(!1)}},k=async()=>{v(!0);try{const p="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let u="";for(let f=0;f<6;f++)u+=p.charAt(Math.floor(Math.random()*p.length));const{error:g}=await h.from("profiles").update({quick_challenge_token:u}).eq("id",r);if(g)throw g;l({title:"New Code Generated",description:"Your challenge code has been updated."}),o&&o({qr_data:a,qr_expiry:d,quick_challenge_token:u})}catch(p){l({title:"Error",description:p.message,variant:"destructive"})}finally{v(!1)}},T=()=>{n&&(navigator.clipboard.writeText(n),navigator.vibrate&&navigator.vibrate(50),l({title:"Code Copied!",description:"Challenge code copied to clipboard"}))},$=()=>{const p=document.getElementById("profile-qr-code");if(!p)return;const u=new XMLSerializer().serializeToString(p),g=document.createElement("canvas"),f=g.getContext("2d"),j=new Image;j.onload=()=>{g.width=j.width,g.height=j.height,f?.drawImage(j,0,0);const R=g.toDataURL("image/png"),S=document.createElement("a");S.download=`${s}-qr-code.png`,S.href=R,S.click()},j.src="data:image/svg+xml;base64,"+btoa(u)},D=()=>{const p=n?`${window.location.origin}/join/${n}`:`${window.location.origin}/player/${s}`;navigator.clipboard.writeText(p),l({title:"Link Copied!",description:"Challenge link copied to clipboard"})},E=new Date(d),L=E<new Date,I=L?"Expired":`Expires ${X(E,{addSuffix:!0})}`,B=n?`${window.location.origin}/join/${n}`:a||`${window.location.origin}/player/${s}`;return e.jsxs(N,{className:"p-6",children:[e.jsx("h3",{className:"font-bold text-lg mb-4",children:"Your Unique Code"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"bg-white p-4 rounded-lg inline-block touch-manipulation active:scale-95 transition-transform cursor-pointer",onClick:()=>{navigator.vibrate&&navigator.vibrate(50)},role:"button",tabIndex:0,"aria-label":`QR code for ${s}. Tap to focus for scanning`,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&p.currentTarget.click()},children:e.jsx(Ce,{id:"profile-qr-code",value:B,size:160,level:"H",includeMargin:!0,"aria-label":`QR code for player ${s}`})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Scan to challenge"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground mt-2",children:[e.jsx(J,{className:"h-3 w-3"}),e.jsx("span",{className:L?"text-destructive":"",children:I})]})]}),e.jsxs("div",{className:"text-center flex flex-col",children:[e.jsxs("div",{className:"bg-muted p-6 rounded-lg flex-1 flex flex-col justify-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx(qe,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Challenge Code"})]}),e.jsx("p",{className:"text-4xl font-mono font-bold tracking-wider",children:n||"------"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Share this code"})]}),e.jsxs(w,{onClick:T,variant:"outline",className:"mt-4 w-full",disabled:!n,children:[e.jsx(Te,{className:"h-4 w-4 mr-2"}),"Copy Code"]}),i&&e.jsxs(w,{onClick:k,variant:"outline",className:"mt-2 w-full text-destructive hover:text-destructive",disabled:c,
1children:[e.jsx(M,{className:`h-4 w-4 mr-2 ${c?"animate-spin":""}`}),"Generate New Code"]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-6 pt-4 border-t",children:[i&&e.jsxs(w,{onClick:_,disabled:m,size:"sm",variant:"outline",children:[e.jsx(M,{className:`h-4 w-4 mr-2 ${m?"animate-spin":""}`}),"Refresh QR"]}),e.jsxs(w,{onClick:$,size:"sm",variant:"outline",children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(w,{onClick:D,size:"sm",variant:"outline",children:[e.jsx(se,{className:"h-4 w-4 mr-2"}),"Share Link"]})]})]})},He=({currentRank:a,eloRating:d,winRate:r,wins:s,losses:i,currentStreak:n=0,streakType:o="win"})=>{const l=[{label:"Global Rank",value:`#${a.toLocaleString()}`,icon:A,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},{label:"Rating",value:d.toLocaleString(),icon:ce,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Total Games",value:(s+i).toString(),icon:Re,color:"text-purple-500",bgColor:"bg-purple-500/10"},{label:"Win Rate",value:`${r.toFixed(1)}%`,icon:P,color:"text-green-500",bgColor:"bg-green-500/10"}];return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:l.map(m=>e.jsx(N,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:m.label}),e.jsx("p",{className:"text-2xl font-bold",children:m.value})]}),e.jsx("div",{className:`${m.bgColor} p-2 rounded-lg`,children:e.jsx(m.icon,{className:`h-5 w-5 ${m.color}`})})]})},m.label))}),e.jsxs(N,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Performance Details"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:"Record"})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:s}),e.jsx("span",{className:"text-muted-foreground",children:"-"}),e.jsx("span",{className:"text-3xl font-bold",children:i})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Win Rate:"}),e.jsxs(q,{variant:r>=50?"default":"secondary",children:[r.toFixed(1),"%"]})]})]}),n>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:`h-5 w-5 ${o==="win"?"text-orange-500":"text-blue-500"}`}),e.jsx("span",{className:"font-medium",children:"Current Streak"})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:n}),e.jsx("span",{className:"text-muted-foreground",children:o==="win"?"Wins":"Losses"})]}),e.jsx(q,{variant:o==="win"?"default":"destructive",className:"w-fit",children:o==="win"?"🔥 On Fire!":"Keep Fighting"})]})]})]})]})},Me=({playerId:a,isOwnProfile:d})=>{const[r,s]=x.useState([]),[i,n]=x.useState(!0);x.useEffect(()=>{o()},[a]);const o=async()=>{try{const{data:t,error:c}=await h.from("qr_scan_history").select(`
2          id,
3          scan_type,
4          scanned_at,
5          is_offline_scan,
6          scanned_by:public_profiles!qr_scan_history_scanned_by_fkey(username, photo_url)
7        `).eq("player_id",a).order("scanned_at",{ascending:!1}).limit(10);if(c)throw c;s(t||[])}catch(t){console.error("Error loading scan history:",t)}finally{n(!1)}},l=t=>{switch(t){case"game_verification":return e.jsx(Q,{className:"h-4 w-4 text-green-500"});case"sponsor_engagement":return e.jsx(me,{className:"h-4 w-4 text-blue-500"});case"social_share":return e.jsx(se,{className:"h-4 w-4 text-purple-500"});default:return e.jsx(Q,{className:"h-4 w-4"})}},m=t=>{switch(t){case"game_verification":return"Game Verification";case"sponsor_engagement":return"Sponsor Scan";case"social_share":return"Social Share";default:return t}};return d?i?e.jsxs(N,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Recent QR Scans"}),e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx(b,{className:"h-16 w-full"},t))})]}):r.length===0?e.jsxs(N,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Recent QR Scans"}),e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No scans yet. Your QR code activity will appear here."})]}):e.jsxs(N,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Recent QR Scans"}),e.jsxs(q,{variant:"secondary",children:[r.length," recent"]})]}),e.jsx("div",{className:"space-y-3",children:r.map(t=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-accent/50 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0",children:l(t.scan_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:m(t.scan_type)}),t.is_offline_scan&&e.jsx(q,{variant:"outline",className:"text-xs",children:"Offline"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.scanned_by?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"h-3 w-3"}),e.jsx("span",{children:t.scanned_by.username})]}):e.jsx("span",{children:"Anonymous scan"}),e.jsx("span",{children:"•"}),e.jsx(J,{className:"h-3 w-3"}),e.jsx("span",{children:X(new Date(t.scanned_at),{addSuffix:!0})})]})]})]},t.id))})]}):null},Qe=a=>
7{const[d,r]=x.useState(null),[s,i]=x.useState(!0);x.useEffect(()=>{n()},[a]);const n=async()=>{try{const{data:o,error:l}=await h.from("profiles").select(`
8          sponsorship_tier,
9          media_value_score,
10          total_earnings,
11          profile_views,
12          qr_scan_count,
13          social_media_reach
14        `).eq("id",a).single();if(l)throw l;const{count:m}=await h.from("follows").select("*",{count:"exact",head:!0}).eq("following_id",a);let t=o.media_value_score||0;if(t===0){const{data:c}=await h.rpc("calculate_media_value_score",{player_id:a});t=c||0,await h.from("profiles").update({media_value_score:t}).eq("id",a)}r({sponsorshipTier:o.sponsorship_tier||"available",mediaValueScore:t,totalEarnings:Number(o.total_earnings||0),profileViews:o.profile_views||0,qrScanCount:o.qr_scan_count||0,socialMediaReach:o.social_media_reach||0,followers:m||0})}catch(o){console.error("Error loading sponsorship data:",o)}finally{i(!1)}};return{data:d,loading:s,refresh:n}},Ue={common:"bg-zinc-500",uncommon:"bg-green-500",rare:"bg-blue-500",epic:"bg-purple-500",legendary:"bg-gradient-to-r from-yellow-500 to-orange-500"},Ge=({playerId:a,compact:d=!1})=>{const[r,s]=x.useState([]),[i,n]=x.useState(0),[o,l]=x.useState(!0);x.useEffect(()=>{m()},[a]);const m=async()=>{try{const{data:t,error:c}=await h.from("player_badges").select(`
15          id,
16          earned_at,
17          badge_definitions (
18            id,
19            name,
20            icon_name,
21            rarity,
22            bg_color,
23            text_color,
24            points
25          )
26        `).eq("player_id",a).eq("is_completed",!0).order("earned_at",{ascending:!1}).limit(d?5:10);if(c)throw c;const v=(t||[]).filter(k=>k.badge_definitions);s(v);const _=v.reduce((k,T)=>k+(T.badge_definitions?.points||0),0);n(_)}catch(t){console.error("Error loading badges:",t)}finally{l(!1)}};return o?e.jsx("div",{className:"flex gap-1",children:[...Array(3)].map((t,c)=>e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted animate-pulse"},c))}):r.length===0?null:d?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex -space-x-2",children:r.slice(0,4).map(t=>{const c=O[t.badge_definitions.icon_name]||P;return e.jsx("div",{className:U("w-7 h-7 rounded-full flex items-center justify-center border-2 border-background",Ue[t.badge_definitions.rarity]),title:t.badge_definitions.name,children:e.jsx(c,{className:"w-3.5 h-3.5 text-white"})},t.id)})}),r.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",r.length-4," more"]})]}):e.jsxs(N,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5 text-primary"}),e.jsx("h3",{className:"font-bold",children:"Badges"})]}),e.jsxs(q,{variant:"secondary",className:"gap-1",children:[e.jsx(xe,{className:"w-3 h-3"}),i," pts"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(t=>{const c=O[t.badge_definitions.icon_name]||P;return e.jsxs("div",{className:"group relative",title:t.badge_definitions.name,children:[e.jsx("div",{className:U("w-10 h-10 rounded-lg flex items-center justify-center transition-transform group-hover:scale-110",t.badge_definitions.rarity==="legendary"&&"animate-pulse"),style:{backgroundColor:t.badge_definitions.bg_color,color:t.badge_definitions.text_color},children:e.jsx(c,{className:"w-5 h-5"})}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-popover text-popover-foreground text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-10 shadow-lg border",children:t.badge_definitions.name})]},t.id)})}),r.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:[r.length," badge",r.length!==1?"s":""," earned"]})]})};function Fe({playerId:a,currentTScore:d}){const{data:r}=$e({queryKey:["player-t-score-history",a],queryFn:async()=>{const{data:i,error:n}=await h.from("player_t_score_history").select("*").eq("player_id",a).order("recorded_at",{ascending:!1}).limit(5);if(n)throw n;const o=[...new Set(i.map(t=>
26t.team_id).filter(Boolean))],{data:l}=await h.from("teams").select("id, name").in("id",o),m={};for(const t of l||[])m[t.id]=t.name;return i.map(t=>({id:t.id,teamName:m[t.team_id]||"Unknown",pointsEarned:Number(t.t_points_earned),before:t.t_score_before,after:t.t_score_after,tierCode:t.tier_code}))},enabled:!!a}),s=d??1e3;return!r?.length&&s===1e3?null:e.jsxs(N,{children:[e.jsx(pe,{children:e.jsxs(he,{className:"flex items-center gap-2",children:[e.jsx(K,{className:"w-5 h-5 text-primary"}),"5v5 T-Score"]})}),e.jsxs(fe,{children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("p",{className:"text-4xl font-black text-primary",children:s.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"T-Score"})]}),r&&r.length>0&&e.jsx("div",{className:"space-y-2",children:r.map(i=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border border-border text-sm",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:i.teamName}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.before," → ",i.after]})]}),e.jsxs("span",{className:`font-bold shrink-0 ${i.pointsEarned>0?"text-green-500":"text-muted-foreground"}`,children:["+",i.pointsEarned]})]},i.id))})]})]})}const mt=()=>{const{userId:a}=ae(),d=re(),{user:r}=ue(),[s,i]=x.useState(null),{tierInfo:n,nextTier:o,loading:l}=_e(s?.elo_rating||1e3),[m,t]=x.useState([]),[c,v]=x.useState(0),[_,k]=x.useState(0),[T,$]=x.useState(null),[D,E]=x.useState(null),[L,I]=x.useState([]),[B,p]=x.useState(!0),u=r?.id===a;Qe(a||""),x.useEffect(()=>{g()},[a]);const g=async()=>{p(!0);try{r&&E(r.id);const{data:f,error:j}=await h.from("public_profiles").select("*").eq("id",a).maybeSingle();if(j)throw j;if(!f){console.error("Profile not found"),p(!1);return}let R=f;if(r?.id===a){const{data:C}=await h.rpc("get_my_qr_credentials"),y=C?.[0];y&&(R={...R,qr_data:y.qr_data,qr_expiry:y.qr_expiry,quick_challenge_token:y.quick_challenge_token})}i(R);const{data:S}=await h.from("elo_history").select("rating_after, created_at").eq("user_id",a).order("created_at",{ascending:!0});if(S){const C=S.map(y=>({date:new Date(y.created_at).toLocaleDateString(),rating:y.rating_after}));t(C)}const{data:z}=await h.from("profiles").select("total_wins, total_losses").eq("id",a).single();z&&(v(z.total_wins||0),k(z.total_losses||0));const{data:te}=await h.from("team_performance").select(`
27          *,
28          gyms:gym_id(name, city)
29        `).eq("user_id",a).order("games_played",{ascending:!1});I(te||[]);const{data:H}=await h.from("public_profiles").select("id, elo_rating").order("elo_rating",{ascending:!1});if(H){const C=H.findIndex(y=>y.id===a)+1;$(C>0?C:null)}}catch(f){console.error("Error loading profile:",f)}finally{p(!1)}};return B||!s?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(G,{}),e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:[e.jsx(b,{className:"h-8 w-32 mb-6"}),e.jsx(N,{className:"p-8 mb-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-8",children:[e.jsx(b,{className:"h-32 w-32 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsx(b,{className:"h-8 w-48"}),e.jsx(b,{className:"h-6 w-32"}),e.jsx(b,{className:"h-20 w-full"}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(b,{className:"h-10 w-32"}),e.jsx(b,{className:"h-10 w-32"})]})]})]})}),e.jsx("div",{className:"grid md:grid-cols-3 gap-6 mb-6",children:[1,2,3].map(f=>e.jsxs(N,{className:"p-6",children:[e.jsx(b,{className:"h-6 w-24 mb-2"}),e.jsx(b,{className:"h-8 w-16"})]},f))})]}),e.jsx(F,{})]}):e.jsxs("div",{className:"min-h-screen",children:[e.jsx(G,{}),e.jsx("div",{className:"p-4 md:p-8",children:e.jsxs("div",{className:"container mx-auto max-w-4xl",children:[e.jsxs(w,{variant:"ghost",onClick:()=>d(-1),className:"mb-6",children:[e.jsx(De,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(N,{className:"glass p-4 sm:p-6 md:p-8 mb-8",children:[e.jsxs("div",{className:"flex flex-col md:flex-row items-center md:items-start gap-4 md:gap-6",children:[e.jsx("div",{className:"w-24 h-24 sm:w-28 sm:h-28 md:w-32 md:h-32 bg-secondary rounded-full overflow-hidden flex items-center justify-center shrink-0",children:s.photo_url?e.jsx("img",{src:s.photo_url,alt:s.username,className:"w-full h-full object-cover"}):e.jsx(Z,{className:"w-12 h-12 sm:w-14 sm:h-14 md:w-16 md:h-16 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 text-center md:text-left w-full min-w-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center md:justify-start gap-2 sm:gap-4 mb-2",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2 break-words max-w-full",children:[e.jsx("span",{className:"truncate",children:s.username}),s.is_verified&&e.jsx(Le,{className:"h-5 w-5 sm:h-6 sm:w-6 text-primary shrink-0"})]}),e.jsx("div",{className:"shrink-0",children:e.jsx(ze,{userId:a||"",city:s.home_city})})]}),n&&!l&&e.jsx(ee,{tierName:n.tier_name,tierIcon:n.tier_icon,tierColor:n.tier_color,size:"md"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm sm:text-base text-muted-foreground my-2 justify-center md:justify-start",children:[e.jsx(ge,{className:"w-4 h-4 shrink-0"}),e.jsxs("span",{className:"break-words text-center md:text-left",children:[s.home_gym||"No gym set"," • ",s.home_city||"No city set",s.home_state&&`, ${s.home_state}`,s.home_country&&s.home_country!=="USA"&&`, ${s.home_country}`]})]}),(s.position||s.height_inches||s.weight_lbs)&&e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 text-xs sm:text-sm text-muted-foreground mb-4 justify-center md:justify-start flex-wrap",children:[s.position&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(A,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{className:"break-words",children:s.position})]}),s.height_inches&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ee,{className:"w-4 h-4"}),Math.floor(s.height_inches/12),"'",s.height_inches%12,'"']}),s.weight_lbs&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pe,{className:"w-4 h-4"}),s.weight_lbs," lbs"]})]}),s.bio&&e.jsx("p",{className:"text-muted-foreground mt-2 mb-4",children:s.bio}),(s.instagram_handle||s.twitter_handle||s.tiktok_handle)&&e.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-center md:justify-start flex-wrap",children:[s.instagram_handle&&e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://instagram.com/${s.instagram_handle?.replace("@","")}`,"_blank"),children:[e.jsx(je,{className:"h-4 w-4 mr-1"}),"Instagram"]}),s.twitter_handle&&e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://twitter.com/${s.twitter_handle?.replace("@","")}`,"_blank"),children:[e.jsx(Ne,{className:"h-4 w-4 mr-1"}),"Twitter"]}),s.tiktok_handle&&e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://tiktok.com/@${s.tiktok_handle?.replace("@","")}`,"_blank"),children:[e.jsx("svg",{className:"h-4 w-4 mr-1",viewBox:"0 0 24 24",fill:"
29currentColor",children:e.jsx("path",{d:"M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 0 1-5.2 1.74 2.89 2.89 0 0 1 2.31-4.64 2.93 2.93 0 0 1 .88.13V9.4a6.84 6.84 0 0 0-1-.05A6.33 6.33 0 0 0 5 20.1a6.34 6.34 0 0 0 10.86-4.43v-7a8.16 8.16 0 0 0 4.77 1.52v-3.4a4.85 4.85 0 0 1-1-.1z"})}),"TikTok"]})]}),D===s.id&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>d(`/profile/${s.id}/edit`),className:"w-full sm:w-auto min-h-[44px]",children:[e.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Edit Profile"]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 p-6 bg-muted/50 rounded-lg mt-6",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:["Rating ",e.jsx(ve,{})]}),e.jsx("p",{className:"text-3xl font-black gradient-text",children:s.elo_rating})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Wins"}),e.jsx("p",{className:"text-3xl font-black text-success",children:c})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Losses"}),e.jsx("p",{className:"text-3xl font-black text-destructive",children:_})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Games"}),e.jsx("p",{className:"text-3xl font-black",children:c+_})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Win Rate"}),e.jsxs("p",{className:"text-3xl font-black text-primary",children:[c+_>0?(c/(c+_)*100).toFixed(1):0,"%"]})]})]})]}),n&&!l&&e.jsx(Be,{tierInfo:n,nextTier:o,currentElo:s.elo_rating}),u&&e.jsx(Ae,{qrData:s.qr_data||"",qrExpiry:s.qr_expiry||new Date(Date.now()+1440*60*1e3).toISOString(),playerId:s.id,username:s.username,isOwnProfile:u,shortCode:s.quick_challenge_token||void 0,onRefresh:f=>{i(j=>j?{...j,qr_data:f.qr_data,qr_expiry:f.qr_expiry,quick_challenge_token:f.quick_challenge_token||j.quick_challenge_token}:null)}}),e.jsx(He,{currentRank:T||0,eloRating:s.elo_rating,winRate:c+_>0?c/(c+_)*100:0,wins:c,losses:_}),e.jsx("div",{className:"mb-6",children:e.jsx(Ge,{playerId:s.id})}),e.jsx("div",{className:"mb-6",children:e.jsx(Fe,{playerId:s.id,currentTScore:s.t_score})}),e.jsx(Me,{playerId:s.id,isOwnProfile:u}),e.jsxs(be,{defaultValue:"videos",className:"mb-8",children:[e.jsxs(we,{className:"grid w-full grid-cols-2",children:[e.jsx(V,{value:"videos",children:"Videos"}),e.jsx(V,{value:"posts",children:"Posts"})]}),e.jsx(W,{value:"videos",children:e.jsx(Se,{playerId:s.id})}),e.jsx(W,{value:"posts",children:e.jsx(ke,{playerId:s.id,isOwnProfile:u})})]})]})}),e.jsx(F,{})]})};export{mt 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.