@mindbill/react 0.18.0 → 0.20.1

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.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/index.tsx
4
4
  import "@mindbill/embed";
5
- import { createElement, useEffect as useEffect5, useRef as useRef4 } from "react";
5
+ import { createElement, useEffect as useEffect5, useRef as useRef5 } from "react";
6
6
 
7
7
  // src/appearance.ts
8
8
  var mindBillThemePresets = {
@@ -1043,9 +1043,123 @@ var NATIVE_THEME_OVERRIDE_STYLES = `
1043
1043
  .mb-native-combo-list{border-color:var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface);box-shadow:var(--mb-shadow)}
1044
1044
  `;
1045
1045
 
1046
- // src/bill-submission-form.tsx
1047
- import { useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
1046
+ // src/bill-read-only-form.tsx
1048
1047
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1048
+ function money2(value) {
1049
+ return new Intl.NumberFormat(void 0, { style: "currency", currency: "USD" }).format(value);
1050
+ }
1051
+ function date(value) {
1052
+ if (!value) return "\u2014";
1053
+ const parsed = /* @__PURE__ */ new Date(`${value.slice(0, 10)}T12:00:00`);
1054
+ return Number.isNaN(parsed.getTime()) ? value : new Intl.DateTimeFormat(void 0, { dateStyle: "medium" }).format(parsed);
1055
+ }
1056
+ function Value({ label, children, wide = false }) {
1057
+ return /* @__PURE__ */ jsxs2("div", { className: wide ? "mb-read-value is-wide" : "mb-read-value", children: [
1058
+ /* @__PURE__ */ jsx2("dt", { children: label }),
1059
+ /* @__PURE__ */ jsx2("dd", { children: children || "\u2014" })
1060
+ ] });
1061
+ }
1062
+ function BillReadOnlyForm({ data, appearance, className, style, onOpenAttachment }) {
1063
+ const { bill, patient, injury } = data;
1064
+ const provider = bill.billingSnapshot?.billingProvider;
1065
+ const clinician = bill.billingSnapshot?.renderingProvider;
1066
+ const location = bill.billingSnapshot?.placeOfService;
1067
+ const address = patient.address;
1068
+ const patientAddress = [address?.line1, address?.city, address?.state, address?.postalCode].filter(Boolean).join(", ");
1069
+ const locationAddress = location ? [location.street, location.city, location.state, location.zip].filter(Boolean).join(", ") : "";
1070
+ return /* @__PURE__ */ jsxs2("section", { className: ["mb-readonly-bill", className].filter(Boolean).join(" "), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill details", children: [
1071
+ /* @__PURE__ */ jsx2("style", { children: READ_ONLY_STYLES }),
1072
+ /* @__PURE__ */ jsxs2("header", { className: "mb-readonly-heading", children: [
1073
+ /* @__PURE__ */ jsxs2("div", { children: [
1074
+ /* @__PURE__ */ jsx2("h2", { children: "Bill details" }),
1075
+ /* @__PURE__ */ jsx2("p", { children: "Immutable snapshot submitted to the payer." })
1076
+ ] }),
1077
+ /* @__PURE__ */ jsx2("strong", { children: money2(bill.totalCharge) })
1078
+ ] }),
1079
+ /* @__PURE__ */ jsxs2("section", { className: "mb-read-card", children: [
1080
+ /* @__PURE__ */ jsx2("h3", { children: "Patient" }),
1081
+ /* @__PURE__ */ jsxs2("dl", { className: "mb-read-grid", children: [
1082
+ /* @__PURE__ */ jsx2(Value, { label: "Name", children: patient.name || [patient.firstName, patient.middleName, patient.lastName].filter(Boolean).join(" ") }),
1083
+ /* @__PURE__ */ jsx2(Value, { label: "Date of birth", children: date(patient.dob) }),
1084
+ /* @__PURE__ */ jsx2(Value, { label: "Phone", children: patient.phone }),
1085
+ /* @__PURE__ */ jsx2(Value, { label: "Address", wide: true, children: patientAddress })
1086
+ ] })
1087
+ ] }),
1088
+ /* @__PURE__ */ jsxs2("section", { className: "mb-read-card", children: [
1089
+ /* @__PURE__ */ jsx2("h3", { children: "Claim & injury" }),
1090
+ /* @__PURE__ */ jsxs2("dl", { className: "mb-read-grid", children: [
1091
+ /* @__PURE__ */ jsx2(Value, { label: "Claim number", children: injury.claimNumber }),
1092
+ /* @__PURE__ */ jsx2(Value, { label: "WCAB / ADJ number", children: injury.adjNumber }),
1093
+ /* @__PURE__ */ jsx2(Value, { label: "Claims administrator", children: injury.claimsAdminName }),
1094
+ /* @__PURE__ */ jsx2(Value, { label: "Employer", children: injury.employer }),
1095
+ /* @__PURE__ */ jsx2(Value, { label: "Date of injury", children: date(injury.doi) }),
1096
+ /* @__PURE__ */ jsx2(Value, { label: "Date of service", children: bill.dosEnd ? `${date(bill.dos)} \u2013 ${date(bill.dosEnd)}` : date(bill.dos) }),
1097
+ /* @__PURE__ */ jsx2(Value, { label: "Injury description", wide: true, children: injury.injuryDescription })
1098
+ ] }),
1099
+ injury.diagnosisCodes?.length ? /* @__PURE__ */ jsx2("div", { className: "mb-read-chips", "aria-label": "Diagnosis codes", children: injury.diagnosisCodes.map((code) => /* @__PURE__ */ jsx2("span", { children: code }, code)) }) : null
1100
+ ] }),
1101
+ /* @__PURE__ */ jsxs2("section", { className: "mb-read-card", children: [
1102
+ /* @__PURE__ */ jsx2("h3", { children: "Providers & location" }),
1103
+ /* @__PURE__ */ jsxs2("dl", { className: "mb-read-grid", children: [
1104
+ /* @__PURE__ */ jsx2(Value, { label: "Billing provider", children: provider?.name }),
1105
+ /* @__PURE__ */ jsx2(Value, { label: "Billing NPI", children: provider?.npi }),
1106
+ /* @__PURE__ */ jsx2(Value, { label: "Rendering provider", children: clinician?.name }),
1107
+ /* @__PURE__ */ jsx2(Value, { label: "Rendering NPI", children: clinician?.npi }),
1108
+ /* @__PURE__ */ jsx2(Value, { label: "Specialty", children: clinician?.specialty }),
1109
+ /* @__PURE__ */ jsx2(Value, { label: "Place of service", children: location?.name }),
1110
+ /* @__PURE__ */ jsx2(Value, { label: "Service address", wide: true, children: locationAddress })
1111
+ ] })
1112
+ ] }),
1113
+ /* @__PURE__ */ jsxs2("section", { className: "mb-read-card", children: [
1114
+ /* @__PURE__ */ jsx2("h3", { children: "Service lines" }),
1115
+ /* @__PURE__ */ jsxs2("div", { className: "mb-read-lines", role: "table", "aria-label": "Service lines", children: [
1116
+ /* @__PURE__ */ jsxs2("div", { className: "mb-read-line-header", role: "row", children: [
1117
+ /* @__PURE__ */ jsx2("span", { children: "Procedure" }),
1118
+ /* @__PURE__ */ jsx2("span", { children: "Modifiers" }),
1119
+ /* @__PURE__ */ jsx2("span", { children: "Units" }),
1120
+ /* @__PURE__ */ jsx2("span", { children: "Charge" })
1121
+ ] }),
1122
+ bill.lineItems.map((line, index) => /* @__PURE__ */ jsxs2("div", { className: "mb-read-line", role: "row", children: [
1123
+ /* @__PURE__ */ jsx2("strong", { children: line.code }),
1124
+ /* @__PURE__ */ jsx2("div", { className: "mb-read-chips", children: line.modifiers.length ? line.modifiers.map((modifier) => /* @__PURE__ */ jsx2("span", { children: modifier }, modifier)) : "\u2014" }),
1125
+ /* @__PURE__ */ jsx2("span", { children: line.units }),
1126
+ /* @__PURE__ */ jsx2("strong", { children: money2(line.charge) })
1127
+ ] }, line.id ?? `${line.code}-${index}`)),
1128
+ /* @__PURE__ */ jsxs2("div", { className: "mb-read-total", children: [
1129
+ /* @__PURE__ */ jsxs2("span", { children: [
1130
+ "Paid ",
1131
+ money2(bill.totalPaid)
1132
+ ] }),
1133
+ /* @__PURE__ */ jsxs2("strong", { children: [
1134
+ "Balance ",
1135
+ money2(bill.balanceDue)
1136
+ ] })
1137
+ ] })
1138
+ ] })
1139
+ ] }),
1140
+ /* @__PURE__ */ jsxs2("section", { className: "mb-read-card", children: [
1141
+ /* @__PURE__ */ jsx2("h3", { children: "Attachments" }),
1142
+ bill.attachments.length ? /* @__PURE__ */ jsx2("ul", { className: "mb-read-documents", children: bill.attachments.map((attachment) => /* @__PURE__ */ jsxs2("li", { children: [
1143
+ /* @__PURE__ */ jsxs2("div", { children: [
1144
+ /* @__PURE__ */ jsx2("strong", { children: attachment.filename }),
1145
+ /* @__PURE__ */ jsx2("span", { children: attachment.description || attachment.documentType.replace(/_/g, " ") })
1146
+ ] }),
1147
+ onOpenAttachment ? /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => void onOpenAttachment(attachment), children: "View" }) : null
1148
+ ] }, attachment.id)) }) : /* @__PURE__ */ jsx2("p", { className: "mb-read-empty", children: "No attachments." })
1149
+ ] })
1150
+ ] });
1151
+ }
1152
+ var READ_ONLY_STYLES = `
1153
+ .mb-readonly-bill{--mb-accent:#176c70;--mb-border:#d7e0df;--mb-surface:#fff;--mb-muted:#607176;color:var(--mb-text,#17282d);font:inherit;display:grid;gap:16px}.mb-readonly-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:20px}.mb-readonly-heading h2,.mb-read-card h3{margin:0}.mb-readonly-heading p{margin:4px 0 0;color:var(--mb-muted)}.mb-readonly-heading>strong{font-size:1.35rem}.mb-read-card{background:var(--mb-surface);border:1px solid var(--mb-border);border-radius:var(--mb-radius,14px);padding:20px;box-shadow:0 1px 2px rgba(15,40,45,.04)}.mb-read-card h3{font-size:1.05rem;margin-bottom:16px}.mb-read-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:17px 28px;margin:0}.mb-read-value{min-width:0}.mb-read-value.is-wide{grid-column:1/-1}.mb-read-value dt{color:var(--mb-muted);font-size:.75rem;font-weight:700;letter-spacing:.07em;text-transform:uppercase}.mb-read-value dd{font-weight:600;margin:5px 0 0;overflow-wrap:anywhere}.mb-read-chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:16px}.mb-read-chips span{border:1px solid var(--mb-border);border-radius:999px;padding:3px 9px;font-size:.82rem;background:#f7f9f8}.mb-read-lines{border:1px solid var(--mb-border);border-radius:10px;overflow:hidden}.mb-read-line-header,.mb-read-line{display:grid;grid-template-columns:1.2fr 1.5fr .45fr .7fr;gap:16px;align-items:center;padding:12px 14px}.mb-read-line-header{background:#f6f8f7;color:var(--mb-muted);font-size:.75rem;font-weight:700;text-transform:uppercase}.mb-read-line{border-top:1px solid var(--mb-border)}.mb-read-line .mb-read-chips{margin:0}.mb-read-line>span:last-child,.mb-read-line>strong:last-child{text-align:right}.mb-read-total{display:flex;justify-content:flex-end;gap:24px;border-top:1px solid var(--mb-border);padding:13px 14px}.mb-read-documents{list-style:none;padding:0;margin:0;display:grid}.mb-read-documents li{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:13px 0;border-top:1px solid var(--mb-border)}.mb-read-documents li:first-child{border-top:0;padding-top:0}.mb-read-documents li:last-child{padding-bottom:0}.mb-read-documents div{display:grid;gap:3px;min-width:0}.mb-read-documents strong{overflow-wrap:anywhere}.mb-read-documents span,.mb-read-empty{color:var(--mb-muted)}.mb-read-documents button{border:1px solid var(--mb-border);border-radius:8px;background:transparent;color:inherit;padding:8px 13px;font:inherit;font-weight:650;cursor:pointer}.mb-read-documents button:hover{border-color:var(--mb-accent);color:var(--mb-accent)}
1154
+ @media(max-width:700px){.mb-readonly-heading{align-items:flex-start}.mb-read-grid{grid-template-columns:1fr}.mb-read-value.is-wide{grid-column:auto}.mb-read-card{padding:16px}.mb-read-line-header{display:none}.mb-read-line{grid-template-columns:1fr auto;gap:8px}.mb-read-line>*:nth-child(2){grid-column:1/-1}.mb-read-total{justify-content:space-between}.mb-readonly-heading>strong{font-size:1.05rem}}
1155
+ `;
1156
+
1157
+ // src/bill-submission-form.tsx
1158
+ import { useCallback, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
1159
+ import {
1160
+ createBillReferenceClient
1161
+ } from "@mindbill/browser";
1162
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1049
1163
  var BILL_SUBMISSION_DOCUMENT_TYPES = [
1050
1164
  "final_report",
1051
1165
  "proof_of_service",
@@ -1060,44 +1174,36 @@ var BILL_SUBMISSION_DOCUMENT_TYPES = [
1060
1174
  var BILL_SUBMISSION_REQUIRED_FIELDS = [
1061
1175
  "patient.firstName",
1062
1176
  "patient.lastName",
1177
+ "patient.dateOfBirth",
1063
1178
  "patient.address.line1",
1064
1179
  "patient.address.city",
1065
1180
  "patient.address.state",
1066
1181
  "patient.address.postalCode",
1067
1182
  "claim.claimNumber",
1183
+ "claim.claimsAdministrator",
1068
1184
  "service.date",
1069
1185
  "serviceLines[].code",
1070
1186
  "serviceLines[].units"
1071
1187
  ];
1072
- function validateBillSubmission(bill) {
1073
- const errors = {};
1074
- const required = (path, value) => {
1075
- if (typeof value !== "string" || !value.trim()) errors[path] = "Required";
1076
- };
1077
- required("patient.firstName", bill.patient.firstName);
1078
- required("patient.lastName", bill.patient.lastName);
1079
- required("patient.address.line1", bill.patient.address.line1);
1080
- required("patient.address.city", bill.patient.address.city);
1081
- required("patient.address.state", bill.patient.address.state);
1082
- required("patient.address.postalCode", bill.patient.address.postalCode);
1083
- required("claim.claimNumber", bill.claim.claimNumber);
1084
- required("service.date", bill.service.date);
1085
- if (bill.patient.address.state.trim().length !== 2)
1086
- errors["patient.address.state"] = "Use a 2-letter state code";
1087
- if (!bill.serviceLines.length) errors.serviceLines = "Add at least one service line";
1088
- bill.serviceLines.forEach((line, index) => {
1089
- required(`serviceLines.${index}.code`, line.code);
1090
- if (!Number.isInteger(line.units) || (line.units ?? 0) < 1)
1091
- errors[`serviceLines.${index}.units`] = "Enter at least 1 unit";
1092
- if (bill.billingMode === "professional" && (!Number.isFinite(line.charge) || (line.charge ?? 0) < 0))
1093
- errors[`serviceLines.${index}.charge`] = "Enter the billed charge";
1094
- });
1095
- return { valid: Object.keys(errors).length === 0, fieldErrors: errors };
1096
- }
1097
- var MAX_PDF_BYTES = 25 * 1024 * 1024;
1098
- var MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
1099
- var MAX_DOCUMENTS = 25;
1100
- var EMPTY_ATTACHMENTS = [];
1188
+ var PROCEDURES2 = [
1189
+ { code: "ML200", description: "Missed appointment for a medical-legal evaluation" },
1190
+ { code: "ML201", description: "Comprehensive medical-legal evaluation" },
1191
+ { code: "ML202", description: "Follow-up medical-legal evaluation" },
1192
+ { code: "ML203", description: "Supplemental medical-legal evaluation" },
1193
+ { code: "ML204", description: "Medical-legal testimony" },
1194
+ { code: "ML205", description: "Review of sub rosa recordings" },
1195
+ { code: "MLPRR", description: "Medical-legal record review" }
1196
+ ];
1197
+ var MODIFIERS2 = [
1198
+ { code: "92", description: "Primary Treating Physician evaluation" },
1199
+ { code: "93", description: "Interpreter required" },
1200
+ { code: "94", description: "Agreed Medical Evaluator" },
1201
+ { code: "95", description: "Qualified Medical Evaluator" },
1202
+ { code: "96", description: "Psychiatric/psychological evaluation" },
1203
+ { code: "97", description: "Toxicology evaluation" },
1204
+ { code: "98", description: "Oncology evaluation" },
1205
+ { code: "59", description: "Distinct procedural service" }
1206
+ ];
1101
1207
  var documentLabels = {
1102
1208
  final_report: "Final report",
1103
1209
  proof_of_service: "Proof of service",
@@ -1109,157 +1215,189 @@ var documentLabels = {
1109
1215
  appeal: "Appeal",
1110
1216
  other: "Other"
1111
1217
  };
1218
+ var MAX_PDF_BYTES = 25 * 1024 * 1024;
1219
+ var MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
1220
+ var MAX_DOCUMENTS = 25;
1221
+ var EMPTY_ATTACHMENTS = [];
1222
+ function blankLine() {
1223
+ return { code: "", modifiers: [], units: 1 };
1224
+ }
1225
+ function lineHasContent(line) {
1226
+ return Boolean(line.code.trim() || line.modifiers?.length || line.charge != null);
1227
+ }
1228
+ function ensureTrailingBillSubmissionLine(lines) {
1229
+ const normalized = lines.length ? lines.map((line) => ({ ...line, modifiers: [...line.modifiers ?? []], units: line.units ?? 1 })) : [];
1230
+ while (normalized.length > 1 && !lineHasContent(normalized.at(-1)) && !lineHasContent(normalized.at(-2))) normalized.pop();
1231
+ if (!normalized.length || lineHasContent(normalized.at(-1))) normalized.push(blankLine());
1232
+ return normalized;
1233
+ }
1234
+ function parseBillSubmissionDate(value) {
1235
+ const trimmed = value.trim();
1236
+ const iso = /^(\d{4})-(\d{2})-(\d{2})$/.exec(trimmed);
1237
+ const us = /^(\d{1,2})[/-](\d{1,2})[/-](\d{4})$/.exec(trimmed);
1238
+ const digits = /^(\d{2})(\d{2})(\d{4})$/.exec(trimmed.replace(/\D/g, ""));
1239
+ const match = iso ? [iso[2], iso[3], iso[1]] : us ? [us[1], us[2], us[3]] : digits ? [digits[1], digits[2], digits[3]] : null;
1240
+ if (!match) return void 0;
1241
+ const month = Number(match[0]);
1242
+ const day = Number(match[1]);
1243
+ const year = Number(match[2]);
1244
+ const date2 = new Date(Date.UTC(year, month - 1, day));
1245
+ if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month - 1 || date2.getUTCDate() !== day) return void 0;
1246
+ return `${String(year).padStart(4, "0")}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
1247
+ }
1248
+ function formatBillSubmissionDate(value) {
1249
+ const parsed = value ? parseBillSubmissionDate(value) : void 0;
1250
+ if (!parsed) return "";
1251
+ const [year, month, day] = parsed.split("-");
1252
+ return `${month}/${day}/${year}`;
1253
+ }
1254
+ function evaluationModifier(type, code) {
1255
+ if (!/^ML(?:200|201|202|203|PRR)$/.test(code.toUpperCase())) return void 0;
1256
+ if (type === "ame") return code.toUpperCase() === "ML200" || code.toUpperCase() === "MLPRR" ? void 0 : "94";
1257
+ if (type === "psych_qme") return code.toUpperCase() === "ML200" ? "95" : code.toUpperCase() === "MLPRR" ? void 0 : "96";
1258
+ return "95";
1259
+ }
1260
+ function applyBillSubmissionEvaluationModifiers(lines, type) {
1261
+ return lines.map((line) => {
1262
+ const auto = evaluationModifier(type, line.code);
1263
+ const modifiers = (line.modifiers ?? []).filter((item) => !["94", "95", "96"].includes(item.replace(/^-/, "")));
1264
+ return { ...line, modifiers: auto ? [auto, ...modifiers] : modifiers };
1265
+ });
1266
+ }
1267
+ function submittedLines(lines) {
1268
+ return lines.filter(lineHasContent).map((line) => ({ ...line, code: line.code.trim(), modifiers: [...line.modifiers ?? []] }));
1269
+ }
1112
1270
  function cloneBill(bill) {
1113
1271
  return {
1114
1272
  ...bill,
1115
1273
  patient: { ...bill.patient, address: { ...bill.patient.address } },
1116
- claim: {
1117
- ...bill.claim,
1118
- ...bill.claim.claimsAdministrator ? { claimsAdministrator: { ...bill.claim.claimsAdministrator } } : {}
1119
- },
1274
+ claim: { ...bill.claim, ...bill.claim.claimsAdministrator ? { claimsAdministrator: { ...bill.claim.claimsAdministrator } } : {} },
1120
1275
  service: { ...bill.service },
1121
- ...bill.billingProvider ? {
1122
- billingProvider: {
1123
- ...bill.billingProvider,
1124
- ...bill.billingProvider.address ? { address: { ...bill.billingProvider.address } } : {}
1125
- }
1126
- } : {},
1276
+ ...bill.billingProvider ? { billingProvider: { ...bill.billingProvider, ...bill.billingProvider.address ? { address: { ...bill.billingProvider.address } } : {} } } : {},
1127
1277
  ...bill.renderingProvider ? { renderingProvider: { ...bill.renderingProvider } } : {},
1128
- ...bill.serviceLocation ? {
1129
- serviceLocation: {
1130
- ...bill.serviceLocation,
1131
- ...bill.serviceLocation.address ? { address: { ...bill.serviceLocation.address } } : {}
1132
- }
1133
- } : {},
1278
+ ...bill.serviceLocation ? { serviceLocation: { ...bill.serviceLocation, ...bill.serviceLocation.address ? { address: { ...bill.serviceLocation.address } } : {} } } : {},
1134
1279
  diagnoses: [...bill.diagnoses ?? []],
1135
- serviceLines: bill.serviceLines.length ? bill.serviceLines.map((line) => ({
1136
- ...line,
1137
- modifiers: [...line.modifiers ?? []],
1138
- diagnosisPointers: [...line.diagnosisPointers ?? []],
1139
- units: line.units ?? 1
1140
- })) : [{ code: "", modifiers: [], units: 1 }]
1280
+ serviceLines: ensureTrailingBillSubmissionLine(bill.serviceLines)
1141
1281
  };
1142
1282
  }
1143
- var styles = {
1144
- root: {
1145
- display: "grid",
1146
- gap: 18,
1147
- color: "var(--mb-text)",
1148
- fontFamily: "var(--mb-font)"
1149
- },
1150
- heading: {
1151
- display: "flex",
1152
- alignItems: "start",
1153
- justifyContent: "space-between",
1154
- gap: 20
1155
- },
1156
- title: { margin: 0, fontSize: 22, lineHeight: 1.2 },
1157
- copy: { margin: "5px 0 0", color: "var(--mb-muted)", fontSize: 14 },
1158
- requiredNote: { color: "var(--mb-muted)", fontSize: 13, whiteSpace: "nowrap" },
1159
- section: {
1160
- minWidth: 0,
1161
- margin: 0,
1162
- padding: 20,
1163
- border: "1px solid var(--mb-border)",
1164
- borderRadius: "var(--mb-radius)",
1165
- background: "var(--mb-surface)",
1166
- boxShadow: "var(--mb-shadow)"
1167
- },
1168
- legend: { padding: "0 8px", fontWeight: 700, fontSize: 15 },
1169
- grid: {
1170
- display: "grid",
1171
- gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 210px), 1fr))",
1172
- gap: 14
1173
- },
1174
- field: { display: "grid", alignContent: "start", gap: 6, minWidth: 0 },
1175
- label: { color: "var(--mb-muted)", fontSize: 12, fontWeight: 700 },
1176
- input: {
1177
- boxSizing: "border-box",
1178
- width: "100%",
1179
- minHeight: 40,
1180
- padding: "9px 11px",
1181
- border: "1px solid var(--mb-border)",
1182
- borderRadius: "var(--mb-control-radius)",
1183
- background: "var(--mb-input)",
1184
- color: "var(--mb-text)",
1185
- font: "inherit"
1186
- },
1187
- tableWrap: { overflowX: "auto" },
1188
- table: { width: "100%", minWidth: 610, borderCollapse: "collapse" },
1189
- th: {
1190
- padding: "0 8px 8px",
1191
- color: "var(--mb-muted)",
1192
- fontSize: 12,
1193
- textAlign: "left"
1194
- },
1195
- td: { padding: "7px 8px", borderTop: "1px solid var(--mb-border)" },
1196
- secondaryButton: {
1197
- minHeight: 36,
1198
- padding: "7px 11px",
1199
- border: "1px solid var(--mb-border)",
1200
- borderRadius: "var(--mb-control-radius)",
1201
- background: "var(--mb-surface)",
1202
- color: "var(--mb-text)",
1203
- font: "inherit",
1204
- fontWeight: 650,
1205
- cursor: "pointer"
1206
- },
1207
- attachment: {
1208
- display: "flex",
1209
- alignItems: "center",
1210
- justifyContent: "space-between",
1211
- gap: 12,
1212
- padding: "11px 0",
1213
- borderBottom: "1px solid var(--mb-border)"
1214
- },
1215
- attachmentName: { display: "grid", gap: 2, minWidth: 0, flex: 1 },
1216
- attachmentMeta: { color: "var(--mb-muted)", fontSize: 12 },
1217
- error: {
1218
- padding: "11px 13px",
1219
- borderRadius: "var(--mb-control-radius)",
1220
- background: "color-mix(in srgb, var(--mb-danger) 10%, transparent)",
1221
- color: "var(--mb-danger)",
1222
- fontSize: 13
1223
- },
1224
- actions: { display: "flex", justifyContent: "flex-end" },
1225
- submit: {
1226
- minWidth: 150,
1227
- minHeight: 42,
1228
- padding: "10px 20px",
1229
- border: 0,
1230
- borderRadius: "var(--mb-control-radius)",
1231
- background: "var(--mb-accent)",
1232
- color: "var(--mb-accent-contrast)",
1233
- font: "inherit",
1234
- fontWeight: 750,
1235
- cursor: "pointer"
1283
+ function validateBillSubmission(bill) {
1284
+ const errors = {};
1285
+ const required = (path, value) => {
1286
+ if (typeof value !== "string" || !value.trim()) errors[path] = "Required";
1287
+ };
1288
+ required("patient.firstName", bill.patient.firstName);
1289
+ required("patient.lastName", bill.patient.lastName);
1290
+ required("patient.dateOfBirth", bill.patient.dateOfBirth);
1291
+ required("patient.address.line1", bill.patient.address.line1);
1292
+ required("patient.address.city", bill.patient.address.city);
1293
+ required("patient.address.state", bill.patient.address.state);
1294
+ required("patient.address.postalCode", bill.patient.address.postalCode);
1295
+ required("claim.claimNumber", bill.claim.claimNumber);
1296
+ required("claim.claimsAdministrator", bill.claim.claimsAdministrator?.name);
1297
+ required("service.date", bill.service.date);
1298
+ if (bill.claim.claimsAdministrator?.name && !bill.claim.claimsAdministrator.id) {
1299
+ errors["claim.claimsAdministrator"] = "Select a claims administrator from the payer directory.";
1236
1300
  }
1237
- };
1301
+ if (bill.patient.dateOfBirth && !parseBillSubmissionDate(bill.patient.dateOfBirth)) errors["patient.dateOfBirth"] = "Use MM/DD/YYYY";
1302
+ if (bill.patient.address.state.trim().length !== 2) errors["patient.address.state"] = "Use a 2-letter state code";
1303
+ const lines = submittedLines(bill.serviceLines);
1304
+ if (!lines.length) errors.serviceLines = "Add at least one service line";
1305
+ lines.forEach((line, index) => {
1306
+ required(`serviceLines.${index}.code`, line.code);
1307
+ if (!Number.isInteger(line.units) || (line.units ?? 0) < 1) errors[`serviceLines.${index}.units`] = "Enter at least 1 unit";
1308
+ if (bill.billingMode === "professional" && (!Number.isFinite(line.charge) || (line.charge ?? 0) < 0)) errors[`serviceLines.${index}.charge`] = "Enter the billed charge";
1309
+ });
1310
+ return { valid: Object.keys(errors).length === 0, fieldErrors: errors };
1311
+ }
1312
+ var css = `
1313
+ .mbsf{display:grid;gap:20px;color:var(--mb-text);font-family:var(--mb-font);font-size:15px}.mbsf *{box-sizing:border-box}
1314
+ .mbsf-head,.mbsf-section-head,.mbsf-attach-row,.mbsf-actions{display:flex;align-items:center;justify-content:space-between;gap:16px}.mbsf-title{margin:0;font-size:24px}.mbsf-copy,.mbsf-help{color:var(--mb-muted);margin:5px 0 0}.mbsf-required{font-size:13px;color:var(--mb-muted);white-space:nowrap}.mbsf-star,.mbsf-error{color:var(--mb-danger)}
1315
+ .mbsf-card{min-width:0;margin:0;padding:24px;border:1px solid var(--mb-border);border-radius:var(--mb-radius);background:var(--mb-surface);box-shadow:var(--mb-shadow)}.mbsf-legend{padding:0 10px;font-size:18px;font-weight:760}.mbsf-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 24px}.mbsf-span{grid-column:1/-1}.mbsf-field{display:grid;align-content:start;gap:7px;min-width:0}.mbsf-label{font-weight:680}.mbsf-input,.mbsf-select{width:100%;min-height:46px;padding:10px 12px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text);font:inherit}.mbsf-input:focus,.mbsf-select:focus{outline:3px solid color-mix(in srgb,var(--mb-accent) 22%,transparent);border-color:var(--mb-accent)}
1316
+ .mbsf-combo{position:relative}.mbsf-menu{position:absolute;z-index:20;top:calc(100% + 5px);left:0;right:0;max-height:300px;overflow:auto;padding:7px;border:1px solid var(--mb-border);border-radius:12px;background:var(--mb-surface);box-shadow:0 14px 35px rgba(17,38,49,.16)}.mbsf-option{display:grid;width:100%;gap:2px;padding:10px;border:0;border-radius:8px;background:transparent;color:var(--mb-text);font:inherit;text-align:left;cursor:pointer}.mbsf-option:hover,.mbsf-option:focus{background:color-mix(in srgb,var(--mb-accent) 9%,var(--mb-surface))}.mbsf-option small{color:var(--mb-muted)}
1317
+ .mbsf-chips{display:flex;flex-wrap:wrap;gap:7px;margin-bottom:8px}.mbsf-chip{display:inline-flex;align-items:center;gap:7px;padding:5px 9px;border:1px solid var(--mb-border);border-radius:999px;background:var(--mb-input)}.mbsf-chip button{border:0;background:transparent;color:var(--mb-muted);cursor:pointer;font:inherit}
1318
+ .mbsf-segments{display:grid;grid-template-columns:repeat(3,1fr);border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);overflow:hidden}.mbsf-segment{min-height:44px;border:0;border-right:1px solid var(--mb-border);background:var(--mb-input);color:var(--mb-text);font:inherit;font-weight:700;cursor:pointer}.mbsf-segment:last-child{border-right:0}.mbsf-segment[aria-pressed=true]{background:var(--mb-accent);color:var(--mb-accent-contrast)}
1319
+ .mbsf-lines{margin-top:18px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);overflow:visible}.mbsf-line-head,.mbsf-line{display:grid;grid-template-columns:minmax(190px,1.05fr) minmax(220px,1.5fr) 100px 120px 42px;gap:12px;align-items:start;padding:12px}.mbsf-line-head{color:var(--mb-muted);font-size:13px;font-weight:700;border-bottom:1px solid var(--mb-border)}.mbsf-line{border-bottom:1px solid var(--mb-border)}.mbsf-line:last-child{border-bottom:0}.mbsf-money{padding-top:12px;text-align:right;font-variant-numeric:tabular-nums}.mbsf-total{display:flex;justify-content:flex-end;gap:45px;padding:16px 56px 16px 16px;font-size:17px;font-weight:760}
1320
+ .mbsf-icon-btn{width:40px;height:42px;border:0;background:transparent;color:var(--mb-text);font-size:22px;cursor:pointer}.mbsf-secondary{min-height:40px;padding:8px 14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface);color:var(--mb-text);font:inherit;font-weight:680;cursor:pointer}.mbsf-attach-list{display:grid;gap:10px;margin-bottom:18px}.mbsf-attach-row{padding:14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius)}.mbsf-attach-row[data-auto=true]{border-color:color-mix(in srgb,#159447 45%,var(--mb-border));background:color-mix(in srgb,#159447 5%,var(--mb-surface))}.mbsf-file{min-width:0}.mbsf-file strong{overflow-wrap:anywhere}.mbsf-badge{display:inline-block;margin-left:8px;padding:2px 7px;border:1px solid var(--mb-border);border-radius:7px;color:var(--mb-muted);font-size:12px;font-weight:600}.mbsf-drop{display:grid;place-items:center;min-height:180px;padding:24px;border:2px dashed color-mix(in srgb,var(--mb-muted) 55%,transparent);border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-accent) 3%,var(--mb-surface));text-align:center;cursor:pointer}.mbsf-drop[data-active=true]{border-color:var(--mb-accent);background:color-mix(in srgb,var(--mb-accent) 10%,var(--mb-surface))}.mbsf-alert{padding:12px 14px;border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-danger) 10%,transparent);color:var(--mb-danger)}.mbsf-actions{justify-content:flex-end}.mbsf-submit{min-width:180px;min-height:48px;padding:11px 24px;border:0;border-radius:var(--mb-control-radius);background:var(--mb-accent);color:var(--mb-accent-contrast);font:inherit;font-weight:780;cursor:pointer}
1321
+ @media(max-width:820px){.mbsf-grid{grid-template-columns:1fr}.mbsf-span{grid-column:auto}.mbsf-card{padding:18px}.mbsf-line-head{display:none}.mbsf-line{grid-template-columns:1fr 1fr}.mbsf-line>*:nth-child(1),.mbsf-line>*:nth-child(2){grid-column:1/-1}.mbsf-money{text-align:left}.mbsf-line .mbsf-icon-btn{justify-self:end}.mbsf-total{padding-right:18px}.mbsf-head{align-items:flex-start}.mbsf-segments{grid-template-columns:1fr}.mbsf-segment{border-right:0;border-bottom:1px solid var(--mb-border)}.mbsf-segment:last-child{border-bottom:0}}
1322
+ `;
1238
1323
  function RequiredMark() {
1239
- return /* @__PURE__ */ jsx2("span", { className: "required-mark", style: { color: "var(--mb-danger)" }, children: " *" });
1324
+ return /* @__PURE__ */ jsx3("span", { className: "mbsf-star", children: " *" });
1240
1325
  }
1241
- function Field2({
1242
- label,
1243
- required,
1244
- error,
1245
- children
1246
- }) {
1247
- return /* @__PURE__ */ jsxs2("label", { style: styles.field, children: [
1248
- /* @__PURE__ */ jsxs2("span", { style: styles.label, children: [
1326
+ function Field2({ label, required, error, span, children }) {
1327
+ return /* @__PURE__ */ jsxs3("label", { className: `mbsf-field${span ? " mbsf-span" : ""}`, children: [
1328
+ /* @__PURE__ */ jsxs3("span", { className: "mbsf-label", children: [
1249
1329
  label,
1250
- required ? /* @__PURE__ */ jsx2(RequiredMark, {}) : null
1330
+ required ? /* @__PURE__ */ jsx3(RequiredMark, {}) : null
1251
1331
  ] }),
1252
1332
  children,
1253
- error ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: error }) : null
1333
+ error ? /* @__PURE__ */ jsx3("small", { className: "mbsf-error", children: error }) : null
1334
+ ] });
1335
+ }
1336
+ function TextDateInput({ value, onChange, disabled, required, ariaLabel }) {
1337
+ const [display, setDisplay] = useState2(() => formatBillSubmissionDate(value));
1338
+ const [invalid, setInvalid] = useState2(false);
1339
+ useEffect2(() => {
1340
+ setDisplay(formatBillSubmissionDate(value));
1341
+ setInvalid(false);
1342
+ }, [value]);
1343
+ return /* @__PURE__ */ jsxs3(Fragment2, { children: [
1344
+ /* @__PURE__ */ jsx3("input", { className: "mbsf-input", type: "text", inputMode: "numeric", autoComplete: "off", placeholder: "MM/DD/YYYY", "aria-label": ariaLabel, "aria-invalid": invalid, required, disabled, value: display, onChange: (event) => {
1345
+ const next = event.target.value;
1346
+ const parsed = parseBillSubmissionDate(next);
1347
+ setDisplay(next);
1348
+ setInvalid(Boolean(next && !parsed));
1349
+ if (!next.trim()) onChange("");
1350
+ else if (parsed) onChange(parsed);
1351
+ }, onBlur: () => setInvalid(Boolean(display && !parseBillSubmissionDate(display))) }),
1352
+ invalid ? /* @__PURE__ */ jsx3("small", { className: "mbsf-error", children: "Use MM/DD/YYYY" }) : null
1353
+ ] });
1354
+ }
1355
+ function ComboBox({ value, placeholder, options, disabled, loading, onQuery, onSelect, ariaLabel }) {
1356
+ const [open, setOpen] = useState2(false);
1357
+ const [query, setQuery] = useState2("");
1358
+ const visible = useMemo2(() => {
1359
+ const q = query.trim().toLowerCase();
1360
+ return q ? options.filter((option) => `${option.id} ${option.label} ${option.detail ?? ""}`.toLowerCase().includes(q)) : options;
1361
+ }, [options, query]);
1362
+ return /* @__PURE__ */ jsxs3("div", { className: "mbsf-combo", children: [
1363
+ /* @__PURE__ */ jsx3("input", { className: "mbsf-input", role: "combobox", "aria-label": ariaLabel, "aria-expanded": open, autoComplete: "off", disabled, placeholder, value: open ? query : value, onFocus: () => {
1364
+ setOpen(true);
1365
+ setQuery("");
1366
+ onQuery?.("");
1367
+ }, onChange: (event) => {
1368
+ setOpen(true);
1369
+ setQuery(event.target.value);
1370
+ onQuery?.(event.target.value);
1371
+ }, onBlur: () => setTimeout(() => setOpen(false), 120) }),
1372
+ open ? /* @__PURE__ */ jsx3("div", { className: "mbsf-menu", role: "listbox", children: loading ? /* @__PURE__ */ jsx3("div", { className: "mbsf-option", children: "Searching\u2026" }) : visible.length ? visible.map((option) => /* @__PURE__ */ jsxs3("button", { className: "mbsf-option", type: "button", role: "option", onMouseDown: (event) => event.preventDefault(), onClick: () => {
1373
+ onSelect(option);
1374
+ setOpen(false);
1375
+ setQuery("");
1376
+ }, children: [
1377
+ /* @__PURE__ */ jsx3("strong", { children: option.label }),
1378
+ option.detail ? /* @__PURE__ */ jsx3("small", { children: option.detail }) : null
1379
+ ] }, option.id)) : /* @__PURE__ */ jsx3("div", { className: "mbsf-option", children: "No matches" }) }) : null
1254
1380
  ] });
1255
1381
  }
1256
- function inputValue(value) {
1257
- return value ?? "";
1382
+ function mergeOptions(defaults, supplied) {
1383
+ const map = new Map(defaults.map((item) => [item.code.toUpperCase(), item]));
1384
+ supplied?.forEach((item) => map.set(item.code.toUpperCase(), item));
1385
+ return [...map.values()];
1258
1386
  }
1259
1387
  function BillSubmissionForm({
1260
1388
  initialBill,
1261
1389
  attachments = EMPTY_ATTACHMENTS,
1262
1390
  onSubmit,
1391
+ getSession,
1392
+ sessionEndpoint,
1393
+ apiBaseUrl,
1394
+ fetch: fetchOverride,
1395
+ onSearchClaimsAdministrators,
1396
+ diagnosisOptions = [],
1397
+ onSearchDiagnoses,
1398
+ onLookupPostalCode,
1399
+ procedureOptions,
1400
+ modifierOptions,
1263
1401
  appearance,
1264
1402
  className = "bill-submission-form",
1265
1403
  style,
@@ -1269,264 +1407,296 @@ function BillSubmissionForm({
1269
1407
  description = "Review the bill details, add attachments, and submit."
1270
1408
  }) {
1271
1409
  const [bill, setBill] = useState2(() => cloneBill(initialBill));
1272
- const [selectedIds, setSelectedIds] = useState2(
1273
- () => attachments.filter((item) => item.selected !== false).map((item) => item.id)
1274
- );
1410
+ const [selectedIds, setSelectedIds] = useState2(() => attachments.filter((item) => item.selected !== false || item.autoAttached).map((item) => item.id));
1275
1411
  const [uploads, setUploads] = useState2([]);
1276
1412
  const [errors, setErrors] = useState2({});
1277
1413
  const [formError, setFormError] = useState2(null);
1278
1414
  const [submitting, setSubmitting] = useState2(false);
1415
+ const [payerResults, setPayerResults] = useState2([]);
1416
+ const [payerLoading, setPayerLoading] = useState2(false);
1417
+ const [diagnosisResults, setDiagnosisResults] = useState2(diagnosisOptions);
1418
+ const [diagnosisLoading, setDiagnosisLoading] = useState2(false);
1419
+ const [postalStatus, setPostalStatus] = useState2(null);
1420
+ const [dragActive, setDragActive] = useState2(false);
1421
+ const fileInput = useRef2(null);
1422
+ const procedures = useMemo2(() => mergeOptions(PROCEDURES2, procedureOptions), [procedureOptions]);
1423
+ const modifiers = useMemo2(() => mergeOptions(MODIFIERS2, modifierOptions), [modifierOptions]);
1424
+ const [evaluationType, setEvaluationType] = useState2(() => initialBill.renderingProvider?.isAme ? "ame" : initialBill.renderingProvider?.specialty?.toLowerCase().includes("psych") ? "psych_qme" : "qme");
1425
+ const referenceClient = useMemo2(() => getSession ? createBillReferenceClient({ getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride }) : null, [getSession, sessionEndpoint, apiBaseUrl, fetchOverride]);
1426
+ const locked = disabled || submitting;
1279
1427
  useEffect2(() => {
1280
1428
  setBill(cloneBill(initialBill));
1281
- setSelectedIds(
1282
- attachments.filter((item) => item.selected !== false).map((item) => item.id)
1283
- );
1429
+ setSelectedIds(attachments.filter((item) => item.selected !== false || item.autoAttached).map((item) => item.id));
1284
1430
  setUploads([]);
1285
1431
  setErrors({});
1286
1432
  setFormError(null);
1287
1433
  }, [initialBill, attachments]);
1288
- const diagnoses = useMemo2(() => (bill.diagnoses ?? []).join(", "), [bill.diagnoses]);
1289
- const locked = disabled || submitting;
1290
- const setPatient = (patch) => setBill((current) => ({ ...current, patient: { ...current.patient, ...patch } }));
1291
- const setOptionalPatient = (key, value) => setBill((current) => {
1292
- const patient = { ...current.patient };
1293
- if (value) patient[key] = value;
1294
- else delete patient[key];
1295
- return { ...current, patient };
1296
- });
1297
- const setAddress = (patch) => setBill((current) => ({
1298
- ...current,
1299
- patient: {
1300
- ...current.patient,
1301
- address: { ...current.patient.address, ...patch }
1302
- }
1303
- }));
1304
- const setClaim = (patch) => setBill((current) => ({ ...current, claim: { ...current.claim, ...patch } }));
1305
- const setOptionalClaim = (key, value) => setBill((current) => {
1306
- const claim = { ...current.claim };
1307
- if (value) claim[key] = value;
1308
- else delete claim[key];
1309
- return { ...current, claim };
1310
- });
1311
- const setService = (patch) => setBill((current) => ({ ...current, service: { ...current.service, ...patch } }));
1312
- const setLine = (index, patch) => setBill((current) => ({
1313
- ...current,
1314
- serviceLines: current.serviceLines.map(
1315
- (line, lineIndex) => lineIndex === index ? { ...line, ...patch } : line
1316
- )
1317
- }));
1318
- const setOptionalLineNumber = (index, key, value) => setBill((current) => ({
1319
- ...current,
1320
- serviceLines: current.serviceLines.map((line, lineIndex) => {
1321
- if (lineIndex !== index) return line;
1322
- const next = { ...line };
1323
- if (value === "") delete next[key];
1324
- else next[key] = Number(value);
1325
- return next;
1326
- })
1327
- }));
1328
- const textInput = (value, onChange, options) => /* @__PURE__ */ jsx2(
1329
- "input",
1330
- {
1331
- style: styles.input,
1332
- value: inputValue(value),
1333
- disabled: locked,
1334
- onChange: (event) => onChange(event.target.value),
1335
- ...options
1434
+ const addFiles = useCallback((fileList) => {
1435
+ const files = Array.from(fileList);
1436
+ if (!files.length) return;
1437
+ setFormError(null);
1438
+ const invalid = files.find((file) => file.type !== "application/pdf" && !file.name.toLowerCase().endsWith(".pdf"));
1439
+ if (invalid) return setFormError(`${invalid.name} is not a PDF.`);
1440
+ const oversized = files.find((file) => file.size > MAX_PDF_BYTES);
1441
+ if (oversized) return setFormError(`${oversized.name} is larger than 25 MB.`);
1442
+ const nextBytes = [...uploads.map((item) => item.file), ...files].reduce((sum, file) => sum + file.size, 0);
1443
+ if (nextBytes > MAX_UPLOAD_BYTES) return setFormError("Attachments exceed the 100 MB upload limit.");
1444
+ if (selectedIds.length + uploads.length + files.length > MAX_DOCUMENTS) return setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1445
+ setUploads((current) => [...current, ...files.map((file) => ({ file, documentType: "other" }))]);
1446
+ }, [selectedIds.length, uploads]);
1447
+ useEffect2(() => {
1448
+ const over = (event) => {
1449
+ if (event.dataTransfer?.types.includes("Files")) {
1450
+ event.preventDefault();
1451
+ setDragActive(true);
1452
+ }
1453
+ };
1454
+ const leave = (event) => {
1455
+ if (!event.relatedTarget) setDragActive(false);
1456
+ };
1457
+ const drop = (event) => {
1458
+ if (event.dataTransfer?.files.length) {
1459
+ event.preventDefault();
1460
+ setDragActive(false);
1461
+ addFiles(event.dataTransfer.files);
1462
+ }
1463
+ };
1464
+ window.addEventListener("dragover", over);
1465
+ window.addEventListener("dragleave", leave);
1466
+ window.addEventListener("drop", drop);
1467
+ return () => {
1468
+ window.removeEventListener("dragover", over);
1469
+ window.removeEventListener("dragleave", leave);
1470
+ window.removeEventListener("drop", drop);
1471
+ };
1472
+ }, [addFiles]);
1473
+ const setAddress = (patch) => setBill((current) => ({ ...current, patient: { ...current.patient, address: { ...current.patient.address, ...patch } } }));
1474
+ const setLine = (index, patch) => setBill((current) => ({ ...current, serviceLines: ensureTrailingBillSubmissionLine(current.serviceLines.map((line, lineIndex) => lineIndex === index ? { ...line, ...patch } : line)) }));
1475
+ const text = (value, onChange, options = {}) => /* @__PURE__ */ jsx3("input", { className: "mbsf-input", disabled: locked, value: value ?? "", onChange: (event) => onChange(event.target.value), ...options });
1476
+ const searchPayers = (query) => {
1477
+ if (query.trim().length < 2) return;
1478
+ setPayerLoading(true);
1479
+ const search = onSearchClaimsAdministrators ?? referenceClient?.searchClaimsAdministrators;
1480
+ if (!search) {
1481
+ setPayerLoading(false);
1482
+ return;
1336
1483
  }
1337
- );
1484
+ void search(query, bill.claim.claimNumber).then(setPayerResults).catch((caught) => setFormError(caught instanceof Error ? caught.message : "Claims administrator search is unavailable.")).finally(() => setPayerLoading(false));
1485
+ };
1486
+ const searchDiagnoses = (query) => {
1487
+ if (!onSearchDiagnoses) return;
1488
+ setDiagnosisLoading(true);
1489
+ void onSearchDiagnoses(query).then(setDiagnosisResults).catch(() => setDiagnosisResults([])).finally(() => setDiagnosisLoading(false));
1490
+ };
1491
+ const updatePostalCode = (postalCode) => {
1492
+ setAddress({ postalCode });
1493
+ setPostalStatus(null);
1494
+ if (!onLookupPostalCode || !/^\d{5}$/.test(postalCode)) return;
1495
+ void onLookupPostalCode(postalCode).then((place) => {
1496
+ if (!place) return setPostalStatus("ZIP not found");
1497
+ setAddress({ city: place.city, state: place.state.toUpperCase() });
1498
+ setPostalStatus(`${place.city}, ${place.state.toUpperCase()} filled from ZIP`);
1499
+ }).catch(() => setPostalStatus("ZIP lookup unavailable"));
1500
+ };
1501
+ const changeEvaluation = (type) => {
1502
+ setEvaluationType(type);
1503
+ setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, isAme: type === "ame", isQme: type !== "ame", ...type === "psych_qme" && !current.renderingProvider?.specialty ? { specialty: "Psychiatry" } : {} }, serviceLines: applyBillSubmissionEvaluationModifiers(current.serviceLines, type) }));
1504
+ };
1505
+ const total = submittedLines(bill.serviceLines).reduce((sum, line) => sum + (Number.isFinite(line.charge) ? Number(line.charge) : 0), 0);
1338
1506
  async function submit() {
1339
- const validation = validateBillSubmission(bill);
1507
+ const clean = { ...cloneBill(bill), serviceLines: submittedLines(bill.serviceLines) };
1508
+ const validation = validateBillSubmission(clean);
1340
1509
  setErrors(validation.fieldErrors);
1341
1510
  setFormError(null);
1342
- if (!validation.valid) {
1343
- setFormError("Complete the required fields before submitting.");
1344
- return;
1345
- }
1346
- if (selectedIds.length + uploads.length > MAX_DOCUMENTS) {
1347
- setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1348
- return;
1349
- }
1511
+ if (!validation.valid) return setFormError("Complete the required fields before submitting.");
1512
+ if (selectedIds.length + uploads.length > MAX_DOCUMENTS) return setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1350
1513
  setSubmitting(true);
1351
1514
  try {
1352
- await onSubmit({ bill: cloneBill(bill), sourceAttachmentIds: selectedIds, uploads });
1515
+ await onSubmit({ bill: clean, sourceAttachmentIds: selectedIds, uploads });
1353
1516
  } catch (caught) {
1354
1517
  setFormError(caught instanceof Error ? caught.message : "Unable to submit the bill.");
1355
1518
  } finally {
1356
1519
  setSubmitting(false);
1357
1520
  }
1358
1521
  }
1359
- return /* @__PURE__ */ jsxs2(
1360
- "form",
1361
- {
1362
- className,
1363
- style: { ...mindBillAppearanceStyle(appearance), ...styles.root, ...style },
1364
- onSubmit: (event) => {
1365
- event.preventDefault();
1366
- void submit();
1367
- },
1368
- noValidate: true,
1369
- children: [
1370
- /* @__PURE__ */ jsxs2("div", { style: styles.heading, children: [
1371
- /* @__PURE__ */ jsxs2("div", { children: [
1372
- /* @__PURE__ */ jsx2("h3", { style: styles.title, children: heading }),
1373
- /* @__PURE__ */ jsx2("p", { style: styles.copy, children: description })
1374
- ] }),
1375
- /* @__PURE__ */ jsxs2("span", { style: styles.requiredNote, children: [
1376
- /* @__PURE__ */ jsx2(RequiredMark, {}),
1377
- " Required"
1378
- ] })
1379
- ] }),
1380
- /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1381
- /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Patient" }),
1382
- /* @__PURE__ */ jsxs2("div", { style: styles.grid, children: [
1383
- /* @__PURE__ */ jsx2(Field2, { label: "First name", required: true, error: errors["patient.firstName"], children: textInput(bill.patient.firstName, (firstName) => setPatient({ firstName }), { required: true }) }),
1384
- /* @__PURE__ */ jsx2(Field2, { label: "Middle name", children: textInput(bill.patient.middleName, (middleName) => setPatient({ middleName })) }),
1385
- /* @__PURE__ */ jsx2(Field2, { label: "Last name", required: true, error: errors["patient.lastName"], children: textInput(bill.patient.lastName, (lastName) => setPatient({ lastName }), { required: true }) }),
1386
- /* @__PURE__ */ jsx2(Field2, { label: "Date of birth", children: textInput(bill.patient.dateOfBirth, (dateOfBirth) => setOptionalPatient("dateOfBirth", dateOfBirth), { type: "date" }) }),
1387
- /* @__PURE__ */ jsx2(Field2, { label: "Phone", children: textInput(bill.patient.phone, (phone) => setPatient({ phone }), { type: "tel" }) }),
1388
- /* @__PURE__ */ jsx2(Field2, { label: "Address", required: true, error: errors["patient.address.line1"], children: textInput(bill.patient.address.line1, (line1) => setAddress({ line1 }), { required: true }) }),
1389
- /* @__PURE__ */ jsx2(Field2, { label: "City", required: true, error: errors["patient.address.city"], children: textInput(bill.patient.address.city, (city) => setAddress({ city }), { required: true }) }),
1390
- /* @__PURE__ */ jsx2(Field2, { label: "State", required: true, error: errors["patient.address.state"], children: textInput(bill.patient.address.state, (state) => setAddress({ state }), { required: true, maxLength: 2 }) }),
1391
- /* @__PURE__ */ jsx2(Field2, { label: "ZIP", required: true, error: errors["patient.address.postalCode"], children: textInput(bill.patient.address.postalCode, (postalCode) => setAddress({ postalCode }), { required: true }) })
1392
- ] })
1393
- ] }),
1394
- /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1395
- /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Claim & service" }),
1396
- /* @__PURE__ */ jsxs2("div", { style: styles.grid, children: [
1397
- /* @__PURE__ */ jsx2(Field2, { label: "Claim number", required: true, error: errors["claim.claimNumber"], children: textInput(bill.claim.claimNumber, (claimNumber) => setClaim({ claimNumber }), { required: true }) }),
1398
- /* @__PURE__ */ jsx2(Field2, { label: "ADJ number", children: textInput(bill.claim.adjNumber, (adjNumber) => setClaim({ adjNumber })) }),
1399
- /* @__PURE__ */ jsx2(Field2, { label: "Employer", children: textInput(bill.claim.employer, (employer) => setClaim({ employer })) }),
1400
- /* @__PURE__ */ jsx2(Field2, { label: "Date of injury", children: textInput(bill.claim.dateOfInjury, (dateOfInjury) => setOptionalClaim("dateOfInjury", dateOfInjury), { type: "date" }) }),
1401
- /* @__PURE__ */ jsx2(Field2, { label: "Claims administrator", children: textInput(bill.claim.claimsAdministrator?.name, (name) => setBill((current) => {
1402
- const claim = { ...current.claim };
1403
- if (name) claim.claimsAdministrator = { ...claim.claimsAdministrator, name };
1404
- else delete claim.claimsAdministrator;
1405
- return { ...current, claim };
1406
- })) }),
1407
- /* @__PURE__ */ jsx2(Field2, { label: "Service date", required: true, error: errors["service.date"], children: textInput(bill.service.date, (date) => setService({ date }), { type: "date", required: true }) }),
1408
- /* @__PURE__ */ jsx2(Field2, { label: "Diagnoses", children: textInput(diagnoses, (value) => setBill((current) => ({ ...current, diagnoses: value.split(",").map((item) => item.trim()).filter(Boolean) })), { placeholder: "Comma-separated codes" }) })
1409
- ] })
1410
- ] }),
1411
- /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1412
- /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Providers & location" }),
1413
- /* @__PURE__ */ jsxs2("div", { style: styles.grid, children: [
1414
- /* @__PURE__ */ jsx2(Field2, { label: "Billing provider", children: textInput(bill.billingProvider?.name, (name) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, name } }))) }),
1415
- /* @__PURE__ */ jsx2(Field2, { label: "Billing tax ID", children: textInput(bill.billingProvider?.taxId, (taxId) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, taxId } }))) }),
1416
- /* @__PURE__ */ jsx2(Field2, { label: "Billing NPI", children: textInput(bill.billingProvider?.npi, (npi) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, npi } }))) }),
1417
- /* @__PURE__ */ jsx2(Field2, { label: "Billing phone", children: textInput(bill.billingProvider?.phone, (phone) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, phone } }))) }),
1418
- /* @__PURE__ */ jsx2(Field2, { label: "Rendering provider", children: textInput(bill.renderingProvider?.name, (name) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, name } }))) }),
1419
- /* @__PURE__ */ jsx2(Field2, { label: "Specialty", children: textInput(bill.renderingProvider?.specialty, (specialty) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, specialty } }))) }),
1420
- /* @__PURE__ */ jsx2(Field2, { label: "Rendering NPI", children: textInput(bill.renderingProvider?.npi, (npi) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, npi } }))) }),
1421
- /* @__PURE__ */ jsx2(Field2, { label: "License number", children: textInput(bill.renderingProvider?.licenseNumber, (licenseNumber) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, licenseNumber } }))) }),
1422
- /* @__PURE__ */ jsx2(Field2, { label: "License state", children: textInput(bill.renderingProvider?.licenseState, (licenseState) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, licenseState } })), { maxLength: 2 }) }),
1423
- /* @__PURE__ */ jsx2(Field2, { label: "Service location", children: textInput(bill.serviceLocation?.name, (name) => setBill((current) => ({ ...current, serviceLocation: { ...current.serviceLocation, name } }))) }),
1424
- /* @__PURE__ */ jsx2(Field2, { label: "Place of service", children: textInput(bill.serviceLocation?.placeOfServiceCode, (placeOfServiceCode) => setBill((current) => ({ ...current, serviceLocation: { ...current.serviceLocation, placeOfServiceCode } })), { maxLength: 2 }) })
1425
- ] })
1522
+ return /* @__PURE__ */ jsxs3("form", { className: `${className} mbsf`, style: { ...mindBillAppearanceStyle(appearance), ...style }, onSubmit: (event) => {
1523
+ event.preventDefault();
1524
+ void submit();
1525
+ }, noValidate: true, children: [
1526
+ /* @__PURE__ */ jsx3("style", { children: css }),
1527
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-head", children: [
1528
+ /* @__PURE__ */ jsxs3("div", { children: [
1529
+ /* @__PURE__ */ jsx3("h3", { className: "mbsf-title", children: heading }),
1530
+ /* @__PURE__ */ jsx3("p", { className: "mbsf-copy", children: description })
1531
+ ] }),
1532
+ /* @__PURE__ */ jsxs3("span", { className: "mbsf-required", children: [
1533
+ /* @__PURE__ */ jsx3(RequiredMark, {}),
1534
+ " Required"
1535
+ ] })
1536
+ ] }),
1537
+ /* @__PURE__ */ jsxs3("fieldset", { className: "mbsf-card", disabled: locked, children: [
1538
+ /* @__PURE__ */ jsx3("legend", { className: "mbsf-legend", children: "Patient" }),
1539
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-grid", children: [
1540
+ /* @__PURE__ */ jsx3(Field2, { label: "First name", required: true, error: errors["patient.firstName"], children: text(bill.patient.firstName, (firstName) => setBill((c) => ({ ...c, patient: { ...c.patient, firstName } }))) }),
1541
+ /* @__PURE__ */ jsx3(Field2, { label: "Last name", required: true, error: errors["patient.lastName"], children: text(bill.patient.lastName, (lastName) => setBill((c) => ({ ...c, patient: { ...c.patient, lastName } }))) }),
1542
+ /* @__PURE__ */ jsx3(Field2, { label: "Middle name", children: text(bill.patient.middleName, (middleName) => setBill((c) => ({ ...c, patient: { ...c.patient, middleName } }))) }),
1543
+ /* @__PURE__ */ jsx3(Field2, { label: "Phone (optional)", children: text(bill.patient.phone, (phone) => setBill((c) => ({ ...c, patient: { ...c.patient, phone } })), { type: "tel" }) }),
1544
+ /* @__PURE__ */ jsx3(Field2, { label: "Date of birth", required: true, error: errors["patient.dateOfBirth"], children: /* @__PURE__ */ jsx3(TextDateInput, { ariaLabel: "Date of birth", value: bill.patient.dateOfBirth, disabled: locked, required: true, onChange: (dateOfBirth) => setBill((c) => ({ ...c, patient: { ...c.patient, dateOfBirth } })) }) }),
1545
+ /* @__PURE__ */ jsx3(Field2, { label: "Address", required: true, span: true, error: errors["patient.address.line1"], children: text(bill.patient.address.line1, (line1) => setAddress({ line1 }), { placeholder: "Street address" }) }),
1546
+ /* @__PURE__ */ jsxs3(Field2, { label: "ZIP", required: true, error: errors["patient.address.postalCode"], children: [
1547
+ text(bill.patient.address.postalCode, updatePostalCode, { maxLength: 10 }),
1548
+ postalStatus ? /* @__PURE__ */ jsx3("small", { className: "mbsf-help", children: postalStatus }) : null
1426
1549
  ] }),
1427
- /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1428
- /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Service lines" }),
1429
- /* @__PURE__ */ jsx2("div", { style: styles.tableWrap, children: /* @__PURE__ */ jsxs2("table", { "aria-label": "Service lines", style: styles.table, children: [
1430
- /* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsxs2("tr", { children: [
1431
- /* @__PURE__ */ jsxs2("th", { style: styles.th, children: [
1432
- "Code",
1433
- /* @__PURE__ */ jsx2(RequiredMark, {})
1434
- ] }),
1435
- /* @__PURE__ */ jsx2("th", { style: styles.th, children: "Modifiers" }),
1436
- /* @__PURE__ */ jsxs2("th", { style: styles.th, children: [
1437
- "Units",
1438
- /* @__PURE__ */ jsx2(RequiredMark, {})
1439
- ] }),
1440
- bill.billingMode === "professional" ? /* @__PURE__ */ jsxs2("th", { style: styles.th, children: [
1441
- "Charge",
1442
- /* @__PURE__ */ jsx2(RequiredMark, {})
1443
- ] }) : null,
1444
- /* @__PURE__ */ jsx2("th", { style: styles.th, "aria-label": "Actions" })
1445
- ] }) }),
1446
- /* @__PURE__ */ jsx2("tbody", { children: bill.serviceLines.map((line, index) => /* @__PURE__ */ jsxs2("tr", { children: [
1447
- /* @__PURE__ */ jsxs2("td", { style: styles.td, children: [
1448
- textInput(line.code, (code) => setLine(index, { code }), { required: true }),
1449
- errors[`serviceLines.${index}.code`] ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors[`serviceLines.${index}.code`] }) : null
1450
- ] }),
1451
- /* @__PURE__ */ jsx2("td", { style: styles.td, children: textInput((line.modifiers ?? []).join(", "), (value) => setLine(index, { modifiers: value.split(",").map((item) => item.trim()).filter(Boolean) })) }),
1452
- /* @__PURE__ */ jsxs2("td", { style: styles.td, children: [
1453
- /* @__PURE__ */ jsx2("input", { style: styles.input, type: "number", min: 1, required: true, value: line.units ?? 1, onChange: (event) => setLine(index, { units: Number(event.target.value) }) }),
1454
- errors[`serviceLines.${index}.units`] ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors[`serviceLines.${index}.units`] }) : null
1455
- ] }),
1456
- bill.billingMode === "professional" ? /* @__PURE__ */ jsxs2("td", { style: styles.td, children: [
1457
- /* @__PURE__ */ jsx2("input", { style: styles.input, type: "number", min: 0, step: "0.01", required: true, value: line.charge ?? "", onChange: (event) => setOptionalLineNumber(index, "charge", event.target.value) }),
1458
- errors[`serviceLines.${index}.charge`] ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors[`serviceLines.${index}.charge`] }) : null
1459
- ] }) : null,
1460
- /* @__PURE__ */ jsx2("td", { style: styles.td, children: /* @__PURE__ */ jsx2("button", { style: styles.secondaryButton, type: "button", disabled: locked || bill.serviceLines.length === 1, onClick: () => setBill((current) => ({ ...current, serviceLines: current.serviceLines.filter((_, lineIndex) => lineIndex !== index) })), children: "Remove" }) })
1461
- ] }, index)) })
1462
- ] }) }),
1463
- errors.serviceLines ? /* @__PURE__ */ jsx2("p", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors.serviceLines }) : null,
1464
- /* @__PURE__ */ jsx2("button", { style: { ...styles.secondaryButton, marginTop: 12 }, type: "button", disabled: locked, onClick: () => setBill((current) => ({ ...current, serviceLines: [...current.serviceLines, { code: "", modifiers: [], units: 1 }] })), children: "+ Add service line" })
1550
+ /* @__PURE__ */ jsx3(Field2, { label: "City", required: true, error: errors["patient.address.city"], children: text(bill.patient.address.city, (city) => setAddress({ city })) }),
1551
+ /* @__PURE__ */ jsx3(Field2, { label: "State", required: true, error: errors["patient.address.state"], children: text(bill.patient.address.state, (state) => setAddress({ state: state.toUpperCase() }), { maxLength: 2 }) })
1552
+ ] })
1553
+ ] }),
1554
+ /* @__PURE__ */ jsxs3("fieldset", { className: "mbsf-card", disabled: locked, children: [
1555
+ /* @__PURE__ */ jsx3("legend", { className: "mbsf-legend", children: "Injury & claim" }),
1556
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-grid", children: [
1557
+ /* @__PURE__ */ jsx3(Field2, { label: "Date of service", required: true, error: errors["service.date"], children: /* @__PURE__ */ jsx3(TextDateInput, { ariaLabel: "Date of service", value: bill.service.date, disabled: locked, required: true, onChange: (date2) => setBill((c) => ({ ...c, service: { ...c.service, date: date2 } })) }) }),
1558
+ /* @__PURE__ */ jsx3(Field2, { label: "Date of injury", children: /* @__PURE__ */ jsx3(TextDateInput, { ariaLabel: "Date of injury", value: bill.claim.dateOfInjury, disabled: locked, onChange: (dateOfInjury) => setBill((c) => ({ ...c, claim: { ...c.claim, dateOfInjury } })) }) }),
1559
+ /* @__PURE__ */ jsx3(Field2, { label: "Employer (optional)", children: text(bill.claim.employer, (employer) => setBill((c) => ({ ...c, claim: { ...c.claim, employer } }))) }),
1560
+ /* @__PURE__ */ jsx3(Field2, { label: "Claim number", required: true, error: errors["claim.claimNumber"], children: text(bill.claim.claimNumber, (claimNumber) => setBill((c) => ({ ...c, claim: { ...c.claim, claimNumber } }))) }),
1561
+ /* @__PURE__ */ jsx3(Field2, { label: "WCAB / ADJ number (optional)", children: text(bill.claim.adjNumber, (adjNumber) => setBill((c) => ({ ...c, claim: { ...c.claim, adjNumber } }))) }),
1562
+ /* @__PURE__ */ jsx3(Field2, { label: "Claims administrator", required: true, span: true, error: errors["claim.claimsAdministrator"], children: /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: "Claims administrator", disabled: locked, loading: payerLoading, value: bill.claim.claimsAdministrator?.name ?? "", placeholder: "Search the payer directory\u2026", options: payerResults.map((payer) => ({ id: payer.id, label: payer.name, detail: [payer.hasElectronic ? "Electronic" : "Work comp", ...payer.states ?? []].join(" \xB7 ") })), onQuery: searchPayers, onSelect: (option) => setBill((c) => ({ ...c, claim: { ...c.claim, claimsAdministrator: { id: option.id, name: option.label } } })) }) }),
1563
+ /* @__PURE__ */ jsx3(Field2, { label: "Injury description (optional)", span: true, children: text(bill.claim.description, (description2) => setBill((c) => ({ ...c, claim: { ...c.claim, description: description2 } }))) }),
1564
+ /* @__PURE__ */ jsxs3(Field2, { label: "Diagnosis codes (ICD-10)", span: true, children: [
1565
+ /* @__PURE__ */ jsx3("div", { className: "mbsf-chips", children: (bill.diagnoses ?? []).map((code) => {
1566
+ const option = [...diagnosisOptions, ...diagnosisResults].find((item) => item.code === code);
1567
+ return /* @__PURE__ */ jsxs3("span", { className: "mbsf-chip", children: [
1568
+ /* @__PURE__ */ jsx3("strong", { children: code }),
1569
+ option?.description ? ` ${option.description}` : "",
1570
+ /* @__PURE__ */ jsx3("button", { type: "button", "aria-label": `Remove ${code}`, onClick: () => setBill((c) => ({ ...c, diagnoses: (c.diagnoses ?? []).filter((item) => item !== code) })), children: "\xD7" })
1571
+ ] }, code);
1572
+ }) }),
1573
+ /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: "Add diagnosis code", disabled: locked, loading: diagnosisLoading, value: "", placeholder: bill.diagnoses?.length ?? 0 ? `${bill.diagnoses.length} selected \u2014 add more\u2026` : "Search ICD-10 codes\u2026", options: [...new Map([...diagnosisOptions, ...diagnosisResults].map((item) => [item.code, item])).values()].filter((item) => !(bill.diagnoses ?? []).includes(item.code)).map((item) => ({ id: item.code, label: item.code, detail: item.description })), onQuery: searchDiagnoses, onSelect: (option) => setBill((c) => ({ ...c, diagnoses: [.../* @__PURE__ */ new Set([...c.diagnoses ?? [], option.id])] })) })
1574
+ ] })
1575
+ ] })
1576
+ ] }),
1577
+ /* @__PURE__ */ jsxs3("fieldset", { className: "mbsf-card", disabled: locked, children: [
1578
+ /* @__PURE__ */ jsx3("legend", { className: "mbsf-legend", children: "Providers & place of service" }),
1579
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-grid", children: [
1580
+ /* @__PURE__ */ jsx3(Field2, { label: "Billing provider", children: text(bill.billingProvider?.name, (name) => setBill((c) => ({ ...c, billingProvider: { ...c.billingProvider, name } }))) }),
1581
+ /* @__PURE__ */ jsx3(Field2, { label: "Billing tax ID", children: text(bill.billingProvider?.taxId, (taxId) => setBill((c) => ({ ...c, billingProvider: { ...c.billingProvider, taxId } }))) }),
1582
+ /* @__PURE__ */ jsx3(Field2, { label: "Billing NPI", children: text(bill.billingProvider?.npi, (npi) => setBill((c) => ({ ...c, billingProvider: { ...c.billingProvider, npi } }))) }),
1583
+ /* @__PURE__ */ jsx3(Field2, { label: "Billing phone", children: text(bill.billingProvider?.phone, (phone) => setBill((c) => ({ ...c, billingProvider: { ...c.billingProvider, phone } })), { type: "tel" }) }),
1584
+ /* @__PURE__ */ jsx3(Field2, { label: "Rendering provider", children: text(bill.renderingProvider?.name, (name) => setBill((c) => ({ ...c, renderingProvider: { ...c.renderingProvider, name } }))) }),
1585
+ /* @__PURE__ */ jsx3(Field2, { label: "Specialty", children: text(bill.renderingProvider?.specialty, (specialty) => setBill((c) => ({ ...c, renderingProvider: { ...c.renderingProvider, specialty } }))) }),
1586
+ /* @__PURE__ */ jsx3(Field2, { label: "Rendering NPI", children: text(bill.renderingProvider?.npi, (npi) => setBill((c) => ({ ...c, renderingProvider: { ...c.renderingProvider, npi } }))) }),
1587
+ /* @__PURE__ */ jsx3(Field2, { label: "License number", children: text(bill.renderingProvider?.licenseNumber, (licenseNumber) => setBill((c) => ({ ...c, renderingProvider: { ...c.renderingProvider, licenseNumber } }))) }),
1588
+ /* @__PURE__ */ jsx3(Field2, { label: "License state", children: text(bill.renderingProvider?.licenseState, (licenseState) => setBill((c) => ({ ...c, renderingProvider: { ...c.renderingProvider, licenseState: licenseState.toUpperCase() } })), { maxLength: 2 }) }),
1589
+ /* @__PURE__ */ jsx3(Field2, { label: "Service location", children: text(bill.serviceLocation?.name, (name) => setBill((c) => ({ ...c, serviceLocation: { ...c.serviceLocation, name } }))) }),
1590
+ /* @__PURE__ */ jsx3(Field2, { label: "Place of service", children: text(bill.serviceLocation?.placeOfServiceCode, (placeOfServiceCode) => setBill((c) => ({ ...c, serviceLocation: { ...c.serviceLocation, placeOfServiceCode } })), { maxLength: 2 }) })
1591
+ ] })
1592
+ ] }),
1593
+ /* @__PURE__ */ jsxs3("fieldset", { className: "mbsf-card", disabled: locked, children: [
1594
+ /* @__PURE__ */ jsx3("legend", { className: "mbsf-legend", children: "Evaluation & service lines" }),
1595
+ /* @__PURE__ */ jsx3("p", { className: "mbsf-help", children: "Sets the evaluator/specialty modifier on medical-legal evaluation lines." }),
1596
+ /* @__PURE__ */ jsx3("div", { className: "mbsf-segments", role: "group", "aria-label": "Evaluation type", children: [["qme", "QME (default)"], ["ame", "AME"], ["psych_qme", "Psych QME"]].map(([type, label]) => /* @__PURE__ */ jsx3("button", { className: "mbsf-segment", type: "button", "aria-pressed": evaluationType === type, onClick: () => changeEvaluation(type), children: label }, type)) }),
1597
+ /* @__PURE__ */ jsx3("p", { className: "mbsf-help", children: evaluationType === "ame" ? "Agreed Medical Evaluator \u2014 eligible ML evaluation codes default to modifier -94." : evaluationType === "psych_qme" ? "Psychiatric QME \u2014 eligible ML evaluation codes default to modifier -96 (-95 for ML200)." : "Qualified Medical Evaluator \u2014 eligible ML evaluation codes default to modifier -95." }),
1598
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-lines", children: [
1599
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-line-head", children: [
1600
+ /* @__PURE__ */ jsx3("span", { children: "Procedure code" }),
1601
+ /* @__PURE__ */ jsx3("span", { children: "Modifiers" }),
1602
+ /* @__PURE__ */ jsx3("span", { children: "Units" }),
1603
+ /* @__PURE__ */ jsx3("span", { children: "Allowed" }),
1604
+ /* @__PURE__ */ jsx3("span", {}),
1605
+ " "
1465
1606
  ] }),
1466
- /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1467
- /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Attachments" }),
1468
- attachments.map((attachment) => /* @__PURE__ */ jsxs2("label", { style: styles.attachment, children: [
1469
- /* @__PURE__ */ jsx2("input", { type: "checkbox", checked: selectedIds.includes(attachment.id), onChange: (event) => {
1470
- if (event.target.checked && selectedIds.length + uploads.length >= MAX_DOCUMENTS) {
1471
- setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1472
- return;
1473
- }
1474
- setSelectedIds((current) => event.target.checked ? [.../* @__PURE__ */ new Set([...current, attachment.id])] : current.filter((id) => id !== attachment.id));
1607
+ bill.serviceLines.map((line, index) => /* @__PURE__ */ jsxs3("div", { className: "mbsf-line", children: [
1608
+ /* @__PURE__ */ jsxs3("div", { children: [
1609
+ /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: `Procedure code ${index + 1}`, disabled: locked, value: line.code, placeholder: "Code\u2026", options: procedures.map((item) => ({ id: item.code, label: item.code, detail: item.description })), onSelect: (option) => {
1610
+ const selected = procedures.find((item) => item.code === option.id);
1611
+ const auto = evaluationModifier(evaluationType, option.id);
1612
+ setLine(index, { code: option.id, ...auto ? { modifiers: [auto, ...(line.modifiers ?? []).filter((item) => !["94", "95", "96"].includes(item.replace(/^-/, "")))] } : line.modifiers ? { modifiers: line.modifiers } : {}, ...selected?.allowedAmount != null ? { charge: selected.allowedAmount * (line.units ?? 1) } : {} });
1475
1613
  } }),
1476
- /* @__PURE__ */ jsxs2("span", { style: styles.attachmentName, children: [
1477
- /* @__PURE__ */ jsx2("strong", { children: attachment.fileName }),
1478
- /* @__PURE__ */ jsx2("span", { style: styles.attachmentMeta, children: attachment.description || documentLabels[attachment.documentType] })
1479
- ] })
1480
- ] }, attachment.id)),
1481
- uploads.map((upload, index) => /* @__PURE__ */ jsxs2("div", { style: styles.attachment, children: [
1482
- /* @__PURE__ */ jsxs2("span", { style: styles.attachmentName, children: [
1483
- /* @__PURE__ */ jsx2("strong", { children: upload.file.name }),
1484
- /* @__PURE__ */ jsxs2("span", { style: styles.attachmentMeta, children: [
1485
- (upload.file.size / 1024 / 1024).toFixed(1),
1486
- " MB"
1614
+ line.code ? /* @__PURE__ */ jsx3("small", { className: "mbsf-help", children: procedures.find((item) => item.code === line.code)?.description }) : null,
1615
+ errors[`serviceLines.${index}.code`] ? /* @__PURE__ */ jsx3("small", { className: "mbsf-error", children: errors[`serviceLines.${index}.code`] }) : null
1616
+ ] }),
1617
+ /* @__PURE__ */ jsxs3("div", { children: [
1618
+ /* @__PURE__ */ jsx3("div", { className: "mbsf-chips", children: (line.modifiers ?? []).map((modifier) => /* @__PURE__ */ jsxs3("span", { className: "mbsf-chip", children: [
1619
+ "\u2212",
1620
+ modifier.replace(/^-/, ""),
1621
+ /* @__PURE__ */ jsx3("button", { type: "button", "aria-label": `Remove modifier ${modifier}`, onClick: () => setLine(index, { modifiers: (line.modifiers ?? []).filter((item) => item !== modifier) }), children: "\xD7" })
1622
+ ] }, modifier)) }),
1623
+ /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: `Modifiers ${index + 1}`, disabled: locked, value: "", placeholder: line.modifiers?.length ?? 0 ? `${line.modifiers.length} modifier${line.modifiers.length === 1 ? "" : "s"}` : "Add modifiers\u2026", options: modifiers.filter((item) => !(line.modifiers ?? []).includes(item.code)).map((item) => ({ id: item.code, label: `\u2212${item.code}`, detail: item.description })), onSelect: (option) => setLine(index, { modifiers: [.../* @__PURE__ */ new Set([...line.modifiers ?? [], option.id])] }) })
1624
+ ] }),
1625
+ /* @__PURE__ */ jsxs3("div", { children: [
1626
+ /* @__PURE__ */ jsx3("input", { className: "mbsf-input", "aria-label": `Units ${index + 1}`, type: "number", min: 1, value: line.units ?? 1, onChange: (event) => {
1627
+ const units = Number(event.target.value);
1628
+ const selected = procedures.find((item) => item.code === line.code);
1629
+ setLine(index, { units, ...selected?.allowedAmount != null ? { charge: selected.allowedAmount * units } : {} });
1630
+ } }),
1631
+ errors[`serviceLines.${index}.units`] ? /* @__PURE__ */ jsx3("small", { className: "mbsf-error", children: errors[`serviceLines.${index}.units`] }) : null
1632
+ ] }),
1633
+ /* @__PURE__ */ jsx3("div", { className: "mbsf-money", children: line.charge == null ? "\u2014" : line.charge.toLocaleString(void 0, { style: "currency", currency: "USD" }) }),
1634
+ /* @__PURE__ */ jsx3("button", { className: "mbsf-icon-btn", type: "button", "aria-label": `Remove service line ${index + 1}`, disabled: locked || !lineHasContent(line) && index === bill.serviceLines.length - 1, onClick: () => setBill((c) => ({ ...c, serviceLines: ensureTrailingBillSubmissionLine(c.serviceLines.filter((_, itemIndex) => itemIndex !== index)) })), children: "\xD7" })
1635
+ ] }, index)),
1636
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-total", children: [
1637
+ /* @__PURE__ */ jsx3("span", { children: "Total" }),
1638
+ /* @__PURE__ */ jsx3("span", { children: total.toLocaleString(void 0, { style: "currency", currency: "USD" }) })
1639
+ ] })
1640
+ ] }),
1641
+ errors.serviceLines ? /* @__PURE__ */ jsx3("p", { className: "mbsf-error", children: errors.serviceLines }) : null
1642
+ ] }),
1643
+ /* @__PURE__ */ jsxs3("fieldset", { className: "mbsf-card", disabled: locked, children: [
1644
+ /* @__PURE__ */ jsx3("legend", { className: "mbsf-legend", children: "Attachments" }),
1645
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-list", children: [
1646
+ attachments.map((attachment) => {
1647
+ const auto = attachment.autoAttached ?? attachment.documentType === "w9";
1648
+ const selected = selectedIds.includes(attachment.id);
1649
+ return /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-row", "data-auto": auto, children: [
1650
+ /* @__PURE__ */ jsxs3("label", { className: "mbsf-attach-row", style: { border: 0, padding: 0, flex: 1, justifyContent: "flex-start" }, children: [
1651
+ /* @__PURE__ */ jsx3("input", { type: "checkbox", checked: selected, disabled: locked || auto || attachment.removable === false, onChange: (event) => setSelectedIds((current) => event.target.checked ? [.../* @__PURE__ */ new Set([...current, attachment.id])] : current.filter((id) => id !== attachment.id)) }),
1652
+ /* @__PURE__ */ jsxs3("span", { className: "mbsf-file", children: [
1653
+ /* @__PURE__ */ jsx3("strong", { children: attachment.fileName }),
1654
+ /* @__PURE__ */ jsx3("span", { className: "mbsf-badge", children: auto ? "Auto-attached" : documentLabels[attachment.documentType] }),
1655
+ /* @__PURE__ */ jsx3("span", { className: "mbsf-help", style: { display: "block" }, children: attachment.description || (auto ? "Included automatically with this bill." : documentLabels[attachment.documentType]) })
1487
1656
  ] })
1488
1657
  ] }),
1489
- /* @__PURE__ */ jsx2("select", { style: { ...styles.input, width: 180 }, value: upload.documentType, onChange: (event) => setUploads((current) => current.map((item, itemIndex) => itemIndex === index ? { ...item, documentType: event.target.value } : item)), children: BILL_SUBMISSION_DOCUMENT_TYPES.map((type) => /* @__PURE__ */ jsx2("option", { value: type, children: documentLabels[type] }, type)) }),
1490
- /* @__PURE__ */ jsx2("button", { style: styles.secondaryButton, type: "button", onClick: () => setUploads((current) => current.filter((_, itemIndex) => itemIndex !== index)), children: "Remove" })
1491
- ] }, `${upload.file.name}-${index}`)),
1492
- !attachments.length && !uploads.length ? /* @__PURE__ */ jsx2("p", { style: styles.copy, children: "No attachments added." }) : null,
1493
- /* @__PURE__ */ jsxs2("label", { style: { ...styles.secondaryButton, display: "inline-flex", alignItems: "center", marginTop: 14 }, children: [
1494
- "Add PDF attachments",
1495
- /* @__PURE__ */ jsx2("input", { hidden: true, type: "file", accept: "application/pdf,.pdf", multiple: true, onChange: (event) => {
1496
- const files = Array.from(event.target.files ?? []);
1497
- event.target.value = "";
1498
- setFormError(null);
1499
- const invalid = files.find((file) => file.type !== "application/pdf" && !file.name.toLowerCase().endsWith(".pdf"));
1500
- if (invalid) return setFormError(`${invalid.name} is not a PDF.`);
1501
- const oversized = files.find((file) => file.size > MAX_PDF_BYTES);
1502
- if (oversized) return setFormError(`${oversized.name} is larger than 25 MB.`);
1503
- const nextBytes = [...uploads.map((item) => item.file), ...files].reduce((sum, file) => sum + file.size, 0);
1504
- if (nextBytes > MAX_UPLOAD_BYTES) return setFormError("Attachments exceed the 100 MB upload limit.");
1505
- if (selectedIds.length + uploads.length + files.length > MAX_DOCUMENTS) return setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1506
- setUploads((current) => [...current, ...files.map((file) => ({ file, documentType: "other" }))]);
1507
- } })
1508
- ] })
1509
- ] }),
1510
- formError ? /* @__PURE__ */ jsx2("div", { style: styles.error, role: "alert", children: formError }) : null,
1511
- /* @__PURE__ */ jsx2("div", { style: styles.actions, children: /* @__PURE__ */ jsx2("button", { style: { ...styles.submit, opacity: locked ? 0.65 : 1 }, type: "submit", disabled: locked, children: submitting ? "Submitting\u2026" : submitLabel }) })
1512
- ]
1513
- }
1514
- );
1658
+ attachment.previewUrl ? /* @__PURE__ */ jsx3("a", { className: "mbsf-secondary", href: attachment.previewUrl, target: "_blank", rel: "noreferrer", children: "View" }) : null
1659
+ ] }, attachment.id);
1660
+ }),
1661
+ uploads.map((upload, index) => /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-row", children: [
1662
+ /* @__PURE__ */ jsxs3("span", { className: "mbsf-file", children: [
1663
+ /* @__PURE__ */ jsx3("strong", { children: upload.file.name }),
1664
+ /* @__PURE__ */ jsxs3("span", { className: "mbsf-help", style: { display: "block" }, children: [
1665
+ (upload.file.size / 1024 / 1024).toFixed(1),
1666
+ " MB"
1667
+ ] })
1668
+ ] }),
1669
+ /* @__PURE__ */ jsx3("select", { className: "mbsf-select", style: { width: 190 }, value: upload.documentType, onChange: (event) => setUploads((current) => current.map((item, itemIndex) => itemIndex === index ? { ...item, documentType: event.target.value } : item)), children: BILL_SUBMISSION_DOCUMENT_TYPES.map((type) => /* @__PURE__ */ jsx3("option", { value: type, children: documentLabels[type] }, type)) }),
1670
+ /* @__PURE__ */ jsx3("button", { className: "mbsf-icon-btn", type: "button", "aria-label": `Remove ${upload.file.name}`, onClick: () => setUploads((current) => current.filter((_, itemIndex) => itemIndex !== index)), children: "\xD7" })
1671
+ ] }, `${upload.file.name}-${index}`))
1672
+ ] }),
1673
+ /* @__PURE__ */ jsx3("input", { ref: fileInput, hidden: true, type: "file", accept: "application/pdf,.pdf", multiple: true, onChange: (event) => {
1674
+ if (event.target.files) addFiles(event.target.files);
1675
+ event.target.value = "";
1676
+ } }),
1677
+ /* @__PURE__ */ jsx3("button", { className: "mbsf-drop", "data-active": dragActive, type: "button", onClick: () => fileInput.current?.click(), children: /* @__PURE__ */ jsxs3("span", { children: [
1678
+ /* @__PURE__ */ jsx3("strong", { style: { fontSize: 18 }, children: "Drop additional PDF files here, or click to choose" }),
1679
+ /* @__PURE__ */ jsx3("span", { className: "mbsf-help", style: { display: "block", marginTop: 8 }, children: "Add supporting documents anywhere on this screen." })
1680
+ ] }) })
1681
+ ] }),
1682
+ formError ? /* @__PURE__ */ jsx3("div", { className: "mbsf-alert", role: "alert", children: formError }) : null,
1683
+ /* @__PURE__ */ jsx3("div", { className: "mbsf-actions", children: /* @__PURE__ */ jsx3("button", { className: "mbsf-submit", type: "submit", disabled: locked, children: submitting ? "Submitting\u2026" : submitLabel }) })
1684
+ ] });
1515
1685
  }
1516
1686
 
1517
1687
  // src/connected-bill-status.tsx
1518
1688
  import {
1519
- useCallback,
1689
+ useCallback as useCallback2,
1520
1690
  useEffect as useEffect3,
1521
1691
  useMemo as useMemo3,
1522
- useRef as useRef2,
1692
+ useRef as useRef3,
1523
1693
  useState as useState3
1524
1694
  } from "react";
1525
1695
  import {
1526
1696
  DEFAULT_API_BASE_URL,
1527
1697
  DEFAULT_SESSION_ENDPOINT
1528
1698
  } from "@mindbill/browser";
1529
- import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1699
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1530
1700
  var DEFAULT_REFRESH_INTERVAL = 6e4;
1531
1701
  async function responseError(response, fallback) {
1532
1702
  const body = await response.json().catch(() => null);
@@ -1670,11 +1840,11 @@ function useBillStatus({
1670
1840
  const [error, setError] = useState3(null);
1671
1841
  const [isLoading, setIsLoading] = useState3(enabled && !initialData);
1672
1842
  const [isRefreshing, setIsRefreshing] = useState3(false);
1673
- const dataRef = useRef2(initialData);
1674
- const initialDataRef = useRef2(initialData);
1843
+ const dataRef = useRef3(initialData);
1844
+ const initialDataRef = useRef3(initialData);
1675
1845
  initialDataRef.current = initialData;
1676
- const activeControllerRef = useRef2(null);
1677
- const requestSequence = useRef2(0);
1846
+ const activeControllerRef = useRef3(null);
1847
+ const requestSequence = useRef3(0);
1678
1848
  useEffect3(() => {
1679
1849
  const seed = initialDataRef.current;
1680
1850
  dataRef.current = seed;
@@ -1684,7 +1854,7 @@ function useBillStatus({
1684
1854
  activeControllerRef.current?.abort();
1685
1855
  return () => activeControllerRef.current?.abort();
1686
1856
  }, [client, enabled]);
1687
- const load = useCallback(async () => {
1857
+ const load = useCallback2(async () => {
1688
1858
  if (!enabled || !billId) return;
1689
1859
  const sequence = ++requestSequence.current;
1690
1860
  activeControllerRef.current?.abort();
@@ -1747,17 +1917,17 @@ function ConnectedBillStatus({
1747
1917
  }) {
1748
1918
  const status = useBillStatus(options);
1749
1919
  if (status.isLoading && !status.data) {
1750
- return /* @__PURE__ */ jsx3(Fragment2, { children: loadingFallback ?? /* @__PURE__ */ jsx3("div", { role: "status", children: "Loading bill status\u2026" }) });
1920
+ return /* @__PURE__ */ jsx4(Fragment3, { children: loadingFallback ?? /* @__PURE__ */ jsx4("div", { role: "status", children: "Loading bill status\u2026" }) });
1751
1921
  }
1752
1922
  if (status.error && !status.data) {
1753
- return /* @__PURE__ */ jsx3(Fragment2, { children: errorFallback?.(status.error, status.refresh) ?? /* @__PURE__ */ jsxs3("div", { role: "alert", children: [
1923
+ return /* @__PURE__ */ jsx4(Fragment3, { children: errorFallback?.(status.error, status.refresh) ?? /* @__PURE__ */ jsxs4("div", { role: "alert", children: [
1754
1924
  status.error.message,
1755
1925
  " ",
1756
- /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => void status.refresh(), children: "Retry" })
1926
+ /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => void status.refresh(), children: "Retry" })
1757
1927
  ] }) });
1758
1928
  }
1759
1929
  if (!status.data) return null;
1760
- return /* @__PURE__ */ jsx3(
1930
+ return /* @__PURE__ */ jsx4(
1761
1931
  BillStatusSummary,
1762
1932
  {
1763
1933
  status: status.data.state,
@@ -1776,7 +1946,7 @@ function ConnectedBillStatus({
1776
1946
  }
1777
1947
 
1778
1948
  // src/bill-lifecycle-surfaces.tsx
1779
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1949
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1780
1950
  function visibleBillLifecycleActions(actions, showUnavailable = false) {
1781
1951
  return actions.filter((action) => action.enabled || showUnavailable);
1782
1952
  }
@@ -1791,17 +1961,15 @@ function BillLifecycleActions({
1791
1961
  }) {
1792
1962
  const visible = visibleBillLifecycleActions(actions, showUnavailable);
1793
1963
  if (!visible.length) return null;
1794
- return /* @__PURE__ */ jsxs4("div", { className: classes("mb-lifecycle-actions", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill actions", children: [
1795
- /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1796
- visible.map((action) => /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-action", children: [
1797
- /* @__PURE__ */ jsx4("button", { type: "button", className: action.primary ? "mb-action-button is-primary" : "mb-action-button", disabled: disabled || !action.enabled, onClick: () => onAction(action), children: action.label }),
1798
- !action.enabled && action.reason ? /* @__PURE__ */ jsx4("span", { className: "mb-action-reason", children: action.reason }) : null
1964
+ return /* @__PURE__ */ jsxs5("div", { className: classes("mb-lifecycle-actions", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill actions", children: [
1965
+ /* @__PURE__ */ jsx5("style", { children: lifecycleSurfaceStyles }),
1966
+ visible.map((action) => /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-action", children: [
1967
+ /* @__PURE__ */ jsx5("button", { type: "button", className: action.primary ? "mb-action-button is-primary" : "mb-action-button", disabled: disabled || !action.enabled, onClick: () => onAction(action), children: action.label }),
1968
+ !action.enabled && action.reason ? /* @__PURE__ */ jsx5("span", { className: "mb-action-reason", children: action.reason }) : null
1799
1969
  ] }, action.id))
1800
1970
  ] });
1801
1971
  }
1802
1972
  var activityLabels = {
1803
- "bill.created": "Bill created",
1804
- "bill.draft": "Bill saved",
1805
1973
  "bill.scrub_failed": "Submission needs attention",
1806
1974
  "bill.submitted": "Bill submitted",
1807
1975
  "bill.accepted": "Bill accepted",
@@ -1827,21 +1995,21 @@ function defaultFormatDate(createdAt) {
1827
1995
  return new Intl.DateTimeFormat(void 0, { dateStyle: "medium", timeStyle: "short" }).format(parsed);
1828
1996
  }
1829
1997
  function BillActivityTimeline({ events, emptyLabel = "No bill activity yet.", appearance, className, style, formatDate = defaultFormatDate }) {
1830
- return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-activity", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill activity", children: [
1831
- /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1832
- /* @__PURE__ */ jsxs4("header", { className: "mb-surface-heading", children: [
1833
- /* @__PURE__ */ jsxs4("div", { children: [
1834
- /* @__PURE__ */ jsx4("strong", { children: "Bill history" }),
1835
- /* @__PURE__ */ jsx4("span", { children: "Submission, payer responses, follow-up, and payments." })
1998
+ return /* @__PURE__ */ jsxs5("section", { className: classes("mb-surface mb-activity", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill activity", children: [
1999
+ /* @__PURE__ */ jsx5("style", { children: lifecycleSurfaceStyles }),
2000
+ /* @__PURE__ */ jsxs5("header", { className: "mb-surface-heading", children: [
2001
+ /* @__PURE__ */ jsxs5("div", { children: [
2002
+ /* @__PURE__ */ jsx5("strong", { children: "Bill history" }),
2003
+ /* @__PURE__ */ jsx5("span", { children: "Submission, payer responses, follow-up, and payments." })
1836
2004
  ] }),
1837
- /* @__PURE__ */ jsx4("span", { children: events.length })
2005
+ /* @__PURE__ */ jsx5("span", { children: events.length })
1838
2006
  ] }),
1839
- !events.length ? /* @__PURE__ */ jsx4("p", { className: "mb-activity-empty", children: emptyLabel }) : /* @__PURE__ */ jsx4("ol", { className: "mb-activity-list", children: events.map((event) => /* @__PURE__ */ jsxs4("li", { className: "mb-activity-item", children: [
1840
- /* @__PURE__ */ jsx4("span", { className: "mb-activity-marker", "aria-hidden": "true" }),
1841
- /* @__PURE__ */ jsxs4("div", { className: "mb-activity-content", children: [
1842
- /* @__PURE__ */ jsx4("strong", { children: event.title ?? billActivityEventLabel(event.type) }),
1843
- event.description ? /* @__PURE__ */ jsx4("p", { children: event.description }) : null,
1844
- /* @__PURE__ */ jsxs4("span", { children: [
2007
+ !events.length ? /* @__PURE__ */ jsx5("p", { className: "mb-activity-empty", children: emptyLabel }) : /* @__PURE__ */ jsx5("ol", { className: "mb-activity-list", children: events.map((event) => /* @__PURE__ */ jsxs5("li", { className: "mb-activity-item", children: [
2008
+ /* @__PURE__ */ jsx5("span", { className: "mb-activity-marker", "aria-hidden": "true" }),
2009
+ /* @__PURE__ */ jsxs5("div", { className: "mb-activity-content", children: [
2010
+ /* @__PURE__ */ jsx5("strong", { children: event.title ?? billActivityEventLabel(event.type) }),
2011
+ event.description ? /* @__PURE__ */ jsx5("p", { children: event.description }) : null,
2012
+ /* @__PURE__ */ jsxs5("span", { children: [
1845
2013
  formatDate(event.createdAt),
1846
2014
  event.actor ? ` \xB7 ${event.actor}` : ""
1847
2015
  ] })
@@ -1850,39 +2018,35 @@ function BillActivityTimeline({ events, emptyLabel = "No bill activity yet.", ap
1850
2018
  ] });
1851
2019
  }
1852
2020
  var lifecycleStages = [
1853
- { id: "created", label: "Created" },
1854
2021
  { id: "submitted", label: "Submitted" },
1855
2022
  { id: "accepted", label: "Accepted" },
1856
- { id: "response", label: "Payer response" },
1857
- { id: "follow_up", label: "Follow-up" },
2023
+ { id: "processed", label: "Processed" },
1858
2024
  { id: "closed", label: "Closed" }
1859
2025
  ];
1860
2026
  function billLifecycleStage(state) {
1861
2027
  const value = state.toLowerCase();
1862
2028
  if (value.includes("closed") || value.includes("written_off")) return "closed";
1863
- if (value.includes("second_review") || value.includes("ibr") || value.includes("lien") || value.includes("appeal")) return "follow_up";
1864
- if (value.includes("processed") || value.includes("paid") || value.includes("denied") || value.includes("rejected") || value.includes("response")) return "response";
2029
+ if (value.includes("processed") || value.includes("paid") || value.includes("denied") || value.includes("reject") || value.includes("partial") || value.includes("response") || value.includes("second_review") || value.includes("ibr") || value.includes("lien") || value.includes("appeal")) return "processed";
1865
2030
  if (value.includes("accepted")) return "accepted";
1866
- if (value.includes("submitted") || value.includes("queued") || value.includes("sent")) return "submitted";
1867
- return "created";
2031
+ return "submitted";
1868
2032
  }
1869
2033
  function BillLifecycleProgress({ state, nativeStatus, submittedAt, agingDays, appearance, className, style }) {
1870
2034
  const current = billLifecycleStage(state);
1871
2035
  const currentIndex = lifecycleStages.findIndex((stage) => stage.id === current);
1872
- return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-progress", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill lifecycle", children: [
1873
- /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1874
- /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1875
- /* @__PURE__ */ jsx4("strong", { children: humanize(nativeStatus || state) }),
1876
- /* @__PURE__ */ jsxs4("span", { children: [
1877
- submittedAt ? `Submitted ${defaultFormatDate(submittedAt)}` : "Not submitted",
2036
+ return /* @__PURE__ */ jsxs5("section", { className: classes("mb-surface mb-progress", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill lifecycle", children: [
2037
+ /* @__PURE__ */ jsx5("style", { children: lifecycleSurfaceStyles }),
2038
+ /* @__PURE__ */ jsx5("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs5("div", { children: [
2039
+ /* @__PURE__ */ jsx5("strong", { children: humanize(nativeStatus || state) }),
2040
+ /* @__PURE__ */ jsxs5("span", { children: [
2041
+ submittedAt ? `Submitted ${defaultFormatDate(submittedAt)}` : "Submitted",
1878
2042
  typeof agingDays === "number" ? ` \xB7 ${agingDays} days old` : ""
1879
2043
  ] })
1880
2044
  ] }) }),
1881
- /* @__PURE__ */ jsx4("ol", { className: "mb-progress-list", children: lifecycleStages.map((stage, index) => {
2045
+ /* @__PURE__ */ jsx5("ol", { className: "mb-progress-list", children: lifecycleStages.map((stage, index) => {
1882
2046
  const status = index < currentIndex ? "complete" : index === currentIndex ? "current" : "upcoming";
1883
- return /* @__PURE__ */ jsxs4("li", { className: `is-${status}`, "aria-current": status === "current" ? "step" : void 0, children: [
1884
- /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: status === "complete" ? "\u2713" : index + 1 }),
1885
- /* @__PURE__ */ jsx4("b", { children: stage.label })
2047
+ return /* @__PURE__ */ jsxs5("li", { className: `is-${status}`, "aria-current": status === "current" ? "step" : void 0, children: [
2048
+ /* @__PURE__ */ jsx5("span", { "aria-hidden": "true", children: status === "complete" ? "\u2713" : index + 1 }),
2049
+ /* @__PURE__ */ jsx5("b", { children: stage.label })
1886
2050
  ] }, stage.id);
1887
2051
  }) })
1888
2052
  ] });
@@ -1896,45 +2060,45 @@ function BillSnapshotSummary({ bill, patient, injury, delivery, appearance, clas
1896
2060
  ["Charged", currency(bill.totalCharge)],
1897
2061
  ["Balance", currency(bill.balanceDue)]
1898
2062
  ];
1899
- return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-snapshot", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill snapshot", children: [
1900
- /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1901
- /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1902
- /* @__PURE__ */ jsx4("strong", { children: "Bill snapshot" }),
1903
- /* @__PURE__ */ jsxs4("span", { children: [
2063
+ return /* @__PURE__ */ jsxs5("section", { className: classes("mb-surface mb-snapshot", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill snapshot", children: [
2064
+ /* @__PURE__ */ jsx5("style", { children: lifecycleSurfaceStyles }),
2065
+ /* @__PURE__ */ jsx5("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs5("div", { children: [
2066
+ /* @__PURE__ */ jsx5("strong", { children: "Bill snapshot" }),
2067
+ /* @__PURE__ */ jsxs5("span", { children: [
1904
2068
  "Bill #",
1905
2069
  bill.billNumber
1906
2070
  ] })
1907
2071
  ] }) }),
1908
- /* @__PURE__ */ jsx4("dl", { children: values.map(([label, value]) => /* @__PURE__ */ jsxs4("div", { children: [
1909
- /* @__PURE__ */ jsx4("dt", { children: label }),
1910
- /* @__PURE__ */ jsx4("dd", { children: value })
2072
+ /* @__PURE__ */ jsx5("dl", { children: values.map(([label, value]) => /* @__PURE__ */ jsxs5("div", { children: [
2073
+ /* @__PURE__ */ jsx5("dt", { children: label }),
2074
+ /* @__PURE__ */ jsx5("dd", { children: value })
1911
2075
  ] }, label)) })
1912
2076
  ] });
1913
2077
  }
1914
2078
  function BillRemittanceCard({ remittance, appearance, className, style }) {
1915
- return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-remittance", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Remittance summary", children: [
1916
- /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1917
- /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1918
- /* @__PURE__ */ jsx4("strong", { children: "Remittance" }),
1919
- /* @__PURE__ */ jsx4("span", { children: "Amounts reported by the payer and posted to the bill." })
2079
+ return /* @__PURE__ */ jsxs5("section", { className: classes("mb-surface mb-remittance", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Remittance summary", children: [
2080
+ /* @__PURE__ */ jsx5("style", { children: lifecycleSurfaceStyles }),
2081
+ /* @__PURE__ */ jsx5("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs5("div", { children: [
2082
+ /* @__PURE__ */ jsx5("strong", { children: "Remittance" }),
2083
+ /* @__PURE__ */ jsx5("span", { children: "Amounts reported by the payer and posted to the bill." })
1920
2084
  ] }) }),
1921
- /* @__PURE__ */ jsxs4("dl", { children: [
1922
- /* @__PURE__ */ jsxs4("div", { children: [
1923
- /* @__PURE__ */ jsx4("dt", { children: "Payer reported" }),
1924
- /* @__PURE__ */ jsx4("dd", { children: remittance.payerReportedPaid === null ? "\u2014" : currency(remittance.payerReportedPaid) })
2085
+ /* @__PURE__ */ jsxs5("dl", { children: [
2086
+ /* @__PURE__ */ jsxs5("div", { children: [
2087
+ /* @__PURE__ */ jsx5("dt", { children: "Payer reported" }),
2088
+ /* @__PURE__ */ jsx5("dd", { children: remittance.payerReportedPaid === null ? "\u2014" : currency(remittance.payerReportedPaid) })
1925
2089
  ] }),
1926
- /* @__PURE__ */ jsxs4("div", { children: [
1927
- /* @__PURE__ */ jsx4("dt", { children: "Posted" }),
1928
- /* @__PURE__ */ jsx4("dd", { children: currency(remittance.totalPaid) })
2090
+ /* @__PURE__ */ jsxs5("div", { children: [
2091
+ /* @__PURE__ */ jsx5("dt", { children: "Posted" }),
2092
+ /* @__PURE__ */ jsx5("dd", { children: currency(remittance.totalPaid) })
1929
2093
  ] }),
1930
- /* @__PURE__ */ jsxs4("div", { children: [
1931
- /* @__PURE__ */ jsx4("dt", { children: "Balance" }),
1932
- /* @__PURE__ */ jsx4("dd", { children: currency(remittance.balanceDue) })
2094
+ /* @__PURE__ */ jsxs5("div", { children: [
2095
+ /* @__PURE__ */ jsx5("dt", { children: "Balance" }),
2096
+ /* @__PURE__ */ jsx5("dd", { children: currency(remittance.balanceDue) })
1933
2097
  ] })
1934
2098
  ] }),
1935
- remittance.denialReason ? /* @__PURE__ */ jsxs4("div", { className: "mb-denial", children: [
1936
- /* @__PURE__ */ jsx4("strong", { children: "Denial reason" }),
1937
- /* @__PURE__ */ jsx4("p", { children: remittance.denialReason })
2099
+ remittance.denialReason ? /* @__PURE__ */ jsxs5("div", { className: "mb-denial", children: [
2100
+ /* @__PURE__ */ jsx5("strong", { children: "Denial reason" }),
2101
+ /* @__PURE__ */ jsx5("p", { children: remittance.denialReason })
1938
2102
  ] }) : null
1939
2103
  ] });
1940
2104
  }
@@ -1949,42 +2113,42 @@ function BillPayerContactCard({ delivery, appearance, className, style }) {
1949
2113
  delivery.contacts.portalUrl ? ["Portal", "Open payer portal", delivery.contacts.portalUrl] : null
1950
2114
  ].filter(Boolean);
1951
2115
  if (!delivery.payerName && !contacts.length) return null;
1952
- return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-contacts", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payer contact information", children: [
1953
- /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1954
- /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1955
- /* @__PURE__ */ jsx4("strong", { children: delivery.payerName || "Claims administrator" }),
1956
- /* @__PURE__ */ jsx4("span", { children: "Billing and follow-up contacts." })
2116
+ return /* @__PURE__ */ jsxs5("section", { className: classes("mb-surface mb-contacts", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payer contact information", children: [
2117
+ /* @__PURE__ */ jsx5("style", { children: lifecycleSurfaceStyles }),
2118
+ /* @__PURE__ */ jsx5("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs5("div", { children: [
2119
+ /* @__PURE__ */ jsx5("strong", { children: delivery.payerName || "Claims administrator" }),
2120
+ /* @__PURE__ */ jsx5("span", { children: "Billing and follow-up contacts." })
1957
2121
  ] }) }),
1958
- !contacts.length ? /* @__PURE__ */ jsx4("p", { className: "mb-empty", children: "No payer contact details are available." }) : /* @__PURE__ */ jsx4("dl", { children: contacts.map(([label, value, href]) => /* @__PURE__ */ jsxs4("div", { children: [
1959
- /* @__PURE__ */ jsx4("dt", { children: label }),
1960
- /* @__PURE__ */ jsx4("dd", { children: href ? /* @__PURE__ */ jsx4("a", { href, target: label === "Portal" ? "_blank" : void 0, rel: label === "Portal" ? "noreferrer noopener" : void 0, children: value }) : value })
2122
+ !contacts.length ? /* @__PURE__ */ jsx5("p", { className: "mb-empty", children: "No payer contact details are available." }) : /* @__PURE__ */ jsx5("dl", { children: contacts.map(([label, value, href]) => /* @__PURE__ */ jsxs5("div", { children: [
2123
+ /* @__PURE__ */ jsx5("dt", { children: label }),
2124
+ /* @__PURE__ */ jsx5("dd", { children: href ? /* @__PURE__ */ jsx5("a", { href, target: label === "Portal" ? "_blank" : void 0, rel: label === "Portal" ? "noreferrer noopener" : void 0, children: value }) : value })
1961
2125
  ] }, label)) })
1962
2126
  ] });
1963
2127
  }
1964
2128
  function BillPaymentLedger({ payments, appearance, className, style }) {
1965
- return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-payments", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payment ledger", children: [
1966
- /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1967
- /* @__PURE__ */ jsxs4("header", { className: "mb-surface-heading", children: [
1968
- /* @__PURE__ */ jsxs4("div", { children: [
1969
- /* @__PURE__ */ jsx4("strong", { children: "Payments" }),
1970
- /* @__PURE__ */ jsx4("span", { children: "Payments posted to this bill." })
2129
+ return /* @__PURE__ */ jsxs5("section", { className: classes("mb-surface mb-payments", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payment ledger", children: [
2130
+ /* @__PURE__ */ jsx5("style", { children: lifecycleSurfaceStyles }),
2131
+ /* @__PURE__ */ jsxs5("header", { className: "mb-surface-heading", children: [
2132
+ /* @__PURE__ */ jsxs5("div", { children: [
2133
+ /* @__PURE__ */ jsx5("strong", { children: "Payments" }),
2134
+ /* @__PURE__ */ jsx5("span", { children: "Payments posted to this bill." })
1971
2135
  ] }),
1972
- /* @__PURE__ */ jsx4("span", { children: payments.length })
2136
+ /* @__PURE__ */ jsx5("span", { children: payments.length })
1973
2137
  ] }),
1974
- !payments.length ? /* @__PURE__ */ jsx4("p", { className: "mb-empty", children: "No payments posted." }) : /* @__PURE__ */ jsx4("div", { className: "mb-payment-list", children: payments.map((payment) => /* @__PURE__ */ jsxs4("article", { children: [
1975
- /* @__PURE__ */ jsxs4("div", { children: [
1976
- /* @__PURE__ */ jsx4("strong", { children: currency(payment.amount) }),
1977
- /* @__PURE__ */ jsxs4("span", { children: [
2138
+ !payments.length ? /* @__PURE__ */ jsx5("p", { className: "mb-empty", children: "No payments posted." }) : /* @__PURE__ */ jsx5("div", { className: "mb-payment-list", children: payments.map((payment) => /* @__PURE__ */ jsxs5("article", { children: [
2139
+ /* @__PURE__ */ jsxs5("div", { children: [
2140
+ /* @__PURE__ */ jsx5("strong", { children: currency(payment.amount) }),
2141
+ /* @__PURE__ */ jsxs5("span", { children: [
1978
2142
  humanize(payment.status || "posted"),
1979
2143
  " \xB7 ",
1980
2144
  payment.method.toUpperCase()
1981
2145
  ] })
1982
2146
  ] }),
1983
- /* @__PURE__ */ jsxs4("div", { children: [
1984
- /* @__PURE__ */ jsx4("span", { children: payment.checkNumber ? `#${payment.checkNumber}` : payment.source.toUpperCase() }),
1985
- /* @__PURE__ */ jsx4("span", { children: payment.depositDate || defaultFormatDate(payment.postedAt) })
2147
+ /* @__PURE__ */ jsxs5("div", { children: [
2148
+ /* @__PURE__ */ jsx5("span", { children: payment.checkNumber ? `#${payment.checkNumber}` : payment.source.toUpperCase() }),
2149
+ /* @__PURE__ */ jsx5("span", { children: payment.depositDate || defaultFormatDate(payment.postedAt) })
1986
2150
  ] }),
1987
- payment.note ? /* @__PURE__ */ jsx4("p", { children: payment.note }) : null
2151
+ payment.note ? /* @__PURE__ */ jsx5("p", { children: payment.note }) : null
1988
2152
  ] }, payment.id)) })
