1import{r,n as Ae,j as e,m as Ke}from"./vendor-ahVw9cdH.js";import{A as at}from"./AppBreadcrumb-DQQeh5xA.js";import{Z as rt,a5 as ae,a6 as re,q as ke,a7 as j,ah as nt,V as u,bZ as _e,az as k,bN as oe,bP as le,bQ as de,bR as ce,bS as me,bT as ue,bU as xe,bV as he,R as Se,ep as it,af as fe,al as De,O as te,bA as J,du as $e,eq as ot,ab as Qe,aj as se,aH as Ve,d0 as lt,fr as He,aO as Ee,aP as Pe,aX as dt,fs as Ye,c$ as We,ak as Ne,fa as Be,ai as qe,f7 as ct,am as mt,bi as ut,_ as Ue,eo as xt,hg as ht,eT as pt,be as ft,bf as gt,bg as we,ba as bt,bh as Ce,cO as vt,S as yt,fz as jt}from"./index-DXi0I5ak.js";import{g as Nt,D as wt}from"./diary-utils-uSqDg-av.js";import{a as Je}from"./query-CeIq2NOR.js";import{u as Ct}from"./useExternalSGImport-DBeOARlz.js";import{a as Rt,S as Re,b as kt,R as _t,D as St,e as Dt}from"./SGImportWizard-M_WQQhmG.js";import{S as Et}from"./SGRoundDrawer-Bkn0_EaB.js";import{g as U,a as Pt}from"./round-journey-state-CAlxnxcv.js";import{R as At}from"./RoundPreviewCard-68e0NU-r.js";import{u as It}from"./useRoundPreviewStats-B3h-OhJk.js";import{C as M}from"./clipboard-check-DOi-ALrE.js";import{C as pe}from"./circle-check-big-BdhKg125.js";import{L as zt,P as Ge}from"./PracticeTrackingComingSoonCard-C4Bedxm6.js";import{R as Tt}from"./RoundScopeLoadingBoundary-BWc5-A9a.js";import"./breadcrumb-C59QT_kB.js";import"./radix--pSzM2y8.js";import"./supabase-DYrB2Yg5.js";import"./charts-CSweoJhv.js";import"./forms-Cc1FL3tT.js";import"./elite-sg-applicability-CWAcEzPE.js";import"./slider-C_IZaYBN.js";import"./useUnifiedCoachChat-BsErDRXx.js";import"./score-utils-CbzbcqzZ.js";import"./markdown-BiKHWscL.js";import"./CourseCombobox-BysBvuu6.js";import"./command-CK_xWGRQ.js";import"./chevrons-up-down-DYfEac18.js";import"./useImportProfiles---0LjDzK.js";import"./exceljs.min-CrWE-Rna.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./LikertOptions-BoJtRtBk.js";import"./battery-cUvfyqgx.js";import"./moon-BoHG4F4i.js";import"./wind-DDM9daqs.js";import"./club-constants-CuFYEor4.js";import"./useRoundDetail-pT4ZcXk-.js";import"./TierLegend-eS4dvAPO.js";import"./golf-stat-tiers-B_t78XU2.js";import"./CircularProgress-BuIze6Y1.js";import"./download-B1xImY38.js";import"./useBottomUpKpiCategoryImpacts-DwUJ4siq.js";import"./useBottomUpReadinessMatrix-Bw0kRfNF.js";import"./RecordingQuickViewSheet-BWlxmGo4.js";import"./RecordingChecklistContent-DUePdraQ.js";import"./circle-help-BWJGwUEn.js";import"./calendar-VJ0tAwC5.js";import"./setYear-lX1ccTYE.js";import"./endOfWeek-CvZ6jUGu.js";import"./isSameDay-CFziqlbR.js";import"./parseISO-UaVqcKYW.js";import"./ruler-B9FVQEL6.js";import"./save-B9yLpn_M.js";import"./sunset-BwSPwb2z.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Lt=rt("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);function Mt({entry:s}){const[d,N]=r.useState(!1),[_,S]=r.useState(!1),[w,h]=r.useState(!1),D=Ae(),c=Je(),G=Nt(s.entry_type),p=s.text_content||s.transcribed_text||"",R=p.length>150?p.substring(0,150)+"...":p,f=s.processing_status==="draft",O=s.processing_status==="processing"||d;s.processing_status;const F=s.processing_status==="error",E=()=>O?"border-violet-500/30 bg-gradient-to-br from-violet-500/5 to-purple-500/5":f?"border-violet-500/30 bg-gradient-to-br from-violet-500/5 to-blue-500/5":F?"border-destructive/30 bg-destructive/5":"",x=async o=>{o.stopPropagation(),N(!0);try{await te.from("diary_entries").update({processing_status:"processing"}).eq("id",s.id);const{error:g}=await te.functions.invoke("analyze-diary-entry",{body:{diary_entry_id:s.id}});if(g)throw g;J.success("Reflection analyzed successfully!"),c.invalidateQueries({queryKey:["diary-entries"]}),c.invalidateQueries({queryKey:["diary-insights-summary",s.player_id]}),c.invalidateQueries({queryKey:["diary-collection-tiers",s.player_id]})}catch(g){console.error("Error processing diary entry:",g),J.error("Failed to analyze reflection"),await te.from("diary_entries").update({processing_status:"draft",error_message:String(g)}).eq("id",s.id)}finally{N(!1)}},Z=o=>{o.stopPropagation(),D(`/diary/${s.id}`)},K=o=>{o.stopPropagation(),D(`/diary/${s.id}`)},$=async()=>{S(!0);try{const{error:o}=await te.from("diary_entries").delete().eq("id",s.id);if(o)throw o;J.success("Reflection deleted"),c.invalidateQueries({queryKey:["diary-entries"]}),c.invalidateQueries({queryKey:["diary-insights-summary",s.player_id]}),h(!1)}catch(o){console.error("Error deleting diary entry:",o),J.error("Failed to delete reflection")}finally{S(!1)}},B=()=>{D(`/diary/${s.id}`)},q=()=>O?e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",disabled:!0,children:[e.jsx(Se,{className:"h-4 w-4 mr-1 animate-spin"}),"Analyzing..."]}):f?s.source_thread_id?e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",onClick:Z,children:[e.jsx(it,{className:"h-4 w-4 mr-1"}),"Continue Reflection"]}):e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",onClick:x,children:[e.jsx(fe,{className:"h-4 w-4 mr-1"}),"Process & Analyze"]}):F?e.jsxs(u,{size:"sm",variant:"outline",className:"flex-1",onClick:x,children:[e.jsx(fe,{className:"h-4 w-4 mr-1"}),"Retry Analysis"]}):e.jsxs(u,{variant:"outline",size:"sm",className:"flex-1",onClick:K,children:[e.jsx(De,{className:"h-4 w-4 mr-1"}),"View Details"]}
6);return e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:k("transition-all cursor-pointer hover:shadow-md",E()),onClick:B,children:e.jsxs(re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[G.icon," ",G.label]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ke(new Date(s.entry_date),"EEEE, MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1.5 shrink-0",children:[e.jsx(wt,{processingStatus:s.processing_status}),s.round_id&&e.jsxs(j,{variant:"outline",className:"text-[10px] gap-1 border-muted text-muted-foreground whitespace-nowrap px-1.5 py-0",children:[e.jsx(nt,{className:"h-2.5 w-2.5"}),"Linked Round"]})]})]}),R&&e.jsxs("p",{className:"text-xs text-muted-foreground italic line-clamp-2 mt-2",children:['"',R,'"']}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[q(),e.jsx(u,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:o=>{o.stopPropagation(),h(!0)},children:e.jsx(_e,{className:"h-4 w-4"})})]})]})}),e.jsx(oe,{open:w,onOpenChange:h,children:e.jsxs(le,{children:[e.jsxs(de,{children:[e.jsx(ce,{children:"Delete Reflection?"}),e.jsx(me,{children:"This will permanently delete this reflection and all its insights. This action cannot be undone."})]}),e.jsxs(ue,{children:[e.jsx(xe,{children:"Cancel"}),e.jsxs(he,{onClick:$,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:_,children:[_?e.jsx(Se,{className:"h-4 w-4 animate-spin mr-2"}):null,"Delete"]})]})]})})]})}const Ot=[{date:"Today",title:"Pre-tournament nerves",mood:"Anxious",moodClass:"bg-amber-500/10 text-amber-600"},{date:"Yesterday",title:"Range work felt sharp",mood:"Confident",moodClass:"bg-emerald-500/10 text-emerald-600"}],Ft=["Pre-shot routine","Course management","Self-talk"];function Bt(){return e.jsxs("div",{className:"space-y-2",children:[Ot.map((s,d)=>e.jsx(ae,{children:e.jsxs(re,{className:"p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:s.date}),e.jsx("span",{className:`text-[10px] font-medium px-2 py-0.5 rounded-full ${s.moodClass}`,children:s.mood})]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx($e,{className:"h-3 w-3 text-teal-500"}),s.title]})]})},d)),e.jsx(ae,{children:e.jsxs(re,{className:"p-3 space-y-1.5",children:[e.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(fe,{className:"h-3 w-3 text-violet-500"})," Recurring themes"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ft.map(s=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-violet-500/10 text-violet-600",children:s},s))})]})})]})}const qt=[{course:"Pine Valley GC",date:"Saturday, Mar 8, 2026",sg:1.82},{course:"Pebble Beach",date:"Sunday, Mar 2, 2026",sg:-.4}];function Ut(){return e.jsx("div",{className:"space-y-2",children:qt.map((s,d)=>e.jsx(ae,{children:e.jsxs(re,{className:"p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:s.date}),e.jsx(ot,{value:s.sg})]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx(Qe,{className:"h-3 w-3 text-emerald-500"}),s.course]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(se,{className:"h-3 w-3 text-violet-500"}),"Record Round Note"]})]})},d))})}function Gt({newRoundToken:s=0}={}){const[d,N]=Ke(),[_,S]=r.useState(s>0),[w,h]=r.useState(null);r.useEffect(()=>{s>0&&S(!0)},[s]);const[D,c]=r.useState(!1),[G,p]=r.useState(!1),[R,f]=r.useState(!1),[O,F]=r.useState(null),[E,x]=r.useState(null),[Z,K]=r.useState(null),[$,B]=r.useState(!1),[q,o]=r.useState(null),{roundFilter:g,customDateRange:X,setRoundFilter:Ie,setCustomDateRange:T}=Ve(),[b,L]=r.useState("all"),P=Ae();r.useEffect(()=>{const t=d.get("resumeRoundId")||d.get("review");t&&(h(t),d.delete("resumeRoundId"),d.delete("review"),N(d,{replace:!0}))},[d,N]);const{data:v}=lt(),Q=Je(),{data:A,isLoading:ge,refetch:ne}=He(),ie=Ct(),{byRoundId:i,byExternalId:y,isLoading:C}=It(v!=null&&v.id?[v.id]:[],g,X),{drafts:V}=Rt({includeCompletedReflection:!0}
6),Ze=async()=>{if(O)try{await te.from("rounds").delete().eq("id",O),Q.invalidateQueries({queryKey:["draft-rounds"]}),Q.invalidateQueries({queryKey:["rounds"]}),Q.invalidateQueries({queryKey:["coach-imported-rounds"]}),Dt(),J.success("Draft round deleted"),f(!1),F(null)}catch{J.error("Failed to delete draft")}};r.useEffect(()=>{ne()},[ne]);const H=r.useMemo(()=>A?Ee(A,g,X,"round_date"):[],[A,g,X,Pe()]),ze=r.useMemo(()=>{const t=new Set;return(A||[]).forEach(n=>{var a;(a=n.match)!=null&&a.round_id&&t.add(n.match.round_id)}),t},[A]),Y=r.useMemo(()=>(V||[]).filter(t=>!ze.has(t.id)),[V,ze]),be=H.filter(t=>!t.match),ve=H.filter(t=>t.match?U(t.match,t.id,t.round_date,t.course_name||void 0).shouldResume:!1),ye=H.filter(t=>{if(!t.match)return!1;const n=U(t.match,t.id,t.round_date,t.course_name||void 0);return n.isComplete&&!n.shouldResume}),Te=r.useMemo(()=>{const t={all:0,setup:0,checkin:0,recording:0,reflection:0,review:0,completed:0};return(Y||[]).forEach(n=>{const a=n.post_round_context;a!=null&&a.reflection_completed_at?n.processing_status==="approved"||n.processing_status==="analyzed"?t.completed++:t.review++:n.end_time?t.reflection++:n.pre_round_context?t.recording++:t.checkin++}),H.forEach(n=>{const a=U(n.match,n.id,n.round_date,n.course_name||void 0);t[a.journeyStep]++}),t.all=t.setup+t.checkin+t.recording+t.reflection+t.review+t.completed,t},[Y,H]),W=r.useMemo(()=>b==="all"?Y||[]:(Y||[]).filter(t=>{const n=t.post_round_context;let a;return n!=null&&n.reflection_completed_at?a=t.processing_status==="approved"||t.processing_status==="analyzed"?"completed":"review":t.end_time?a="reflection":t.pre_round_context?a="recording":a="checkin",a===b}),[Y,b]),I=r.useMemo(()=>b==="all"?{unlinked:be,inProgress:ve,completed:ye}:{unlinked:be.filter(t=>U(t.match,t.id,t.round_date,t.course_name||void 0).journeyStep===b),inProgress:ve.filter(t=>U(t.match,t.id,t.round_date,t.course_name||void 0).journeyStep===b),completed:ye.filter(t=>U(t.match,t.id,t.round_date,t.course_name||void 0).journeyStep===b)},[b,be,ve,ye]),z=ie.isPending,Xe=async()=>{if(E)try{await ie.mutateAsync(E.id),p(!1),c(!1),x(null)}catch(t){console.error("Error deleting round:",t)}},je=({sg:t,status:n})=>{var Oe,Fe;const a=r.useMemo(()=>U(t.match,t.id,t.round_date,t.course_name||void 0),[t]),Le=()=>n==="unlinked"?"border-amber-500/30 bg-gradient-to-br from-amber-500/5 to-orange-500/5":a.shouldResume?"border-violet-500/30 bg-gradient-to-br from-violet-500/5 to-blue-500/5":a.displayState==="pending_review"||a.displayState==="ready_for_analysis"?"border-violet-500/30 bg-gradient-to-br from-violet-500/5 to-purple-500/5":"",ee=()=>{if(a.displayState==="approved")return e.jsxs(j,{variant:"outline",className:"text-emerald-600 border-emerald-500/30 bg-emerald-500/10",children:[e.jsx(mt,{className:"h-3 w-3 mr-1"}),"Approved"]});if(a.shouldResume){const l={setup:{label:"Setup",className:"text-muted-foreground border-border",icon:e.jsx(qe,{className:"h-3 w-3 mr-1"})},checkin:{label:"Check-In",className:"text-amber-600 border-amber-500/30 bg-amber-500/10",icon:e.jsx(M,{className:"h-3 w-3 mr-1"})},recording:{label:"Recording",className:"text-violet-600 border-violet-500/30 bg-violet-500/10 animate-pulse",icon:e.jsx(se,{className:"h-3 w-3 mr-1"})},reflection:{label:"Reflection",className:"text-violet-600 border-violet-500/30 bg-violet-500/10",icon:e.jsx(Ne,{className:"h-3 w-3 mr-1"})},review:{label:"Review",className:"text-violet-600 border-violet-500/30 bg-violet-500/10",icon:e.jsx(M,{className:"h-3 w-3 mr-1"})},completed:{label:"Complete",className:"text-emerald-600 border-emerald-500/30 bg-emerald-500/10",icon:e.jsx(pe,{className:"h-3 w-3 mr-1"})}},m=l[a.journeyStep]||l.recording;return e.jsxs(j,{variant:"outline",className:k("text-xs",m.className),children:[m.icon,m.label]})}return a.displayState==="pending_review"?e.jsxs(j,{variant:"outline",className:"text-violet-600 dark:text-violet-400 border-violet-500/30 bg-violet-500/10",children:[e.jsx(M,{className:"h-3 w-3 mr-1"}),"Review"]}):a.displayState==="ready_for_analysis"?e.jsx(j,{variant:"outline",className:"text-blue-600 dark:text-blue-400 border-blue-500/30 bg-blue-500/10",children:"Ready for Analysis"}):e.jsx(j,{variant:"outline",className:"text-amber-600 border-amber-500/30 bg-amber-500/10",children:"Ready for Round Notes"})},Me=l=>{l&&l.stopPropagation();const m=Pt(a,t.id,t.round_date,t.course_name||void 0);m.type==="wizard"?h(m.roundId):m.type==="navigate"?P(m.path):m.type==="drawer"&&(K(t),B(!0))},et=()=>a.displayState==="approved"?e.jsxs(u,{variant:"outline",size:"sm",className:"flex-1",onClick:l=>{var m;l.stopPropagation(),P(`/rounds/${(m=t.match)==null?void 0:m.round_id}`)},children:[e.jsx(De,{className:"h-4 w-4 mr-1"}),"View Details"]}
6):a.shouldResume?e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",onClick:l=>Me(l),children:[e.jsx(Be,{className:"h-4 w-4 mr-1"}),"Resume Round"]}):a.displayState==="pending_review"?e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",onClick:l=>{var m;l.stopPropagation(),P(`/rounds/${(m=t.match)==null?void 0:m.round_id}`)},children:[e.jsx(M,{className:"h-4 w-4 mr-1"}),"Review & Approve"]}):a.displayState==="ready_for_analysis"?e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",onClick:l=>{var m;l.stopPropagation(),P(`/rounds/${(m=t.match)==null?void 0:m.round_id}`)},children:[e.jsx(fe,{className:"h-4 w-4 mr-1"}),"Analyze Round"]}):e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700",onClick:l=>{l.stopPropagation(),P(`/talk?mode=round&sgId=${t.id}&sgDate=${t.round_date}&sgCourse=${encodeURIComponent(t.course_name||"")}`)},children:[e.jsx(se,{className:"h-4 w-4 mr-1"}),"Record Round Note"]});a.shouldResume;const tt=()=>{var l;if(a.shouldResume){Me();return}n==="unlinked"?(K(t),B(!0)):a.canViewDetails&&((l=t.match)!=null&&l.round_id)&&P(`/rounds/${t.match.round_id}`)},st=((Oe=t.match)!=null&&Oe.round_id?i.get(t.match.round_id):void 0)??y.get(t.id);return e.jsx(At,{className:Le(),onClick:tt,courseName:t.course_name||"Unknown Course",dateLabel:ke(new Date(t.round_date),"EEEE, MMM d, yyyy"),stats:st,statsLoading:C,badges:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex items-center gap-2",children:ee()})}),actions:e.jsxs(e.Fragment,{children:[et(),a.canViewDetails&&((Fe=t.match)==null?void 0:Fe.round_id)&&e.jsx(u,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-primary shrink-0",onClick:l=>{l.stopPropagation(),o(t.match.round_id)},children:e.jsx(ct,{className:"h-4 w-4"})}),e.jsx(u,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:l=>{l.stopPropagation(),x(t),c(!0)},children:e.jsx(_e,{className:"h-4 w-4"})})]})})};return ge?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx(dt,{className:"h-32 w-full"},t))}):(!A||A.length===0)&&Y.length===0?e.jsxs(e.Fragment,{children:[e.jsx(Ye,{page:"activity",roundsRecorded:0,children:e.jsx(Ut,{})}),e.jsx(Re,{open:_,onOpenChange:S})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(We,{value:g,onChange:Ie,customDateRange:X,onCustomDateRangeChange:T}),e.jsx("div",{className:"flex gap-1.5 overflow-x-auto pb-1 -mx-1 px-1",children:[{key:"all",label:"All",icon:null},{key:"checkin",label:"Check-In",icon:e.jsx(M,{className:"h-3 w-3"})},{key:"recording",label:"Recording",icon:e.jsx(se,{className:"h-3 w-3"})},{key:"reflection",label:"Reflection",icon:e.jsx(Ne,{className:"h-3 w-3"})},{key:"review",label:"Review",icon:e.jsx(De,{className:"h-3 w-3"})},{key:"completed",label:"Completed",icon:e.jsx(pe,{className:"h-3 w-3"})}].map(t=>e.jsxs("button",{onClick:()=>L(t.key),className:k("flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium whitespace-nowrap transition-colors border shrink-0",b===t.key?"bg-primary text-primary-foreground border-primary":"bg-muted/50 text-muted-foreground border-border hover:bg-muted"),children:[t.icon,t.label,Te[t.key]>0&&e.jsx("span",{className:k("ml-0.5 text-[10px] min-w-[16px] h-4 flex items-center justify-center rounded-full",b===t.key?"bg-primary-foreground/20":"bg-muted-foreground/20"),children:Te[t.key]})]},t.key))}),W&&W.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-violet-700 dark:text-violet-400",children:"In Progress"}),e.jsx(j,{variant:"outline",className:"text-violet-600 border-violet-500/30",children:W.length})]}),W.map(t=>{const n=t.post_round_context;let a;n!=null&&n.reflection_completed_at?a=t.processing_status==="approved"||t.processing_status==="analyzed"?"completed":"review":t.end_time?a="reflection":t.pre_round_context?a="recording":a="checkin";const ee={setup:{label:"Setup",className:"text-muted-foreground border-border",icon:e.jsx(qe,{className:"h-3 w-3 mr-0.5"})},checkin:{label:"Check-In",className:"text-amber-600 border-amber-500/30 bg-amber-500/10",icon:e.jsx(M,{className:"h-3 w-3 mr-0.5"})},recording:{label:"Recording",className:"text-blue-600 border-blue-500/30 bg-blue-500/10",icon:e.jsx(se,{className:"h-3 w-3 mr-0.5"})},reflection:{label:"Reflection",className:"text-violet-600 border-violet-500/30 bg-violet-500/10",icon:e.jsx(Ne,{className:"h-3 w-3 mr-0.5"})},review:{label:"Review",className:"text-violet-600 border-violet-500/30 bg-violet-500/10",icon:e.jsx(M,{className:"h-3 w-3 mr-0.5"})},completed:{label:"Complete",className:"text-emerald-600 border-emerald-500/30 bg-emerald-500/10",icon:e.jsx(pe,{className:"h-3 w-3 mr-0.5"})}}[a];return e.jsx(ae,{className:k("transition-all","border-violet-500/30 bg-gradient-to-br from-violet-500/5 to-blue-500/5"),children:e.jsxs(re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:t.course_name||"Unknown Course"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ke(new Date(t.created_at),"MMM d, yyyy")})]}),e.jsxs(j,{variant:"outline",className:k("text-xs shrink-0",ee.className,a==="recording"&&"animate-pulse"),children:[ee.icon,ee.label]})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[a==="review"?e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",onClick:()=>
6{h(t.id)},children:[e.jsx(M,{className:"h-4 w-4 mr-1"}),"Review & Approve"]}):e.jsxs(u,{size:"sm",className:"flex-1 bg-violet-600 hover:bg-violet-700 text-white",onClick:()=>{h(t.id)},children:[e.jsx(Be,{className:"h-4 w-4 mr-1"}),"Resume Round"]}),e.jsx(u,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:()=>{F(t.id),f(!0)},children:e.jsx(_e,{className:"h-4 w-4"})})]})]})},t.id)})]}),H.length===0&&(!W||W.length===0)&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No rounds match the selected filters"}),I.unlinked.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-amber-700 dark:text-amber-400",children:"Ready for Round Notes"}),e.jsx(j,{variant:"outline",className:"text-amber-600 border-amber-500/30",children:I.unlinked.length})]}),I.unlinked.map(t=>e.jsx(je,{sg:t,status:"unlinked"},t.id))]}),I.inProgress.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-blue-700 dark:text-blue-400",children:"In Progress"}),e.jsx(j,{variant:"outline",className:"text-blue-600 border-blue-500/30",children:I.inProgress.length})]}),I.inProgress.map(t=>e.jsx(je,{sg:t,status:"in_progress"},t.id))]}),I.completed.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Rounds"}),e.jsxs(j,{variant:"outline",className:"text-emerald-600 border-emerald-500/30",children:["Complete ",I.completed.length]})]}),I.completed.map(t=>e.jsx(je,{sg:t,status:"completed"},t.id))]}),e.jsx(Re,{open:_,onOpenChange:S}),w&&e.jsx(Re,{open:!!w,onOpenChange:t=>{t||(h(null),Q.invalidateQueries({queryKey:["draft-rounds"]}))},initialDraftRoundId:w}),e.jsx(Et,{open:$,onOpenChange:B,sgData:Z}),q&&e.jsx(kt,{open:!!q,onOpenChange:t=>{t||o(null)},roundId:q,playerId:v==null?void 0:v.id}),e.jsx(oe,{open:D,onOpenChange:t=>{z||c(t)},children:e.jsxs(le,{className:"overflow-hidden",onEscapeKeyDown:t=>{z&&t.preventDefault()},children:[e.jsxs(de,{children:[e.jsx(ce,{children:"Delete Round"}),e.jsxs(me,{children:["Are you sure you want to delete this round from ",(E==null?void 0:E.course_name)||"Unknown Course","? This action cannot be undone."]})]}),e.jsxs(ue,{children:[e.jsx(xe,{disabled:z,children:"Cancel"}),e.jsx(he,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:z,onClick:t=>{t.preventDefault(),c(!1),p(!0)},children:"Delete"})]})]})}),e.jsx(oe,{open:G,onOpenChange:t=>{z||p(t)},children:e.jsxs(le,{className:"overflow-hidden",onEscapeKeyDown:t=>{z&&t.preventDefault()},children:[e.jsxs(de,{children:[e.jsx(ce,{children:"Are you absolutely sure?"}),e.jsx(me,{children:"Deleting this round will permanently remove all shots, mental metrics and recorded data. Your player profile will be recalculated, which can take up to a minute."})]}),e.jsxs(ue,{children:[e.jsx(xe,{disabled:z,children:"Cancel"}),e.jsx(he,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:z,onClick:t=>{t.preventDefault(),Xe()},children:"Yes, permanently delete"})]}),z&&e.jsx(_t,{title:"Deleting your round",messages:St})]})}),e.jsx(oe,{open:R,onOpenChange:f,children:e.jsxs(le,{children:[e.jsxs(de,{children:[e.jsx(ce,{children:"Delete Draft Round"}),e.jsx(me,{children:"Delete this draft round? Any pre-round check-in data will be lost."})]}),e.jsxs(ue,{children:[e.jsx(xe,{children:"Cancel"}),e.jsx(he,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:Ze,children:"Delete"})]})]})})]})}function Ks(){const s=Ae(),[d,N]=Ke(),{userId:_,sessionReady:S}=ut(),w=_??void 0,h=Ue("LIFESTYLE_FEATURES_ENABLED"),D=Ue("PRACTICE_FEATURES_ENABLED"),c=d.get("tab")||"rounds",G=c==="on-course"?"rounds":c==="off-course"||c==="diary"?"lifestyle":c,{roundFilter:p,customDateRange:R,customN:f,setRoundFilter:O,setCustomDateRange:F,setCustomN:E}=Ve(),[x,Z]=r.useState("all"),[K,$]=r.useState(!1);r.useEffect(()=>{S&&!_&&s("/auth")},[S,_,s]);const[B,q]=r.useState(0);r.useEffect(()=>{if(d.get("new")!=="round")return;q(y=>y+1);const i=new URLSearchParams(d);i.delete("new"),i.set("tab","rounds"),N(i,{replace:!0})},[d,N]),r.useEffect(()=>{const i=d.get("new")==="1";if(c==="on-course"||c==="off-course"||c==="diary"||i){const C=i?"lifestyle":c==="on-course"?"rounds":"lifestyle",V=new URLSearchParams(d);V.set("tab",C),i&&V.delete("new"),N(V,{replace:!0})}i&&$(!0)},[c,d,N]);const{data:o,isLoading:g}=xt(w),{data:X,isLoading:Ie}=He(),{data:T,isLoading:b}=ht(w),L=r.useMemo(()=>!o||o.length===0?[]:Ee(o,p,"entry_date",{customDateRange:R,customN:f}),[o,p,R,f,Pe()]);r.useMemo(()=>!T||T.length===0?[]:Ee(T,p,"saved_at",{customDateRange:R,customN:f}),[T,p,R,f,Pe()]);const P=r.useMemo(()=>{const i={all:0,draft:0,processing:0,analyzed:0,error:0};
6return i.all=L.length,L.forEach(y=>{const C=y.processing_status||"draft";i[C]!==void 0&&i[C]++}),i},[L]),v=r.useMemo(()=>[...x==="all"?L:L.filter(y=>(y.processing_status||"draft")===x)].sort((y,C)=>new Date(C.entry_date).getTime()-new Date(y.entry_date).getTime()),[L,x]),Q=i=>{N(y=>{const C=new URLSearchParams(y);return C.set("tab",i),C})},A=o&&o.length>0,ge=T&&T.length>0,ne=A||ge,ie=g||b;return w?e.jsxs("div",{className:"space-y-3",children:[e.jsx(at,{items:[{label:"Home",href:"/dashboard"},{label:"Activity"}]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(pt,{className:"h-6 w-6 text-orange-500"}),"Activity"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your activity page"})]}),e.jsxs(ft,{value:G,onValueChange:Q,className:"w-full",children:[(h||D)&&e.jsxs(gt,{className:"grid w-full grid-cols-3",children:[e.jsxs(we,{value:"rounds",className:"flex items-center gap-2 text-emerald-600 dark:text-emerald-400",children:[e.jsx(Qe,{className:"h-4 w-4"}),"On-Course"]}),e.jsxs(we,{value:"lifestyle",className:k("flex items-center gap-2 text-teal-600 dark:text-teal-400",!h&&"opacity-70"),children:[e.jsx($e,{className:"h-4 w-4"}),"Off-Course"]}),e.jsxs(we,{value:"practice",className:k("flex items-center gap-2 text-blue-600 dark:text-blue-400",!D&&"opacity-70"),children:[e.jsx(bt,{className:"h-4 w-4"}),"Practice"]})]}),e.jsx(Ce,{value:"rounds",className:"mt-4 space-y-3",children:e.jsx(Tt,{variant:"rounds",children:e.jsx(Gt,{newRoundToken:B})})}),e.jsx(Ce,{value:"lifestyle",className:"mt-4 space-y-3",children:h?ie?e.jsx(vt,{}):ne?e.jsxs(e.Fragment,{children:[e.jsx(We,{value:p,onChange:O,customDateRange:R,onCustomDateRangeChange:F,customN:f,onCustomNChange:E}),e.jsx("div",{className:"flex gap-1.5 overflow-x-auto pb-1 -mx-1 px-1",children:[{key:"all",label:"All",icon:null},{key:"draft",label:"Draft",icon:e.jsx(Lt,{className:"h-3 w-3"})},{key:"processing",label:"Processing",icon:e.jsx(Se,{className:"h-3 w-3"})},{key:"analyzed",label:"Analyzed",icon:e.jsx(pe,{className:"h-3 w-3"})},{key:"error",label:"Error",icon:e.jsx(yt,{className:"h-3 w-3"})}].map(i=>e.jsxs("button",{onClick:()=>Z(i.key),className:k("flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium whitespace-nowrap transition-colors border shrink-0",x===i.key?"bg-primary text-primary-foreground border-primary":"bg-muted/50 text-muted-foreground border-border hover:bg-muted"),children:[i.icon,i.label,P[i.key]>0&&e.jsx("span",{className:k("ml-0.5 text-[10px] min-w-[16px] h-4 flex items-center justify-center rounded-full",x===i.key?"bg-primary-foreground/20":"bg-muted-foreground/20"),children:P[i.key]})]},i.key))}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-semibold text-base",children:x==="all"?"All activities":x.charAt(0).toUpperCase()+x.slice(1)}),e.jsxs(j,{variant:"secondary",className:"text-xs",children:[v.length," ",v.length===1?"entry":"entries"]})]}),e.jsx("div",{className:"space-y-3",children:v.length>0?v.map(i=>e.jsx(Mt,{entry:i},`reflection-${i.id}`)):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No entries in this time period"})})]})]}):e.jsx(Ye,{page:"diary",hideProgress:!0,children:e.jsx(Bt,{})}):e.jsx(zt,{})}),e.jsx(Ce,{value:"practice",className:"mt-4 space-y-3",children:D?e.jsx(Ge,{}):e.jsx(Ge,{})})]}),w&&e.jsx(jt,{open:K,onOpenChange:$,payload:{contextType:"diary_reflection",contextKey:"default",pageTitle:"Activity",viewerRole:"player",contextData:{userId:w}}})]}):null}export{Ks 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.