ahs-cti 0.0.2-beta.8 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +425 -294
  2. package/dist/agentDetailReport-XSBMOUMW.mjs +12 -0
  3. package/dist/agentDetailReport-XSBMOUMW.mjs.map +1 -0
  4. package/dist/agentPerformanceReport-UT6QZWYD.mjs +533 -0
  5. package/dist/agentPerformanceReport-UT6QZWYD.mjs.map +1 -0
  6. package/dist/auditReport-R67BYA4Z.mjs +15 -0
  7. package/dist/auditReport-R67BYA4Z.mjs.map +1 -0
  8. package/dist/callHistory-PHGY224F.mjs +805 -0
  9. package/dist/callHistory-PHGY224F.mjs.map +1 -0
  10. package/dist/campaigns-JSMYHHDF.mjs +3049 -0
  11. package/dist/campaigns-JSMYHHDF.mjs.map +1 -0
  12. package/dist/caroQualityAuditDashboard-7X44HRZL.mjs +66 -0
  13. package/dist/caroQualityAuditDashboard-7X44HRZL.mjs.map +1 -0
  14. package/dist/caroVoiceAI-OZAB7LK4.mjs +21 -0
  15. package/dist/caroVoiceAI-OZAB7LK4.mjs.map +1 -0
  16. package/dist/cdrReport-44LN5VUX.mjs +819 -0
  17. package/dist/cdrReport-44LN5VUX.mjs.map +1 -0
  18. package/dist/chunk-6ICPXSN6.mjs +61 -0
  19. package/dist/chunk-6ICPXSN6.mjs.map +1 -0
  20. package/dist/chunk-CXULBAK6.mjs +493 -0
  21. package/dist/chunk-CXULBAK6.mjs.map +1 -0
  22. package/dist/chunk-FVXHNBYV.mjs +82 -0
  23. package/dist/chunk-FVXHNBYV.mjs.map +1 -0
  24. package/dist/chunk-G6KDIN5W.mjs +749 -0
  25. package/dist/chunk-G6KDIN5W.mjs.map +1 -0
  26. package/dist/chunk-GGACEO3I.mjs +180 -0
  27. package/dist/chunk-GGACEO3I.mjs.map +1 -0
  28. package/dist/chunk-HBR2JS4C.mjs +95 -0
  29. package/dist/chunk-HBR2JS4C.mjs.map +1 -0
  30. package/dist/chunk-HRM6S6J2.mjs +61 -0
  31. package/dist/chunk-HRM6S6J2.mjs.map +1 -0
  32. package/dist/chunk-JOZ4YQMR.mjs +116 -0
  33. package/dist/chunk-JOZ4YQMR.mjs.map +1 -0
  34. package/dist/chunk-O2XGWZLT.mjs +1060 -0
  35. package/dist/chunk-O2XGWZLT.mjs.map +1 -0
  36. package/dist/chunk-RZZQ42MG.mjs +115 -0
  37. package/dist/chunk-RZZQ42MG.mjs.map +1 -0
  38. package/dist/chunk-UZF5Q3GR.mjs +678 -0
  39. package/dist/chunk-UZF5Q3GR.mjs.map +1 -0
  40. package/dist/chunk-VQCHBU2Q.mjs +27 -0
  41. package/dist/chunk-VQCHBU2Q.mjs.map +1 -0
  42. package/dist/chunk-WWWM33FY.mjs +57 -0
  43. package/dist/chunk-WWWM33FY.mjs.map +1 -0
  44. package/dist/index.d.mts +795 -112
  45. package/dist/index.d.ts +796 -112
  46. package/dist/index.js +13690 -2103
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +2335 -2250
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/liveStatus-AHKS4XLW.mjs +1077 -0
  51. package/dist/liveStatus-AHKS4XLW.mjs.map +1 -0
  52. package/dist/loginReport-7GBMZP55.mjs +828 -0
  53. package/dist/loginReport-7GBMZP55.mjs.map +1 -0
  54. package/dist/managementDashboard-TYON77NW.mjs +529 -0
  55. package/dist/managementDashboard-TYON77NW.mjs.map +1 -0
  56. package/dist/qualityAuditDashboard-AGJH5VVN.mjs +66 -0
  57. package/dist/qualityAuditDashboard-AGJH5VVN.mjs.map +1 -0
  58. package/package.json +16 -6