1989
2153
  ] });
1990
2154
  }
@@ -2003,7 +2167,7 @@ var lifecycleSurfaceStyles = `
2003
2167
  .mb-surface-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:16px}.mb-surface-heading>div{display:grid;gap:2px}.mb-surface-heading strong{font-size:16px}.mb-surface-heading span,.mb-empty{color:var(--mb-muted);font-size:13px}.mb-surface-heading>span{border-radius:999px;background:var(--mb-soft);font-weight:750;padding:4px 8px}
2004
2168
  .mb-lifecycle-actions{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-start}.mb-lifecycle-action{display:grid;gap:5px;max-width:260px}.mb-action-button{appearance:none;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-surface);color:var(--mb-text);font:inherit;font-weight:700;line-height:1.2;padding:11px 15px;cursor:pointer}.mb-action-button:hover:not(:disabled){border-color:var(--mb-accent);color:var(--mb-accent)}.mb-action-button:focus-visible{outline:3px solid color-mix(in srgb,var(--mb-accent) 28%,transparent);outline-offset:2px}.mb-action-button.is-primary{background:var(--mb-accent);border-color:var(--mb-accent);color:var(--mb-accent-contrast)}.mb-action-button:disabled{cursor:not-allowed;opacity:.55}.mb-action-reason{color:var(--mb-muted);font-size:12px;line-height:1.35}
2005
2169
  .mb-activity-list{list-style:none;margin:0;padding:0}.mb-activity-item{display:grid;grid-template-columns:18px minmax(0,1fr);gap:12px;position:relative;padding:0 0 22px}.mb-activity-item:last-child{padding-bottom:0}.mb-activity-item:not(:last-child)::before{background:var(--mb-border);content:"";left:8px;position:absolute;top:10px;bottom:0;width:1px}.mb-activity-marker{background:var(--mb-surface);border:3px solid var(--mb-accent);border-radius:999px;height:11px;margin-top:4px;position:relative;width:11px;z-index:1}.mb-activity-content{display:grid;gap:4px;min-width:0}.mb-activity-content strong{font-size:15px;line-height:1.35}.mb-activity-content p{color:var(--mb-text);font-size:14px;line-height:1.5;margin:0}.mb-activity-content span,.mb-activity-empty{color:var(--mb-muted);font-size:13px;line-height:1.45}.mb-activity-empty,.mb-empty{margin:0}
2006
- .mb-progress-list{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));list-style:none;margin:0;padding:0}.mb-progress-list li{display:grid;gap:7px;position:relative;text-align:center;color:var(--mb-muted);font-size:12px}.mb-progress-list li:not(:last-child)::after{content:"";position:absolute;left:calc(50% + 14px);right:calc(-50% + 14px);top:13px;height:2px;background:var(--mb-border)}.mb-progress-list li.is-complete:not(:last-child)::after{background:var(--mb-accent)}.mb-progress-list li>span{display:grid;place-items:center;justify-self:center;position:relative;z-index:1;width:28px;height:28px;border:2px solid var(--mb-border);border-radius:50%;background:var(--mb-surface);font-weight:800}.mb-progress-list li.is-complete>span,.mb-progress-list li.is-current>span{border-color:var(--mb-accent);background:var(--mb-accent);color:var(--mb-accent-contrast)}.mb-progress-list li.is-current{color:var(--mb-text)}
2170
+ .mb-progress-list{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));list-style:none;margin:0;padding:0}.mb-progress-list li{display:grid;gap:7px;position:relative;text-align:center;color:var(--mb-muted);font-size:12px}.mb-progress-list li:not(:last-child)::after{content:"";position:absolute;left:calc(50% + 14px);right:calc(-50% + 14px);top:13px;height:2px;background:var(--mb-border)}.mb-progress-list li.is-complete:not(:last-child)::after{background:var(--mb-accent)}.mb-progress-list li>span{display:grid;place-items:center;justify-self:center;position:relative;z-index:1;width:28px;height:28px;border:2px solid var(--mb-border);border-radius:50%;background:var(--mb-surface);font-weight:800}.mb-progress-list li.is-complete>span,.mb-progress-list li.is-current>span{border-color:var(--mb-accent);background:var(--mb-accent);color:var(--mb-accent-contrast)}.mb-progress-list li.is-current{color:var(--mb-text)}
2007
2171
  .mb-snapshot dl,.mb-remittance dl,.mb-contacts dl{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0;margin:0}.mb-snapshot dl>div,.mb-remittance dl>div,.mb-contacts dl>div{display:grid;gap:3px;padding:10px 14px;border-left:1px solid var(--mb-border)}.mb-snapshot dl>div:nth-child(3n+1),.mb-remittance dl>div:first-child,.mb-contacts dl>div:first-child{border-left:0}.mb-snapshot dt,.mb-remittance dt,.mb-contacts dt{color:var(--mb-muted);font-size:11px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.mb-snapshot dd,.mb-remittance dd,.mb-contacts dd{font-size:14px;font-weight:750;margin:0;overflow-wrap:anywhere}.mb-contacts a{color:var(--mb-accent)}.mb-denial{margin-top:16px;border-left:4px solid var(--mb-danger);border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-danger) 8%,var(--mb-surface));padding:12px 14px}.mb-denial p{margin:4px 0 0}
2008
2172
  .mb-payment-list{display:grid}.mb-payment-list article{display:grid;grid-template-columns:1fr auto;gap:5px 18px;padding:12px 0;border-top:1px solid var(--mb-border)}.mb-payment-list article:first-child{border-top:0}.mb-payment-list article>div{display:grid;gap:2px}.mb-payment-list article>div:nth-child(2){text-align:right}.mb-payment-list article span{color:var(--mb-muted);font-size:12px}.mb-payment-list article p{grid-column:1/-1;margin:0;color:var(--mb-muted);font-size:13px}
2009
2173
  @media(max-width:700px){.mb-progress-list{grid-template-columns:1fr;text-align:left}.mb-progress-list li{grid-template-columns:28px 1fr;align-items:center;text-align:left}.mb-progress-list li:not(:last-child)::after{left:13px;right:auto;top:28px;bottom:-7px;width:2px;height:auto}.mb-progress-list li>span{grid-row:1}.mb-snapshot dl,.mb-remittance dl,.mb-contacts dl{grid-template-columns:1fr 1fr}.mb-snapshot dl>div,.mb-remittance dl>div,.mb-contacts dl>div{border:0;border-top:1px solid var(--mb-border);padding:10px 0}.mb-snapshot dl>div:nth-child(-n+2),.mb-remittance dl>div:nth-child(-n+2),.mb-contacts dl>div:nth-child(-n+2){border-top:0}.mb-payment-list article{grid-template-columns:1fr}.mb-payment-list article>div:nth-child(2){text-align:left}}
@@ -2011,10 +2175,10 @@ var lifecycleSurfaceStyles = `
2011
2175
 
