1import{z as O,j as e,a_ as G,bT as I,bU as K,aB as Y,bV as U,B as S,e as k,p as V,cv as _,i as R,Y as C,a0 as q,a1 as W,a2 as z,a3 as J,a4 as X,T as $,w as E,C as u,d as g,cw as Q,b as p,c as j,bq as A,s as Z,bl as D,R as ee,V as se}from"./index-DGo-vssZ.js";import{r as f}from"./vendor-Qgthw7N1.js";import{S as re,u as te}from"./useParallelQueries-BP3is_yX.js";import{A as F}from"./activity-BpWmCysw.js";import{n as ae,B as H,X as v,Y as b,o as oe,R as M,s as ie,T as N,L as T,C as w}from"./generateCategoricalChart-Ccg4ytiv.js";import{P as le,a as ne}from"./PieChart-DvPtr6vS.js";import{L as ce,a as P}from"./LineChart-D1bfgCBJ.js";import{A as de,a as L}from"./AreaChart-CfNv0fRv.js";/** 2 * @license lucide-react v0.453.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 xe=O("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);var me=ae({chartName:"BarChart",GraphicalChild:H,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:v},{axisType:"yAxis",AxisComp:b}],formatAxisMap:oe});function he({user:s,onStrategyChange:n}){const[t,o]=f.useState(!1),i=()=>{try{const d=sessionStorage.getItem("analytics-view-strategy");if(d)return JSON.parse(d)}catch(d){console.error("Error reading stored strategy:",d)}return{repType:(s==null?void 0:s.repType)||"longTerm",strSubType:(s==null?void 0:s.strSubType)||"path_500"}},[r,a]=f.useState(i);f.useEffect(()=>{try{sessionStorage.setItem("analytics-view-strategy",JSON.stringify(r))}catch(d){console.error("Error saving strategy to sessionStorage:",d)}n(r)},[r,n]);const l=d=>{d!==r.repType&&(d==="shortTerm"?o(!0):a({repType:d,strSubType:void 0}))},h=d=>{a({repType:"shortTerm",strSubType:d}),o(!1)},m=()=>{if(r.repType==="longTerm")return"750 hrs";if(r.repType==="shortTerm"){if(r.strSubType==="path_500")return"500 hrs";if(r.strSubType==="path_100")return"100 hrs"}return"750 hrs"},c=r.repType!==(s==null?void 0:s.repType)||r.repType==="shortTerm"&&r.strSubType!==(s==null?void 0:s.strSubType);return e.jsxs("div",{className:"inline-flex items-center gap-3",children:[e.jsx(G,{children:e.jsxs(I,{children:[e.jsx(K,{children:e.jsx(Y,{className:"h-4 w-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"})}),e.jsx(U,{children:e.jsx("p",{className:"text-sm",children:"View analytics using different goal tracking strategies"})})]})}),e.jsxs("div",{className:"flex items-center bg-gray-100 dark:bg-gray-700 rounded-full p-1",children:[e.jsx(S,{variant:r.repType==="longTerm"?"default":"ghost",size:"sm",className:`h-8 px-3 text-xs rounded-full transition-all ${r.repType==="longTerm"?"bg-green-600 text-white shadow-sm hover:bg-green-700":"bg-transparent text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600"}`,onClick:()=>l("longTerm"),children:"LTR"}),e.jsx(S,{variant:r.repType==="shortTerm"?"default":"ghost",size:"sm",className:`h-8 px-3 text-xs rounded-full transition-all ${r.repType==="shortTerm"?"bg-green-600 text-white shadow-sm hover:bg-green-700":"bg-transparent text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600"}`,onClick:()=>l("shortTerm"),children:"STR"})]}),e.jsx(k,{variant:"outline",className:"text-xs",children:m()}),c&&e.jsx(k,{variant:"secondary",className:"text-xs",children:"View Only"}),e.jsx(re,{isOpen:t,onClose:()=>o(!1),onSelectionComplete:h})]})}const ue=[{value:"7d",label:"Last 7 Days"},{value:"30d",label:"Last 30 Days"},{value:"90d",label:"Last 90 Days"},{value:"1y",label:"Last Year"}],x={primary:"#3b82f6",secondary:"#10b981",accent:"#f59e0b",danger:"#ef4444",muted:"#6b7280"};function ge({analyticsData:s,isLoading:n}){var i,r,a;const t=(s==null?void 0:s.goalHours)||750;s!=null&&s.materialGoalHours;const o=[{title:"Total Hours",value:((i=s==null?void 0:s.totalHours)==null?void 0:i.toFixed(1))||"0.0",icon:R,change:"+12%",changeType:"positive",subtitle:"This period"},{title:"Material Hours",value:((r=s==null?void 0:s.materialParticipationHours)==null?void 0:r.toFixed(1))||"0.0",icon:$,change:"+8%",changeType:"positive",subtitle:"REP qualifying"},{title:"Activities Logged",value:((a=s==null?void 0:s.totalActivities)==null?void 0:a.toString())||"0",icon:F,change:"+5%",changeType:"positive",subtitle:"Total entries"},{title:"Goal Progress",value:`${Math.min(((s==null?void 0:s.totalHours)||0)/t*100,100).toFixed(1)}%`,icon:E,change:"+2%",changeType:"positive",subtitle:`Toward ${t} hrs`}];return n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:[1,2,3,4].map(l=>e.jsx(u,{children:e.jsxs(g,{className:"p-6",children:[e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})]})},l))}):e.jsx("div",{"data-tour":"analytics-summary",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:o.map((l,h)=>{const m=l.icon;return e.jsx(u,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:l.title}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-2xl font-bold",children:l.value}),e.jsxs("div",{className:`flex items-center text-sm ${l.changeType==="positive"?"text-green-600":"text-red-600"}`,children:[l.changeType==="positive"?e.jsx(Q,{className:"h-4 w-4"}):e.jsx(xe,{className:"h-4 w-4"}),e.jsx("span",{children:l.change})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.subt
6itle})]}),e.jsx("div",{className:"p-3 bg-primary/10 rounded-lg",children:e.jsx(m,{className:"h-6 w-6 text-primary"})})]})})},h)})})}function pe({timeSeriesData:s,isLoading:n}){const[t,o]=f.useState("area");if(n)return e.jsxs(u,{className:"mb-8",children:[e.jsx(p,{children:e.jsx(j,{children:"Hours Tracked Over Time"})}),e.jsx(g,{children:e.jsx("div",{className:"h-80 bg-gray-100 dark:bg-gray-800 rounded animate-pulse"})})]});if(!s||s.length===0)return e.jsxs(u,{className:"mb-8",children:[e.jsx(p,{children:e.jsx(j,{children:"Hours Tracked Over Time"})}),e.jsx(g,{children:e.jsx("div",{className:"h-80 flex items-center justify-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Z,{className:"h-12 w-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{className:"text-lg font-medium",children:"No Time Data Available"}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Start logging time entries to see your progress chart."})]})})})]});const i=s.map(a=>({date:new Date(a.date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),totalHours:a.hours||0,materialHours:a.materialHours||0,activityCount:a.activityCount||0})),r=()=>{const a={data:i,margin:{top:5,right:30,left:20,bottom:5}};switch(t){case"area":return e.jsxs(de,{...a,children:[e.jsx(w,{strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"date"}),e.jsx(b,{}),e.jsx(N,{}),e.jsx(T,{}),e.jsx(L,{type:"monotone",dataKey:"totalHours",stackId:"1",stroke:x.primary,fill:x.primary,fillOpacity:.6,name:"Total Hours"}),e.jsx(L,{type:"monotone",dataKey:"materialHours",stackId:"2",stroke:x.secondary,fill:x.secondary,fillOpacity:.6,name:"Material Hours"})]});case"bar":return e.jsxs(me,{...a,children:[e.jsx(w,{strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"date"}),e.jsx(b,{}),e.jsx(N,{}),e.jsx(T,{}),e.jsx(H,{dataKey:"totalHours",fill:x.primary,name:"Total Hours"}),e.jsx(H,{dataKey:"materialHours",fill:x.secondary,name:"Material Hours"})]});default:return e.jsxs(ce,{...a,children:[e.jsx(w,{strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"date"}),e.jsx(b,{}),e.jsx(N,{}),e.jsx(T,{}),e.jsx(P,{type:"monotone",dataKey:"totalHours",stroke:x.primary,strokeWidth:3,name:"Total Hours",dot:{fill:x.primary}}),e.jsx(P,{type:"monotone",dataKey:"materialHours",stroke:x.secondary,strokeWidth:3,name:"Material Hours",dot:{fill:x.secondary}})]})}};return e.jsxs(u,{"data-tour":"analytics-charts",className:"mb-8",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsx(j,{className:"text-lg font-semibold",children:"Hours Tracked Over Time"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>o("area"),className:`px-3 py-1 text-sm rounded ${t==="area"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"Area"}),e.jsx("button",{onClick:()=>o("line"),className:`px-3 py-1 text-sm rounded ${t==="line"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"Line"}),e.jsx("button",{onClick:()=>o("bar"),className:`px-3 py-1 text-sm rounded ${t==="bar"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"Bar"})]})]})}),e.jsx(g,{children:e.jsx(M,{width:"100%",height:300,children:r()})})]})}function je({analyticsData:s}){const n=(s==null?void 0:s.totalHours)||0,t=(s==null?void 0:s.materialParticipationHours)||0,o=(s==null?void 0:s.goalHours)||750,i=(s==null?void 0:s.materialGoalHours)||500,r=Math.min(n/o*100,100),a=Math.min(t/i*100,100),l=n>=o?"complete":n>=o*.67?"on-track":"needs-attention",h=l==="complete"?"text-green-600":l==="on-track"?"text-yellow-600":"text-red-600",m=l==="complete"?"bg-green-100":l==="on-track"?"bg-yellow-100":"bg-red-100";return e.jsxs(u,{className:"mb-8",children:[e.jsx(p,{children:e.jsxs(j,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx($,{className:"h-5 w-5 mr-2 text-primary"}),"Goal Status Progress"]}),e.jsx(k,{className:`${m} ${h} border-0`,children:l==="complete"?"Complete":l==="on-track"?"On Track":"Needs Focus"})]})}),e.jsx(g,{children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Total Hours Goal"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[n.toFixed(1)," / ",o," hrs"]})]}),e.jsx(A,{value:r,className:"h-3"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.toFixed(1),"% complete"]})]}),e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{width:"120",height:"120",className:"transform -rotate-90",children:[e.jsx("circle",{cx:"60",cy:"60",r:"50",fill:"none",stroke:"currentColor",strokeWidth:"8",className:"text-gray-200 dark:text-gray-700"}),e.jsx("circle",{cx:"60",cy:"60",r:"50",fill:"none",stroke:"currentColor",strokeWidth:"8",strokeDasharray:`${r/100*314.16} 314.16`,className:"text-primary transition-all duration-500",strokeLinecap:"round"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-2xl font-bold text-primary",children:[r.toFixed(1),"%"]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Complete"})]})})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Material Participation"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.toFixed(1)," / ",i," hrs"]})]}),e.jsx(A,{value:a,className:"h-3"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a.toFixed(1),"% complete"]})]}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Hours This Month:"}),e.jsx("span",{className:"font-medium",children:"0.0 hrs"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Average Daily:"}),e.jsxs("span",{className:"font-medium",children:[(n/365).toFixed(1)," hrs"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Days Remaining:"}),e.jsxs("span",{className:"font-medium",children:[Math.ceil((new Date(new Date().getFullYear(),11,31).getTime()-new Date().getTime())/(1e3*60*60*24))," ","days"]})]})]})]})]})})]})}function ye({activityData:s,isLoading:n}){if(n)return e.jsxs(u,{children:[e.jsx(p,{children:e.jsx(j,{children:"Activity Breakdown"})}),e.jsx(g,{children:e.jsx("div",{className:"h-64 bg-gray-100 rounded animate-pulse"})})]});if(!s||s.length===0)return e.jsxs(u,{children:[e.jsx(p,{children:e.jsx(j,{children:"Activity Breakdown"})}),e.jsx(g,{children:e.jsx("div",{className:"h-64 flex items-center justify-center text-gray-500",children:e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"h-12 w-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"text-lg font-medium",children:"No Activity Data"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Log activities to see breakdown."})]})})})]});const t=s.map((i,r)=>{var a;return{name:((a=i.activityType)==null?void 0:a.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase()))||"Unknown",value:i.totalHours||0,hours:i.totalHours||0,count:i.frequency||0}}),o=[x.primary,x.secondary,x.accent,x.danger,x.muted];return e.jsxs(u,{children:[e.jsx(p,{children:e.jsxs(j,{className:"flex items-center",children:[e.jsx(F,{className:"h-5 w-5 mr-2"}),"Activity Breakdown"]})}),e.jsxs(g,{children:[e.jsx(M,{width:"100%",height:300,children:e.jsxs(le,{children:[e.jsx(ne,{data:t,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:5,dataKey:"value",children:t.map((i,r)=>e.jsx(ie,{fill:o[r%o.length]},`cell-${r}`))}),e.jsx(N,{formatter:i=>[`${i.toFixed(1)} hrs`,"Hours"]}),e.jsx(T,{})]})}),e.jsx("div",{className:"mt-4 space-y-2",children:t.map((i,r)=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"w-3 h-3 rounded-full mr-2",style:{backgroundColor:o[r%o.length]}}),e.jsx("span",{children:i.name})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("span",{className:"font-medium",children:[i.hours.toFixed(1)," hrs"]}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["(",i.count," entries)"]}
6)]})]},r))})]})]})}function fe({analyticsData:s,timeSeriesData:n}){var h,m;const t=(s==null?void 0:s.totalHours)||0,o=(s==null?void 0:s.goalHours)||750,i=(s==null?void 0:s.materialGoalHours)||500,r=t/365,a=n&&n.length>1?((h=n[n.length-1])==null?void 0:h.hours)-((m=n[n.length-2])==null?void 0:m.hours):0,l=[{title:"REP Status Forecast",description:t>=o?"Congratulations! You've met the REP status requirements for this year.":`At your current pace, you'll reach ${(r*365).toFixed(0)} hours by year-end. ${r*365>=o?"You're on track!":"Consider increasing your weekly hours."}`,type:t>=o?"success":r*365>=o?"info":"warning"},{title:"Recent Activity Trend",description:a>0?`Great momentum! You logged ${a.toFixed(1)} more hours than the previous period.`:a<0?`Activity decreased by ${Math.abs(a).toFixed(1)} hours from the previous period. Consider setting weekly goals.`:"Your activity level has been consistent. Keep up the steady progress!",type:a>0?"success":a<0?"warning":"info"},{title:"Material Participation",description:((s==null?void 0:s.materialParticipationHours)||0)>=i?"Excellent! You've met the material participation threshold.":`You need ${(i-((s==null?void 0:s.materialParticipationHours)||0)).toFixed(0)} more material participation hours.`,type:((s==null?void 0:s.materialParticipationHours)||0)>=i?"success":"info"}];return e.jsxs(u,{children:[e.jsx(p,{children:e.jsxs(j,{className:"flex items-center",children:[e.jsx(E,{className:"h-5 w-5 mr-2"}),"Smart Insights"]})}),e.jsx(g,{children:e.jsx("div",{className:"space-y-4",children:l.map((c,d)=>e.jsxs(ee,{className:c.type==="success"?"border-green-200 bg-green-50":c.type==="warning"?"border-yellow-200 bg-yellow-50":"border-blue-200 bg-blue-50",children:[e.jsx(C,{className:`h-4 w-4 ${c.type==="success"?"text-green-600":c.type==="warning"?"text-yellow-600":"text-blue-600"}`}),e.jsxs(se,{children:[e.jsx("div",{className:`font-medium mb-1 ${c.type==="success"?"text-green-800":c.type==="warning"?"text-yellow-800":"text-blue-800"}`,children:c.title}),e.jsx("div",{className:c.type==="success"?"text-green-700":c.type==="warning"?"text-yellow-700":"text-blue-700",children:c.description})]})]},d))})})]})}function Se(){const[s,n]=f.useState("30d"),{user:t,isLoading:o}=V(),[i,r]=f.useState({repType:(t==null?void 0:t.repType)||"longTerm",strSubType:(t==null?void 0:t.strSubType)||"path_500"});_();const{summary:a,timeSeries:l,activityBreakdown:h,isLoading:m,errors:c}=te(t==null?void 0:t.id,!!t&&!o,s,i);if(o)return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(R,{className:"h-12 w-12 mx-auto mb-4 animate-spin text-blue-500"}),e.jsx("p",{children:"Loading..."})]})});if(!t)return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"h-12 w-12 mx-auto mb-4 text-red-500"}),e.jsx("p",{className:"text-lg font-medium",children:"Authentication Required"}),e.jsx("p",{className:"text-muted-foreground",children:"Please log in to view your analytics dashboard."})]})});if(c&&c.some(y=>y!=null)){const y=c.filter(B=>B!=null);return console.error("Analytics errors:",y),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"h-12 w-12 mx-auto mb-4 text-red-500"}),e.jsx("p",{className:"text-lg font-medium",children:"Error Loading Analytics"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load your analytics data. Please try again later."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"mt-4 px-4 py-2 bg-primary text-white rounded hover:bg-primary/90",children:"Retry"})]})})}return e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Analytics Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:"Track your goal progress with detailed insights"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(he,{user:t,onStrategyChange:r}),e.jsxs(q,{value:s,onValueChange:n,children:[e.jsx(W,{className:"w-48",children:e.jsx(z,{})}),e.jsx(J,{children:ue.map(y=>e.jsx(X,{value:y.value,children:y.label},y.value))})]})]})]}),e.jsx(ge,{analyticsData:a,isLoading:m}),e.jsx(je,{analyticsData:a}),e.jsx(pe,{timeSeriesData:l,isLoading:m}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(ye,{activityData:h,isLoading:m}),e.jsx(fe,{analyticsData:a,timeSeriesData:l})]})]})}export{Se 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.