@@ -0,0 +1,678 @@
1
+ import {
2
+ END_POINT,
3
+ axios_default
4
+ } from "./chunk-O2XGWZLT.mjs";
5
+ import {
6
+ __spreadProps,
7
+ __spreadValues
8
+ } from "./chunk-VQCHBU2Q.mjs";
9
+
10
+ // call-control-sdk/lib/pages/common/components/AuditReport.tsx
11
+ import { useEffect, useState } from "react";
12
+ import { createPortal } from "react-dom";
13
+ import {
14
+ Avatar,
15
+ Box,
16
+ Typography,
17
+ Table,
18
+ TableBody,
19
+ TableCell,
20
+ TableContainer,
21
+ TableHead,
22
+ TableRow,
23
+ Tabs,
24
+ Tab,
25
+ LinearProgress,
26
+ useTheme,
27
+ Dialog,
28
+ IconButton,
29
+ GlobalStyles,
30
+ CircularProgress,
31
+ Alert,
32
+ ToggleButton,
33
+ ToggleButtonGroup
34
+ } from "@mui/material";
35
+ import { alpha } from "@mui/material/styles";
36
+ import CloseIcon from "@mui/icons-material/Close";
37
+ import LaunchIcon from "@mui/icons-material/Launch";
38
+ import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutlined";
39
+ import HighlightOffIcon from "@mui/icons-material/HighlightOff";
40
+ import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutlined";
41
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
42
+ function toStringArray(value) {
43
+ if (!value) return [];
44
+ if (Array.isArray(value)) return value;
45
+ return value.split("\n").map((l) => l.replace(/^\s*[\*\-]\s*/, "").trim()).filter(Boolean);
46
+ }
47
+ var STATUS_COLOUR = {
48
+ completed: { color: "#2e7d32", bg: "#e8f5e9" },
49
+ complied: { color: "#2e7d32", bg: "#e8f5e9" },
50
+ pass: { color: "#2e7d32", bg: "#e8f5e9" },
51
+ compliant: { color: "#2e7d32", bg: "#e8f5e9" },
52
+ achieved: { color: "#2e7d32", bg: "#e8f5e9" },
53
+ strong: { color: "#2e7d32", bg: "#e8f5e9" },
54
+ excellent: { color: "#2e7d32", bg: "#e8f5e9" },
55
+ low: { color: "#2e7d32", bg: "#e8f5e9" },
56
+ no: { color: "#2e7d32", bg: "#e8f5e9" },
57
+ good: { color: "#1565c0", bg: "#e3f2fd" },
58
+ partial: { color: "#e65100", bg: "#fff3e0" },
59
+ moderate: { color: "#e65100", bg: "#fff3e0" },
60
+ medium: { color: "#e65100", bg: "#fff3e0" },
61
+ missed: { color: "#c62828", bg: "#ffebee" },
62
+ fail: { color: "#c62828", bg: "#ffebee" },
63
+ high: { color: "#c62828", bg: "#ffebee" },
64
+ yes: { color: "#c62828", bg: "#ffebee" },
65
+ "n/a": { color: "#757575", bg: "#f5f5f5" },
66
+ na: { color: "#757575", bg: "#f5f5f5" }
67
+ };
68
+ function resolveColour(label) {
69
+ var _a;
70
+ const key = label.toLowerCase().trim();
71
+ if (STATUS_COLOUR[key]) return STATUS_COLOUR[key];
72
+ const stripped = key.replace(/[^a-z]/g, "");
73
+ return (_a = STATUS_COLOUR[stripped]) != null ? _a : { color: "#555", bg: "#f0f0f0" };
74
+ }
75
+ function StatusBadge({ label }) {
76
+ const { color, bg } = resolveColour(label);
77
+ return /* @__PURE__ */ jsx(Box, { sx: { display: "inline-flex", alignItems: "center", px: "7px", py: "2px", borderRadius: "4px", backgroundColor: bg, whiteSpace: "nowrap" }, children: /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.72rem", fontWeight: 600, color, letterSpacing: "0.02em" }, children: label.toUpperCase() }) });
78
+ }
79
+ function StatusIconBadge({ label }) {
80
+ const key = label.toLowerCase().replace(/[^a-z]/g, "");
81
+ let icon;
82
+ if (key === "complied" || key === "completed" || key === "pass") {
83
+ icon = /* @__PURE__ */ jsx(CheckCircleOutlineIcon, { sx: { fontSize: 15, color: "#2e7d32" } });
84
+ } else if (key === "partial") {
85
+ icon = /* @__PURE__ */ jsx(RemoveCircleOutlineIcon, { sx: { fontSize: 15, color: "#e65100" } });
86
+ } else if (key === "na") {
87
+ icon = /* @__PURE__ */ jsx(RemoveCircleOutlineIcon, { sx: { fontSize: 15, color: "#757575" } });
88
+ } else {
89
+ icon = /* @__PURE__ */ jsx(HighlightOffIcon, { sx: { fontSize: 15, color: "#c62828" } });
90
+ }
91
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "inline-flex", alignItems: "center", gap: "4px" }, children: [
92
+ icon,
93
+ /* @__PURE__ */ jsx(StatusBadge, { label })
94
+ ] });
95
+ }
96
+ function ProgressCell({ value, primary }) {
97
+ const pct = Math.min(Math.round(value.score / value.max * 100), 100);
98
+ const barColor = pct < 80 ? "#c62828" : primary;
99
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1, minWidth: 100 }, children: [
100
+ /* @__PURE__ */ jsx(LinearProgress, { variant: "determinate", value: pct, sx: { flex: 1, height: 5, borderRadius: 3, backgroundColor: alpha(barColor, 0.12), "& .MuiLinearProgress-bar": { backgroundColor: barColor, borderRadius: 3 } } }),
101
+ /* @__PURE__ */ jsxs(Typography, { sx: { fontSize: "0.68rem", color: "text.secondary", minWidth: 28, textAlign: "right" }, children: [
102
+ pct,
103
+ "%"
104
+ ] })
105
+ ] });
106
+ }
107
+ var TH = { fontSize: "0.72rem", fontWeight: 700, color: "text.secondary", py: "7px", px: "10px", backgroundColor: "#f5f7f8", borderBottom: "1px solid", borderColor: "divider", whiteSpace: "nowrap" };
108
+ var TD = { fontSize: "0.75rem", color: "text.primary", py: "6px", px: "10px", borderBottom: "1px solid", borderColor: "divider", verticalAlign: "middle" };
109
+ function SectionTitle({ children }) {
110
+ return /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.78rem", fontWeight: 700, color: "text.primary", mb: "8px", mt: "4px" }, children });
111
+ }
112
+ function TranscriptBubbles({ text }) {
113
+ const lines = text.split("\n").filter((l) => l.trim().length > 0);
114
+ if (!lines.length) {
115
+ return /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.75rem", color: "text.secondary" }, children: "No transcript available." });
116
+ }
117
+ return /* @__PURE__ */ jsx(Box, { sx: { display: "flex", flexDirection: "column", gap: "6px" }, children: lines.map((line, idx) => {
118
+ const isPatient = line.trim().toLowerCase().startsWith("patient");
119
+ const text2 = line.replace(/^\s*(Patient|Agent)\s*:\s*/i, "");
120
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", justifyContent: isPatient ? "flex-end" : "flex-start", alignItems: "flex-end", gap: "6px" }, children: [
121
+ !isPatient && /* @__PURE__ */ jsx(Avatar, { sx: { width: 22, height: 22, fontSize: 12 } }),
122
+ /* @__PURE__ */ jsx(
123
+ Box,
124
+ {
125
+ sx: (t) => ({
126
+ maxWidth: "70%",
127
+ px: "10px",
128
+ py: "7px",
129
+ borderRadius: isPatient ? "8px 8px 0 8px" : "8px 8px 8px 0",
130
+ backgroundColor: isPatient ? t.palette.primary.main : "#fff",
131
+ color: isPatient ? t.palette.common.white : "#222",
132
+ border: isPatient ? "none" : "1px solid #e0e0e0",
133
+ fontSize: "0.78rem",
134
+ lineHeight: 1.5
135
+ }),
136
+ children: text2
137
+ }
138
+ ),
139
+ isPatient && /* @__PURE__ */ jsx(Avatar, { sx: { width: 22, height: 22, fontSize: 12 } })
140
+ ] }, idx);
141
+ }) });
142
+ }
143
+ function OverviewTab({ data }) {
144
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
145
+ const meta = (_a = data.Audit_Metadata) != null ? _a : {};
146
+ const kvItems = [
147
+ { label: "Hospital Name", value: (_b = meta.Hospital_Name) != null ? _b : "N/A" },
148
+ { label: "Call Duration", value: (_c = meta.Call_Duration) != null ? _c : "N/A" },
149
+ { label: "Department", value: (_d = meta["Process/Department"]) != null ? _d : "N/A" },
150
+ { label: "Agent Name", value: (_e = meta.Agent_Name) != null ? _e : "N/A" },
151
+ { label: "Call Disposition", value: (_f = meta.Call_Disposition) != null ? _f : "N/A" },
152
+ { label: "Employee ID", value: (_g = meta.Employee_ID) != null ? _g : "N/A" },
153
+ { label: "Call Category", value: (_h = meta.Call_Category) != null ? _h : "N/A" },
154
+ { label: "Team Leader", value: (_i = meta.Team_Leader) != null ? _i : "N/A" },
155
+ { label: "Call Type", value: (_j = meta.Call_Type) != null ? _j : "N/A" },
156
+ { label: "Auditor Name", value: (_k = meta.Auditor_Name) != null ? _k : "N/A" },
157
+ { label: "Call Date & Time", value: (_l = meta.Call_Date_Time) != null ? _l : "N/A" },
158
+ { label: "Language", value: (_m = meta.Language) != null ? _m : "N/A" },
159
+ { label: "Recording ID", value: (_n = meta.Recording_ID) != null ? _n : "N/A" }
160
+ ];
161
+ const half = Math.ceil(kvItems.length / 2);
162
+ const col1 = kvItems.slice(0, half);
163
+ const col2 = kvItems.slice(half);
164
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
165
+ /* @__PURE__ */ jsxs(Box, { children: [
166
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Audit Metadata" }),
167
+ /* @__PURE__ */ jsx(Box, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", overflow: "hidden", backgroundColor: "background.paper" }, children: /* @__PURE__ */ jsx(Box, { sx: { display: "flex" }, children: [col1, col2].map((chunk, ci) => /* @__PURE__ */ jsx(Box, { sx: { flex: "1 1 240px", minWidth: 0, borderRight: ci === 0 ? "1px solid" : "none", borderColor: "divider" }, children: chunk.map((item, ii) => /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "baseline", borderBottom: ii < chunk.length - 1 ? "1px solid" : "none", borderColor: "divider", px: "10px", py: "6px", gap: 1 }, children: [
168
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.72rem", color: "text.secondary", minWidth: 140, flexShrink: 0 }, children: item.label }),
169
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.75rem", color: "text.primary", fontWeight: 500 }, children: item.value })
170
+ ] }, ii)) }, ci)) }) })
171
+ ] }),
172
+ /* @__PURE__ */ jsxs(Box, { children: [
173
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Call Summary" }),
174
+ /* @__PURE__ */ jsx(Box, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", backgroundColor: "background.paper", px: "14px", py: "10px", maxHeight: 160, overflowY: "auto" }, children: /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.75rem", color: "text.secondary", lineHeight: 1.7 }, children: (_o = data.Call_Summary) != null ? _o : "No summary available." }) })
175
+ ] }),
176
+ /* @__PURE__ */ jsxs(Box, { children: [
177
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Call Transcription" }),
178
+ /* @__PURE__ */ jsx(Box, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", backgroundColor: "#f9f9f9", px: "14px", py: "12px", maxHeight: 320, overflowY: "auto" }, children: /* @__PURE__ */ jsx(TranscriptBubbles, { text: (_p = data.transcript) != null ? _p : "" }) })
179
+ ] })
180
+ ] });
181
+ }
182
+ var SCORECARD_PARAMS = [
183
+ { key: "Opening_and_Greeting", label: "Opening & Greeting", defaultMax: 10 },
184
+ { key: "Verification_and_Authentication", label: "Verification & Authentication", defaultMax: 10 },
185
+ { key: "Communication_and_Soft_Skills", label: "Communication & Soft Skills", defaultMax: 15 },
186
+ { key: "Process_and_Workflow_Adherence", label: "Process & Workflow Adherence", defaultMax: 20 },
187
+ { key: "Resolution_Accuracy", label: "Resolution Accuracy", defaultMax: 20 },
188
+ { key: "Empathy_and_Patient_Assurance", label: "Empathy & Patient Assurance", defaultMax: 10 },
189
+ { key: "Call_Handling", label: "Call Handling", defaultMax: 5 },
190
+ { key: "CRM_Documentation_Alignment", label: "CRM Documentation Alignment", defaultMax: 5 },
191
+ { key: "Closing_and_Customer_Education", label: "Closing & Customer Education", defaultMax: 5 }
192
+ ];
193
+ function ScorecardTab({ data, primary }) {
194
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
195
+ const sc = (_a = data.Quality_Scorecard) != null ? _a : {};
196
+ const summary = (_b = data.Executive_Audit_Summary) != null ? _b : {};
197
+ const rawScore = (_d = (_c = sc.Total_Score) != null ? _c : summary.Overall_Audit_Score_Percentage) != null ? _d : 0;
198
+ const overallScore = typeof rawScore === "string" ? parseFloat(rawScore.replace("%", "")) || 0 : rawScore;
199
+ const pct = Math.min(Math.round(overallScore / 100 * 100), 100);
200
+ const resultBadge = (_f = (_e = summary.Audit_Result) != null ? _e : sc.Final_Rating) != null ? _f : "N/A";
201
+ const metrics = [
202
+ { label: "Audit Result", value: (_g = summary.Audit_Result) != null ? _g : "N/A" },
203
+ { label: "First Call Resolution", value: (_h = summary.First_Call_Resolution_FCR) != null ? _h : "N/A" },
204
+ { label: "Patient Experience", value: (_j = (_i = summary.Customer_Experience) != null ? _i : summary.Patient_Sentiment) != null ? _j : "N/A" },
205
+ { label: "Process Adherence", value: (_k = summary.Process_Adherence) != null ? _k : "N/A" },
206
+ { label: "Effective Communication", value: (_l = summary.Communication_Effectiveness) != null ? _l : "N/A" }
207
+ ];
208
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2.5 }, children: [
209
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", gap: 2, flexWrap: "wrap", alignItems: "stretch" }, children: [
210
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", border: "1px solid", borderColor: "divider", borderRadius: "8px", backgroundColor: "background.paper", px: 3, py: 2, minWidth: 140, gap: 0.5 }, children: [
211
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.72rem", color: "text.secondary", fontWeight: 600, mb: 0.5, letterSpacing: "0.04em" }, children: "OVERALL SCORE" }),
212
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "baseline", gap: "3px" }, children: [
213
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "2.4rem", fontWeight: 700, color: primary, lineHeight: 1 }, children: overallScore }),
214
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.85rem", color: "text.secondary", fontWeight: 600 }, children: "/100" })
215
+ ] }),
216
+ /* @__PURE__ */ jsx(Box, { sx: { width: "100%", mt: 0.75 }, children: /* @__PURE__ */ jsx(LinearProgress, { variant: "determinate", value: pct, sx: { height: 6, borderRadius: 3, backgroundColor: alpha(primary, 0.12), "& .MuiLinearProgress-bar": { backgroundColor: primary, borderRadius: 3 } } }) }),
217
+ /* @__PURE__ */ jsx(Box, { sx: { mt: 0.75 }, children: /* @__PURE__ */ jsx(StatusBadge, { label: resultBadge }) })
218
+ ] }),
219
+ /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, minWidth: 260, display: "flex", flexDirection: "column", gap: "8px", alignSelf: "stretch" }, children: [
220
+ /* @__PURE__ */ jsx(Box, { sx: { flex: 1, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "8px" }, children: metrics.slice(0, 3).map((m) => /* @__PURE__ */ jsxs(Box, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "6px", backgroundColor: "background.paper", px: "10px", py: "8px", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: "6px" }, children: [
221
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.72rem", color: "text.secondary", lineHeight: 1.3, textAlign: "center" }, children: m.label }),
222
+ /* @__PURE__ */ jsx(StatusBadge, { label: m.value })
223
+ ] }, m.label)) }),
224
+ /* @__PURE__ */ jsx(Box, { sx: { flex: 1, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "8px" }, children: metrics.slice(3).map((m) => /* @__PURE__ */ jsxs(Box, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "6px", backgroundColor: "background.paper", px: "10px", py: "8px", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: "6px" }, children: [
225
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.72rem", color: "text.secondary", lineHeight: 1.3, textAlign: "center" }, children: m.label }),
226
+ /* @__PURE__ */ jsx(StatusBadge, { label: m.value })
227
+ ] }, m.label)) })
228
+ ] })
229
+ ] }),
230
+ /* @__PURE__ */ jsxs(Box, { children: [
231
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Quality Scorecard" }),
232
+ /* @__PURE__ */ jsx(TableContainer, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", overflow: "hidden" }, children: /* @__PURE__ */ jsxs(Table, { size: "small", children: [
233
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: [
234
+ { label: "Evaluation Parameter", align: "left", minWidth: 180 },
235
+ { label: "Weightage", align: "center", minWidth: 90 },
236
+ { label: "Score", align: "center", minWidth: 80 },
237
+ { label: "", align: "left", minWidth: 120 },
238
+ { label: "Remarks", align: "left", minWidth: 160 }
239
+ ].map((col, i) => /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TH), { textAlign: col.align, minWidth: col.minWidth }), children: col.label }, i)) }) }),
240
+ /* @__PURE__ */ jsxs(TableBody, { children: [
241
+ SCORECARD_PARAMS.map((p) => {
242
+ var _a2, _b2;
243
+ const entry = sc[p.key];
244
+ const rawEntryScore = entry == null ? void 0 : entry.Score_Obtained;
245
+ const score = typeof rawEntryScore === "string" ? parseFloat(rawEntryScore) || 0 : rawEntryScore != null ? rawEntryScore : 0;
246
+ const max = (_a2 = entry == null ? void 0 : entry.Weightage) != null ? _a2 : p.defaultMax;
247
+ return /* @__PURE__ */ jsxs(TableRow, { children: [
248
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: p.label }),
249
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TD), { textAlign: "center" }), children: max }),
250
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TD), { textAlign: "center" }), children: rawEntryScore != null ? rawEntryScore : "\u2014" }),
251
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: /* @__PURE__ */ jsx(ProgressCell, { value: { score, max }, primary }) }),
252
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: (_b2 = entry == null ? void 0 : entry.Remarks) != null ? _b2 : "\u2014" })
253
+ ] }, p.key);
254
+ }),
255
+ /* @__PURE__ */ jsxs(TableRow, { sx: { backgroundColor: "#f5f7f8", "& td": { borderBottom: 0 } }, children: [
256
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TD), { fontWeight: 700 }), children: "Total Score" }),
257
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TD), { textAlign: "center", fontWeight: 700 }), children: "100" }),
258
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TD), { textAlign: "center", fontWeight: 700 }), children: overallScore }),
259
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: /* @__PURE__ */ jsx(ProgressCell, { value: { score: overallScore, max: 100 }, primary }) }),
260
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TD), { fontWeight: 700 }), children: /* @__PURE__ */ jsx(StatusBadge, { label: (_m = sc.Final_Rating) != null ? _m : resultBadge }) })
261
+ ] })
262
+ ] })
263
+ ] }) })
264
+ ] })
265
+ ] });
266
+ }
267
+ var OPENING_LABELS = { Standard_Greeting_Used: "Standard Greeting Used", Hospital_Name_Mentioned: "Hospital Name Mentioned", Agent_Introduction_Provided: "Agent Introduction Provided", Professional_Tone_Maintained: "Professional Tone Maintained" };
268
+ var OPENING_EXPECTED = { Standard_Greeting_Used: "Agent must greet as per approved hospital script", Hospital_Name_Mentioned: "Mandatory hospital identification", Agent_Introduction_Provided: "Agent must introduce self", Professional_Tone_Maintained: "Warm and professional tone expected" };
269
+ var VERIFICATION_LABELS = { Patient_Name_Captured: "Patient Name Captured", "Existing_New_Patient_Validation": "Existing/New Patient Validation", Registered_Mobile_Number_Verified: "Registered Mobile Number Verified", "Secondary_Authentication_DOB_UHID": "Secondary Authentication (DOB/UHID)" };
270
+ var VERIFICATION_EXPECTED = { Patient_Name_Captured: "Mandatory for identification", "Existing_New_Patient_Validation": "Required for workflow routing", Registered_Mobile_Number_Verified: "Mandatory authentication step", "Secondary_Authentication_DOB_UHID": "Recommended compliance practice" };
271
+ var COMM_LABELS = { Clarity_of_Speech: "Clarity of Speech", Active_Listening_Demonstrated: "Active Listening Demonstrated", Avoidance_of_Dead_Air: "Avoidance of Dead Air", Professional_Language_Usage: "Professional Language Usage", Empathy_Statements_Used: "Empathy Statements Used" };
272
+ var COMM_EXPECTED = { Clarity_of_Speech: "Clear and understandable communication", Active_Listening_Demonstrated: "Agent should acknowledge caller inputs", Avoidance_of_Dead_Air: "Minimal silence during call", Professional_Language_Usage: "No slang/rude language", Empathy_Statements_Used: "Emotional acknowledgement expected" };
273
+ var EMPATHY_LABELS = { Patient_Concern_Acknowledged: "Patient Concern Acknowledged", Empathy_Toward_Patient_Condition: "Empathy Toward Patient Condition", Severity_Red_Flag_Probing: "Severity/Red Flag Probing", Professional_Behaviour_Maintained: "Professional Behaviour Maintained" };
274
+ var EMPATHY_EXPECTED = { Patient_Concern_Acknowledged: "Agent should acknowledge caller concern", Empathy_Toward_Patient_Condition: "Empathetic reassurance expected", Severity_Red_Flag_Probing: "Escalation probing recommended where applicable", Professional_Behaviour_Maintained: "Calm and respectful handling required" };
275
+ var CALL_HANDLING_LABELS = { "Placing the Call on Hold": "Placing the Call on Hold", Resuming_After_Hold: "Resuming After Hold", Apologizing_for_Inconvenience: "Apologizing for Inconvenience", Offering_Further_Assistance: "Offering Further Assistance" };
276
+ var CALL_HANDLING_EXPECTED = { "Placing the Call on Hold": "Inform customer before placing on hold", Resuming_After_Hold: "Thank customer for holding", Apologizing_for_Inconvenience: "Apologize for any delays", Offering_Further_Assistance: "Ask if further help is needed" };
277
+ var CLOSURE_LABELS = { Additional_Assistance_Offered: "Additional Assistance Offered", Professional_Closing_Provided: "Professional Closing Provided", "Wellness/Courtesy_Statement_Used": "Wellness/Courtesy Statement Used" };
278
+ var CLOSURE_EXPECTED = { Additional_Assistance_Offered: "Mandatory closure check", Professional_Closing_Provided: "Standard closure etiquette expected", "Wellness/Courtesy_Statement_Used": "Positive healthcare closure preferred" };
279
+ var EXCLUDED_KEYS = /* @__PURE__ */ new Set(["Patient_Data_Handling", "Recontact_Information_Shared"]);
280
+ function obsRecordToRows(record, labelMap, expectedMap) {
281
+ return Object.entries(record != null ? record : {}).filter(([key]) => !EXCLUDED_KEYS.has(key)).map(([key, val]) => {
282
+ var _a, _b, _c, _d, _e;
283
+ return {
284
+ parameter: (_a = labelMap[key]) != null ? _a : key.replace(/_/g, " "),
285
+ expectedStandard: (_b = expectedMap[key]) != null ? _b : "\u2014",
286
+ status: (_c = val.Status) != null ? _c : "N/A",
287
+ remarks: (_d = val.Remarks) != null ? _d : "\u2014",
288
+ qaObservation: (_e = val.Observation_Impact) != null ? _e : "\u2014"
289
+ };
290
+ });
291
+ }
292
+ function processWorkflowRows(groups) {
293
+ return (groups != null ? groups : []).flatMap(
294
+ (g) => {
295
+ var _a;
296
+ return ((_a = g == null ? void 0 : g.items) != null ? _a : []).map((item) => {
297
+ var _a2, _b, _c, _d, _e;
298
+ return {
299
+ parameter: (_a2 = item.parameter) != null ? _a2 : "\u2014",
300
+ expectedStandard: (_b = item.expectedStandard) != null ? _b : "\u2014",
301
+ status: (_c = item.status) != null ? _c : "N/A",
302
+ remarks: (_d = item.remarks) != null ? _d : "\u2014",
303
+ qaObservation: (_e = item.qaObservation) != null ? _e : "\u2014"
304
+ };
305
+ });
306
+ }
307
+ );
308
+ }
309
+ var CHECKLIST_COLS = [
310
+ { key: "parameter", label: "Audit Parameter", minWidth: 180 },
311
+ { key: "expectedStandard", label: "Expected Standard", minWidth: 200 },
312
+ { key: "status", label: "Status", minWidth: 130 },
313
+ { key: "remarks", label: "Remarks", minWidth: 160 },
314
+ { key: "qaObservation", label: "QA Observation / Impact", minWidth: 180 }
315
+ ];
316
+ function ChecklistTable({ title, rows }) {
317
+ const visibleRows = rows;
318
+ if (!visibleRows.length) return null;
319
+ return /* @__PURE__ */ jsxs(Box, { children: [
320
+ /* @__PURE__ */ jsx(SectionTitle, { children: title }),
321
+ /* @__PURE__ */ jsx(TableContainer, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", overflow: "hidden" }, children: /* @__PURE__ */ jsxs(Table, { size: "small", children: [
322
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: CHECKLIST_COLS.map((col) => /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TH), { minWidth: col.minWidth }), children: col.label }, col.key)) }) }),
323
+ /* @__PURE__ */ jsx(TableBody, { children: visibleRows.map((row, ri) => /* @__PURE__ */ jsxs(TableRow, { sx: { "&:last-child td": { borderBottom: 0 } }, children: [
324
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: row.parameter }),
325
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: row.expectedStandard }),
326
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: /* @__PURE__ */ jsx(StatusIconBadge, { label: row.status }) }),
327
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: row.remarks }),
328
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: row.qaObservation })
329
+ ] }, ri)) })
330
+ ] }) })
331
+ ] });
332
+ }
333
+ function DispositionFrameworkTable({ data }) {
334
+ var _a;
335
+ const rows = ((_a = data.Disposition_Based_Quality_Framework) != null ? _a : []).flatMap(
336
+ (df) => {
337
+ var _a2;
338
+ return ((_a2 = df == null ? void 0 : df.frameworks) != null ? _a2 : []).map((fw) => {
339
+ var _a3, _b, _c, _d;
340
+ return {
341
+ dispositionType: (_a3 = df.dispositionType) != null ? _a3 : "\u2014",
342
+ expectedFramework: (_b = fw.expectedFramework) != null ? _b : "\u2014",
343
+ status: (_c = fw.status) != null ? _c : "N/A",
344
+ remarks: (_d = fw.remarks) != null ? _d : "\u2014"
345
+ };
346
+ });
347
+ }
348
+ ).filter((r) => r.expectedFramework.toLowerCase().trim() !== "clinical sensitivity handling");
349
+ if (!rows.length) {
350
+ return /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.75rem", color: "text.secondary" }, children: "No disposition framework data available." });
351
+ }
352
+ return /* @__PURE__ */ jsxs(Box, { children: [
353
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Disposition-Based Quality Framework" }),
354
+ /* @__PURE__ */ jsx(TableContainer, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", overflow: "hidden" }, children: /* @__PURE__ */ jsxs(Table, { size: "small", children: [
355
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: [
356
+ { label: "Disposition Type", minWidth: 160 },
357
+ { label: "Expected Framework", minWidth: 200 },
358
+ { label: "Status", minWidth: 120 },
359
+ { label: "Remarks", minWidth: 160 }
360
+ ].map((col, i) => /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TH), { minWidth: col.minWidth }), children: col.label }, i)) }) }),
361
+ /* @__PURE__ */ jsx(TableBody, { children: rows.map((row, ri) => /* @__PURE__ */ jsxs(TableRow, { sx: { "&:last-child td": { borderBottom: 0 } }, children: [
362
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: row.dispositionType }),
363
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: row.expectedFramework }),
364
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: /* @__PURE__ */ jsx(StatusIconBadge, { label: row.status }) }),
365
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: row.remarks })
366
+ ] }, ri)) })
367
+ ] }) })
368
+ ] });
369
+ }
370
+ function AuditChecklistContent({ data }) {
371
+ var _a;
372
+ const obs = (_a = data.Section_Wise_Audit_Observations_Checklist) != null ? _a : {};
373
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
374
+ /* @__PURE__ */ jsx(DispositionFrameworkTable, { data }),
375
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Opening & Greeting", rows: obsRecordToRows(obs.Opening_and_Greeting, OPENING_LABELS, OPENING_EXPECTED) }),
376
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Verification & Authentication", rows: obsRecordToRows(obs.Verification_and_Authentication, VERIFICATION_LABELS, VERIFICATION_EXPECTED) }),
377
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Communication Effectiveness", rows: obsRecordToRows(obs.Communication_and_Soft_Skills, COMM_LABELS, COMM_EXPECTED) }),
378
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Process & Workflow Adherence", rows: processWorkflowRows(obs.Process_and_Workflow_Adherence) }),
379
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Empathy & Patient Assurance", rows: obsRecordToRows(obs.Empathy_and_Patient_Assurance, EMPATHY_LABELS, EMPATHY_EXPECTED) }),
380
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Call Handling", rows: obsRecordToRows(obs.Call_Handling, CALL_HANDLING_LABELS, CALL_HANDLING_EXPECTED) }),
381
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Call Closure & Customer Education", rows: obsRecordToRows(obs.Call_Closure_and_Customer_Education, CLOSURE_LABELS, CLOSURE_EXPECTED) })
382
+ ] });
383
+ }
384
+ function AuditChecklistTab({ data, primary: _primary }) {
385
+ var _a;
386
+ const [view, setView] = useState("overview");
387
+ const obs = (_a = data.Section_Wise_Audit_Observations_Checklist) != null ? _a : {};
388
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
389
+ /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ jsxs(
390
+ ToggleButtonGroup,
391
+ {
392
+ value: view,
393
+ exclusive: true,
394
+ onChange: (_, v) => v && setView(v),
395
+ size: "small",
396
+ sx: {
397
+ "& .MuiToggleButton-root": {
398
+ fontSize: "0.72rem",
399
+ fontWeight: 600,
400
+ textTransform: "none",
401
+ px: 1.5,
402
+ py: "4px",
403
+ border: "1px solid",
404
+ borderColor: "divider",
405
+ color: "text.secondary",
406
+ "&.Mui-selected": { backgroundColor: _primary, color: "#fff", borderColor: _primary, "&:hover": { backgroundColor: _primary } }
407
+ }
408
+ },
409
+ children: [
410
+ /* @__PURE__ */ jsx(ToggleButton, { value: "overview", children: "Overview" }),
411
+ /* @__PURE__ */ jsx(ToggleButton, { value: "detailed", children: "Detailed" })
412
+ ]
413
+ }
414
+ ) }),
415
+ view === "overview" && /* @__PURE__ */ jsx(DispositionFrameworkTable, { data }),
416
+ view === "detailed" && /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
417
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Opening & Greeting", rows: obsRecordToRows(obs.Opening_and_Greeting, OPENING_LABELS, OPENING_EXPECTED) }),
418
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Verification & Authentication", rows: obsRecordToRows(obs.Verification_and_Authentication, VERIFICATION_LABELS, VERIFICATION_EXPECTED) }),
419
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Communication Effectiveness", rows: obsRecordToRows(obs.Communication_and_Soft_Skills, COMM_LABELS, COMM_EXPECTED) }),
420
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Process & Workflow Adherence", rows: processWorkflowRows(obs.Process_and_Workflow_Adherence) }),
421
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Empathy & Patient Assurance", rows: obsRecordToRows(obs.Empathy_and_Patient_Assurance, EMPATHY_LABELS, EMPATHY_EXPECTED) }),
422
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Call Handling", rows: obsRecordToRows(obs.Call_Handling, CALL_HANDLING_LABELS, CALL_HANDLING_EXPECTED) }),
423
+ /* @__PURE__ */ jsx(ChecklistTable, { title: "Call Closure & Customer Education", rows: obsRecordToRows(obs.Call_Closure_and_Customer_Education, CLOSURE_LABELS, CLOSURE_EXPECTED) })
424
+ ] })
425
+ ] });
426
+ }
427
+ function RootCauseAnalysisTab({ data, primary }) {
428
+ var _a, _b;
429
+ const rcaRows = (_a = data.Root_Cause_Analysis) != null ? _a : [];
430
+ const rec = (_b = data.Auditor_Recommendation) != null ? _b : {};
431
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
432
+ /* @__PURE__ */ jsxs(Box, { children: [
433
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Root Cause Analysis" }),
434
+ rcaRows.length > 0 ? /* @__PURE__ */ jsx(TableContainer, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", overflow: "hidden" }, children: /* @__PURE__ */ jsxs(Table, { size: "small", children: [
435
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: [{ label: "Observation", minWidth: 180 }, { label: "Root Cause", minWidth: 200 }, { label: "Impact", minWidth: 200 }, { label: "Severity", minWidth: 90 }].map((col, i) => /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TH), { minWidth: col.minWidth }), children: col.label }, i)) }) }),
436
+ /* @__PURE__ */ jsx(TableBody, { children: rcaRows.map((row, ri) => {
437
+ var _a2, _b2, _c;
438
+ return /* @__PURE__ */ jsxs(TableRow, { sx: { "&:last-child td": { borderBottom: 0 } }, children: [
439
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: (_a2 = row.Observation) != null ? _a2 : "\u2014" }),
440
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: (_b2 = row.Root_Cause) != null ? _b2 : "\u2014" }),
441
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadValues({}, TD), children: (_c = row.Impact) != null ? _c : "\u2014" }),
442
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, TD), { textAlign: "center" }), children: row.Severity ? /* @__PURE__ */ jsx(StatusBadge, { label: row.Severity }) : "\u2014" })
443
+ ] }, ri);
444
+ }) })
445
+ ] }) }) : /* @__PURE__ */ jsx(Box, { sx: { border: "1px solid", borderColor: "divider", borderRadius: "8px", px: "14px", py: "10px", backgroundColor: "background.paper" }, children: /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.75rem", color: "text.secondary" }, children: "No significant root causes identified for this interaction." }) })
446
+ ] }),
447
+ (toStringArray(rec.Key_Strengths).length > 0 || toStringArray(rec.Improvement_Areas).length > 0) && /* @__PURE__ */ jsxs(Box, { children: [
448
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Auditor's Recommendation" }),
449
+ /* @__PURE__ */ jsx(Box, { sx: { display: "flex", gap: 2, flexWrap: "wrap" }, children: [
450
+ { title: "Key Strengths", items: toStringArray(rec.Key_Strengths), color: "#2e7d32" },
451
+ { title: "Improvement Areas", items: toStringArray(rec.Improvement_Areas), color: "#e65100" }
452
+ ].filter((g) => {
453
+ var _a2, _b2;
454
+ return ((_b2 = (_a2 = g.items) == null ? void 0 : _a2.length) != null ? _b2 : 0) > 0;
455
+ }).map((g) => {
456
+ var _a2;
457
+ return /* @__PURE__ */ jsxs(Box, { sx: { flex: "1 1 200px", border: "1px solid", borderColor: "divider", borderRadius: "6px", backgroundColor: "background.paper", px: "14px", py: "10px" }, children: [
458
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.78rem", fontWeight: 600, color: "text.primary", mb: "8px" }, children: g.title }),
459
+ (_a2 = g.items) == null ? void 0 : _a2.map((item, ii) => /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "flex-start", gap: "7px", mb: "5px" }, children: [
460
+ /* @__PURE__ */ jsx(Box, { sx: { width: 5, height: 5, borderRadius: "50%", backgroundColor: g.color, mt: "5px", flexShrink: 0 } }),
461
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.75rem", color: "text.secondary", lineHeight: 1.5 }, children: item })
462
+ ] }, ii))
463
+ ] }, g.title);
464
+ }) })
465
+ ] }),
466
+ data.Final_Auditor_Remarks && /* @__PURE__ */ jsxs(Box, { sx: { border: "1px solid", borderLeft: "3px solid", borderColor: "divider", borderLeftColor: primary, borderRadius: "6px", px: "14px", py: "10px", backgroundColor: alpha(primary, 0.04) }, children: [
467
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.78rem", fontWeight: 600, color: primary, mb: "6px" }, children: "Final Auditor Remarks" }),
468
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.75rem", color: "text.secondary", lineHeight: 1.6 }, children: data.Final_Auditor_Remarks })
469
+ ] })
470
+ ] });
471
+ }
472
+ var STATIC_TABS = [
473
+ { id: "overview", label: "Overview" },
474
+ { id: "scorecard", label: "Scorecard" },
475
+ { id: "checklist", label: "Audit Checklist" },
476
+ { id: "rca", label: "Root Cause Analysis" }
477
+ ];
478
+ function useAuditReportData(callUuid, active = true) {
479
+ const [activeTab, setActiveTab] = useState(0);
480
+ const [apiData, setApiData] = useState(null);
481
+ const [auditLoading, setAuditLoading] = useState(false);
482
+ const [auditError, setAuditError] = useState(null);
483
+ useEffect(() => {
484
+ setApiData(null);
485
+ setAuditError(null);
486
+ setActiveTab(0);
487
+ if (!active || !callUuid) return;
488
+ let cancelled = false;
489
+ setAuditLoading(true);
490
+ axios_default.get(END_POINT.CALLSAGE_AUDIT(callUuid)).then((res) => {
491
+ if (!cancelled) setApiData(res.data);
492
+ }).catch((err) => {
493
+ var _a, _b, _c, _d;
494
+ if (!cancelled) setAuditError((_d = (_c = (_b = (_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) != null ? _c : err == null ? void 0 : err.message) != null ? _d : "Failed to generate audit report");
495
+ }).finally(() => {
496
+ if (!cancelled) setAuditLoading(false);
497
+ });
498
+ return () => {
499
+ cancelled = true;
500
+ };
501
+ }, [active, callUuid]);
502
+ return { activeTab, setActiveTab, apiData, auditLoading, auditError };
503
+ }
504
+ var PRINT_ROOT_ID = "audit-report-print-root";
505
+ var PRINT_STYLES = /* @__PURE__ */ jsx(
506
+ GlobalStyles,
507
+ {
508
+ styles: {
509
+ [`#${PRINT_ROOT_ID}`]: { position: "absolute", width: "1px", height: "1px", overflow: "hidden", clip: "rect(0 0 0 0)", clipPath: "inset(50%)", whiteSpace: "nowrap", pointerEvents: "none" },
510
+ "@media print": {
511
+ "body *": { visibility: "hidden" },
512
+ [`#${PRINT_ROOT_ID}`]: { visibility: "visible", position: "absolute", top: 0, left: 0, width: "100%", height: "auto", overflow: "visible", clip: "auto", clipPath: "none", whiteSpace: "normal", padding: "0 8mm", boxSizing: "border-box" },
513
+ [`#${PRINT_ROOT_ID} *`]: { visibility: "visible", printColorAdjust: "exact", WebkitPrintColorAdjust: "exact" }
514
+ }
515
+ }
516
+ }
517
+ );
518
+ function buildHeaderBadges(data) {
519
+ var _a, _b, _c, _d, _e, _f, _g;
520
+ const sc = (_a = data.Quality_Scorecard) != null ? _a : {};
521
+ const summary = (_b = data.Executive_Audit_Summary) != null ? _b : {};
522
+ const meta = (_c = data.Audit_Metadata) != null ? _c : {};
523
+ return [
524
+ { label: "Call Disposition", value: (_d = meta.Call_Disposition) != null ? _d : "N/A" },
525
+ { label: "Result", value: (_e = summary.Audit_Result) != null ? _e : "N/A", asBadge: true },
526
+ { label: "Score", value: `${(_g = (_f = sc.Total_Score) != null ? _f : summary.Overall_Audit_Score_Percentage) != null ? _g : 0}/100` }
527
+ ];
528
+ }
529
+ function AuditReportInner({ callUuid, active = true, primary, onClose, onMaximize }) {
530
+ var _a, _b, _c;
531
+ const { activeTab, setActiveTab, apiData, auditLoading, auditError } = useAuditReportData(callUuid, active);
532
+ const headerBadges = apiData ? buildHeaderBadges(apiData) : [];
533
+ const subtitle = apiData ? [(_a = apiData.Audit_Metadata) == null ? void 0 : _a.Agent_Name, (_b = apiData.Audit_Metadata) == null ? void 0 : _b.Hospital_Name, (_c = apiData.Audit_Metadata) == null ? void 0 : _c.Call_Date_Time].filter(Boolean).join(" \xB7 ") || void 0 : void 0;
534
+ const iconButtonSx = {
535
+ flexShrink: 0,
536
+ width: 28,
537
+ height: 28,
538
+ borderRadius: "6px",
539
+ backgroundColor: "action.hover",
540
+ color: "text.secondary",
541
+ "&:hover": { backgroundColor: "action.selected", color: "text.primary" },
542
+ transition: "all 0.15s ease"
543
+ };
544
+ function renderTab() {
545
+ if (!apiData) return null;
546
+ switch (activeTab) {
547
+ case 0:
548
+ return /* @__PURE__ */ jsx(OverviewTab, { data: apiData });
549
+ case 1:
550
+ return /* @__PURE__ */ jsx(ScorecardTab, { data: apiData, primary });
551
+ case 2:
552
+ return /* @__PURE__ */ jsx(AuditChecklistTab, { data: apiData, primary });
553
+ case 3:
554
+ return /* @__PURE__ */ jsx(RootCauseAnalysisTab, { data: apiData, primary });
555
+ default:
556
+ return null;
557
+ }
558
+ }
559
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
560
+ PRINT_STYLES,
561
+ createPortal(
562
+ /* @__PURE__ */ jsxs("div", { id: PRINT_ROOT_ID, children: [
563
+ /* @__PURE__ */ jsxs(Box, { sx: { mb: 2.5, pb: 1.5, borderBottom: "2px solid", borderColor: "divider" }, children: [
564
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.2rem", fontWeight: 700, color: "text.primary" }, children: "Audit Report" }),
565
+ subtitle && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.8rem", color: "text.secondary", mt: "4px" }, children: subtitle })
566
+ ] }),
567
+ apiData && /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: [
568
+ /* @__PURE__ */ jsx(OverviewTab, { data: apiData }),
569
+ /* @__PURE__ */ jsx(ScorecardTab, { data: apiData, primary }),
570
+ /* @__PURE__ */ jsxs(Box, { children: [
571
+ /* @__PURE__ */ jsx(SectionTitle, { children: "Audit Checklist" }),
572
+ /* @__PURE__ */ jsx(AuditChecklistContent, { data: apiData })
573
+ ] }),
574
+ /* @__PURE__ */ jsx(RootCauseAnalysisTab, { data: apiData, primary })
575
+ ] })
576
+ ] }),
577
+ document.body
578
+ ),
579
+ /* @__PURE__ */ jsxs(Box, { sx: { px: { xs: 2, md: 2.5 }, py: "12px", display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 1, borderBottom: "1px solid", borderColor: "divider", flexShrink: 0 }, children: [
580
+ /* @__PURE__ */ jsxs(Box, { sx: { minWidth: 0 }, children: [
581
+ /* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 700, fontSize: { xs: "1rem", sm: "1.2rem" }, color: "text.primary", lineHeight: 1.3 }, children: "Audit Report" }),
582
+ subtitle && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.78rem", color: "text.secondary", mt: "3px" }, children: subtitle })
583
+ ] }),
584
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.75, flexShrink: 0 }, children: [
585
+ onMaximize && /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: onMaximize, title: "Open in new tab", sx: iconButtonSx, children: /* @__PURE__ */ jsx(LaunchIcon, { sx: { fontSize: 14 } }) }),
586
+ onClose && /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: onClose, title: "Close", sx: iconButtonSx, children: /* @__PURE__ */ jsx(CloseIcon, { sx: { fontSize: 15 } }) })
587
+ ] })
588
+ ] }),
589
+ headerBadges.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { px: { xs: 2, md: 2.5 }, py: "8px", display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap", borderBottom: "1px solid", borderColor: "divider", backgroundColor: "#f5f7f8", flexShrink: 0 }, children: headerBadges.map(
590
+ (badge, i) => badge.asBadge ? /* @__PURE__ */ jsx(StatusBadge, { label: badge.value }, i) : /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: "5px", px: "9px", height: 26, border: "1px solid", borderColor: "divider", borderRadius: "5px", backgroundColor: "background.paper" }, children: [
591
+ /* @__PURE__ */ jsx(Box, { sx: { width: 5, height: 5, borderRadius: "50%", backgroundColor: primary, flexShrink: 0 } }),
592
+ /* @__PURE__ */ jsxs(Typography, { sx: { fontSize: "0.72rem", color: "text.secondary", whiteSpace: "nowrap" }, children: [
593
+ /* @__PURE__ */ jsxs(Box, { component: "span", sx: { fontWeight: 600, color: "text.primary", mr: "3px" }, children: [
594
+ badge.label,
595
+ ":"
596
+ ] }),
597
+ badge.value
598
+ ] })
599
+ ] }, i)
600
+ ) }),
601
+ /* @__PURE__ */ jsx(Box, { sx: { borderBottom: "1px solid", borderColor: "divider", backgroundColor: "background.paper", flexShrink: 0 }, children: /* @__PURE__ */ jsx(
602
+ Tabs,
603
+ {
604
+ value: activeTab,
605
+ onChange: (_, v) => setActiveTab(v),
606
+ variant: "scrollable",
607
+ scrollButtons: "auto",
608
+ sx: {
609
+ minHeight: 40,
610
+ px: { xs: 1, md: 2 },
611
+ "& .MuiTab-root": { fontSize: "0.78rem", fontWeight: 600, minHeight: 40, textTransform: "none", color: "text.secondary", py: 0, px: 1.5, "&.Mui-selected": { color: primary } },
612
+ "& .MuiTabs-indicator": { backgroundColor: primary, height: 2 }
613
+ },
614
+ children: STATIC_TABS.map((tab) => /* @__PURE__ */ jsx(Tab, { label: tab.label, disableRipple: true }, tab.id))
615
+ }
616
+ ) }),
617
+ /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "auto", px: { xs: 2, md: 2.5 }, py: 2 }, children: [
618
+ auditLoading && /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", py: 6 }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 32 }) }),
619
+ !auditLoading && auditError && /* @__PURE__ */ jsx(Alert, { severity: "warning", sx: { mb: 2, fontSize: "0.78rem" }, children: auditError }),
620
+ !auditLoading && !auditError && !apiData && /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", py: 6 }, children: /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.78rem", color: "text.secondary" }, children: "No audit data available." }) }),
621
+ !auditLoading && apiData && renderTab()
622
+ ] })
623
+ ] });
624
+ }
625
+ var auditReportUrlResolver = (callUuid) => `/audit-report/${encodeURIComponent(callUuid)}`;
626
+ function setAuditReportUrlResolver(resolver) {
627
+ auditReportUrlResolver = resolver;
628
+ }
629
+ function AuditReportDialog({ open, onClose, width = "80vw", rowData, onMaximize }) {
630
+ const theme = useTheme();
631
+ const primary = theme.palette.primary.main;
632
+ const callUuid = rowData == null ? void 0 : rowData.callUuid;
633
+ const handleMaximize = () => {
634
+ if (!callUuid) return;
635
+ if (onMaximize) {
636
+ onMaximize(callUuid);
637
+ return;
638
+ }
639
+ window.open(auditReportUrlResolver(callUuid), "_blank");
640
+ };
641
+ return /* @__PURE__ */ jsx(
642
+ Dialog,
643
+ {
644
+ open,
645
+ onClose: (_e, reason) => {
646
+ if (reason !== "backdropClick") onClose();
647
+ },
648
+ fullWidth: true,
649
+ slotProps: {
650
+ paper: {
651
+ sx: { width, maxWidth: width, height: "90vh", display: "flex", flexDirection: "column", overflow: "hidden", borderRadius: "10px" }
652
+ }
653
+ },
654
+ children: open && /* @__PURE__ */ jsx(
655
+ AuditReportInner,
656
+ {
657
+ callUuid,
658
+ active: open,
659
+ primary,
660
+ onClose,
661
+ onMaximize: callUuid ? handleMaximize : void 0
662
+ }
663
+ )
664
+ }
665
+ );
666
+ }
667
+ function AuditReportFullPage({ callUuid }) {
668
+ const theme = useTheme();
669
+ const primary = theme.palette.primary.main;
670
+ return /* @__PURE__ */ jsx(Box, { sx: { height: "100vh", display: "flex", flexDirection: "column", overflow: "hidden", backgroundColor: "background.paper" }, children: /* @__PURE__ */ jsx(AuditReportInner, { callUuid, active: true, primary }) });
671
+ }
672
+
673
+ export {
674
+ setAuditReportUrlResolver,
675
+ AuditReportDialog,
676
+ AuditReportFullPage
677
+ };
678
+ //# sourceMappingURL=chunk-UZF5Q3GR.mjs.map