2012
2176
  // src/connected-bill-lifecycle.tsx
2013
2177
  import {
2014
- useCallback as useCallback2,
2178
+ useCallback as useCallback3,
2015
2179
  useEffect as useEffect4,
2016
2180
  useMemo as useMemo4,
2017
- useRef as useRef3,
2181
+ useRef as useRef4,
2018
2182
  useState as useState4
2019
2183
  } from "react";
2020
2184
  import {
@@ -2023,15 +2187,15 @@ import {
2023
2187
  createBillLifecycleClient
2024
2188
  } from "@mindbill/browser";
2025
2189
  import { createBillLifecycleClient as createBillLifecycleClient2 } from "@mindbill/browser";
2026
- import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
2190
+ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
2027
2191
  var DEFAULT_REFRESH_INTERVAL2 = 6e4;
2028
- function openPdf(blob, filename) {
2192
+ function downloadBlob(blob, filename, open = false) {
2029
2193
  const url = URL.createObjectURL(blob);
2030
2194
  const link = document.createElement("a");
2031
2195
  link.href = url;
2032
- link.target = "_blank";
2033
2196
  link.rel = "noopener noreferrer";
2034
2197
  link.download = filename;
2198
+ if (open) link.target = "_blank";
2035
2199
  link.click();
2036
2200
  window.setTimeout(() => URL.revokeObjectURL(url), 6e4);
2037
2201
  }
@@ -2045,17 +2209,12 @@ function useBillLifecycle({
2045
2209
  initialData = null,
2046
2210
  fetch: fetchOverride
2047
2211
  }) {
2048
- const billId = providedBillId;
2049
2212
  const [data, setData] = useState4(initialData);
2050
2213
  const [error, setError] = useState4(null);
2051
2214
  const [isLoading, setIsLoading] = useState4(enabled && !initialData);
2052
2215
  const [isRefreshing, setIsRefreshing] = useState4(false);
2053
2216
  const [isMutating, setIsMutating] = useState4(false);
2054
- const mounted = useRef3(true);
2055
- useEffect4(() => {
2056
- setData(initialData);
2057
- setError(null);
2058
- }, [initialData, providedBillId]);
2217
+ const mounted = useRef4(true);
2059
2218
  const client = useMemo4(() => createBillLifecycleClient({
2060
2219
  billId: providedBillId,
2061
2220
  sessionEndpoint,
@@ -2063,6 +2222,10 @@ function useBillLifecycle({
2063
2222
  apiBaseUrl,
2064
2223
  fetch: fetchOverride
2065
2224
  }), [apiBaseUrl, fetchOverride, getSession, providedBillId, sessionEndpoint]);
2225
+ useEffect4(() => {
2226
+ setData(initialData);
2227
+ setError(null);
2228
+ }, [initialData, providedBillId]);
2066
2229
  useEffect4(() => {
2067
2230
  mounted.current = true;
2068
2231
  return () => {
@@ -2070,7 +2233,7 @@ function useBillLifecycle({
2070
2233
  client.clearSession();
2071
2234
  };
2072
2235
  }, [client]);
2073
- const refresh = useCallback2(async () => {
2236
+ const refresh = useCallback3(async () => {
2074
2237
  if (!enabled) return;
2075
2238
  setIsRefreshing(true);
2076
2239
  try {
@@ -2079,8 +2242,7 @@ function useBillLifecycle({
2079
2242
  setData(next);
2080
2243
  setError(null);
2081
2244
  } catch (cause) {
2082
- if (!mounted.current) return;
2083
- setError(cause instanceof Error ? cause : new Error("Bill could not be loaded."));
2245
+ if (mounted.current) setError(cause instanceof Error ? cause : new Error("Bill could not be loaded."));
2084
2246
  } finally {
2085
2247
  if (mounted.current) {
2086
2248
  setIsLoading(false);
@@ -2099,7 +2261,7 @@ function useBillLifecycle({
2099
2261
  window.removeEventListener("focus", onFocus);
2100
2262
  };
2101
2263
  }, [enabled, refresh, refreshInterval]);
2102
- const mutate = useCallback2(async (task) => {
2264
+ const mutate = useCallback3(async (task) => {
2103
2265
  setIsMutating(true);
2104
2266
  setError(null);
2105
2267
  try {
@@ -2114,364 +2276,273 @@ function useBillLifecycle({
2114
2276
  if (mounted.current) setIsMutating(false);
2115
2277
  }
2116
2278
  }, []);
2117
- const searchClaimsAdministrators = useCallback2(
2118
- (query, claimNumber) => client.searchClaimsAdministrators(query, claimNumber),
2119
- [client]
2120
- );
2121
- const getDeliveryOptions = useCallback2(
2122
- () => client.getDeliveryOptions(),
2123
- [client]
2124
- );
2125
- const closeBill = useCallback2(
2126
- (input) => mutate(() => client.closeBill(input)),
2127
- [client, mutate]
2128
- );
2129
- const postPayment = useCallback2(
2130
- (input) => mutate(() => client.postPayment(input)),
2131
- [client, mutate]
2132
- );
2133
- const submitSecondReview = useCallback2(
2134
- (input) => mutate(() => client.submitSecondReview(input)),
2135
- [client, mutate]
2136
- );
2137
- const openAttachment = useCallback2(async (attachment) => {
2138
- openPdf(await client.getAttachment(attachment.id), attachment.filename);
2279
+ const openAttachment = useCallback3(async (attachment) => {
2280
+ downloadBlob(await client.getAttachment(attachment.id), attachment.filename, true);
2139
2281
  }, [client]);
2140
- const openEor = useCallback2(async (document2) => {
2141
- openPdf(await client.getEor(document2.id), document2.filename);
2282
+ const openEor = useCallback3(async (document2) => {
2283
+ downloadBlob(await client.getEor(document2.id), document2.filename, true);
2142
2284
  }, [client]);
2285
+ const downloadPacket = useCallback3(async () => {
2286
+ const packet = await client.getPacket();
2287
+ downloadBlob(packet, `mindbill-${data?.bill.billNumber ?? providedBillId}-submission-packet.pdf`);
2288
+ }, [client, data?.bill.billNumber, providedBillId]);
2143
2289
  return {
2144
- billId,
2290
+ billId: providedBillId,
2145
2291
  data,
2146
2292
  error,
2147
2293
  isLoading,
2148
2294
  isRefreshing,
2149
2295
  isMutating,
2150
2296
  refresh,
2151
- searchClaimsAdministrators,
2152
- getDeliveryOptions,
2297
+ searchClaimsAdministrators: (query, claimNumber) => client.searchClaimsAdministrators(query, claimNumber),
2298
+ getDeliveryOptions: () => client.getDeliveryOptions(),
2153
2299
  openAttachment,
2154
2300
  openEor,
2155
- closeBill,
2156
- postPayment,
2157
- submitSecondReview
2301
+ downloadPacket,
2302
+ closeBill: (input) => mutate(() => client.closeBill(input)),
2303
+ reopenBill: (input) => mutate(() => client.reopenBill(input)),
2304
+ postPayment: (input) => mutate(() => client.postPayment(input)),
2305
+ submitSecondReview: (input) => mutate(() => client.submitSecondReview(input))
2158
2306
  };
2159
2307
  }
2160
- function LifecycleDialog({
2161
- children,
2162
- title,
2163
- onClose
2164
- }) {
2165
- const dialog = useRef3(null);
2308
+ function LifecycleDialog({ children, title, onClose }) {
2309
+ const dialog = useRef4(null);
2166
2310
  useEffect4(() => {
2167
2311
  const previous = document.activeElement;
2168
2312
  dialog.current?.focus();
2169
- const onKeyDown = (event) => {
2170
- if (event.key === "Escape") onClose();
2171
- };
2313
+ const onKeyDown = (event) => event.key === "Escape" && onClose();
2172
2314
  document.addEventListener("keydown", onKeyDown);
2173
2315
  return () => {
2174
2316
  document.removeEventListener("keydown", onKeyDown);
2175
2317
  previous?.focus();
2176
2318
  };
2177
2319
  }, [onClose]);
2178
- return /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-dialog-backdrop", onMouseDown: (event) => {
2179
- if (event.currentTarget === event.target) onClose();
2180
- }, children: /* @__PURE__ */ jsxs5("div", { ref: dialog, className: "mb-lifecycle-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, tabIndex: -1, children: [
2181
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-dialog-close", "aria-label": "Close", onClick: onClose, children: "\xD7" }),
2320
+ return /* @__PURE__ */ jsx6("div", { className: "mb-lifecycle-dialog-backdrop", onMouseDown: (event) => event.currentTarget === event.target && onClose(), children: /* @__PURE__ */ jsxs6("div", { ref: dialog, className: "mb-lifecycle-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, tabIndex: -1, children: [
2321
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-dialog-close", "aria-label": "Close", onClick: onClose, children: "\xD7" }),
2182
2322
  children
2183
2323
  ] }) });
2184
2324
  }
2185
- function dateInputValue() {
2325
+ function today() {
2186
2326
  const now = /* @__PURE__ */ new Date();
2187
- const offset = now.getTimezoneOffset() * 6e4;
2188
- return new Date(now.getTime() - offset).toISOString().slice(0, 10);
2327
+ return new Date(now.getTime() - now.getTimezoneOffset() * 6e4).toISOString().slice(0, 10);
2189
2328
  }
2190
- function ConnectedBillLifecycle({
2191
- appearance,
2192
- className,
2193
- style,
2194
- loadingFallback,
2195
- errorFallback,
2196
- onChanged,
2197
- ...options
2198
- }) {
2329
+ function stateLabel(state) {
2330
+ return state.replace(/[._-]+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
2331
+ }
2332
+ function actionPanel(action) {
2333
+ if (action.id === "second_review") return "second_review";
2334
+ if (action.id === "post_payment") return "payment";
2335
+ if (action.id === "close") return "close";
2336
+ if (action.id === "reopen") return "reopen";
2337
+ return "";
2338
+ }
2339
+ function ConnectedBillLifecycle({ appearance, className, style, loadingFallback, errorFallback, onChanged, ...options }) {
2199
2340
  const lifecycle = useBillLifecycle(options);
2200
2341
  const { data } = lifecycle;
2342
+ const [tab, setTab] = useState4("details");
2201
2343
  const [panel, setPanel] = useState4("");
2202
2344
  const [notice, setNotice] = useState4("");
2203
- const [closeReason, setCloseReason] = useState4("");
2204
- const [payment, setPayment] = useState4({
2205
- amount: 0,
2206
- method: "check",
2207
- checkNumber: "",
2208
- depositDate: dateInputValue(),
2209
- note: ""
2210
- });
2211
- const [review, setReview] = useState4({
2212
- reason: "",
2213
- payerClaimControlNumber: "",
2214
- disputedAmount: void 0,
2215
- attachmentIds: [],
2216
- route: "ebill"
2217
- });
2218
- const lastData = useRef3(null);
2219
- const closePanel = useCallback2(() => setPanel(""), []);
2345
+ const [reason, setReason] = useState4("");
2346
+ const [payment, setPayment] = useState4({ amount: 0, method: "check", checkNumber: "", depositDate: today(), note: "" });
2347
+ const [review, setReview] = useState4({ reason: "", payerClaimControlNumber: "", disputedAmount: void 0, attachmentIds: [], route: "ebill" });
2348
+ const lastData = useRef4(null);
2220
2349
  useEffect4(() => {
2221
2350
  if (!data || data === lastData.current) return;
2222
2351
  lastData.current = data;
2223
2352
  onChanged?.(data);
2224
- setPayment((current) => ({
2225
- ...current,
2226
- amount: current.amount > 0 ? current.amount : data.bill.balanceDue
2227
- }));
2353
+ setPayment((current) => ({ ...current, amount: current.amount > 0 ? current.amount : data.bill.balanceDue }));
2228
2354
  setReview((current) => ({
2229
2355
  ...current,
2230
2356
  disputedAmount: current.disputedAmount ?? data.bill.balanceDue,
2231
- attachmentIds: current.attachmentIds.length ? current.attachmentIds.filter((id) => data.bill.attachments.some((doc) => doc.id === id)) : data.bill.attachments.map((doc) => doc.id)
2357
+ attachmentIds: current.attachmentIds.length ? current.attachmentIds.filter((id) => data.bill.attachments.some((document2) => document2.id === id)) : data.bill.attachments.map((document2) => document2.id)
2232
2358
  }));
2233
2359
  }, [data, onChanged]);
2234
- if (lifecycle.isLoading && !data) {
2235
- return /* @__PURE__ */ jsx5(Fragment3, { children: loadingFallback ?? /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-loading", children: "Loading billing\u2026" }) });
2236
- }
2360
+ if (lifecycle.isLoading && !data) return /* @__PURE__ */ jsx6(Fragment4, { children: loadingFallback ?? /* @__PURE__ */ jsx6("div", { className: "mb-lifecycle-loading", children: "Loading bill\u2026" }) });
2237
2361
  if (!data) {
2238
2362
  const error = lifecycle.error ?? new Error("Bill could not be loaded.");
2239
- return /* @__PURE__ */ jsx5(Fragment3, { children: errorFallback?.(error, lifecycle.refresh) ?? /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-error", role: "alert", children: [
2240
- /* @__PURE__ */ jsx5("strong", { children: "Billing is unavailable." }),
2241
- /* @__PURE__ */ jsx5("span", { children: error.message }),
2242
- /* @__PURE__ */ jsx5("button", { type: "button", onClick: () => void lifecycle.refresh(), children: "Try again" })
2363
+ return /* @__PURE__ */ jsx6(Fragment4, { children: errorFallback?.(error, lifecycle.refresh) ?? /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-error", role: "alert", children: [
2364
+ /* @__PURE__ */ jsx6("strong", { children: "Billing is unavailable." }),
2365
+ /* @__PURE__ */ jsx6("span", { children: error.message }),
2366
+ /* @__PURE__ */ jsx6("button", { type: "button", onClick: () => void lifecycle.refresh(), children: "Try again" })
2243
2367
  ] }) });
2244
2368
  }
2245
- const actionMap = new Map(data.lifecycle.actions.map((action) => [action.id, action]));
2246
- const has = (id) => actionMap.get(id);
2247
- const selectPanel = (next) => {
2248
- setNotice("");
2249
- setPanel((current) => current === next ? "" : next);
2250
- };
2251
2369
  const complete = async (message, task) => {
2252
2370
  setNotice("");
2253
2371
  try {
2254
2372
  await task();
2255
2373
  setPanel("");
2374
+ setReason("");
2256
2375
  setNotice(message);
2257
2376
  } catch {
2258
2377
  }
2259
2378
  };
2260
- const actionButtons = data.lifecycle.actions.filter((action) => action.id !== "view_eor" && action.id !== "independent_bill_review").map((action) => ({
2261
- ...action,
2262
- onClick: () => {
2263
- if (!action.enabled) return;
2264
- if (action.id === "second_review") selectPanel("second_review");
2265
- if (action.id === "post_payment") selectPanel("payment");
2266
- if (action.id === "close") selectPanel("close");
2267
- },
2268
- disabled: !action.enabled || lifecycle.isMutating
2269
- }));
2270
- return /* @__PURE__ */ jsxs5("section", { className: ["mb-connected-lifecycle", className].filter(Boolean).join(" "), style: mindBillAppearanceStyle(appearance, style), children: [
2271
- /* @__PURE__ */ jsx5("style", { children: CONNECTED_LIFECYCLE_STYLES }),
2272
- /* @__PURE__ */ jsx5("style", { children: CONNECTED_THEME_OVERRIDE_STYLES }),
2273
- /* @__PURE__ */ jsx5(
2274
- BillLifecycleProgress,
2275
- {
2276
- state: data.lifecycle.state,
2277
- nativeStatus: data.lifecycle.nativeStatus,
2278
- submittedAt: data.lifecycle.submittedAt ?? null,
2279
- agingDays: data.lifecycle.agingDays ?? null,
2280
- ...appearance ? { appearance } : {}
2281
- }
2282
- ),
2283
- /* @__PURE__ */ jsx5(
2284
- BillSnapshotSummary,
2285
- {
2286
- bill: data.bill,
2287
- patient: data.patient,
2288
- injury: data.injury,
2289
- delivery: data.delivery,
2290
- ...appearance ? { appearance } : {}
2291
- }
2292
- ),
2293
- /* @__PURE__ */ jsx5(
2294
- BillStatusSummary,
2295
- {
2296
- status: data.lifecycle.state,
2297
- submittedAt: data.lifecycle.submittedAt ?? null,
2298
- agingDays: data.lifecycle.agingDays ?? null,
2299
- updatedAt: data.lifecycle.updatedAt ?? null,
2300
- totalCharge: data.bill.totalCharge,
2301
- totalPaid: data.bill.totalPaid,
2302
- balanceDue: data.bill.balanceDue,
2303
- actions: actionButtons,
2304
- ...appearance ? { appearance } : {}
2305
- }
2306
- ),
2307
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-toolbar", children: [
2308
- /* @__PURE__ */ jsxs5("div", { children: [
2309
- /* @__PURE__ */ jsxs5("strong", { children: [
2310
- "Bill #",
2311
- data.bill.billNumber
2379
+ const viewEor = data.lifecycle.actions.find((action) => action.id === "view_eor" && action.enabled);
2380
+ const supportedActions = /* @__PURE__ */ new Set(["second_review", "post_payment", "close", "reopen"]);
2381
+ const actions = data.lifecycle.actions.filter((action) => action.enabled && supportedActions.has(action.id));
2382
+ return /* @__PURE__ */ jsxs6("section", { className: ["mb-connected-lifecycle", className].filter(Boolean).join(" "), style: mindBillAppearanceStyle(appearance, style), children: [
2383
+ /* @__PURE__ */ jsx6("style", { children: CONNECTED_LIFECYCLE_STYLES }),
2384
+ /* @__PURE__ */ jsx6(BillLifecycleProgress, { state: data.lifecycle.state, nativeStatus: data.lifecycle.nativeStatus, submittedAt: data.lifecycle.submittedAt ?? null, agingDays: data.lifecycle.agingDays ?? null, ...appearance ? { appearance } : {} }),
2385
+ /* @__PURE__ */ jsxs6("header", { className: "mb-lifecycle-head", children: [
2386
+ /* @__PURE__ */ jsxs6("div", { children: [
2387
+ /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-title", children: [
2388
+ /* @__PURE__ */ jsxs6("h2", { children: [
2389
+ "Bill #",
2390
+ data.bill.billNumber
2391
+ ] }),
2392
+ /* @__PURE__ */ jsx6("span", { children: stateLabel(data.lifecycle.nativeStatus || data.lifecycle.state) })
2312
2393
  ] }),
2313
- /* @__PURE__ */ jsx5("span", { children: lifecycle.isRefreshing ? "Refreshing\u2026" : "Status and actions update automatically." })
2394
+ /* @__PURE__ */ jsxs6("p", { children: [
2395
+ "Claim ",
2396
+ data.injury.claimNumber || "\u2014",
2397
+ lifecycle.isRefreshing ? " \xB7 Refreshing\u2026" : ""
2398
+ ] })
2314
2399
  ] }),
2315
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-toolbar-actions", children: [
2316
- has("view_eor") ? /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => document.getElementById(`mb-eors-${data.bill.id}`)?.scrollIntoView({ behavior: "smooth", block: "center" }), children: "View EOR" }) : null,
2317
- has("close") ? /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button quiet", onClick: () => selectPanel("close"), children: "Close bill" }) : null
2400
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating, onClick: () => void lifecycle.downloadPacket().catch(() => void 0), children: "Download packet" })
2401
+ ] }),
2402
+ /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-tabs", role: "tablist", "aria-label": "Bill view", children: [
2403
+ /* @__PURE__ */ jsx6("button", { type: "button", role: "tab", "aria-selected": tab === "details", onClick: () => setTab("details"), children: "Bill details" }),
2404
+ /* @__PURE__ */ jsxs6("button", { type: "button", role: "tab", "aria-selected": tab === "history", onClick: () => setTab("history"), children: [
2405
+ "Bill history ",
2406
+ /* @__PURE__ */ jsx6("span", { children: data.activity.length })
2318
2407
  ] })
2319
2408
  ] }),
2320
- data.eors.length ? /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-card", id: `mb-eors-${data.bill.id}`, children: [
2321
- /* @__PURE__ */ jsxs5("header", { children: [
2322
- /* @__PURE__ */ jsxs5("div", { children: [
2323
- /* @__PURE__ */ jsx5("h3", { children: "Explanation of Review" }),
2324
- /* @__PURE__ */ jsx5("p", { children: "Review the payer response and original PDF before posting payment." })
2409
+ tab === "details" ? /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-tabpanel", role: "tabpanel", children: [
2410
+ /* @__PURE__ */ jsx6(BillReadOnlyForm, { data, onOpenAttachment: lifecycle.openAttachment, ...appearance ? { appearance } : {} }),
2411
+ data.eors.length ? /* @__PURE__ */ jsxs6("section", { className: "mb-lifecycle-card", id: `mb-eors-${data.bill.id}`, children: [
2412
+ /* @__PURE__ */ jsxs6("header", { children: [
2413
+ /* @__PURE__ */ jsxs6("div", { children: [
2414
+ /* @__PURE__ */ jsx6("h3", { children: "Explanation of Review" }),
2415
+ /* @__PURE__ */ jsx6("p", { children: "The payer response associated with this immutable submission." })
2416
+ ] }),
2417
+ /* @__PURE__ */ jsx6("span", { children: data.eors.length })
2325
2418
  ] }),
2326
- /* @__PURE__ */ jsxs5("span", { children: [
2327
- data.eors.length,
2328
- " PDF",
2329
- data.eors.length === 1 ? "" : "s"
2419
+ /* @__PURE__ */ jsx6("ul", { className: "mb-lifecycle-documents", children: data.eors.map((eor) => /* @__PURE__ */ jsxs6("li", { children: [
2420
+ /* @__PURE__ */ jsxs6("div", { children: [
2421
+ /* @__PURE__ */ jsx6("strong", { children: eor.filename }),
2422
+ /* @__PURE__ */ jsx6("span", { children: eor.description || `Received ${new Date(eor.addedAt).toLocaleDateString()}` })
2423
+ ] }),
2424
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => void lifecycle.openEor(eor).catch(() => void 0), children: "View EOR" })
2425
+ ] }, eor.id)) })
2426
+ ] }) : null,
2427
+ viewEor || actions.length ? /* @__PURE__ */ jsxs6("section", { className: "mb-lifecycle-actions-sheet", children: [
2428
+ /* @__PURE__ */ jsxs6("div", { children: [
2429
+ /* @__PURE__ */ jsx6("h3", { children: data.lifecycle.state.includes("closed") ? "This bill is closed" : data.lifecycle.state.includes("denied") || data.lifecycle.state.includes("rejected") ? "This bill needs attention" : "Available actions" }),
2430
+ /* @__PURE__ */ jsx6("p", { children: "Actions are determined by the current bill status." })
2431
+ ] }),
2432
+ /* @__PURE__ */ jsxs6("div", { children: [
2433
+ viewEor ? /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => document.getElementById(`mb-eors-${data.bill.id}`)?.scrollIntoView({ behavior: "smooth" }), children: viewEor.label }) : null,
2434
+ actions.map((action) => /* @__PURE__ */ jsx6("button", { type: "button", className: action.primary ? "mb-lifecycle-button primary" : "mb-lifecycle-button secondary", onClick: () => {
2435
+ const next = actionPanel(action);
2436
+ if (next) setPanel(next);
2437
+ }, children: action.label }, action.id))
2330
2438
  ] })
2439
+ ] }) : null
2440
+ ] }) : /* @__PURE__ */ jsx6("div", { className: "mb-lifecycle-tabpanel", role: "tabpanel", children: /* @__PURE__ */ jsx6(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }) }),
2441
+ panel === "second_review" ? /* @__PURE__ */ jsx6(LifecycleDialog, { title: "Submit Second Review", onClose: () => setPanel(""), children: /* @__PURE__ */ jsxs6("section", { className: "mb-lifecycle-panel", children: [
2442
+ /* @__PURE__ */ jsxs6("div", { children: [
2443
+ /* @__PURE__ */ jsx6("h3", { children: "Submit Second Review" }),
2444
+ /* @__PURE__ */ jsx6("p", { children: "Explain the dispute and include the payer control number and supporting documents." })
2331
2445
  ] }),
2332
- /* @__PURE__ */ jsx5("ul", { className: "mb-lifecycle-documents", children: data.eors.map((eor) => /* @__PURE__ */ jsxs5("li", { children: [
2333
- /* @__PURE__ */ jsxs5("div", { children: [
2334
- /* @__PURE__ */ jsx5("strong", { children: eor.filename }),
2335
- /* @__PURE__ */ jsx5("span", { children: eor.description || `Added ${new Date(eor.addedAt).toLocaleDateString()}` })
2446
+ /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-fields two", children: [
2447
+ /* @__PURE__ */ jsxs6("label", { className: "full", children: [
2448
+ /* @__PURE__ */ jsx6("span", { children: "Reason" }),
2449
+ /* @__PURE__ */ jsx6("textarea", { required: true, value: review.reason, onChange: (event) => setReview((current) => ({ ...current, reason: event.target.value })) })
2336
2450
  ] }),
2337
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => void lifecycle.openEor(eor).catch(() => void 0), children: "View PDF" })
2338
- ] }, eor.id)) })
2339
- ] }) : null,
2340
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-detail-grid", children: [
2341
- /* @__PURE__ */ jsx5(BillRemittanceCard, { remittance: data.remittance, ...appearance ? { appearance } : {} }),
2342
- /* @__PURE__ */ jsx5(BillPayerContactCard, { delivery: data.delivery, ...appearance ? { appearance } : {} }),
2343
- /* @__PURE__ */ jsx5(BillPaymentLedger, { payments: data.payments, ...appearance ? { appearance } : {} })
2344
- ] }),
2345
- /* @__PURE__ */ jsx5(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }),
2346
- has("independent_bill_review") ? /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-info", children: [
2347
- /* @__PURE__ */ jsx5("strong", { children: has("independent_bill_review")?.label }),
2348
- /* @__PURE__ */ jsx5("span", { children: has("independent_bill_review")?.reason })
2349
- ] }) : null,
2350
- panel === "second_review" ? /* @__PURE__ */ jsx5(LifecycleDialog, { title: "Submit Second Review", onClose: closePanel, children: /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-panel wide", children: [
2351
- /* @__PURE__ */ jsxs5("div", { children: [
2352
- /* @__PURE__ */ jsx5("h3", { children: "Submit Second Review" }),
2353
- /* @__PURE__ */ jsx5("p", { children: "State why payment is disputed, confirm the payer control number, and choose the supporting documents to send." })
2354
- ] }),
2355
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-fields two", children: [
2356
- /* @__PURE__ */ jsxs5("label", { children: [
2357
- /* @__PURE__ */ jsx5("span", { children: "Reason for Second Review" }),
2358
- /* @__PURE__ */ jsx5("textarea", { required: true, value: review.reason, onChange: (event) => setReview((current) => ({ ...current, reason: event.target.value })) })
2451
+ /* @__PURE__ */ jsxs6("label", { children: [
2452
+ /* @__PURE__ */ jsx6("span", { children: "Payer claim control number" }),
2453
+ /* @__PURE__ */ jsx6("input", { required: true, value: review.payerClaimControlNumber, onChange: (event) => setReview((current) => ({ ...current, payerClaimControlNumber: event.target.value })) })
2359
2454
  ] }),
2360
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-fields", children: [
2361
- /* @__PURE__ */ jsxs5("label", { children: [
2362
- /* @__PURE__ */ jsx5("span", { children: "Payer claim control number" }),
2363
- /* @__PURE__ */ jsx5("input", { required: true, value: review.payerClaimControlNumber, onChange: (event) => setReview((current) => ({ ...current, payerClaimControlNumber: event.target.value })) })
2364
- ] }),
2365
- /* @__PURE__ */ jsxs5("label", { children: [
2366
- /* @__PURE__ */ jsx5("span", { children: "Disputed amount" }),
2367
- /* @__PURE__ */ jsx5("input", { type: "number", min: "0.01", step: "0.01", value: review.disputedAmount ?? "", onChange: (event) => setReview((current) => ({ ...current, disputedAmount: event.target.value ? Number(event.target.value) : void 0 })) })
2368
- ] }),
2369
- /* @__PURE__ */ jsxs5("label", { children: [
2370
- /* @__PURE__ */ jsx5("span", { children: "Send via" }),
2371
- /* @__PURE__ */ jsxs5("select", { value: review.route, onChange: (event) => setReview((current) => ({ ...current, route: event.target.value })), children: [
2372
- /* @__PURE__ */ jsx5("option", { value: "ebill", children: "E-bill" }),
2373
- /* @__PURE__ */ jsx5("option", { value: "fax", children: "Fax" }),
2374
- /* @__PURE__ */ jsx5("option", { value: "mail", children: "Mail" }),
2375
- /* @__PURE__ */ jsx5("option", { value: "email", children: "Email" })
2376
- ] })
2455
+ /* @__PURE__ */ jsxs6("label", { children: [
2456
+ /* @__PURE__ */ jsx6("span", { children: "Disputed amount" }),
2457
+ /* @__PURE__ */ jsx6("input", { type: "number", min: "0.01", step: "0.01", value: review.disputedAmount ?? "", onChange: (event) => setReview((current) => ({ ...current, disputedAmount: event.target.value ? Number(event.target.value) : void 0 })) })
2458
+ ] }),
2459
+ /* @__PURE__ */ jsxs6("label", { children: [
2460
+ /* @__PURE__ */ jsx6("span", { children: "Send via" }),
2461
+ /* @__PURE__ */ jsxs6("select", { value: review.route, onChange: (event) => setReview((current) => ({ ...current, route: event.target.value })), children: [
2462
+ /* @__PURE__ */ jsx6("option", { value: "ebill", children: "E-bill" }),
2463
+ /* @__PURE__ */ jsx6("option", { value: "fax", children: "Fax" }),
2464
+ /* @__PURE__ */ jsx6("option", { value: "mail", children: "Mail" }),
2465
+ /* @__PURE__ */ jsx6("option", { value: "email", children: "Email" })
2377
2466
  ] })
2378
2467
  ] })
2379
2468
  ] }),
2380
- /* @__PURE__ */ jsxs5("fieldset", { className: "mb-lifecycle-packet", children: [
2381
- /* @__PURE__ */ jsx5("legend", { children: "Supporting packet" }),
2382
- data.bill.attachments.map((attachment) => /* @__PURE__ */ jsxs5("label", { children: [
2383
- /* @__PURE__ */ jsx5("input", { type: "checkbox", checked: review.attachmentIds.includes(attachment.id), onChange: (event) => setReview((current) => ({ ...current, attachmentIds: event.target.checked ? [...current.attachmentIds, attachment.id] : current.attachmentIds.filter((id) => id !== attachment.id) })) }),
2384
- /* @__PURE__ */ jsxs5("span", { children: [
2385
- /* @__PURE__ */ jsx5("strong", { children: attachment.filename }),
2386
- /* @__PURE__ */ jsx5("small", { children: attachment.description || attachment.documentType })
2469
+ /* @__PURE__ */ jsxs6("fieldset", { className: "mb-lifecycle-packet", children: [
2470
+ /* @__PURE__ */ jsx6("legend", { children: "Supporting packet" }),
2471
+ data.bill.attachments.map((attachment) => /* @__PURE__ */ jsxs6("label", { children: [
2472
+ /* @__PURE__ */ jsx6("input", { type: "checkbox", checked: review.attachmentIds.includes(attachment.id), onChange: (event) => setReview((current) => ({ ...current, attachmentIds: event.target.checked ? [...current.attachmentIds, attachment.id] : current.attachmentIds.filter((id) => id !== attachment.id) })) }),
2473
+ /* @__PURE__ */ jsxs6("span", { children: [
2474
+ /* @__PURE__ */ jsx6("strong", { children: attachment.filename }),
2475
+ /* @__PURE__ */ jsx6("small", { children: attachment.description || attachment.documentType })
2387
2476
  ] }),
2388
- /* @__PURE__ */ jsx5("button", { type: "button", onClick: () => void lifecycle.openAttachment(attachment).catch(() => void 0), children: "View" })
2477
+ /* @__PURE__ */ jsx6("button", { type: "button", onClick: () => void lifecycle.openAttachment(attachment).catch(() => void 0), children: "View" })
2389
2478
  ] }, attachment.id))
2390
2479
  ] }),
2391
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-panel-actions", children: [
2392
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2393
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || !review.reason.trim() || !review.payerClaimControlNumber.trim(), onClick: () => void complete("Second Review submitted.", () => lifecycle.submitSecondReview(review)), children: lifecycle.isMutating ? "Submitting\u2026" : "Submit Second Review" })
2480
+ /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-panel-actions", children: [
2481
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => setPanel(""), children: "Cancel" }),
2482
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || !review.reason.trim() || !review.payerClaimControlNumber.trim(), onClick: () => void complete("Second Review submitted.", () => lifecycle.submitSecondReview(review)), children: lifecycle.isMutating ? "Submitting\u2026" : "Submit Second Review" })
2394
2483
  ] })
2395
2484
  ] }) }) : null,
2396
- panel === "payment" ? /* @__PURE__ */ jsx5(LifecycleDialog, { title: "Post payment", onClose: closePanel, children: /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-panel", children: [
2397
- /* @__PURE__ */ jsxs5("div", { children: [
2398
- /* @__PURE__ */ jsx5("h3", { children: "Post payment" }),
2399
- /* @__PURE__ */ jsx5("p", { children: "Record funds shown on the EOR. The balance updates and the bill closes automatically when configured." })
2485
+ panel === "payment" ? /* @__PURE__ */ jsx6(LifecycleDialog, { title: "Post payment", onClose: () => setPanel(""), children: /* @__PURE__ */ jsxs6("section", { className: "mb-lifecycle-panel", children: [
2486
+ /* @__PURE__ */ jsxs6("div", { children: [
2487
+ /* @__PURE__ */ jsx6("h3", { children: "Post payment" }),
2488
+ /* @__PURE__ */ jsx6("p", { children: "Record funds shown on the payer response." })
2400
2489
  ] }),
2401
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-fields two", children: [
2402
- /* @__PURE__ */ jsxs5("label", { children: [
2403
- /* @__PURE__ */ jsx5("span", { children: "Amount" }),
2404
- /* @__PURE__ */ jsx5("input", { type: "number", min: "0.01", max: data.bill.balanceDue, step: "0.01", required: true, value: payment.amount || "", onChange: (event) => setPayment((current) => ({ ...current, amount: Number(event.target.value) })) })
2490
+ /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-fields two", children: [
2491
+ /* @__PURE__ */ jsxs6("label", { children: [
2492
+ /* @__PURE__ */ jsx6("span", { children: "Amount" }),
2493
+ /* @__PURE__ */ jsx6("input", { type: "number", min: "0.01", max: data.bill.balanceDue, step: "0.01", value: payment.amount || "", onChange: (event) => setPayment((current) => ({ ...current, amount: Number(event.target.value) })) })
2405
2494
  ] }),
2406
- /* @__PURE__ */ jsxs5("label", { children: [
2407
- /* @__PURE__ */ jsx5("span", { children: "Method" }),
2408
- /* @__PURE__ */ jsxs5("select", { value: payment.method, onChange: (event) => setPayment((current) => ({ ...current, method: event.target.value })), children: [
2409
- /* @__PURE__ */ jsx5("option", { value: "check", children: "Check" }),
2410
- /* @__PURE__ */ jsx5("option", { value: "eft", children: "EFT" })
2495
+ /* @__PURE__ */ jsxs6("label", { children: [
2496
+ /* @__PURE__ */ jsx6("span", { children: "Method" }),
2497
+ /* @__PURE__ */ jsxs6("select", { value: payment.method, onChange: (event) => setPayment((current) => ({ ...current, method: event.target.value })), children: [
2498
+ /* @__PURE__ */ jsx6("option", { value: "check", children: "Check" }),
2499
+ /* @__PURE__ */ jsx6("option", { value: "eft", children: "EFT" })
2411
2500
  ] })
2412
2501
  ] }),
2413
- /* @__PURE__ */ jsxs5("label", { children: [
2414
- /* @__PURE__ */ jsx5("span", { children: payment.method === "check" ? "Check number" : "EFT reference" }),
2415
- /* @__PURE__ */ jsx5("input", { value: payment.checkNumber, onChange: (event) => setPayment((current) => ({ ...current, checkNumber: event.target.value })) })
2502
+ /* @__PURE__ */ jsxs6("label", { children: [
2503
+ /* @__PURE__ */ jsx6("span", { children: payment.method === "check" ? "Check number" : "EFT reference" }),
2504
+ /* @__PURE__ */ jsx6("input", { value: payment.checkNumber, onChange: (event) => setPayment((current) => ({ ...current, checkNumber: event.target.value })) })
2416
2505
  ] }),
2417
- /* @__PURE__ */ jsxs5("label", { children: [
2418
- /* @__PURE__ */ jsx5("span", { children: "Deposit date" }),
2419
- /* @__PURE__ */ jsx5("input", { type: "date", required: true, value: payment.depositDate, onChange: (event) => setPayment((current) => ({ ...current, depositDate: event.target.value })) })
2506
+ /* @__PURE__ */ jsxs6("label", { children: [
2507
+ /* @__PURE__ */ jsx6("span", { children: "Deposit date" }),
2508
+ /* @__PURE__ */ jsx6("input", { required: true, value: payment.depositDate, placeholder: "MM/DD/YYYY", onChange: (event) => setPayment((current) => ({ ...current, depositDate: event.target.value })) })
2420
2509
  ] }),
2421
- /* @__PURE__ */ jsxs5("label", { className: "full", children: [
2422
- /* @__PURE__ */ jsxs5("span", { children: [
2423
- "Note ",
2424
- /* @__PURE__ */ jsx5("small", { children: "Optional" })
2425
- ] }),
2426
- /* @__PURE__ */ jsx5("input", { value: payment.note, onChange: (event) => setPayment((current) => ({ ...current, note: event.target.value })) })
2510
+ /* @__PURE__ */ jsxs6("label", { className: "full", children: [
2511
+ /* @__PURE__ */ jsx6("span", { children: "Note (optional)" }),
2512
+ /* @__PURE__ */ jsx6("input", { value: payment.note, onChange: (event) => setPayment((current) => ({ ...current, note: event.target.value })) })
2427
2513
  ] })
2428
2514
  ] }),
2429
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-panel-actions", children: [
2430
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2431
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || payment.amount <= 0 || payment.amount > data.bill.balanceDue || !payment.depositDate, onClick: () => void complete("Payment posted.", () => lifecycle.postPayment(payment)), children: lifecycle.isMutating ? "Posting\u2026" : "Post payment" })
2515
+ /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-panel-actions", children: [
2516
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => setPanel(""), children: "Cancel" }),
2517
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || payment.amount <= 0 || payment.amount > data.bill.balanceDue || !payment.depositDate, onClick: () => void complete("Payment posted.", () => lifecycle.postPayment(payment)), children: lifecycle.isMutating ? "Posting\u2026" : "Post payment" })
2432
2518
  ] })
2433
2519
  ] }) }) : null,
2434
- panel === "close" ? /* @__PURE__ */ jsx5(LifecycleDialog, { title: "Close bill", onClose: closePanel, children: /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-panel danger", children: [
2435
- /* @__PURE__ */ jsxs5("div", { children: [
2436
- /* @__PURE__ */ jsx5("h3", { children: "Close bill" }),
2437
- /* @__PURE__ */ jsx5("p", { children: "Closing removes this bill from active A/R. Any remaining balance will be written off and the original lifecycle is preserved." })
2520
+ panel === "close" || panel === "reopen" ? /* @__PURE__ */ jsx6(LifecycleDialog, { title: panel === "close" ? "Close bill" : "Reopen bill", onClose: () => setPanel(""), children: /* @__PURE__ */ jsxs6("section", { className: "mb-lifecycle-panel", children: [
2521
+ /* @__PURE__ */ jsxs6("div", { children: [
2522
+ /* @__PURE__ */ jsx6("h3", { children: panel === "close" ? "Close bill" : "Reopen bill" }),
2523
+ /* @__PURE__ */ jsx6("p", { children: panel === "close" ? "The immutable submission and history remain available." : "Return this bill to active follow-up without changing the submitted snapshot." })
2438
2524
  ] }),
2439
- /* @__PURE__ */ jsxs5("label", { children: [
2440
- /* @__PURE__ */ jsx5("span", { children: "Reason for closing" }),
2441
- /* @__PURE__ */ jsx5("textarea", { required: true, value: closeReason, onChange: (event) => setCloseReason(event.target.value) })
2525
+ /* @__PURE__ */ jsxs6("label", { children: [
2526
+ /* @__PURE__ */ jsx6("span", { children: "Reason" }),
2527
+ /* @__PURE__ */ jsx6("textarea", { required: true, value: reason, onChange: (event) => setReason(event.target.value) })
2442
2528
  ] }),
2443
- /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-panel-actions", children: [
2444
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2445
- /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button danger", disabled: lifecycle.isMutating || !closeReason.trim(), onClick: () => void complete("Bill closed.", () => lifecycle.closeBill({ reason: closeReason })), children: lifecycle.isMutating ? "Closing\u2026" : "Close bill" })
2529
+ /* @__PURE__ */ jsxs6("div", { className: "mb-lifecycle-panel-actions", children: [
2530
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => setPanel(""), children: "Cancel" }),
2531
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || !reason.trim(), onClick: () => void complete(panel === "close" ? "Bill closed." : "Bill reopened.", () => panel === "close" ? lifecycle.closeBill({ reason }) : lifecycle.reopenBill({ reason })), children: lifecycle.isMutating ? "Saving\u2026" : panel === "close" ? "Close bill" : "Reopen bill" })
2446
2532
  ] })
2447
2533
  ] }) }) : null,
2448
- notice ? /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-message success", role: "status", children: notice }) : null,
2449
- lifecycle.error ? /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-message error", role: "alert", children: lifecycle.error.message }) : null
2534
+ notice ? /* @__PURE__ */ jsx6("div", { className: "mb-lifecycle-message success", role: "status", children: notice }) : null,
2535
+ lifecycle.error ? /* @__PURE__ */ jsx6("div", { className: "mb-lifecycle-message error", role: "alert", children: lifecycle.error.message }) : null
2450
2536
  ] });
2451
2537
  }
2452
2538
  var CONNECTED_LIFECYCLE_STYLES = `
2453
- .mb-connected-lifecycle{--mb-accent:#238dbd;--mb-text:#203743;--mb-muted:#657982;--mb-border:#dbe6ea;--mb-soft:#f3f8fa;--mb-surface:#fff;display:grid;gap:14px;color:var(--mb-text);font:14px/1.45 var(--mb-font,Inter,ui-sans-serif,system-ui,sans-serif)}.mb-connected-lifecycle *{box-sizing:border-box}.mb-lifecycle-detail-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.mb-lifecycle-detail-grid>*:last-child:nth-child(odd){grid-column:1/-1}.mb-lifecycle-toolbar{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 14px;border:1px solid var(--mb-border);border-radius:10px;background:var(--mb-surface)}.mb-lifecycle-toolbar>div:first-child{display:grid;gap:2px}.mb-lifecycle-toolbar span,.mb-lifecycle-card p,.mb-lifecycle-panel p,.mb-lifecycle-info span{color:var(--mb-muted)}.mb-lifecycle-toolbar-actions,.mb-lifecycle-panel-actions{display:flex;justify-content:flex-end;gap:8px}.mb-lifecycle-button{min-height:38px;border:1px solid var(--mb-border);border-radius:8px;background:#fff;color:var(--mb-text);cursor:pointer;font:inherit;font-weight:750;padding:8px 13px}.mb-lifecycle-button.primary{border-color:var(--mb-accent);background:var(--mb-accent);color:#fff}.mb-lifecycle-button.quiet{border-color:transparent;background:transparent;color:var(--mb-muted)}.mb-lifecycle-button.danger{border-color:#b63d35;background:#b63d35;color:#fff}.mb-lifecycle-button:disabled{cursor:not-allowed;opacity:.5}.mb-lifecycle-card,.mb-lifecycle-panel{padding:18px;border:1px solid var(--mb-border);border-radius:12px;background:var(--mb-surface)}.mb-lifecycle-card header{display:flex;align-items:start;justify-content:space-between;gap:16px}.mb-lifecycle-card h3,.mb-lifecycle-panel h3{margin:0;font-size:18px}.mb-lifecycle-card p,.mb-lifecycle-panel p{margin:3px 0 0}.mb-lifecycle-card header>span{padding:5px 8px;border-radius:999px;background:var(--mb-soft);color:var(--mb-muted);font-size:11px;font-weight:800;text-transform:uppercase}.mb-lifecycle-documents{list-style:none;margin:12px 0 0;padding:0}.mb-lifecycle-documents li{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:11px 0;border-top:1px solid var(--mb-border)}.mb-lifecycle-documents li>div{display:grid}.mb-lifecycle-documents span{color:var(--mb-muted);font-size:12px}.mb-lifecycle-info{display:grid;gap:3px;padding:13px 15px;border:1px solid #cddfe5;border-radius:10px;background:var(--mb-soft)}.mb-lifecycle-dialog-backdrop{position:fixed;z-index:2147483000;inset:0;display:grid;place-items:center;padding:20px;background:rgba(18,35,43,.56);backdrop-filter:blur(3px)}.mb-lifecycle-dialog{position:relative;width:min(760px,100%);max-height:calc(100vh - 40px);overflow:auto;outline:0}.mb-lifecycle-dialog-close{position:absolute;z-index:1;top:12px;right:12px;width:34px;height:34px;border:1px solid var(--mb-border);border-radius:8px;background:var(--mb-surface);color:var(--mb-text);cursor:pointer;font:22px/1 inherit}.mb-lifecycle-panel{display:grid;gap:16px;padding-top:24px;box-shadow:0 24px 70px rgba(18,35,43,.22)}.mb-lifecycle-panel.danger{border-color:#ecc5c2}.mb-lifecycle-panel label{display:grid;gap:6px;font-size:12px;font-weight:750}.mb-lifecycle-panel label small{color:var(--mb-muted);font-size:inherit;font-weight:500}.mb-lifecycle-panel input,.mb-lifecycle-panel select,.mb-lifecycle-panel textarea,.mb-lifecycle-upload input,.mb-lifecycle-upload select{width:100%;min-height:42px;border:1px solid var(--mb-border);border-radius:8px;background:#fff;color:var(--mb-text);font:inherit;padding:9px 11px}.mb-lifecycle-panel textarea{min-height:100px;resize:vertical}.mb-lifecycle-fields{display:grid;gap:12px}.mb-lifecycle-fields.two{grid-template-columns:repeat(2,minmax(0,1fr))}.mb-lifecycle-fields .full{grid-column:1/-1}.mb-lifecycle-packet{display:grid;gap:0;margin:0;padding:0;border:0}.mb-lifecycle-packet legend{margin-bottom:7px;font-size:12px;font-weight:800}.mb-lifecycle-packet>label{display:grid;grid-template-columns:auto 1fr auto auto;align-items:center;gap:10px;padding:10px 2px;border-top:1px solid var(--mb-border)}.mb-lifecycle-packet>label>input{width:16px;min-height:16px}.mb-lifecycle-packet>label>span{display:grid}.mb-lifecycle-packet button{border:0;background:transparent;color:var(--mb-accent);cursor:pointer;font:inherit}.mb-lifecycle-upload{display:grid;grid-template-columns:220px 1fr auto;align-items:end;gap:10px;padding:12px;border-radius:9px;background:var(--mb-soft)}.mb-lifecycle-message,.mb-lifecycle-error,.mb-lifecycle-loading{padding:12px 14px;border-radius:9px}.mb-lifecycle-message.success{background:#edf9f2;color:#217449}.mb-lifecycle-message.error,.mb-lifecycle-error{background:#fff0ef;color:#9d3029}.mb-lifecycle-error{display:flex;align-items:center;gap:12px}.mb-lifecycle-error span{flex:1}.mb-lifecycle-error button{border:1px solid currentColor;border-radius:7px;background:transparent;color:inherit;padding:7px 10px}@media(max-width:760px){.mb-lifecycle-detail-grid{grid-template-columns:1fr}.mb-lifecycle-detail-grid>*:last-child:nth-child(odd){grid-column:auto}.mb-lifecycle-toolbar,.mb-lifecycle-card header{align-items:stretch;flex-direction:column}.mb-lifecycle-toolbar-actions,.mb-lifecycle-panel-actions{justify-content:start}.mb-lifecycle-fields.two,.mb-lifecycle-upload{grid-template-columns:1fr}.mb-lifecycle-documents li{align-items:start}.mb-lifecycle-packet>label{grid-template-columns:auto 1fr auto}.mb-lifecycle-dialog-backdrop{align-items:end;padding:0}.mb-lifecycle-dialog{max-height:92vh}.mb-lifecycle-dialog .mb-lifecycle-panel{border-radius:18px 18px 0 0}.mb-lifecycle-packet>label>button:last-child{grid-column:3}}
2454
- `;
2455
- var CONNECTED_THEME_OVERRIDE_STYLES = `
2456
- .mb-connected-lifecycle{color:var(--mb-text);font-family:var(--mb-font,Inter,ui-sans-serif,system-ui,sans-serif)}
2457
- .mb-lifecycle-toolbar,.mb-lifecycle-card,.mb-lifecycle-panel{border-color:var(--mb-border);border-radius:var(--mb-radius);background:var(--mb-surface)}
2458
- .mb-lifecycle-panel{box-shadow:var(--mb-shadow)}
2459
- .mb-lifecycle-toolbar span,.mb-lifecycle-card p,.mb-lifecycle-panel p,.mb-lifecycle-info span{color:var(--mb-muted)}
2460
- .mb-lifecycle-button{border-color:var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text)}
2461
- .mb-lifecycle-button.primary{border-color:var(--mb-accent);background:var(--mb-accent);color:var(--mb-accent-contrast)}
2462
- .mb-lifecycle-button.primary:hover{filter:brightness(.96)}
2463
- .mb-lifecycle-button.danger{border-color:var(--mb-danger);background:var(--mb-danger);color:white}
2464
- .mb-lifecycle-card header>span,.mb-lifecycle-info,.mb-lifecycle-upload{background:var(--mb-soft)}
2465
- .mb-lifecycle-info,.mb-lifecycle-panel input,.mb-lifecycle-panel select,.mb-lifecycle-panel textarea,.mb-lifecycle-upload input,.mb-lifecycle-upload select{border-color:var(--mb-border);border-radius:var(--mb-control-radius)}
2466
- .mb-lifecycle-panel input,.mb-lifecycle-panel select,.mb-lifecycle-panel textarea,.mb-lifecycle-upload input,.mb-lifecycle-upload select{background:var(--mb-input);color:var(--mb-text)}
2467
- .mb-lifecycle-message,.mb-lifecycle-error,.mb-lifecycle-loading,.mb-lifecycle-upload{border-radius:var(--mb-control-radius)}
2468
- .mb-lifecycle-message.success{background:color-mix(in srgb,var(--mb-success) 10%,white);color:var(--mb-success)}
2469
- .mb-lifecycle-message.error,.mb-lifecycle-error{background:color-mix(in srgb,var(--mb-danger) 10%,white);color:var(--mb-danger)}
2539
+ .mb-connected-lifecycle{--mb-accent:#176c70;--mb-text:#17282d;--mb-muted:#607176;--mb-border:#d7e0df;--mb-soft:#f4f7f6;--mb-surface:#fff;display:grid;gap:18px;color:var(--mb-text);font:14px/1.45 var(--mb-font,Inter,ui-sans-serif,system-ui,sans-serif)}.mb-connected-lifecycle *{box-sizing:border-box}.mb-lifecycle-head{display:flex;align-items:center;justify-content:space-between;gap:20px}.mb-lifecycle-title{display:flex;align-items:center;flex-wrap:wrap;gap:10px}.mb-lifecycle-title h2{margin:0;font-size:1.7rem}.mb-lifecycle-title span{border-radius:999px;background:var(--mb-soft);padding:5px 10px;font-weight:750}.mb-lifecycle-head p{margin:3px 0 0;color:var(--mb-muted)}.mb-lifecycle-tabs{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--mb-border);border-radius:12px;background:var(--mb-surface);padding:6px}.mb-lifecycle-tabs button{min-height:46px;border:0;border-radius:8px;background:transparent;color:var(--mb-muted);font:inherit;font-size:1rem;font-weight:750;cursor:pointer}.mb-lifecycle-tabs button[aria-selected=true]{background:var(--mb-accent);color:white}.mb-lifecycle-tabs span{display:inline-grid;place-items:center;min-width:24px;height:24px;margin-left:6px;border-radius:999px;background:rgba(127,127,127,.14);font-size:.8rem}.mb-lifecycle-tabpanel{display:grid;gap:18px}.mb-lifecycle-button{min-height:40px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-input,#fff);color:var(--mb-text);cursor:pointer;font:inherit;font-weight:750;padding:9px 14px}.mb-lifecycle-button.primary{border-color:var(--mb-accent);background:var(--mb-accent);color:var(--mb-accent-contrast,#fff)}.mb-lifecycle-button:disabled{cursor:not-allowed;opacity:.5}.mb-lifecycle-card,.mb-lifecycle-actions-sheet,.mb-lifecycle-panel{padding:20px;border:1px solid var(--mb-border);border-radius:var(--mb-radius,14px);background:var(--mb-surface)}.mb-lifecycle-card header,.mb-lifecycle-actions-sheet{display:flex;align-items:center;justify-content:space-between;gap:20px}.mb-lifecycle-card h3,.mb-lifecycle-actions-sheet h3,.mb-lifecycle-panel h3{margin:0;font-size:1.08rem}.mb-lifecycle-card p,.mb-lifecycle-actions-sheet p,.mb-lifecycle-panel p{margin:3px 0 0;color:var(--mb-muted)}.mb-lifecycle-card header>span{display:grid;place-items:center;min-width:28px;height:28px;border-radius:999px;background:var(--mb-soft);font-weight:750}.mb-lifecycle-actions-sheet>div:last-child{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}.mb-lifecycle-documents{list-style:none;margin:14px 0 0;padding:0}.mb-lifecycle-documents li{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:12px 0;border-top:1px solid var(--mb-border)}.mb-lifecycle-documents li>div{display:grid;gap:3px;min-width:0}.mb-lifecycle-documents li span{color:var(--mb-muted);font-size:.85rem}.mb-lifecycle-dialog-backdrop{position:fixed;z-index:2147483000;inset:0;display:grid;place-items:center;padding:20px;background:rgba(18,35,43,.56);backdrop-filter:blur(3px)}.mb-lifecycle-dialog{position:relative;width:min(760px,100%);max-height:calc(100vh - 40px);overflow:auto;outline:0}.mb-lifecycle-dialog-close{position:absolute;z-index:1;top:12px;right:12px;width:34px;height:34px;border:1px solid var(--mb-border);border-radius:8px;background:var(--mb-surface);color:var(--mb-text);cursor:pointer;font:22px/1 inherit}.mb-lifecycle-panel{display:grid;gap:17px;padding-top:24px;box-shadow:0 24px 70px rgba(18,35,43,.22)}.mb-lifecycle-panel label{display:grid;gap:6px;font-size:.85rem;font-weight:750}.mb-lifecycle-panel label small{color:var(--mb-muted);font-weight:500}.mb-lifecycle-panel input,.mb-lifecycle-panel select,.mb-lifecycle-panel textarea{width:100%;min-height:44px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-input,#fff);color:var(--mb-text);font:inherit;padding:10px 12px}.mb-lifecycle-panel textarea{min-height:100px;resize:vertical}.mb-lifecycle-fields{display:grid;gap:13px}.mb-lifecycle-fields.two{grid-template-columns:repeat(2,minmax(0,1fr))}.mb-lifecycle-fields .full{grid-column:1/-1}.mb-lifecycle-panel-actions{display:flex;justify-content:flex-end;gap:8px}.mb-lifecycle-packet{display:grid;gap:0;margin:0;padding:0;border:0}.mb-lifecycle-packet legend{margin-bottom:7px;font-size:.85rem;font-weight:800}.mb-lifecycle-packet>label{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:10px;padding:10px 2px;border-top:1px solid var(--mb-border)}.mb-lifecycle-packet>label>input{width:16px;min-height:16px}.mb-lifecycle-packet>label>span{display:grid}.mb-lifecycle-packet button{border:0;background:transparent;color:var(--mb-accent);cursor:pointer;font:inherit}.mb-lifecycle-message,.mb-lifecycle-error,.mb-lifecycle-loading{padding:12px 14px;border-radius:9px}.mb-lifecycle-message.success{background:#edf9f2;color:#217449}.mb-lifecycle-message.error,.mb-lifecycle-error{background:#fff0ef;color:#9d3029}.mb-lifecycle-error{display:flex;align-items:center;gap:12px}.mb-lifecycle-error span{flex:1}.mb-lifecycle-error button{border:1px solid currentColor;border-radius:7px;background:transparent;color:inherit;padding:7px 10px}
2540
+ @media(max-width:700px){.mb-lifecycle-head,.mb-lifecycle-actions-sheet,.mb-lifecycle-card header{align-items:stretch;flex-direction:column}.mb-lifecycle-head>.mb-lifecycle-button{width:100%}.mb-lifecycle-actions-sheet>div:last-child{justify-content:stretch}.mb-lifecycle-actions-sheet .mb-lifecycle-button{width:100%}.mb-lifecycle-fields.two{grid-template-columns:1fr}.mb-lifecycle-fields .full{grid-column:auto}.mb-lifecycle-dialog-backdrop{align-items:end;padding:0}.mb-lifecycle-dialog{max-height:92vh}.mb-lifecycle-dialog .mb-lifecycle-panel{border-radius:18px 18px 0 0}.mb-lifecycle-tabs button{font-size:.9rem}.mb-lifecycle-title h2{font-size:1.4rem}}
2470
2541
  `;
2471
2542
 
2472
2543
  // src/index.tsx
2473
2544
  function widget(tagName, props) {
2474
- const ref = useRef4(null);
2545
+ const ref = useRef5(null);
2475
2546
  const { onMindBill, onMindBillError } = props;
2476
2547
  useEffect5(() => {
2477
2548
  const element = ref.current;
@@ -2517,6 +2588,7 @@ export {
2517
2588
  BillLifecycleProgress,
2518
2589
  BillPayerContactCard,
2519
2590
  BillPaymentLedger,
2591
+ BillReadOnlyForm,
2520
2592
  BillRemittanceCard,
2521
2593
  BillReviewForm,
2522
2594
  BillSnapshotSummary,
@@ -2526,14 +2598,18 @@ export {
2526
2598
  ConnectedBillStatus,
2527
2599
  MindBillBillReview,
2528
2600
  MindBillBillTimeline,
2601
+ applyBillSubmissionEvaluationModifiers,
2529
2602
  billActivityEventLabel,
2530
2603
  billLifecycleStage,
2531
2604
  buildBillReviewSaveInput,
2532
2605
  createBillLifecycleClient2 as createBillLifecycleClient,
2533
2606
  createBillStatusClient,
2607
+ ensureTrailingBillSubmissionLine,
2534
2608
  ensureTrailingProcedureLine,
2609
+ formatBillSubmissionDate,
2535
2610
  mindBillAppearanceStyle,
2536
2611
  mindBillThemePresets,
2612
+ parseBillSubmissionDate,
2537
2613
  resolveMindBillAppearance,
2538
2614
  useBillLifecycle,
2539
2615
  useBillStatus,