1import{j as e,aP as M,q as z,s as K,r as v,a as Q,L as V,E as Y,d as Z,y as J,cZ as X,B as ee,a7 as se,dW as te,gM as ae}from"./index-rYWslEI1.js";import{p as $,d as A,a as R,i as U,b as re,c as ne,t as F,S as oe,s as le,e as ie,f as S,g as ce}from"./system-usage-api-D3yWlhG3.js";import"./parseISO-uS8Yaw1V.js";import"./subWeeks-BCdSu4Qz.js";try{let r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new r.Error().stack;n&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[n]="cdceb4b8-3630-4e08-a958-dc9fcd6ba1ac",r._sentryDebugIdIdentifier="sentry-dbid-cdceb4b8-3630-4e08-a958-dc9fcd6ba1ac")}catch{}function de({text:r,children:n,className:o,style:d}){return e.jsxs("div",{className:M("group/tip relative",o),style:d,title:r,children:[n,e.jsx("span",{role:"tooltip",className:"pointer-events-none absolute bottom-[calc(100%+4px)] left-1/2 z-20 hidden w-max max-w-64 -translate-x-1/2 rounded-md bg-foreground px-2 py-1 text-left text-[11px] leading-snug text-background shadow-md group-hover/tip:block",children:r})]})}const B=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))","hsl(197 52% 42%)","hsl(152 30% 36%)","hsl(28 55% 48%)","hsl(262 28% 48%)"];function _({title:r,caption:n,rows:o,series:d,valueSuffix:a="",onRowClick:i,className:b}){const f=new Map(d.map((l,c)=>[l,B[c%B.length]])),m=Math.max(...o.map(l=>l.segments.reduce((c,x)=>c+x.value,0)),1e-4),h=!!i;return e.jsxs("section",{className:M("space-y-3 overflow-visible rounded-md border p-4",b),children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:r}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n})]}),e.jsx("ul",{className:"flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:d.map(l=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"size-2.5 shrink-0 rounded-sm",style:{backgroundColor:f.get(l)},"aria-hidden":!0}),e.jsx("span",{children:l})]},l))}),e.jsx("ul",{className:"space-y-2.5",children:o.map(l=>{const c=l.segments.reduce((u,N)=>u+N.value,0),x=H(c,a),t=`${l.label}: ${x} total`,k=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:l.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:x})]}),e.jsx("div",{className:"flex h-3 overflow-visible rounded bg-muted",children:l.segments.map(u=>{if(u.value<=0)return null;const N=u.value/m*100,j=`${l.label} · ${u.key}: ${H(u.value,a)}`;return e.jsx(de,{text:j,className:"h-3 min-w-1",style:{width:`${N}%`,backgroundColor:f.get(u.key)},children:e.jsx("span",{className:"sr-only",children:j})},u.key)})})]});return e.jsx("li",{children:h?e.jsx("button",{type:"button",className:"w-full text-left",onClick:()=>i==null?void 0:i(l.id),"aria-label":t,title:t,children:k}):k},l.id)})})]})}function H(r,n){const o=Number.isInteger(r)?String(r):r.toFixed(1);return n?`${o}${n}`:o}const me=[{value:"ALL",label:"All"},{value:"operator",label:"Employees"},{value:"registrant",label:"Registrants"},{value:"government",label:"Government"}],ue="Deregistrations approved",pe="Deregistrations denied";function xe({initialFrom:r,initialTo:n}={}){var L,E,P,I;const{isAuthSetupComplete:o}=z(),d=K(),[a,i]=v.useState("ALL"),[b,f]=v.useState(()=>$(r,A())),[m,h]=v.useState(()=>$(n,R())),l=U(b,A()),c=U(m,R()),x=Q({queryKey:["operator-system-usage",l,c,a],queryFn:()=>ce({fromDate:l,toDate:c,userType:a}),enabled:o,placeholderData:te,...se}),t=x.data,k=(t==null?void 0:t.stacked_task_breakdown.map(s=>s.kind))??[],u=v.useMemo(()=>D((t==null?void 0:t.users)??[],(t==null?void 0:t.stacked_task_breakdown)??[]),[t]),N=((L=t==null?void 0:t.area_breakdown)==null?void 0:L.map(s=>s.kind))??[],j=v.useMemo(()=>D((t==null?void 0:t.users)??[],(t==null?void 0:t.area_breakdown)??[]),[t]),T=v.useMemo(()=>re((t==null?void 0:t.active_users_over_time)??[],(t==null?void 0:t.active_users_grain)??"day"),[t]),C=ne((t==null?void 0:t.active_users_grain)??"day"),w=v.useMemo(()=>he((t==null?void 0:t.task_breakdown)??[]),[t]);if(!o||x.isPending&&!t)return e.jsx(V,{});if(x.isError)return e.jsx(Y,{title:J(x.error),message:Z(x.error)});if(!t)return null;const G=t.users.reduce((s,p)=>s+F(p),0),O=t.users.reduce((s,p)=>s+p.working_hours,0),W=t.users.reduce((s,p)=>s+p.completed_tasks,0),q=t.users.filter(s=>s.active_days>0).length,g=s=>d({to:"/operator/system-usage/$userId",params:{userId:s},search:{from:l,to:c}});return e.jsxs("div",{className:"flex flex-1 min-h-0 w-full min-w-[768px] flex-col gap-8 overflow-y-auto scrollbar-overlay",children:[e.jsx(X,{title:"System Usage",subt
1itle:ge(a)}),e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"People"}),e.jsx("fieldset",{className:"flex gap-1 rounded-md border bg-muted/40 p-1","aria-label":"User type",children:me.map(s=>e.jsx("button",{type:"button",className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${a===s.value?"bg-background shadow-sm":""}`,onClick:()=>i(s.value),children:s.label},s.value))})]}),e.jsx(oe,{fromDate:b,toDate:m,onFromChange:f,onToChange:h})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Source: nightly snapshots through yesterday, plus live portal activity for today. ",le(t)]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3 lg:grid-cols-5",children:[e.jsx(y,{label:"People in range",value:String(t.users.length)}),e.jsx(y,{label:"Active people",value:String(q)}),e.jsx(y,{label:"Time in system",value:G.toFixed(1)}),e.jsx(y,{label:"Write-active hours",value:O.toFixed(1)}),e.jsx(y,{label:"Completed tasks",value:W.toLocaleString()})]}),w.total>0&&e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Deregistration reviews"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Decisions made in the selected range. Approvals cancel a de-registration-pending license; denials return it to compliant. Service transfers and licence links from that queue are not counted here."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(y,{label:"Approvals",value:w.approvals.toLocaleString()}),e.jsx(y,{label:"Denials",value:w.denials.toLocaleString()}),e.jsx(y,{label:"Total decisions",value:w.total.toLocaleString()})]}),e.jsx("div",{className:"overflow-x-auto rounded-md border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-left",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"Person"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Approvals"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Denials"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Total"})]})}),e.jsx("tbody",{children:w.byUser.map(s=>e.jsxs("tr",{className:"border-t",children:[e.jsx("td",{className:"px-3 py-2",children:s.label}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:s.approvals.toLocaleString()}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:s.denials.toLocaleString()}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:s.total.toLocaleString()})]},s.id))})]})})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"People"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Time in system is reconstructed portal presence. Gaps over 20 minutes are not counted; health checks and live-update heartbeats are excluded. Write-active hours are attributed writes only. Deactivated logins still appear when they have activity in the range. Click a name for the weekly and daily breakdown."})]}),e.jsx("div",{className:"overflow-x-auto rounded-md border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-left",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Portals"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Time in system"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Write-active"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Tasks"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Min / task"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Top work"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Top area"}),e.jsx("th",{className:"px-3 py-2 font-medium text-right",children:"Days"})]})}),e.jsx("tbody",{children:t.users.map(s=>e.jsxs("tr",{className:"border-t",children:[e.jsxs("td",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{variant:"link",className:"h-auto p-0",onClick:()=>g(s.id),children:s.name}),s.inactive?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inactive"}):null]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.email})]}),e.jsxs("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:[ie(s.user_types),s.portal_count>1?` · ${s.portal_count} logins`:""]}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:F(s).toFixed(2)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:s.working_hours.toFixed(2)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:s.completed_tasks}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:s.minutes_per_task.toFixed(1)}),e.jsx("td",{className:"px-3 py-2",children:s.top_work_type??"â"}),e.jsx("td",{className:"px-3 py-2",children:s.top_area??"â"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:s.active_days})]},s.id))})]})})]}),t.hours_by_user.length>0&&e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(S,{title:"Time in system b
1y person",caption:"Reconstructed portal presence in the selected range. Gaps over 20 minutes, health checks, and live-update heartbeats are excluded. Click a bar to open that person.",bars:t.hours_by_user.map(s=>({...s,tooltip:`${s.label}: ${s.value.toFixed(2)}h in system`})),valueSuffix:"h",orientation:"horizontal",xAxisLabel:"Hours",onBarClick:g}),e.jsx(S,{title:"Completed tasks by person",caption:"Distinct business actions. Click a bar to open that person.",bars:t.tasks_by_user.map(s=>({...s,tooltip:`${s.label}: ${s.value.toLocaleString()} completed tasks`})),orientation:"horizontal",xAxisLabel:"Tasks",onBarClick:g})]}),(j.hours.length>0||(((E=t.portal_breakdown)==null?void 0:E.length)??0)>0)&&e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[j.hours.length>0&&e.jsx(_,{title:"Time in system by person and area",caption:"Portal presence split across licenses, cases, payments, inspections, and other screens. Click a row to open that person.",rows:j.hours,series:N,valueSuffix:"h",onRowClick:g}),(((P=t.portal_breakdown)==null?void 0:P.length)??0)>0&&e.jsx(_,{title:"Time in system by person and portal",caption:"Which portal each person was using (employee, government, registrant, or inspection).",rows:D(t.users,t.portal_breakdown??[]).hours,series:((I=t.portal_breakdown)==null?void 0:I.map(s=>s.kind))??[],valueSuffix:"h",onRowClick:g})]}),u.hours.length>0&&e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(_,{title:"Hours by person and task",caption:"How each person's write-active time splits across task types. Click a row to open that person.",rows:u.hours,series:k,valueSuffix:"h",onRowClick:g}),e.jsx(_,{title:"Tasks by person and type",caption:"Completed-task counts stacked by type, so the mix is visible at a glance.",rows:u.counts,series:k,onRowClick:g})]}),t.task_breakdown.length>0&&e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Each task type"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How much of that work each person completed. Same layout as the employee workload comparison."})]}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:t.task_breakdown.map(s=>e.jsx(S,{title:s.kind,caption:`${s.count.toLocaleString()} tasks · ${s.hours.toFixed(1)}h total`,bars:s.by_user.map(p=>({id:p.id,label:p.label,value:p.count,tooltip:`${p.label}: ${p.count.toLocaleString()} ${s.kind} · ${p.hours.toFixed(1)}h`})),orientation:"horizontal",xAxisLabel:"Tasks",onBarClick:g},s.kind))})]}),T.length>0&&e.jsx(S,{title:C.title,caption:C.caption,xAxisLabel:C.xAxisLabel,yAxisLabel:"People",className:"max-w-3xl",bars:T})]})}function D(r,n){const o=n.map(i=>i.kind),d=[],a=[];for(const i of r){const b=o.map(m=>{var h,l;return{key:m,value:((l=(h=n.find(c=>c.kind===m))==null?void 0:h.by_user.find(c=>c.id===i.id))==null?void 0:l.hours)??0}}),f=o.map(m=>{var h,l;return{key:m,value:((l=(h=n.find(c=>c.kind===m))==null?void 0:h.by_user.find(c=>c.id===i.id))==null?void 0:l.count)??0}});b.some(m=>m.value>0)&&d.push({id:i.id,label:i.name,segments:b}),f.some(m=>m.value>0)&&a.push({id:i.id,label:i.name,segments:f})}return{hours:d,counts:a}}function he(r){const n=r.find(a=>a.kind===ue),o=r.find(a=>a.kind===pe),d=new Map;for(const a of(n==null?void 0:n.by_user)??[])d.set(a.id,{id:a.id,label:a.label,approvals:a.count,denials:0,total:a.count});
1for(const a of(o==null?void 0:o.by_user)??[]){const i=d.get(a.id);i?(i.denials+=a.count,i.total+=a.count):d.set(a.id,{id:a.id,label:a.label,approvals:0,denials:a.count,total:a.count})}return{approvals:(n==null?void 0:n.count)??0,denials:(o==null?void 0:o.count)??0,total:((n==null?void 0:n.count)??0)+((o==null?void 0:o.count)??0),byUser:[...d.values()].sort((a,i)=>i.total-a.total||a.label.localeCompare(i.label))}}function ge(r){return r==="registrant"?"Actual registrant accounts only. Employees who also log into the registrant portal are hidden. Gaps over 20 minutes are not working time.":r==="government"?"Actual government accounts only. Employees who also log into a government portal are hidden. Gaps over 20 minutes are not working time.":r==="operator"?"Employees only. Portal aliases for the same person are combined. Gaps over 20 minutes are not working time.":"One row per person. Portal logins for the same person are combined. Gaps over 20 minutes are not working time."}function y({label:r,value:n}){return e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:r}),e.jsx("p",{className:"text-2xl font-semibold tabular-nums",children:n})]})}const je=function(){const{from:n,to:o}=ae.useSearch();return e.jsx(xe,{initialFrom:n,initialTo:o})};export{je as component}; 2//# sourceMappingURL=index-DaHj8_9V.js.map
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.