PageSourceSearch

https://www.practiapp.ai/assets/CallsPage-vTNTPRsT.js

js practiapp.ai collected 2026-10-05 14:30:59 UTC 32,299 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CallDetailDrawer-D5t7z0hk.js","assets/index-H8IzDUMv.js","assets/index-Cvwl6Rv4.css","assets/chunk-SJQJEQVQ-CzRjmg2Q.js","assets/chunk-KBDBFQHS-BrctABWi.js","assets/X.es-bR1Wwwjd.js","assets/EmailReportButton-Caa8B_60.js","assets/team-wOJ3vfnV.js","assets/chunk-434VSNPK-BJ_4UO-P.js","assets/WarningCircle.es-CNnxL-GK.js","assets/chunk-R6Z562ER-Cf5vJFn7.js","assets/chunk-OX4BU4S7-CYbRK5LP.js","assets/chunk-TO37YBM2-0yBdJQ1s.js","assets/index-CtR03H1d.js","assets/index-BrV41PBl.js","assets/index-CzOIuAer.js","assets/index-BrRbKPTe.js","assets/index-ZZFFG32g.js","assets/index-B5_GaaPg.js","assets/CaretUp.es-BlVSLAXg.js","assets/Check.es-C36jg8bk.js","assets/chunk-KFEHZDUQ-Bw28FaZs.js","assets/types-DCez28Tp.js","assets/ConfirmDialog-iIVQEsBz.js","assets/transferRecipients-CvHkn5iN.js","assets/eligibilityDetail-K4JLpRgv.js","assets/jspdf.es.min-HrcQWV6j.js","assets/practaiLogo-2t70iWJF.js","assets/CalendarPopover-dGe7DcJw.js","assets/ExportCallsModal-E9pU7bq0.js","assets/callsCsv-D5FLBtNl.js","assets/AssignmentConfigSection-Dsz9ScF6.js","assets/DateRangeControl-DARu4pEk.js","assets/DatePicker-BI2rMyWw.js"])))=>i.map(i=>d[i]);
2import{aL as ue,aP as Mt,aQ as fe,r as u,j as e,aR as it,R as G,aS as Rt,b as lt,aT as Tt,aU as At,n as Ot,o as Bt,q as Dt,t as It,W as He,C as Ye,w as Ft,g as Ut,H as Ke,G as Ze,I as Qe,D as Wt,aV as Gt,z as ot,aN as zt,P as de,aO as be,aW as qt}from"./index-H8IzDUMv.js";import{N as Je,a as Vt}from"./chunk-SJQJEQVQ-CzRjmg2Q.js";import{B as Ht}from"./chunk-KBDBFQHS-BrctABWi.js";import{P as Yt}from"./Pager-BhYgbZmp.js";import{P as Kt}from"./PtClock-ug8VEDRF.js";import{D as Zt}from"./DataTable-CHpQbyRm.js";import{a as he}from"./team-wOJ3vfnV.js";import{C as ve}from"./ConfirmDialog-iIVQEsBz.js";import{R as pe,a as Qt,E as xe,t as Jt,m as Xt,b as ea,r as ta,e as aa}from"./transferRecipients-CvHkn5iN.js";import{r as sa,D as na}from"./DateRangeControl-DARu4pEk.js";const ye=6;async function _e(a,n,l){const r=[];if(a.length===0)return r;const c=Math.min(Math.max(n,1),a.length);let o=0;const h=Array.from({length:c},()=>(async()=>{for(;;){const i=o++;if(i>=a.length)return;try{await l(a[i])}catch{r.push(a[i])}}})());return await Promise.all(h),r}function ra({selectedIds:a,filterLabel:n,orgId:l,onDone:r}){var _;const c=ue(!0,l),o=Mt(),h=fe(),[i,b]=u.useState(),[p,g]=u.useState(!1),v=he(((_=c.data)==null?void 0:_.members)??[]),x=async()=>{if(!i)return;g(!0);const f=await _e(a,ye,L=>o.mutateAsync({conversationId:L,assigneeSub:i.sub,skipListInvalidation:!0}));h(),g(!1),b(void 0),f.length===0?G.success(`${a.length} ${a.length===1?"call":"calls"} ${i.sub?"assigned":"unassigned"}`):G.error(`${a.length-f.length} of ${a.length} ${i.sub?"assigned":"unassigned"} — ${f.length} failed`),r(f)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sel-assign",children:e.jsx(it,{variant:"toolbar",ariaLabel:"Assign to",placeholder:"Assign to…",value:"",disabled:a.length===0||p,emptyLabel:"No teammates to assign",options:[...v.map(f=>({value:f.sub,label:f.role==="org_admin"?`${f.email} (Owner)`:f.email})),{value:"__unassign__",label:"Unassign",separated:!0}],onChange:f=>{if(f==="__unassign__"){b({sub:null,label:"Unassigned"});return}const L=v.find(X=>X.sub===f);L&&b({sub:L.sub,label:L.email})}})}),i&&e.jsx(ve,{open:!0,title:i.sub?`Assign ${a.length} ${a.length===1?"call":"calls"} to ${i.label}?`:`Unassign ${a.length} ${a.length===1?"call":"calls"}?`,description:`Filter in effect: ${n}. Each call is written and audited individually.`,confirmLabel:"Confirm",pending:p,onConfirm:()=>void x(),onOpenChange:f=>{f||b(void 0)}})]})}const ia=["no_action_needed","spam","unreachable","voicemail"];function la({selectedIds:a,skipped:n=0,filterLabel:l,narrowed:r,onDone:c}){const o=Rt(),h=fe(),[i,b]=u.useState(),[p,g]=u.useState(!1),v=async()=>{if(!i)return;g(!0);const x=await _e(a,ye,_=>o.mutateAsync({conversationId:_,reviewed:!0,outcome:i,skipListInvalidation:!0}));h(),g(!1),b(void 0),x.length===0?G.success(`${a.length} ${a.length===1?"call":"calls"} marked reviewed`):G.error(`${a.length-x.length} of ${a.length} marked reviewed — ${x.length} failed`),c(x)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sel-assign",children:e.jsx(it,{variant:"toolbar",ariaLabel:"Mark reviewed",placeholder:"Mark reviewed…",value:"",disabled:a.length===0||!r||p,title:r?void 0:"Apply a filter beyond the date range to bulk-close",options:ia.map(x=>({value:x,label:pe[x]})),onChange:x=>b(x)})}),i&&e.jsx(ve,{open:!0,title:`Mark ${a.length} ${a.length===1?"call":"calls"} as ${pe[i]}?`,description:`Filter in effect: ${l}. Each call is reviewed and audited individually.${n>0?` ${n} selected ${n===1?"call is":"calls are"} already reviewed or transferred and will be skipped.`:""}`,confirmLabel:"Confirm",destructive:!0,pending:p,onConfirm:()=>void v(),onOpenChange:x=>{x||b(void 0)}})]})}function oa({selectedIds:a,filterLabel:n,onDone:l}){const{claims:r}=lt(),c=Tt(),o=fe(),[h,i]=u.useState(!1),[b,p]=u.useState(!1),g=a.length,v=g===1?"call":"calls",x=(r==null?void 0:r.email)??"your account",_=async()=>{p(!0);const f=await _e(a,ye,L=>c.mutateAsync({conversationId:L,skipListInvalidation:!0}
2));o(),p(!1),i(!1),f.length===0?G.success(`${g} ${v} deleted`):G.error(`${g-f.length} of ${g} deleted, ${f.length} failed`),l(f)};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"sel-danger",disabled:g===0||b,onClick:()=>i(!0),children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"}),e.jsx("path",{d:"M10 11v5M14 11v5"})]}),"Delete"]}),h&&e.jsx(ve,{open:!0,title:`Permanently delete ${g} ${v}?`,description:e.jsxs(e.Fragment,{children:["This erases the ",v," outright: the record, the recording, the transcript and the original webhook payload are all removed from storage. There is no undo, no archive, and no way to recover them.",e.jsx("br",{}),e.jsx("br",{}),"Filter in effect: ",n,". Each deletion is recorded against"," ",e.jsx("strong",{children:x})," in the admin audit log."]}),confirmLabel:`Delete ${g} ${v}`,destructive:!0,pending:b,onConfirm:()=>void _(),onOpenChange:f=>{!f&&!b&&i(!1)}})]})}const ca=[{v:"",label:"Any Status"},{v:"done",label:"Done"},{v:"failed",label:"Failed"}],Ta=[{v:"",label:"Any Eligibility"},{v:"active",label:"Active"},{v:"inactive",label:"Inactive"},{v:"needs_review",label:"Payer Not Matched"},{v:"error",label:"Check Failed"},{v:"pending",label:"Verifying"},{v:"not_enabled",label:"Not Enabled"},{v:"limit_reached",label:"Limit Reached"},{v:"none",label:"Unverified"}],Xe=[{v:"",label:"Any Category"},...Object.entries(At).map(([a,n])=>({v:a,label:n})),{v:"uncategorized",label:"Uncategorized"}],et=[{v:"",label:"Any duration"},{v:"lte30",label:"30s or less"},{v:"lte45",label:"45s or less"},{v:"lte60",label:"60s or less"},{v:"gt60",label:"Over 60s"}],tt=[{v:"",label:"Any capture"},{v:"none",label:"Nothing captured"},{v:"some",label:"Something captured"}],at=[{v:"",label:"Any Eligibility"},{v:"none",label:Qt},...Object.entries(xe).filter(([a])=>a!=="none").map(([a,n])=>({v:a,label:n}))],st=[{v:"",label:"Any Handling"},{v:"ai",label:"AI Handled"},{v:"transferred",label:"Transfer"},{v:"unclassified",label:"Unclassified"}],nt=[{v:"",label:"Any Review Status"},{v:"needs",label:"Needs Review"},{v:"done",label:"Reviewed"}];function je(a,n){return a!==n[0].v}function me(a,n,l){const r=n.find(c=>c.v===a);return r?je(a,n)||!l?r.label:l:`${l??n[0].label} (unknown)`}function da({value:a,onChange:n,options:l=ca,ariaLabel:r="Status filter",placeholder:c}){const[o,h]=u.useState(!1),i=u.useRef(null);u.useEffect(()=>{if(!o)return;const p=g=>{i.current&&!i.current.contains(g.target)&&h(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]);const b=je(a,l);return e.jsxs("div",{className:"status-wrap",ref:i,children:[e.jsxs("button",{type:"button",className:`statusbtn${o?" active":""}${b?" set":""}`,"aria-label":r,"aria-haspopup":"listbox","aria-expanded":o,onClick:()=>h(p=>!p),children:[me(a,l,c),e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),o&&e.jsx("div",{className:"status-menu",role:"listbox",children:l.map(p=>e.jsxs("button",{type:"button",role:"option","aria-selected":p.v===a,className:p.v===a?"active":void 0,onClick:()=>{n(p.v),h(!1)},children:[p.label,e.jsx("svg",{className:"chk",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})]},p.v))})]})}function ua({children:a,ariaLabel:n="More filters"}){const[l,r]=u.useState(!1),c=u.useRef(null);return u.useEffect(()=>{if(!l)return;const o=i=>{c.current&&!c.current.contains(i.target)&&r(!1)},h=i=>
2{i.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",o),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",h)}},[l]),e.jsxs("div",{className:"status-wrap more-wrap",ref:c,children:[e.jsxs("button",{type:"button",className:`statusbtn${l?" active":""}`,"aria-label":n,"aria-haspopup":"true","aria-expanded":l,"data-testid":"more-filters",onClick:()=>r(o=>!o),children:["More",e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),l&&e.jsx("div",{className:"more-menu",children:a})]})}function ha({onClick:a}){return e.jsx("button",{type:"button",className:"clear-filters","data-testid":"clear-filters",onClick:a,children:"Clear Filters"})}const pa=({up:a})=>e.jsx("svg",{className:`caret${a?" up":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})});function ma({label:a,sortKey:n,num:l,sort:r,onToggle:c}){const o=r.key===n;return e.jsxs("button",{type:"button",className:`th sortable${l?" num":""}${o?" active-sort":""}`,onClick:()=>c(n),"aria-label":`Sort by ${a}`,children:[a,e.jsx(pa,{up:o&&r.dir==="asc"})]})}const rt=[{v:"",label:"Any repeat count"},{v:"2",label:"Repeats: 2+"},{v:"3",label:"Repeats: 3+"},{v:"5",label:"Repeats: 5+"}],ga=[{value:"off",label:"Flat"},{value:"stacked",label:"Stacked"}];function fa(a){return a==="stacked"||a==="list"||a==="slider"?"stacked":"off"}function ba({value:a,ready:n,onChange:l}){return e.jsx("div",{className:"groupmode",role:"group","aria-label":"Group repeat callers","data-testid":"group-mode",children:ga.map(r=>e.jsx("button",{type:"button",className:a===r.value?"gm-btn on":"gm-btn","aria-pressed":a===r.value,disabled:!n&&r.value!=="off",title:!n&&r.value!=="off"?"Available once the full range has loaded":void 0,onClick:()=>l(r.value),"data-testid":`group-mode-${r.value}`,children:r.label},r.value))})}const va=u.lazy(()=>be(()=>import("./CallDetailDrawer-D5t7z0hk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])).then(a=>({default:a.CallDetailDrawer}))),xa=u.lazy(()=>be(()=>import("./ExportCallsModal-E9pU7bq0.js"),__vite__mapDeps([29,1,2,6,7,8,9,4,30,24])).then(a=>({default:a.ExportCallsModal}))),ya=u.lazy(()=>be(()=>import("./AssignmentConfigSection-Dsz9ScF6.js"),__vite__mapDeps([31,1,2,23,4,13,15,32,33,28])));function ct(a,n){if(!n||[a.caller_number,a.called_number,a.summary,a.call_type,ot(a.call_type,a.redacted),a.org_id,a.conversation_id,a.patient_first_name,a.patient_last_name,a.patient_dob,a.assignee_email].filter(Boolean).join(" ").toLowerCase().includes(n.toLowerCase()))return!0;const r=de(n);return!!(r.length>=3&&`${de(a.caller_number)} ${de(a.called_number)}`.includes(r))}const _a=15;function dt(a,n,l){return n?n==="unassigned"?!a.assignee_sub:n==="me"?!!l&&a.assignee_sub===l:a.assignee_sub===n:!0}const ja=new Intl.DateTimeFormat("en-CA",{timeZone:qt,year:"numeric",month:"2-digit",day:"2-digit"});function ke(a){return ja.format(new Date(a))}function we(a){return!!a.caller_number&&!Number.isNaN(Date.parse(a.start_time))}function Ne(a){return`${a.org_id}|${a.caller_number}|${ke(a.start_time)}`}function ut(a){const n=new Map;for(const r of a){if(!we(r)||r.caller_day_seq===void 0)continue;const c=Ne(r),o=n.get(c);(!o||r.caller_day_seq>o.caller_day_seq||r.caller_day_seq===o.caller_day_seq&&(r.start_time>o.start_time||r.start_time===o.start_time&&r.conversation_id>o.conversation_id))&&n.set(c,r)}const l=new Set;for(const r of n.values())r.caller_day_seq>1&&l.add(r.conversation_id);return l}function ht(a,n){var r,c;if(!n)return;const l=((r=a.get(n))==null?void 0:r.group)??((c=[...a.values()].find(o=>o.group.calls.some(h=>h.conversation_id===n)))==null?void 0:c.group);if(l)return[...l.calls].sort((o,h)=>o.start_time<h.start_time?1:-1).map(o=>o.conversation_id)}function pt(a){const n=new Map,l=[],r=[];for(const o of a){if(!we(o)){r.push({kind:"call",call:o});continue}const h=Ne(o),i=n.get(h);i?i.push(o):(n.set(h,[o]),l.push(h))}const c=[];for(const o of l){const h=n.get(o);if(h.length<2){c.push({kind:"call",call:h[0]});continue}const i=[...h].sort((g,v)=>g.start_time<v.start_time?-1:g.start_time>v.start_time?1:0),b=h.map(g=>g.caller_day_seq).filter(g=>typeof g=="number"),p=b.length?Math.max(...b):void 0;c.push({kind:"group",group:{key:o,caller_number:h[0].caller_number,pacific_day:ke(h[0].start_time),calls:h,count:h.length,dayTotal:p&&p>h.length?p:void 0,first:i[0],last:i[i.length-1]}})}return[...c,...r]}function mt(a,n){if(!n)return!0;const l=a.duration_secs;return l==null?!1:n==="lte30"?l<=30:n==="lte45"?l<=45:n==="lte60"?l<=60:n==="gt60"?l>60:!0}function gt(a,n){return!n||!(n in xe)?!0:(a.eligibility_status??"none")===n}function ft(a,n){if(!n||n!=="some"&&n!=="none")return!0;
2if(a.redacted)return!1;const l=(a.capture_status??"none")!=="none",r=!!(a.patient_first_name||a.patient_last_name||a.patient_dob),c=l||r;return n==="some"?c:!c}function ge(a,n){return n==="start_time"?Date.parse(a.start_time):a.duration_secs??0}function ka(){var Ie,Fe,Ue,We,Ge,ze,qe;const{isAdmin:a,isOrgAdmin:n,claims:l}=lt(),r=l==null?void 0:l.sub,{orgScope:c}=Ot(),[o,h]=u.useState("calls"),[i,b]=Bt(),[p,g]=u.useState(""),[v,x]=u.useState({key:"start_time",dir:"desc"}),_=i.get("call")??void 0,f=t=>{const s=new URLSearchParams(i);t?s.set("call",t):(s.delete("call"),s.delete("pdf")),b(s,{replace:!0})},L=i.get("pdf")==="1",[X,Ce]=u.useState(!1),[E,D]=u.useState(new Set),Le=u.useMemo(()=>Dt("last7"),[]),F=i.get("from")??Le.from,U=i.get("to")??Le.to,I=It(i.get("months")),ee=sa({from:F,to:U,...I.length?{months:I}:{}}).label,N=i.get("type")??"",C=i.get("handling")??"",S=i.get("review")??"",$=i.get("duration")??"",P=i.get("capture")??"",M=i.get("eligibility")??"",R=i.get("recipient")??"",j=fa(i.get("group")),V=j==="off"?"":i.get("repeats")??"2",te=i.get("assignee"),T=te==="any"?"":te??(a||n||!r?"":"me"),bt=te!==null,Se=(t,s)=>{if(t===null||t.trim()==="")return;const d=Number(t);return Number.isInteger(d)&&d>=0&&d<=s?d:void 0},A=Se(i.get("hour"),23),O=Se(i.get("weekday"),6),H=[...A!==void 0?[{kind:"hour",value:A,label:Ye(A)}]:[],...O!==void 0?[{kind:"weekday",value:O,label:He[O]}]:[]],Ee=ue(!a||!!c,a?c:void 0),$e=u.useMemo(()=>{var s;const t=(s=Ee.data)==null?void 0:s.members;if(t)return new Set(he(t).map(d=>d.sub))},[Ee.data]),ae=!!(C||N||S||$||P||M||R||bt&&T||p||V||H.length);u.useEffect(()=>{D(t=>t.size?new Set:t)},[F,U,N,C,S,$,P,M,R,T,p,A,O,c,j,V]);const vt=ue(!a||!!c,a?c:void 0),Pe=[{v:"any",label:"Anyone"},{v:"me",label:"Assigned to Me"},{v:"unassigned",label:"Unassigned"},...he(((Ie=vt.data)==null?void 0:Ie.members)??[]).map(t=>({v:t.sub,label:t.email}))],se=[ee,N&&((Fe=Xe.find(t=>t.v===N))==null?void 0:Fe.label),C&&((Ue=st.find(t=>t.v===C))==null?void 0:Ue.label),S&&((We=nt.find(t=>t.v===S))==null?void 0:We.label),$&&((Ge=et.find(t=>t.v===$))==null?void 0:Ge.label),P&&((ze=tt.find(t=>t.v===P))==null?void 0:ze.label),M&&((qe=at.find(t=>t.v===M))==null?void 0:qe.label),R&&`transferred to ${R}`,T&&me(T,Pe,"Assignee"),p&&`search "${p}"`,V&&me(V,rt,"Repeats"),A!==void 0&&Ye(A),O!==void 0&&He[O]].filter(Boolean).join(" · ")||"no filter",Me=(t,s)=>{const d=new URLSearchParams(i);s?d.set(t,s):d.delete(t),b(d,{replace:!0})},xt=()=>{const t=new URLSearchParams(i);for(const s of["handling","type","review","duration","capture","recipient","hour","weekday","assignee","repeats"])t.delete(s);b(t,{replace:!0}),g("")},yt=t=>{const s=new URLSearchParams(i);t==="off"?(s.delete("group"),s.delete("repeats")):s.set("group",t),b(s,{replace:!0})},_t=t=>{var d;const s=new URLSearchParams(i);t.from?s.set("from",t.from):s.delete("from"),t.to?s.set("to",t.to):s.delete("to"),(d=t.months)!=null&&d.length?s.set("months",t.months.join(",")):s.delete("months"),b(s,{replace:!0})},jt=t=>x(s=>s.key===t?{key:t,dir:s.dir==="asc"?"desc":"asc"}:{key:t,dir:"desc"}),y=Ft({from:F,to:U,...I.length?{months:I}:{},orgId:a?c:void 0,...A!==void 0?{hour:A}:{},...O!==void 0?{weekday:O}:{}},{refetchIntervalMs:6e4,drainAll:!0}),ne=!y.hasNextPage,Y=u.useMemo(()=>{var t;return(((t=y.data)==null?void 0:t.pages)??[]).flatMap(s=>s.items)},[y.data]),Re=(()=>{const t=Jt(Y);return t.length?[{v:"",label:"Any Recipient"},...t.map(s=>({v:s,label:s}))]:[]})(),re=(()=>{const t=[],s=[],d=[{key:"handling",value:C,options:st,ariaLabel:"Handling filter",placeholder:"Handling"},{key:"type",value:N,options:Xe,ariaLabel:"Category filter",placeholder:"Category"},{key:"review",value:S,options:nt,ariaLabel:"Review filter",placeholder:"Review"},{key:"duration",value:$,options:et,ariaLabel:"Duration filter",placeholder:"Duration"},{key:"capture",value:P,options:tt,ariaLabel:"Capture filter",placeholder:"Capture"},{key:"eligibility",value:M,options:at,ariaLabel:"Eligibility filter",placeholder:"Eligibility"},...Re.length?[{key:"recipient",value:R,options:Re,ariaLabel:"Transferred-to filter",placeholder:"Transferred To"}]:[],...j==="off"?[]:[{key:"repeats",value:i.get("repeats")??"2",options:rt,ariaLabel:"Minimum repeat calls",placeholder:"Repeats"}],{key:"assignee",value:T||"any",options:Pe,ariaLabel:"Assigned-to filter",placeholder:"Assignee"}];for(const m of d){const k=e.jsx(da,{value:m.value,onChange:w=>Me(m.key,w),options:m.options,ariaLabel:m.ariaLabel,placeholder:m.placeholder},m.key);(je(m.value,m.options)?t:s).push(k)}return{shown:t,hidden:s}})(),ie=u.useMemo(()=>{const t=m=>!S||(S==="done"?!!m.review_outcome:m.handled_by==="ai"&&!m.review_outcome),s=m=>!N||(N==="uncategorized"?!m.call_type:m.call_type===N);return Y.filter(m=>ct(m,p)&&s(m)&&(!C||(C==="unclassified"?!m.handled_by:m.handled_by===C))&&t(m)&&mt(m,$)&&ft(m,P)&&gt(m,M)&&Xt(m,R)&&dt(m,T,r)).sort((m,k)=>{const w=ge(m,v.key)-ge(k,v.key);return v.dir==="asc"?w:-w})},[Y,p,v,N,C,S,$,P,M,R,T,r]),[kt,K]=u.useState(1),[z,wt]=u.useState(_a);u.useEffect(()=>{K(1)},[p,v,F,U,N,C,S,$,P,M,R,T]);const W=ie,Nt=u.useMemo(()=>ut(W),[W]),[Te,Ct]=u.useState(new Set),Lt=t=>Ct(s=>{const d=new Set(s);return d.has(t)?d.delete(t):d.add(t),d}),{displayRows:Z,matchingCalls:B,groupMeta:le}=u.useMemo(()=>
2{if(j==="off"||!ne)return{displayRows:W,matchingCalls:W,groupMeta:new Map};const t=Number(i.get("repeats")??"2")||0,s=[],d=[],m=new Map;for(const k of pt(W)){if(k.kind==="call"){t<=1&&(s.push(k.call),d.push(k.call));continue}const w=k.group;if(w.count<t)continue;const oe=Te.has(w.key),Ve=[...w.calls].sort((q,J)=>q.start_time<J.start_time?1:q.start_time>J.start_time?-1:0),ce=w.calls[0];if(m.set(ce.conversation_id,{group:w,role:"header",open:oe}),s.push(ce),d.push(...Ve),oe)for(const q of Ve.filter(J=>J.conversation_id!==ce.conversation_id))m.set(q.conversation_id,{group:w,role:"member",open:oe}),s.push(q)}return{displayRows:s,matchingCalls:d,groupMeta:m}},[j,ne,W,Te,i]),Ae=Math.max(1,Math.ceil(Z.length/z)),Q=Math.min(kt,Ae),St=u.useMemo(()=>Z.slice((Q-1)*z,Q*z),[Z,Q,z]),Et=u.useMemo(()=>j==="off"?void 0:ht(le,_),[j,_,le]),Oe=u.useMemo(()=>{const t=ie.filter(d=>E.has(d.conversation_id)),s=t.filter(d=>!d.review_outcome&&d.handled_by!=="transferred").map(d=>d.conversation_id);return{ids:s,skipped:t.length-s.length}},[ie,E]),$t=!y.isLoading&&!y.isError&&B.length===0;function Pt({label:t,sortKey:s,num:d}){return e.jsx(ma,{label:t,sortKey:s,num:d,sort:v,onToggle:jt})}const Be=n||a,De=Be?e.jsxs("div",{className:"sub-tabs",role:"tablist",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":o==="calls",className:o==="calls"?"active":void 0,onClick:()=>h("calls"),children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),e.jsx("path",{d:"M3 9h18M9 4v16"})]}),"Calls"]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":o==="assignment",className:o==="assignment"?"active":void 0,onClick:()=>h("assignment"),children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2.5"}),e.jsx("circle",{cx:"6",cy:"18",r:"2.5"}),e.jsx("circle",{cx:"18",cy:"12",r:"2.5"}),e.jsx("path",{d:"M8.5 6H14a2 2 0 0 1 2 2v2M8.5 18H14a2 2 0 0 0 2-2v-2"})]}),"Assignment Config"]})]}):null;return Be&&o==="assignment"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"hero calls-hero",children:[e.jsx("span",{className:"orb a","aria-hidden":"true"}),e.jsx("div",{className:"hero-ic",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92Z"})})}),e.jsxs("div",{className:"hero-txt",children:[e.jsx("h1",{children:"Calls"}),e.jsx("p",{children:"Who each category of call is assigned to by default"})]})]}),De,e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"card routing-card",children:e.jsx("p",{className:"routing-empty",children:"Loading assignment config…"})}),children:e.jsx(ya,{orgId:a?c:void 0})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"hero calls-hero",children:[e.jsx("span",{className:"orb a","aria-hidden":"true"}),e.jsx("div",{className:"hero-ic",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92Z"})})}),e.jsxs("div",{className:"hero-txt",children:[e.jsx("h1",{children:"Calls"}),e.jsx("p",{children:"Every call PractiAi has handled, captured at call end"})]}),e.jsx(ba,{value:j,ready:ne,onChange:yt}),e.jsxs("span",{className:"hero-tag",children:[e.jsx("span",{className:"d","aria-hidden":"true"})," ",Ut(Y.length),y.hasNextPage?"+…":""," Calls ·"," ",H.length>0?`${H.map(t=>t.label).join(" · ")} · `:"",ee]}),e.jsx(Kt,{})]}),De,j==="off"&&e.jsxs("p",{className:"calls-legend","data-testid":"repeat-legend",children:[e.jsx("span",{className:"c-repeat",role:"img","aria-label":"Example badge",children:"3"})," ","= this was the 3rd call from that number that day, shown on its most recent call."]}),e.jsxs("section",{className:"card table-card",children:[e.jsxs("div",{className:"filters",children:[e.jsx(na,{initialRange:{from:F,to:U,...I.length?{months:I}:{}},onChange:_t,allowMonths:!0}),H.map(t=>e.jsxs("button",{type:"button",className:"chip bucket-chip",onClick:()=>Me(t.kind,""),"data-testid":"bucket-chip",title:"Clear this filter","aria-label":`Clear the ${t.label} filter`,children:[t.label,e.jsx("span",{"aria-hidden":"true",children:"×"})]},t.kind)),re.shown,re.hidden.length>0&&e.jsx(ua,{children:re.hidden}),ae&&e.jsx(ha,{onClick:xt}),e.jsxs("div",{className:"search",children:[e.jsxs("svg",{className:"lead",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),e.jsx("input",{type:"text","aria-label":"Search",placeholder:"Search by phone number, patient name, or category…",value:p,onChange:t=>g(t.target.value)})]}),e.jsxs("span",{className:"result-count",children:[B.length,y.hasNextPage?"+":""," ",B.length===1?"call":"calls"]}),e.jsx(Ht,{type:"button",variant:"outline",size:"sm",className:"dl-slot","data-testid":"export-csv-open",onClick:()=>Ce(!0),leftIcon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),children:"Export CSV"})]}),E.size>0&&e.jsxs("div",{className:"sel-bar","data-testid":"selection-bar",children:[e.jsxs("span",{className:"sel-count",children:[E.size," selected"]}),!y.hasNextPage&&E.size<B.length&&e.jsxs("button",{type:"button",className:"sel-link",onClick:()=>D(new Set(B.map(t=>t.conversation_id))),children:["Select all ",B.length," matching the filter"]}),e.jsx("button",{type:"button",className:"sel-link",onClick:()=>D(new Set),children:"Clear all"}),e.jsx("div",{className:"sel-spacer"}),(!a||c)&&e.jsx(ra,{selectedIds:[...E],filterLabel:se,orgId:a?c:void 0,onDone:t=>D(new Set(t))}),e.jsx(la,{selectedIds:Oe.ids,skipped:Oe.skipped,filterLabel:se,narrowed:ae,onDone:t=>D(new Set(t))}),a&&e.jsx(oa,{selectedIds:[...E],filterLabel:se,onDone:t=>D(new Set(t))})]}),e.jsx(Zt,{columns:[{key:"start_time",label:"Call Time",width:"148px",sortKey:"start_time",cell:t=>{const s=Ke(t.start_time),[d,...m]=s.split(", "),k=m.join(", ");return e.jsxs("span",{className:"c-started stacked",children:[e.jsx("span",{className:"d",children:d}),k?e.jsx("span",{className:"t",children:k}):null]})}},a&&{key:"org",label:"Organization",width:"160px",cell:t=>e.jsxs("span",{className:"c-org",title:Ze(t.org_id),children:[e.jsx("span",{className:"dot"}),e.jsx("span",{className:"name",children:Ze(t.org_id)})]})},{key:"caller",label:"Phone Number",width:j==="off"?"156px":"254px",cell:t=>{const s=le.get(t.conversation_id);return(s==null?void 0:s.role)==="header"?e.jsxs("span",{className:"c-phone c-group","data-testid":"group-row",children:[e.jsx("button",{type:"button",className:"gx-btn","data-testid":"group-toggle","aria-expanded":s.open,"aria-label":`${s.open?"Collapse":"Expand"} ${s.group.count} calls from this number`,onClick:d=>{d.stopPropagation(),Lt(s.group.key)},children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}),Qe(t.caller_number),e.jsx("span",{className:"c-gcount","data-testid":"group-count",children:s.group.dayTotal?`${s.group.count} of ${s.group.dayTotal} that day`:`${s.group.count} calls`})]}):e.jsxs("span",{className:(s==null?void 0:s.role)==="member"?"c-phone c-gmember":"c-phone",children:[Qe(t.caller_number),!s&&Nt.has(t.conversation_id)?e.jsx("span",{className:"c-repeat",role:"img",title:`Call ${t.caller_day_seq} from this number that day`,"aria-label":`Call ${t.caller_day_seq} from this number that day`,"data-testid":"caller-day-seq",children:t.caller_day_seq}):null]})}},{key:"patient_first",label:"First Name",width:"96px",cell:t=>e.jsx("span",{className:"c-patient","data-testid":"patient-first",children:t.patient_first_name??(t.patient_last_name?e.jsx("span",{className:"c-none",children:"—"}):e.jsx("span",{className:"c-none",title:"Unidentified caller",children:"Unidentified"}))})},{key:"patient_last",label:"Last Name",width:"96px",cell:t=>e.jsx("span",{className:"c-patient","data-testid":"patient-last",children:t.patient_last_name??e.jsx("span",{className:"c-none",children:"—"})})},{key:"patient_dob",label:"DOB",width:"92px",cell:t=>e.jsx("span",{className:"c-patient","data-testid":"patient-dob",children:t.patient_dob??"—"})},{key:"duration",label:"Duration",width:"80px",sortKey:"duration_secs",num:!0,
2cell:t=>e.jsx("span",{className:"c-dur",children:Wt(t.duration_secs)})},{key:"handling",label:"Call Resolution",width:"100px",cell:t=>e.jsx("span",{children:t.handled_by?e.jsx("span",{className:`tag ${t.handled_by==="transferred"?"transfer":"ai"}`,"data-testid":"handling-tag",children:Gt(t.handled_by)}):e.jsx("span",{className:"c-none",children:"—"})})},{key:"transferred",label:"Transferred To",width:"160px",cell:t=>{const s=ea(t);return s?e.jsx("span",{className:"c-transfer",title:s,children:s}):e.jsx("span",{className:"c-none",children:"—"})}},{key:"category",label:"Category",width:"132px",cell:t=>e.jsx("span",{children:e.jsx("span",{className:`tag ${t.call_type==="appointment"?"appt":"general"}`,children:ot(t.call_type,t.redacted)})})},{key:"review",label:"Callback Status",width:"minmax(206px, 1fr)",cell:t=>e.jsx("span",{children:t.handled_by!=="ai"&&!t.review_outcome?e.jsx("span",{className:"c-none",children:"—"}):t.review_outcome?e.jsx("span",{className:`spill ${ta(t.review_outcome)}`,"data-testid":"review-badge",children:pe[t.review_outcome]}):e.jsx("span",{className:"spill muted","data-testid":"review-badge",children:"Needs Review"})})},{key:"assignee",label:"Assigned To",width:"150px",cell:t=>{if(!t.assignee_email)return e.jsx("span",{className:"c-none",children:"Unassigned"});const s=$e!==void 0&&!!t.assignee_sub&&!$e.has(t.assignee_sub);return e.jsxs("span",{className:`c-assignee${s?" gone":""}`,title:s?`${t.assignee_email} (removed)`:t.assignee_email,children:[zt(t.assignee_email,s?13:t.auto_routed?15:22),s&&e.jsx("span",{className:"gone-tag","data-testid":"assignee-removed",children:"(removed)"}),t.auto_routed&&e.jsx("span",{className:"auto-tag","data-testid":"assignee-auto",children:"Auto"})]})}},{key:"eligibility",label:"Eligibility",width:"110px",cell:t=>e.jsx("span",{children:(t.eligibility_status??"none")==="none"?e.jsx("span",{className:"c-none",children:"—"}):e.jsx("span",{className:`spill ${aa(t.eligibility_status)}`,"data-testid":"eligibility-badge",children:xe[t.eligibility_status]})})}],rows:St,rowKey:t=>t.conversation_id,rowLabel:t=>`Open call from ${Ke(t.start_time)}`,rowTestId:"call-row",ariaLabel:"Calls",selection:{selected:E,onChange:D,rowLabel:t=>`Select call ${t}`},onRowClick:t=>{f(t.conversation_id)},renderSortHead:t=>e.jsx(Pt,{label:String(t.label),sortKey:t.sortKey,num:t.num}),loading:y.isLoading,loadingLabel:"Loading calls…",tableClassName:`table${a?"":" no-org"}`,tableStyle:a?{minWidth:j==="off"?1980:2078}:void 0,pager:!y.isLoading&&!y.isError&&B.length>0?e.jsx(Yt,{page:Q,pageCount:Ae,onPage:K,total:Z.length,pageSize:z,onPageSize:t=>{wt(t),K(1)},hasMore:y.hasNextPage,loadingMore:y.isFetchingNextPage,onLoadMore:()=>void Promise.resolve(y.fetchNextPage()).then(()=>K(t=>t+1))}):null}),y.isError&&e.jsx(Je,{entityName:"calls"}),$t&&(p?e.jsx(Vt,{searchQuery:p,onClearSearch:()=>g("")}):e.jsx(Je,{entityName:"calls"}))]}),_&&e.jsx(u.Suspense,{fallback:null,children:e.jsx(va,{conversationId:_,onClose:()=>f(void 0),siblings:Et,onNavigate:f,autoPdf:L})}),X&&e.jsx(u.Suspense,{fallback:null,children:e.jsx(xa,{isAdmin:a,orgScope:a?c:"",from:F,to:U,months:I,rangeLabel:ee,filtersApplied:ae,screenRows:B,onClose:()=>Ce(!1)})})]})}const Aa=Object.freeze(Object.defineProperty({__proto__:null,CallsPage:ka,dayGroupKey:Ne,groupCalls:pt,isDayGroupable:we,latestRepeatIds:ut,matchesAssignee:dt,matchesCapture:ft,matchesDuration:mt,matchesEligibility:gt,matchesSearch:ct,pacificDate:ke,siblingIdsFor:ht,sortValue:ge},Symbol.toStringTag,{value:"Module"}));export{ha as C,Ta as E,da as S,dt as a,ma as b,Aa as c,ct as m};

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.