@mindbill/react 0.17.0 → 0.20.0

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 useEffect4, 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 = {
@@ -258,8 +258,11 @@ function Field({
258
258
  return /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
259
259
  /* @__PURE__ */ jsxs("span", { children: [
260
260
  label,
261
- " ",
262
- optional ? /* @__PURE__ */ jsx("small", { children: "Optional" }) : null
261
+ required ? /* @__PURE__ */ jsx("span", { className: "mb-native-required", "aria-hidden": "true", children: " *" }) : null,
262
+ optional ? /* @__PURE__ */ jsxs(Fragment, { children: [
263
+ " ",
264
+ /* @__PURE__ */ jsx("small", { children: "Optional" })
265
+ ] }) : null
263
266
  ] }),
264
267
  /* @__PURE__ */ jsx(
265
268
  "input",
@@ -314,7 +317,10 @@ function Combobox({ label, value, options, onChange, placeholder, required, disa
314
317
  };
315
318
  return /* @__PURE__ */ jsxs("div", { className: "mb-native-combo", ref: root, children: [
316
319
  /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
317
- /* @__PURE__ */ jsx("span", { children: label }),
320
+ /* @__PURE__ */ jsxs("span", { children: [
321
+ label,
322
+ required ? /* @__PURE__ */ jsx("span", { className: "mb-native-required", "aria-hidden": "true", children: " *" }) : null
323
+ ] }),
318
324
  /* @__PURE__ */ jsx(
319
325
  "input",
320
326
  {
@@ -394,6 +400,8 @@ function applyPreset(lines, preset) {
394
400
  }
395
401
  function BillReviewForm({
396
402
  data,
403
+ mode = "review",
404
+ initialSubmission = { route: "ebill" },
397
405
  onSave,
398
406
  onSubmit,
399
407
  onGetDeliveryOptions,
@@ -414,7 +422,7 @@ function BillReviewForm({
414
422
  const [payerResults, setPayerResults] = useState([]);
415
423
  const [payerBusy, setPayerBusy] = useState(false);
416
424
  const [deliveryOptions, setDeliveryOptions] = useState(null);
417
- const [submission, setSubmission] = useState({ route: "ebill" });
425
+ const [submission, setSubmission] = useState(initialSubmission);
418
426
  const [showSubmit, setShowSubmit] = useState(false);
419
427
  const [deliveryBusy, setDeliveryBusy] = useState(false);
420
428
  const [file, setFile] = useState(null);
@@ -422,7 +430,7 @@ function BillReviewForm({
422
430
  const [busy, setBusy] = useState("");
423
431
  const [error, setError] = useState("");
424
432
  const [notice, setNotice] = useState("");
425
- const editable = data.bill.status === "incomplete" && !disabled;
433
+ const editable = (mode === "submission" || data.bill.status === "incomplete") && !disabled;
426
434
  useEffect(() => {
427
435
  setDraft(toDraft(data));
428
436
  setPayerQuery(data.injury.claimsAdminName || "");
@@ -530,12 +538,19 @@ function BillReviewForm({
530
538
  }
531
539
  const handleSave = (event) => {
532
540
  event.preventDefault();
541
+ if (mode === "submission") {
542
+ if (!canSubmit) return;
543
+ void run("submit", () => onSubmit(buildBillReviewSaveInput(draft), initialSubmission));
544
+ return;
545
+ }
546
+ if (!onSave) return;
533
547
  void run("save", async () => {
534
548
  const updated = await onSave(buildBillReviewSaveInput(draft));
535
549
  if (updated) setDraft(toDraft(updated));
536
550
  });
537
551
  };
538
552
  const openSubmit = async () => {
553
+ if (!onGetDeliveryOptions) return;
539
554
  setDeliveryBusy(true);
540
555
  setError("");
541
556
  try {
@@ -588,51 +603,51 @@ function BillReviewForm({
588
603
  /* @__PURE__ */ jsx("style", { children: NATIVE_BILL_REVIEW_STYLES }),
589
604
  /* @__PURE__ */ jsx("style", { children: NATIVE_THEME_OVERRIDE_STYLES }),
590
605
  /* @__PURE__ */ jsx("style", { children: NATIVE_SUBMISSION_DIALOG_STYLES }),
591
- /* @__PURE__ */ jsxs("header", { className: "mb-native-heading", children: [
592
- /* @__PURE__ */ jsxs("div", { children: [
593
- /* @__PURE__ */ jsx("span", { className: "mb-native-eyebrow", children: "Billing review" }),
594
- /* @__PURE__ */ jsxs("h2", { children: [
595
- "Bill #",
596
- data.bill.billNumber
606
+ mode === "review" ? /* @__PURE__ */ jsxs(Fragment, { children: [
607
+ /* @__PURE__ */ jsxs("header", { className: "mb-native-heading", children: [
608
+ /* @__PURE__ */ jsxs("div", { children: [
609
+ /* @__PURE__ */ jsx("span", { className: "mb-native-eyebrow", children: "Billing review" }),
610
+ /* @__PURE__ */ jsxs("h2", { children: [
611
+ "Bill #",
612
+ data.bill.billNumber
613
+ ] }),
614
+ /* @__PURE__ */ jsx("p", { children: "Review the prefilled claim and payer packet, then submit." })
597
615
  ] }),
598
- /* @__PURE__ */ jsx("p", { children: "Review the prefilled claim and payer packet, then submit." })
599
- ] }),
600
- /* @__PURE__ */ jsxs("div", { className: "mb-native-total", children: [
601
- /* @__PURE__ */ jsx("span", { children: data.bill.status }),
602
- /* @__PURE__ */ jsx("strong", { children: money(data.bill.totalCharge) })
603
- ] })
604
- ] }),
605
- /* @__PURE__ */ jsxs("dl", { className: "mb-native-summary", children: [
606
- /* @__PURE__ */ jsxs("div", { children: [
607
- /* @__PURE__ */ jsx("dt", { children: "Patient" }),
608
- /* @__PURE__ */ jsx("dd", { children: [draft.patientFirstName, draft.patientMiddleName, draft.patientLastName].filter(Boolean).join(" ") || "\u2014" })
609
- ] }),
610
- /* @__PURE__ */ jsxs("div", { children: [
611
- /* @__PURE__ */ jsx("dt", { children: "Claim" }),
612
- /* @__PURE__ */ jsx("dd", { children: draft.claimNumber || "\u2014" })
613
- ] }),
614
- /* @__PURE__ */ jsxs("div", { children: [
615
- /* @__PURE__ */ jsx("dt", { children: "Employer" }),
616
- /* @__PURE__ */ jsx("dd", { children: draft.employer || "\u2014" })
616
+ /* @__PURE__ */ jsxs("div", { className: "mb-native-total", children: [
617
+ /* @__PURE__ */ jsx("span", { children: data.bill.status }),
618
+ /* @__PURE__ */ jsx("strong", { children: money(data.bill.totalCharge) })
619
+ ] })
617
620
  ] }),
618
- /* @__PURE__ */ jsxs("div", { children: [
619
- /* @__PURE__ */ jsx("dt", { children: "Date of injury" }),
620
- /* @__PURE__ */ jsx("dd", { children: draft.doi || "\u2014" })
621
- ] })
622
- ] }),
623
- /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
624
- /* @__PURE__ */ jsxs("div", { className: "mb-native-section-head", children: [
621
+ /* @__PURE__ */ jsxs("dl", { className: "mb-native-summary", children: [
625
622
  /* @__PURE__ */ jsxs("div", { children: [
626
- /* @__PURE__ */ jsx("h3", { children: "Claims administrator" }),
627
- /* @__PURE__ */ jsx("p", { children: "Select the carrier or administrator that should receive this bill." })
623
+ /* @__PURE__ */ jsx("dt", { children: "Patient" }),
624
+ /* @__PURE__ */ jsx("dd", { children: [draft.patientFirstName, draft.patientMiddleName, draft.patientLastName].filter(Boolean).join(" ") || "\u2014" })
628
625
  ] }),
629
- draft.claimsAdminId ? /* @__PURE__ */ jsx("span", { children: "Selected" }) : /* @__PURE__ */ jsx("span", { children: "Required" })
630
- ] }),
626
+ /* @__PURE__ */ jsxs("div", { children: [
627
+ /* @__PURE__ */ jsx("dt", { children: "Claim" }),
628
+ /* @__PURE__ */ jsx("dd", { children: draft.claimNumber || "\u2014" })
629
+ ] }),
630
+ /* @__PURE__ */ jsxs("div", { children: [
631
+ /* @__PURE__ */ jsx("dt", { children: "Employer" }),
632
+ /* @__PURE__ */ jsx("dd", { children: draft.employer || "\u2014" })
633
+ ] }),
634
+ /* @__PURE__ */ jsxs("div", { children: [
635
+ /* @__PURE__ */ jsx("dt", { children: "Date of injury" }),
636
+ /* @__PURE__ */ jsx("dd", { children: draft.doi || "\u2014" })
637
+ ] })
638
+ ] })
639
+ ] }) : null,
640
+ /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
641
+ /* @__PURE__ */ jsx("div", { className: "mb-native-section-head", children: /* @__PURE__ */ jsxs("div", { children: [
642
+ /* @__PURE__ */ jsx("h3", { children: "Claims administrator" }),
643
+ /* @__PURE__ */ jsx("p", { children: "Select the carrier or administrator that should receive this bill." })
644
+ ] }) }),
631
645
  /* @__PURE__ */ jsxs("div", { className: "mb-native-payer-picker", children: [
632
646
  /* @__PURE__ */ jsx(
633
647
  Combobox,
634
648
  {
635
649
  label: "Insurance company or claims administrator",
650
+ required: true,
636
651
  value: payerQuery,
637
652
  disabled: !editable,
638
653
  placeholder: "Search by payer or administrator name",
@@ -664,13 +679,10 @@ function BillReviewForm({
664
679
  ] })
665
680
  ] }),
666
681
  /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
667
- /* @__PURE__ */ jsxs("div", { className: "mb-native-section-head", children: [
668
- /* @__PURE__ */ jsxs("div", { children: [
669
- /* @__PURE__ */ jsx("h3", { children: "Patient and claim" }),
670
- /* @__PURE__ */ jsx("p", { children: "Prefilled from the case. Correct anything that should print differently on this bill." })
671
- ] }),
672
- /* @__PURE__ */ jsx("span", { children: "Editable" })
673
- ] }),
682
+ /* @__PURE__ */ jsx("div", { className: "mb-native-section-head", children: /* @__PURE__ */ jsxs("div", { children: [
683
+ /* @__PURE__ */ jsx("h3", { children: "Patient and claim" }),
684
+ /* @__PURE__ */ jsx("p", { children: "Review the case details that will print on this bill." })
685
+ ] }) }),
674
686
  /* @__PURE__ */ jsxs("div", { className: "mb-native-grid three", children: [
675
687
  /* @__PURE__ */ jsx(Field, { label: "Patient first name", required: true, disabled: !editable, value: draft.patientFirstName, onChange: (patientFirstName) => setDraft((current) => ({ ...current, patientFirstName })) }),
676
688
  /* @__PURE__ */ jsx(Field, { label: "Middle name", optional: true, disabled: !editable, value: draft.patientMiddleName, onChange: (patientMiddleName) => setDraft((current) => ({ ...current, patientMiddleName })) }),
@@ -700,56 +712,47 @@ function BillReviewForm({
700
712
  ] })
701
713
  ] }),
702
714
  /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
703
- /* @__PURE__ */ jsxs("div", { className: "mb-native-section-head", children: [
704
- /* @__PURE__ */ jsxs("div", { children: [
705
- /* @__PURE__ */ jsx("h3", { children: "Billing practice" }),
706
- /* @__PURE__ */ jsx("p", { children: "Payee identity and billing address for this claim." })
707
- ] }),
708
- /* @__PURE__ */ jsx("span", { children: "Prefilled" })
709
- ] }),
715
+ /* @__PURE__ */ jsx("div", { className: "mb-native-section-head", children: /* @__PURE__ */ jsxs("div", { children: [
716
+ /* @__PURE__ */ jsx("h3", { children: "Billing practice" }),
717
+ /* @__PURE__ */ jsx("p", { children: "Payee identity and billing address for this claim." })
718
+ ] }) }),
710
719
  /* @__PURE__ */ jsxs("div", { className: "mb-native-grid three", children: [
711
- /* @__PURE__ */ jsx(Field, { label: "Practice name", required: true, value: draft.billingProvider.name, onChange: (value) => updateBillingProvider("name", value) }),
712
- /* @__PURE__ */ jsx(Field, { label: "Tax ID", required: true, value: draft.billingProvider.taxId, onChange: (value) => updateBillingProvider("taxId", value) }),
713
- /* @__PURE__ */ jsx(Field, { label: "Billing NPI", required: true, value: draft.billingProvider.npi, onChange: (value) => updateBillingProvider("npi", value) }),
714
- /* @__PURE__ */ jsx(Field, { label: "Phone", optional: true, value: draft.billingProvider.phone || "", onChange: (value) => updateBillingProvider("phone", value) }),
715
- /* @__PURE__ */ jsx(Field, { label: "Billing street", required: true, value: draft.billingProvider.billingStreet || "", onChange: (value) => updateBillingProvider("billingStreet", value) }),
716
- /* @__PURE__ */ jsx(Field, { label: "City", required: true, value: draft.billingProvider.billingCity || "", onChange: (value) => updateBillingProvider("billingCity", value) }),
720
+ /* @__PURE__ */ jsx(Field, { label: "Practice name", required: true, disabled: !editable, value: draft.billingProvider.name, onChange: (value) => updateBillingProvider("name", value) }),
721
+ /* @__PURE__ */ jsx(Field, { label: "Tax ID", required: true, disabled: !editable, value: draft.billingProvider.taxId, onChange: (value) => updateBillingProvider("taxId", value) }),
722
+ /* @__PURE__ */ jsx(Field, { label: "Billing NPI", required: true, disabled: !editable, value: draft.billingProvider.npi, onChange: (value) => updateBillingProvider("npi", value) }),
723
+ /* @__PURE__ */ jsx(Field, { label: "Phone", optional: true, disabled: !editable, value: draft.billingProvider.phone || "", onChange: (value) => updateBillingProvider("phone", value) }),
724
+ /* @__PURE__ */ jsx(Field, { label: "Billing street", required: true, disabled: !editable, value: draft.billingProvider.billingStreet || "", onChange: (value) => updateBillingProvider("billingStreet", value) }),
725
+ /* @__PURE__ */ jsx(Field, { label: "City", required: true, disabled: !editable, value: draft.billingProvider.billingCity || "", onChange: (value) => updateBillingProvider("billingCity", value) }),
717
726
  /* @__PURE__ */ jsx(StateCombobox, { label: "State", required: true, disabled: !editable, value: draft.billingProvider.billingState || "", onChange: (value) => updateBillingProvider("billingState", value) }),
718
- /* @__PURE__ */ jsx(Field, { label: "ZIP", required: true, value: draft.billingProvider.billingZip || "", onChange: (value) => updateBillingProvider("billingZip", value) })
727
+ /* @__PURE__ */ jsx(Field, { label: "ZIP", required: true, disabled: !editable, value: draft.billingProvider.billingZip || "", onChange: (value) => updateBillingProvider("billingZip", value) })
719
728
  ] })
720
729
  ] }),
721
730
  /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
722
- /* @__PURE__ */ jsxs("div", { className: "mb-native-section-head", children: [
723
- /* @__PURE__ */ jsxs("div", { children: [
724
- /* @__PURE__ */ jsx("h3", { children: "Clinician" }),
725
- /* @__PURE__ */ jsx("p", { children: "Provider identity printed on the claim." })
726
- ] }),
727
- /* @__PURE__ */ jsx("span", { children: "Prefilled" })
728
- ] }),
731
+ /* @__PURE__ */ jsx("div", { className: "mb-native-section-head", children: /* @__PURE__ */ jsxs("div", { children: [
732
+ /* @__PURE__ */ jsx("h3", { children: "Clinician" }),
733
+ /* @__PURE__ */ jsx("p", { children: "Provider identity printed on the claim." })
734
+ ] }) }),
729
735
  /* @__PURE__ */ jsxs("div", { className: "mb-native-grid three", children: [
730
- /* @__PURE__ */ jsx(Field, { label: "Clinician name", required: true, value: draft.clinician.name, onChange: (value) => updateClinician("name", value) }),
731
- /* @__PURE__ */ jsx(Field, { label: "Specialty", value: draft.clinician.specialty, onChange: (value) => updateClinician("specialty", value) }),
732
- /* @__PURE__ */ jsx(Field, { label: "NPI", required: true, value: draft.clinician.npi, onChange: (value) => updateClinician("npi", value) }),
733
- /* @__PURE__ */ jsx(Field, { label: "Taxonomy", optional: true, value: draft.clinician.taxonomy || "", onChange: (value) => updateClinician("taxonomy", value) }),
734
- /* @__PURE__ */ jsx(Field, { label: "License number", optional: true, value: draft.clinician.licenseNumber || "", onChange: (value) => updateClinician("licenseNumber", value) }),
736
+ /* @__PURE__ */ jsx(Field, { label: "Clinician name", required: true, disabled: !editable, value: draft.clinician.name, onChange: (value) => updateClinician("name", value) }),
737
+ /* @__PURE__ */ jsx(Field, { label: "Specialty", disabled: !editable, value: draft.clinician.specialty, onChange: (value) => updateClinician("specialty", value) }),
738
+ /* @__PURE__ */ jsx(Field, { label: "NPI", required: true, disabled: !editable, value: draft.clinician.npi, onChange: (value) => updateClinician("npi", value) }),
739
+ /* @__PURE__ */ jsx(Field, { label: "Taxonomy", optional: true, disabled: !editable, value: draft.clinician.taxonomy || "", onChange: (value) => updateClinician("taxonomy", value) }),
740
+ /* @__PURE__ */ jsx(Field, { label: "License number", optional: true, disabled: !editable, value: draft.clinician.licenseNumber || "", onChange: (value) => updateClinician("licenseNumber", value) }),
735
741
  /* @__PURE__ */ jsx(StateCombobox, { label: "License state (optional)", disabled: !editable, value: draft.clinician.licenseState || "", onChange: (value) => updateClinician("licenseState", value) })
736
742
  ] })
737
743
  ] }),
738
744
  /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
739
- /* @__PURE__ */ jsxs("div", { className: "mb-native-section-head", children: [
740
- /* @__PURE__ */ jsxs("div", { children: [
741
- /* @__PURE__ */ jsx("h3", { children: "Service location" }),
742
- /* @__PURE__ */ jsx("p", { children: "The exact place of service for this bill." })
743
- ] }),
744
- /* @__PURE__ */ jsx("span", { children: "Prefilled" })
745
- ] }),
745
+ /* @__PURE__ */ jsx("div", { className: "mb-native-section-head", children: /* @__PURE__ */ jsxs("div", { children: [
746
+ /* @__PURE__ */ jsx("h3", { children: "Service location" }),
747
+ /* @__PURE__ */ jsx("p", { children: "The exact place of service for this bill." })
748
+ ] }) }),
746
749
  /* @__PURE__ */ jsxs("div", { className: "mb-native-grid three", children: [
747
- /* @__PURE__ */ jsx(Field, { label: "Location name", required: true, value: draft.location.name, onChange: (value) => updateLocation("name", value) }),
748
- /* @__PURE__ */ jsx(Field, { label: "Street", required: true, value: draft.location.street, onChange: (value) => updateLocation("street", value) }),
749
- /* @__PURE__ */ jsx(Field, { label: "City", required: true, value: draft.location.city, onChange: (value) => updateLocation("city", value) }),
750
+ /* @__PURE__ */ jsx(Field, { label: "Location name", required: true, disabled: !editable, value: draft.location.name, onChange: (value) => updateLocation("name", value) }),
751
+ /* @__PURE__ */ jsx(Field, { label: "Street", required: true, disabled: !editable, value: draft.location.street, onChange: (value) => updateLocation("street", value) }),
752
+ /* @__PURE__ */ jsx(Field, { label: "City", required: true, disabled: !editable, value: draft.location.city, onChange: (value) => updateLocation("city", value) }),
750
753
  /* @__PURE__ */ jsx(StateCombobox, { label: "State", required: true, disabled: !editable, value: draft.location.state, onChange: (value) => updateLocation("state", value) }),
751
- /* @__PURE__ */ jsx(Field, { label: "ZIP", required: true, value: draft.location.zip, onChange: (value) => updateLocation("zip", value) }),
752
- /* @__PURE__ */ jsx(Field, { label: "Place of service code", required: true, value: draft.location.posCode || "11", onChange: (value) => updateLocation("posCode", value) })
754
+ /* @__PURE__ */ jsx(Field, { label: "ZIP", required: true, disabled: !editable, value: draft.location.zip, onChange: (value) => updateLocation("zip", value) }),
755
+ /* @__PURE__ */ jsx(Field, { label: "Place of service code", required: true, disabled: !editable, value: draft.location.posCode || "11", onChange: (value) => updateLocation("posCode", value) })
753
756
  ] })
754
757
  ] }),
755
758
  /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
@@ -766,7 +769,10 @@ function BillReviewForm({
766
769
  ] }),
767
770
  /* @__PURE__ */ jsx("div", { className: "mb-native-lines", children: draft.lineItems.map((line, index) => /* @__PURE__ */ jsxs("div", { className: `mb-native-line ${data.bill.billingMode === "professional" ? "professional" : ""}`, children: [
768
771
  /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
769
- /* @__PURE__ */ jsx("span", { children: "Procedure" }),
772
+ /* @__PURE__ */ jsxs("span", { children: [
773
+ "Procedure",
774
+ /* @__PURE__ */ jsx("span", { className: "mb-native-required", "aria-hidden": "true", children: " *" })
775
+ ] }),
770
776
  data.bill.billingMode === "professional" ? /* @__PURE__ */ jsx("input", { disabled: !editable, placeholder: "CPT / HCPCS code", value: line.code, onChange: (event) => {
771
777
  const code = event.target.value.toUpperCase();
772
778
  setDraft((current) => ({ ...current, lineItems: ensureTrailingProcedureLine(current.lineItems.map((item, itemIndex) => itemIndex === index ? { ...item, code } : item)) }));
@@ -820,12 +826,18 @@ function BillReviewForm({
820
826
  ] }, modifier)) : null })
821
827
  ] }),
822
828
  /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
823
- /* @__PURE__ */ jsx("span", { children: "Units" }),
829
+ /* @__PURE__ */ jsxs("span", { children: [
830
+ "Units",
831
+ /* @__PURE__ */ jsx("span", { className: "mb-native-required", "aria-hidden": "true", children: " *" })
832
+ ] }),
824
833
  /* @__PURE__ */ jsx("input", { type: "number", min: "1", required: true, disabled: !editable, value: line.units, onChange: (event) => setDraft((current) => ({ ...current, lineItems: ensureTrailingProcedureLine(current.lineItems.map((item, itemIndex) => itemIndex === index ? { ...item, units: Number(event.target.value) } : item)) })) })
825
834
  ] }),
826
835
  data.bill.billingMode === "professional" ? /* @__PURE__ */ jsxs(Fragment, { children: [
827
836
  /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
828
- /* @__PURE__ */ jsx("span", { children: "Service date" }),
837
+ /* @__PURE__ */ jsxs("span", { children: [
838
+ "Service date",
839
+ /* @__PURE__ */ jsx("span", { className: "mb-native-required", "aria-hidden": "true", children: " *" })
840
+ ] }),
829
841
  /* @__PURE__ */ jsx("input", { type: "date", required: Boolean(line.code), disabled: !editable, value: line.serviceDate || "", onChange: (event) => setDraft((current) => ({ ...current, lineItems: ensureTrailingProcedureLine(current.lineItems.map((item, itemIndex) => itemIndex === index ? { ...item, serviceDate: event.target.value } : item)) })) })
830
842
  ] }),
831
843
  /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
@@ -836,7 +848,10 @@ function BillReviewForm({
836
848
  /* @__PURE__ */ jsx("input", { type: "date", disabled: !editable, value: line.serviceDateEnd || "", onChange: (event) => setDraft((current) => ({ ...current, lineItems: ensureTrailingProcedureLine(current.lineItems.map((item, itemIndex) => itemIndex === index ? { ...item, serviceDateEnd: event.target.value } : item)) })) })
837
849
  ] }),
838
850
  /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
839
- /* @__PURE__ */ jsx("span", { children: "Charge" }),
851
+ /* @__PURE__ */ jsxs("span", { children: [
852
+ "Charge",
853
+ /* @__PURE__ */ jsx("span", { className: "mb-native-required", "aria-hidden": "true", children: " *" })
854
+ ] }),
840
855
  /* @__PURE__ */ jsx("input", { type: "number", min: "0.01", step: "0.01", required: Boolean(line.code), disabled: !editable, value: line.charge || "", onChange: (event) => setDraft((current) => ({ ...current, lineItems: ensureTrailingProcedureLine(current.lineItems.map((item, itemIndex) => itemIndex === index ? { ...item, charge: Number(event.target.value) } : item)) })) })
841
856
  ] }),
842
857
  /* @__PURE__ */ jsxs("label", { className: "mb-native-field", children: [
@@ -858,16 +873,10 @@ function BillReviewForm({
858
873
  ] }, line.id || index)) })
859
874
  ] }),
860
875
  /* @__PURE__ */ jsxs("section", { className: sectionClass, children: [
861
- /* @__PURE__ */ jsxs("div", { className: "mb-native-section-head", children: [
862
- /* @__PURE__ */ jsxs("div", { children: [
863
- /* @__PURE__ */ jsx("h3", { children: "Payer billing packet" }),
864
- /* @__PURE__ */ jsx("p", { children: "Review exactly what will be sent with this bill." })
865
- ] }),
866
- /* @__PURE__ */ jsxs("span", { children: [
867
- data.bill.attachments.length,
868
- " files"
869
- ] })
870
- ] }),
876
+ /* @__PURE__ */ jsx("div", { className: "mb-native-section-head", children: /* @__PURE__ */ jsxs("div", { children: [
877
+ /* @__PURE__ */ jsx("h3", { children: "Payer billing packet" }),
878
+ /* @__PURE__ */ jsx("p", { children: "Review exactly what will be sent with this bill." })
879
+ ] }) }),
871
880
  /* @__PURE__ */ jsxs("div", { className: "mb-native-note", children: [
872
881
  /* @__PURE__ */ jsx("strong", { children: "Separate from attorney report service." }),
873
882
  " Final reports, proof of service, and required billing forms may be preselected. Medical records are never silently attached."
@@ -893,9 +902,8 @@ function BillReviewForm({
893
902
  ] }),
894
903
  /* @__PURE__ */ jsxs("section", { className: "mb-native-submit", children: [
895
904
  /* @__PURE__ */ jsxs("div", { children: [
896
- /* @__PURE__ */ jsx("span", { className: "mb-native-eyebrow", children: "Delivery" }),
897
- /* @__PURE__ */ jsx("h3", { children: "Submit this bill" }),
898
- /* @__PURE__ */ jsx("p", { children: "After submission, status, payments, denials, and resubmissions stay available here." })
905
+ /* @__PURE__ */ jsx("h3", { children: "Submit bill" }),
906
+ /* @__PURE__ */ jsx("p", { children: "Submitting creates the bill as an immutable snapshot of the information and documents above." })
899
907
  ] }),
900
908
  error ? /* @__PURE__ */ jsx("div", { className: "mb-native-message error", role: "alert", children: error }) : null,
901
909
  notice ? /* @__PURE__ */ jsx("div", { className: "mb-native-message success", role: "status", children: notice }) : null,
@@ -903,10 +911,10 @@ function BillReviewForm({
903
911
  /* @__PURE__ */ jsx("strong", { children: "Before you can submit:" }),
904
912
  /* @__PURE__ */ jsx("span", { children: blockers.join(" \xB7 ") })
905
913
  ] }) : null,
906
- /* @__PURE__ */ jsxs("div", { className: "mb-native-actions", children: [
914
+ /* @__PURE__ */ jsx("div", { className: "mb-native-actions", children: mode === "submission" ? /* @__PURE__ */ jsx("button", { className: "mb-native-button primary", type: "submit", disabled: !editable || !canSubmit || busy !== "", children: busy === "submit" ? "Submitting\u2026" : "Submit bill" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
907
915
  /* @__PURE__ */ jsx("button", { className: "mb-native-button secondary", type: "submit", disabled: !editable || busy !== "", children: busy === "save" ? "Saving\u2026" : "Save changes" }),
908
916
  /* @__PURE__ */ jsx("button", { className: "mb-native-button primary", type: "button", disabled: !editable || !canSubmit || busy !== "" || deliveryBusy, onClick: () => void openSubmit(), children: deliveryBusy ? "Loading delivery\u2026" : "Review delivery" })
909
- ] })
917
+ ] }) })
910
918
  ] }),
911
919
  showSubmit && deliveryOptions ? /* @__PURE__ */ jsx("div", { className: "mb-native-modal-backdrop", role: "presentation", onMouseDown: (event) => {
912
920
  if (event.target === event.currentTarget && busy !== "submit") setShowSubmit(false);
@@ -991,7 +999,7 @@ var NATIVE_SUBMISSION_DIALOG_STYLES = `
991
999
  `;
992
1000
  var NATIVE_BILL_REVIEW_STYLES = `
993
1001
  .mb-native-review,.mb-native-status{font-family:var(--mb-font,Inter,ui-sans-serif,system-ui,sans-serif)}
994
- .mb-native-review,.mb-native-status{--mb-accent:#238dbd;--mb-accent-dark:#176f98;--mb-text:#203743;--mb-muted:#657982;--mb-border:#dbe6ea;--mb-soft:#f3f8fa;--mb-surface:#fff;color:var(--mb-text);font:14px/1.45 Inter,ui-sans-serif,system-ui,sans-serif}.mb-native-review *,.mb-native-status *{box-sizing:border-box}.mb-native-review{display:grid;gap:16px}.mb-native-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;padding:6px 2px}.mb-native-heading h2,.mb-native-section h3,.mb-native-submit h3,.mb-native-status h3{margin:3px 0 2px;line-height:1.2}.mb-native-heading h2{font-size:25px}.mb-native-heading p,.mb-native-section p,.mb-native-submit p,.mb-native-status p{margin:0;color:var(--mb-muted)}.mb-native-eyebrow{color:#59727d;font-size:11px;font-weight:800;letter-spacing:.14em;text-transform:uppercase}.mb-native-total{display:flex;align-items:center;gap:18px}.mb-native-total span,.mb-native-section-head>span{border-radius:999px;background:var(--mb-soft);color:#58717c;font-size:11px;font-weight:800;padding:6px 10px;text-transform:capitalize}.mb-native-total strong{font-size:24px}.mb-native-summary{display:grid;grid-template-columns:repeat(4,1fr);margin:0;border:1px solid var(--mb-border);border-radius:12px;background:var(--mb-surface);overflow:hidden}.mb-native-summary div{padding:17px 20px;border-right:1px solid var(--mb-border)}.mb-native-summary div:last-child{border:0}.mb-native-summary dt,.mb-native-allowed span{color:#647982;font-size:10px;font-weight:800;letter-spacing:.12em;text-transform:uppercase}.mb-native-summary dd{margin:5px 0 0;font-weight:750}.mb-native-section{padding:20px;border:1px solid var(--mb-border);border-radius:14px;background:var(--mb-surface);box-shadow:0 8px 24px rgba(28,58,72,.04)}.mb-native-section-head{display:flex;align-items:start;justify-content:space-between;gap:16px;margin-bottom:17px}.mb-native-section h3,.mb-native-submit h3,.mb-native-status h3{font-size:19px}.mb-native-grid{display:grid;gap:14px}.mb-native-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.mb-native-field{display:grid;gap:6px;min-width:0;color:var(--mb-text);font-size:12px;font-weight:750}.mb-native-field small{color:var(--mb-muted);font-size:inherit;font-weight:500}.mb-native-field input,.mb-native-attach select,.mb-native-attach input{width:100%;min-height:43px;border:1px solid var(--mb-border);border-radius:8px;background:#fff;color:var(--mb-text);font:inherit;padding:10px 12px}.mb-native-field input:focus,.mb-native-attach select:focus,.mb-native-attach input:focus{border-color:var(--mb-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--mb-accent) 14%,transparent);outline:0}.mb-native-lines{display:grid;gap:10px}.mb-native-line{display:grid;grid-template-columns:1.1fr 1.1fr 110px 120px 28px;align-items:end;gap:12px;padding:13px;background:var(--mb-soft);border:1px solid #e3edf0;border-radius:10px}.mb-native-allowed{display:grid;gap:5px;padding:0 8px 11px;text-align:right}.mb-native-allowed strong{font-size:16px}.mb-native-remove{border:0;background:transparent;color:#667d86;cursor:pointer;font-size:20px;padding:7px}.mb-native-note{padding:13px 15px;border:1px solid #bdd9e4;border-radius:9px;background:#f2f9fc;color:#526d78}.mb-native-note strong{color:var(--mb-text);margin-right:12px}.mb-native-documents{list-style:none;margin:14px 0;padding:0}.mb-native-documents li{display:grid;grid-template-columns:42px 1fr auto 28px;align-items:center;gap:12px;padding:12px 4px;border-bottom:1px solid var(--mb-border)}.mb-native-documents li>div{display:grid}.mb-native-documents li span{color:var(--mb-muted);font-size:12px}.mb-native-file{display:grid;place-items:center;width:40px;height:40px;border-radius:8px;background:#eaf5f9;color:var(--mb-accent)!important;font-size:11px!important;font-weight:850}.mb-native-attach{display:grid;grid-template-columns:1fr 230px minmax(220px,1fr) auto;align-items:end;gap:12px;padding:15px;border-radius:10px;background:var(--mb-soft)}.mb-native-attach>div{display:grid;gap:3px}.mb-native-attach span{color:var(--mb-muted);font-size:12px}.mb-native-button{min-height:40px;border:1px solid var(--mb-border);border-radius:8px;background:#fff;color:var(--mb-text);cursor:pointer;font:inherit;font-weight:750;padding:9px 14px}.mb-native-button.primary{border-color:var(--mb-accent);background:var(--mb-accent);color:#fff}.mb-native-button.primary:hover{background:var(--mb-accent-dark)}.mb-native-button.secondary{background:#fff}.mb-native-button.quiet{min-height:auto;background:var(--mb-soft);padding:7px 11px}.mb-native-button:disabled,.mb-native-remove:disabled{cursor:not-allowed;opacity:.5}.mb-native-submit{display:grid;grid-template-columns:1fr auto;align-items:end;gap:18px;padding:22px;border:1px solid #bcd8e2;border-radius:14px;background:linear-gradient(135deg,#f3fafc,#eaf6fa)}.mb-native-submit fieldset{display:flex;gap:6px;margin:0;padding:0;border:0}.mb-native-submit legend{position:absolute;width:1px;height:1px;overflow:hidden}.mb-native-submit fieldset label{display:flex;align-items:center;gap:6px;padding:9px 11px;border:1px solid #c9dce3;border-radius:8px;background:#fff;font-weight:700}.mb-native-actions{display:flex;justify-content:flex-end;gap:10px;grid-column:1/-1}.mb-native-message{grid-column:1/-1;padding:10px 12px;border-radius:8px}.mb-native-message.error{background:#fff0ef;color:#9d3029}.mb-native-message.success{background:#edf9f2;color:#217449}.mb-native-status{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:20px;border:1px solid var(--mb-border);border-radius:12px;background:#fff}.mb-native-status h3{text-transform:capitalize}.mb-native-status dl{display:flex;margin:0}.mb-native-status dl div{min-width:110px;padding:0 18px;border-left:1px solid var(--mb-border)}.mb-native-status dt{color:var(--mb-muted);font-size:11px}.mb-native-status dd{margin:4px 0 0;font-size:17px;font-weight:800}@media(max-width:900px){.mb-native-grid.three{grid-template-columns:repeat(2,minmax(0,1fr))}.mb-native-summary{grid-template-columns:repeat(2,1fr)}.mb-native-summary div:nth-child(2){border-right:0}.mb-native-summary div:nth-child(-n+2){border-bottom:1px solid var(--mb-border)}.mb-native-line{grid-template-columns:1fr 1fr 90px}.mb-native-allowed{align-self:center}.mb-native-attach{grid-template-columns:1fr 1fr}.mb-native-submit{grid-template-columns:1fr}.mb-native-submit fieldset,.mb-native-actions{grid-column:1}.mb-native-actions{justify-content:start}}@media(max-width:620px){.mb-native-heading,.mb-native-total,.mb-native-status{align-items:start;flex-direction:column}.mb-native-grid.three,.mb-native-summary,.mb-native-line,.mb-native-attach{grid-template-columns:1fr}.mb-native-summary div,.mb-native-summary div:nth-child(2){border-right:0;border-bottom:1px solid var(--mb-border)}.mb-native-line{align-items:stretch}.mb-native-allowed{text-align:left}.mb-native-submit fieldset{display:grid;grid-template-columns:1fr 1fr}.mb-native-status dl{width:100%}.mb-native-status dl div{min-width:0;flex:1;padding:0 10px}.mb-native-status dl div:first-child{padding-left:0;border-left:0}}
1002
+ .mb-native-review,.mb-native-status{--mb-accent:#238dbd;--mb-accent-dark:#176f98;--mb-text:#203743;--mb-muted:#657982;--mb-border:#dbe6ea;--mb-soft:#f3f8fa;--mb-surface:#fff;color:var(--mb-text);font:14px/1.45 Inter,ui-sans-serif,system-ui,sans-serif}.mb-native-review *,.mb-native-status *{box-sizing:border-box}.mb-native-review{display:grid;gap:16px}.mb-native-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;padding:6px 2px}.mb-native-heading h2,.mb-native-section h3,.mb-native-submit h3,.mb-native-status h3{margin:3px 0 2px;line-height:1.2}.mb-native-heading h2{font-size:25px}.mb-native-heading p,.mb-native-section p,.mb-native-submit p,.mb-native-status p{margin:0;color:var(--mb-muted)}.mb-native-eyebrow{color:#59727d;font-size:11px;font-weight:800;letter-spacing:.14em;text-transform:uppercase}.mb-native-total{display:flex;align-items:center;gap:18px}.mb-native-total span,.mb-native-section-head>span{border-radius:999px;background:var(--mb-soft);color:#58717c;font-size:11px;font-weight:800;padding:6px 10px;text-transform:capitalize}.mb-native-total strong{font-size:24px}.mb-native-summary{display:grid;grid-template-columns:repeat(4,1fr);margin:0;border:1px solid var(--mb-border);border-radius:12px;background:var(--mb-surface);overflow:hidden}.mb-native-summary div{padding:17px 20px;border-right:1px solid var(--mb-border)}.mb-native-summary div:last-child{border:0}.mb-native-summary dt,.mb-native-allowed span{color:#647982;font-size:10px;font-weight:800;letter-spacing:.12em;text-transform:uppercase}.mb-native-summary dd{margin:5px 0 0;font-weight:750}.mb-native-section{padding:20px;border:1px solid var(--mb-border);border-radius:14px;background:var(--mb-surface);box-shadow:0 8px 24px rgba(28,58,72,.04)}.mb-native-section-head{display:flex;align-items:start;justify-content:space-between;gap:16px;margin-bottom:17px}.mb-native-section h3,.mb-native-submit h3,.mb-native-status h3{font-size:19px}.mb-native-grid{display:grid;gap:14px}.mb-native-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.mb-native-field{display:grid;gap:6px;min-width:0;color:var(--mb-text);font-size:12px;font-weight:750}.mb-native-required{color:#c5352e}.mb-native-field small{color:var(--mb-muted);font-size:inherit;font-weight:500}.mb-native-field input,.mb-native-attach select,.mb-native-attach input{width:100%;min-height:43px;border:1px solid var(--mb-border);border-radius:8px;background:#fff;color:var(--mb-text);font:inherit;padding:10px 12px}.mb-native-field input:focus,.mb-native-attach select:focus,.mb-native-attach input:focus{border-color:var(--mb-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--mb-accent) 14%,transparent);outline:0}.mb-native-lines{display:grid;gap:10px}.mb-native-line{display:grid;grid-template-columns:1.1fr 1.1fr 110px 120px 28px;align-items:end;gap:12px;padding:13px;background:var(--mb-soft);border:1px solid #e3edf0;border-radius:10px}.mb-native-allowed{display:grid;gap:5px;padding:0 8px 11px;text-align:right}.mb-native-allowed strong{font-size:16px}.mb-native-remove{border:0;background:transparent;color:#667d86;cursor:pointer;font-size:20px;padding:7px}.mb-native-note{padding:13px 15px;border:1px solid #bdd9e4;border-radius:9px;background:#f2f9fc;color:#526d78}.mb-native-note strong{color:var(--mb-text);margin-right:12px}.mb-native-documents{list-style:none;margin:14px 0;padding:0}.mb-native-documents li{display:grid;grid-template-columns:42px 1fr auto 28px;align-items:center;gap:12px;padding:12px 4px;border-bottom:1px solid var(--mb-border)}.mb-native-documents li>div{display:grid}.mb-native-documents li span{color:var(--mb-muted);font-size:12px}.mb-native-file{display:grid;place-items:center;width:40px;height:40px;border-radius:8px;background:#eaf5f9;color:var(--mb-accent)!important;font-size:11px!important;font-weight:850}.mb-native-attach{display:grid;grid-template-columns:1fr 230px minmax(220px,1fr) auto;align-items:end;gap:12px;padding:15px;border-radius:10px;background:var(--mb-soft)}.mb-native-attach>div{display:grid;gap:3px}.mb-native-attach span{color:var(--mb-muted);font-size:12px}.mb-native-button{min-height:40px;border:1px solid var(--mb-border);border-radius:8px;background:#fff;color:var(--mb-text);cursor:pointer;font:inherit;font-weight:750;padding:9px 14px}.mb-native-button.primary{border-color:var(--mb-accent);background:var(--mb-accent);color:#fff}.mb-native-button.primary:hover{background:var(--mb-accent-dark)}.mb-native-button.secondary{background:#fff}.mb-native-button.quiet{min-height:auto;background:var(--mb-soft);padding:7px 11px}.mb-native-button:disabled,.mb-native-remove:disabled{cursor:not-allowed;opacity:.5}.mb-native-submit{display:grid;grid-template-columns:1fr auto;align-items:end;gap:18px;padding:22px;border:1px solid #bcd8e2;border-radius:14px;background:linear-gradient(135deg,#f3fafc,#eaf6fa)}.mb-native-submit fieldset{display:flex;gap:6px;margin:0;padding:0;border:0}.mb-native-submit legend{position:absolute;width:1px;height:1px;overflow:hidden}.mb-native-submit fieldset label{display:flex;align-items:center;gap:6px;padding:9px 11px;border:1px solid #c9dce3;border-radius:8px;background:#fff;font-weight:700}.mb-native-actions{display:flex;justify-content:flex-end;gap:10px;grid-column:1/-1}.mb-native-message{grid-column:1/-1;padding:10px 12px;border-radius:8px}.mb-native-message.error{background:#fff0ef;color:#9d3029}.mb-native-message.success{background:#edf9f2;color:#217449}.mb-native-status{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:20px;border:1px solid var(--mb-border);border-radius:12px;background:#fff}.mb-native-status h3{text-transform:capitalize}.mb-native-status dl{display:flex;margin:0}.mb-native-status dl div{min-width:110px;padding:0 18px;border-left:1px solid var(--mb-border)}.mb-native-status dt{color:var(--mb-muted);font-size:11px}.mb-native-status dd{margin:4px 0 0;font-size:17px;font-weight:800}@media(max-width:900px){.mb-native-grid.three{grid-template-columns:repeat(2,minmax(0,1fr))}.mb-native-summary{grid-template-columns:repeat(2,1fr)}.mb-native-summary div:nth-child(2){border-right:0}.mb-native-summary div:nth-child(-n+2){border-bottom:1px solid var(--mb-border)}.mb-native-line{grid-template-columns:1fr 1fr 90px}.mb-native-allowed{align-self:center}.mb-native-attach{grid-template-columns:1fr 1fr}.mb-native-submit{grid-template-columns:1fr}.mb-native-submit fieldset,.mb-native-actions{grid-column:1}.mb-native-actions{justify-content:start}}@media(max-width:620px){.mb-native-heading,.mb-native-total,.mb-native-status{align-items:start;flex-direction:column}.mb-native-grid.three,.mb-native-summary,.mb-native-line,.mb-native-attach{grid-template-columns:1fr}.mb-native-summary div,.mb-native-summary div:nth-child(2){border-right:0;border-bottom:1px solid var(--mb-border)}.mb-native-line{align-items:stretch}.mb-native-allowed{text-align:left}.mb-native-submit fieldset{display:grid;grid-template-columns:1fr 1fr}.mb-native-status dl{width:100%}.mb-native-status dl div{min-width:0;flex:1;padding:0 10px}.mb-native-status dl div:first-child{padding-left:0;border-left:0}}
995
1003
  .mb-native-status-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}.mb-native-status-copy{min-width:150px}.mb-native-review,.mb-native-status{font-family:var(--mb-font,Inter,ui-sans-serif,system-ui,sans-serif)}
996
1004
  .mb-native-review{padding:clamp(16px,2vw,24px)}
997
1005
  .mb-native-grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}
@@ -1035,19 +1043,660 @@ var NATIVE_THEME_OVERRIDE_STYLES = `
1035
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)}
1036
1044
  `;
1037
1045
 
1046
+ // src/bill-read-only-form.tsx
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";
1163
+ var BILL_SUBMISSION_DOCUMENT_TYPES = [
1164
+ "final_report",
1165
+ "proof_of_service",
1166
+ "letter_of_attestation",
1167
+ "form_122",
1168
+ "return_to_work_voucher",
1169
+ "w9",
1170
+ "medical_records",
1171
+ "appeal",
1172
+ "other"
1173
+ ];
1174
+ var BILL_SUBMISSION_REQUIRED_FIELDS = [
1175
+ "patient.firstName",
1176
+ "patient.lastName",
1177
+ "patient.dateOfBirth",
1178
+ "patient.address.line1",
1179
+ "patient.address.city",
1180
+ "patient.address.state",
1181
+ "patient.address.postalCode",
1182
+ "claim.claimNumber",
1183
+ "claim.claimsAdministrator",
1184
+ "service.date",
1185
+ "serviceLines[].code",
1186
+ "serviceLines[].units"
1187
+ ];
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
+ ];
1207
+ var documentLabels = {
1208
+ final_report: "Final report",
1209
+ proof_of_service: "Proof of service",
1210
+ letter_of_attestation: "Letter of attestation",
1211
+ form_122: "Form 122",
1212
+ return_to_work_voucher: "Return-to-work voucher",
1213
+ w9: "W-9",
1214
+ medical_records: "Medical records",
1215
+ appeal: "Appeal",
1216
+ other: "Other"
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
+ }
1270
+ function cloneBill(bill) {
1271
+ return {
1272
+ ...bill,
1273
+ patient: { ...bill.patient, address: { ...bill.patient.address } },
1274
+ claim: { ...bill.claim, ...bill.claim.claimsAdministrator ? { claimsAdministrator: { ...bill.claim.claimsAdministrator } } : {} },
1275
+ service: { ...bill.service },
1276
+ ...bill.billingProvider ? { billingProvider: { ...bill.billingProvider, ...bill.billingProvider.address ? { address: { ...bill.billingProvider.address } } : {} } } : {},
1277
+ ...bill.renderingProvider ? { renderingProvider: { ...bill.renderingProvider } } : {},
1278
+ ...bill.serviceLocation ? { serviceLocation: { ...bill.serviceLocation, ...bill.serviceLocation.address ? { address: { ...bill.serviceLocation.address } } : {} } } : {},
1279
+ diagnoses: [...bill.diagnoses ?? []],
1280
+ serviceLines: ensureTrailingBillSubmissionLine(bill.serviceLines)
1281
+ };
1282
+ }
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.";
1300
+ }
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
+ `;
1323
+ function RequiredMark() {
1324
+ return /* @__PURE__ */ jsx3("span", { className: "mbsf-star", children: " *" });
1325
+ }
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: [
1329
+ label,
1330
+ required ? /* @__PURE__ */ jsx3(RequiredMark, {}) : null
1331
+ ] }),
1332
+ children,
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
1380
+ ] });
1381
+ }
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()];
1386
+ }
1387
+ function BillSubmissionForm({
1388
+ initialBill,
1389
+ attachments = EMPTY_ATTACHMENTS,
1390
+ onSubmit,
1391
+ getSession,
1392
+ sessionEndpoint,
1393
+ apiBaseUrl,
1394
+ fetch: fetchOverride,
1395
+ onSearchClaimsAdministrators,
1396
+ diagnosisOptions = [],
1397
+ onSearchDiagnoses,
1398
+ onLookupPostalCode,
1399
+ procedureOptions,
1400
+ modifierOptions,
1401
+ appearance,
1402
+ className = "bill-submission-form",
1403
+ style,
1404
+ disabled = false,
1405
+ submitLabel = "Submit bill",
1406
+ heading = "Bill information",
1407
+ description = "Review the bill details, add attachments, and submit."
1408
+ }) {
1409
+ const [bill, setBill] = useState2(() => cloneBill(initialBill));
1410
+ const [selectedIds, setSelectedIds] = useState2(() => attachments.filter((item) => item.selected !== false || item.autoAttached).map((item) => item.id));
1411
+ const [uploads, setUploads] = useState2([]);
1412
+ const [errors, setErrors] = useState2({});
1413
+ const [formError, setFormError] = useState2(null);
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;
1427
+ useEffect2(() => {
1428
+ setBill(cloneBill(initialBill));
1429
+ setSelectedIds(attachments.filter((item) => item.selected !== false || item.autoAttached).map((item) => item.id));
1430
+ setUploads([]);
1431
+ setErrors({});
1432
+ setFormError(null);
1433
+ }, [initialBill, attachments]);
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;
1483
+ }
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);
1506
+ async function submit() {
1507
+ const clean = { ...cloneBill(bill), serviceLines: submittedLines(bill.serviceLines) };
1508
+ const validation = validateBillSubmission(clean);
1509
+ setErrors(validation.fieldErrors);
1510
+ setFormError(null);
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.`);
1513
+ setSubmitting(true);
1514
+ try {
1515
+ await onSubmit({ bill: clean, sourceAttachmentIds: selectedIds, uploads });
1516
+ } catch (caught) {
1517
+ setFormError(caught instanceof Error ? caught.message : "Unable to submit the bill.");
1518
+ } finally {
1519
+ setSubmitting(false);
1520
+ }
1521
+ }
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
1549
+ ] }),
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
+ " "
1606
+ ] }),
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) } : {} });
1613
+ } }),
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]) })
1656
+ ] })
1657
+ ] }),
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
+ ] });
1685
+ }
1686
+
1038
1687
  // src/connected-bill-status.tsx
1039
1688
  import {
1040
- useCallback,
1041
- useEffect as useEffect2,
1042
- useMemo as useMemo2,
1043
- useRef as useRef2,
1044
- useState as useState2
1689
+ useCallback as useCallback2,
1690
+ useEffect as useEffect3,
1691
+ useMemo as useMemo3,
1692
+ useRef as useRef3,
1693
+ useState as useState3
1045
1694
  } from "react";
1046
1695
  import {
1047
1696
  DEFAULT_API_BASE_URL,
1048
1697
  DEFAULT_SESSION_ENDPOINT
1049
1698
  } from "@mindbill/browser";
1050
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1699
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1051
1700
  var DEFAULT_REFRESH_INTERVAL = 6e4;
1052
1701
  async function responseError(response, fallback) {
1053
1702
  const body = await response.json().catch(() => null);
@@ -1180,23 +1829,23 @@ function useBillStatus({
1180
1829
  initialData = null,
1181
1830
  fetch: fetchOverride
1182
1831
  }) {
1183
- const client = useMemo2(() => createBillStatusClient({
1832
+ const client = useMemo3(() => createBillStatusClient({
1184
1833
  billId,
1185
1834
  sessionEndpoint,
1186
1835
  ...getSession ? { getSession } : {},
1187
1836
  apiBaseUrl,
1188
1837
  ...fetchOverride ? { fetch: fetchOverride } : {}
1189
1838
  }), [apiBaseUrl, billId, fetchOverride, getSession, sessionEndpoint]);
1190
- const [data, setData] = useState2(initialData);
1191
- const [error, setError] = useState2(null);
1192
- const [isLoading, setIsLoading] = useState2(enabled && !initialData);
1193
- const [isRefreshing, setIsRefreshing] = useState2(false);
1194
- const dataRef = useRef2(initialData);
1195
- const initialDataRef = useRef2(initialData);
1839
+ const [data, setData] = useState3(initialData);
1840
+ const [error, setError] = useState3(null);
1841
+ const [isLoading, setIsLoading] = useState3(enabled && !initialData);
1842
+ const [isRefreshing, setIsRefreshing] = useState3(false);
1843
+ const dataRef = useRef3(initialData);
1844
+ const initialDataRef = useRef3(initialData);
1196
1845
  initialDataRef.current = initialData;
1197
- const activeControllerRef = useRef2(null);
1198
- const requestSequence = useRef2(0);
1199
- useEffect2(() => {
1846
+ const activeControllerRef = useRef3(null);
1847
+ const requestSequence = useRef3(0);
1848
+ useEffect3(() => {
1200
1849
  const seed = initialDataRef.current;
1201
1850
  dataRef.current = seed;
1202
1851
  setData(seed);
@@ -1205,7 +1854,7 @@ function useBillStatus({
1205
1854
  activeControllerRef.current?.abort();
1206
1855
  return () => activeControllerRef.current?.abort();
1207
1856
  }, [client, enabled]);
1208
- const load = useCallback(async () => {
1857
+ const load = useCallback2(async () => {
1209
1858
  if (!enabled || !billId) return;
1210
1859
  const sequence = ++requestSequence.current;
1211
1860
  activeControllerRef.current?.abort();
@@ -1237,10 +1886,10 @@ function useBillStatus({
1237
1886
  }
1238
1887
  }
1239
1888
  }, [billId, client, enabled]);
1240
- useEffect2(() => {
1889
+ useEffect3(() => {
1241
1890
  if (enabled) void load();
1242
1891
  }, [enabled, load]);
1243
- useEffect2(() => {
1892
+ useEffect3(() => {
1244
1893
  if (!enabled || refreshInterval <= 0) return;
1245
1894
  const timer = window.setInterval(() => void load(), refreshInterval);
1246
1895
  const onFocus = () => void load();
@@ -1268,17 +1917,17 @@ function ConnectedBillStatus({
1268
1917
  }) {
1269
1918
  const status = useBillStatus(options);
1270
1919
  if (status.isLoading && !status.data) {
1271
- return /* @__PURE__ */ jsx2(Fragment2, { children: loadingFallback ?? /* @__PURE__ */ jsx2("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" }) });
1272
1921
  }
1273
1922
  if (status.error && !status.data) {
1274
- return /* @__PURE__ */ jsx2(Fragment2, { children: errorFallback?.(status.error, status.refresh) ?? /* @__PURE__ */ jsxs2("div", { role: "alert", children: [
1923
+ return /* @__PURE__ */ jsx4(Fragment3, { children: errorFallback?.(status.error, status.refresh) ?? /* @__PURE__ */ jsxs4("div", { role: "alert", children: [
1275
1924
  status.error.message,
1276
1925
  " ",
1277
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => void status.refresh(), children: "Retry" })
1926
+ /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => void status.refresh(), children: "Retry" })
1278
1927
  ] }) });
1279
1928
  }
1280
1929
  if (!status.data) return null;
1281
- return /* @__PURE__ */ jsx2(
1930
+ return /* @__PURE__ */ jsx4(
1282
1931
  BillStatusSummary,
1283
1932
  {
1284
1933
  status: status.data.state,
@@ -1297,7 +1946,7 @@ function ConnectedBillStatus({
1297
1946
  }
1298
1947
 
1299
1948
  // src/bill-lifecycle-surfaces.tsx
1300
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1949
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1301
1950
  function visibleBillLifecycleActions(actions, showUnavailable = false) {
1302
1951
  return actions.filter((action) => action.enabled || showUnavailable);
1303
1952
  }
@@ -1312,17 +1961,15 @@ function BillLifecycleActions({
1312
1961
  }) {
1313
1962
  const visible = visibleBillLifecycleActions(actions, showUnavailable);
1314
1963
  if (!visible.length) return null;
1315
- return /* @__PURE__ */ jsxs3("div", { className: classes("mb-lifecycle-actions", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill actions", children: [
1316
- /* @__PURE__ */ jsx3("style", { children: lifecycleSurfaceStyles }),
1317
- visible.map((action) => /* @__PURE__ */ jsxs3("div", { className: "mb-lifecycle-action", children: [
1318
- /* @__PURE__ */ jsx3("button", { type: "button", className: action.primary ? "mb-action-button is-primary" : "mb-action-button", disabled: disabled || !action.enabled, onClick: () => onAction(action), children: action.label }),
1319
- !action.enabled && action.reason ? /* @__PURE__ */ jsx3("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
1320
1969
  ] }, action.id))
1321
1970
  ] });
1322
1971
  }
1323
1972
  var activityLabels = {
1324
- "bill.created": "Bill created",
1325
- "bill.draft": "Bill saved",
1326
1973
  "bill.scrub_failed": "Submission needs attention",
1327
1974
  "bill.submitted": "Bill submitted",
1328
1975
  "bill.accepted": "Bill accepted",
@@ -1348,21 +1995,21 @@ function defaultFormatDate(createdAt) {
1348
1995
  return new Intl.DateTimeFormat(void 0, { dateStyle: "medium", timeStyle: "short" }).format(parsed);
1349
1996
  }
1350
1997
  function BillActivityTimeline({ events, emptyLabel = "No bill activity yet.", appearance, className, style, formatDate = defaultFormatDate }) {
1351
- return /* @__PURE__ */ jsxs3("section", { className: classes("mb-surface mb-activity", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill activity", children: [
1352
- /* @__PURE__ */ jsx3("style", { children: lifecycleSurfaceStyles }),
1353
- /* @__PURE__ */ jsxs3("header", { className: "mb-surface-heading", children: [
1354
- /* @__PURE__ */ jsxs3("div", { children: [
1355
- /* @__PURE__ */ jsx3("strong", { children: "Bill history" }),
1356
- /* @__PURE__ */ jsx3("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." })
1357
2004
  ] }),
1358
- /* @__PURE__ */ jsx3("span", { children: events.length })
2005
+ /* @__PURE__ */ jsx5("span", { children: events.length })
1359
2006
  ] }),
1360
- !events.length ? /* @__PURE__ */ jsx3("p", { className: "mb-activity-empty", children: emptyLabel }) : /* @__PURE__ */ jsx3("ol", { className: "mb-activity-list", children: events.map((event) => /* @__PURE__ */ jsxs3("li", { className: "mb-activity-item", children: [
1361
- /* @__PURE__ */ jsx3("span", { className: "mb-activity-marker", "aria-hidden": "true" }),
1362
- /* @__PURE__ */ jsxs3("div", { className: "mb-activity-content", children: [
1363
- /* @__PURE__ */ jsx3("strong", { children: event.title ?? billActivityEventLabel(event.type) }),
1364
- event.description ? /* @__PURE__ */ jsx3("p", { children: event.description }) : null,
1365
- /* @__PURE__ */ jsxs3("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: [
1366
2013
  formatDate(event.createdAt),
1367
2014
  event.actor ? ` \xB7 ${event.actor}` : ""
1368
2015
  ] })
@@ -1371,39 +2018,35 @@ function BillActivityTimeline({ events, emptyLabel = "No bill activity yet.", ap
1371
2018
  ] });
1372
2019
  }
1373
2020
  var lifecycleStages = [
1374
- { id: "created", label: "Created" },
1375
2021
  { id: "submitted", label: "Submitted" },
1376
2022
  { id: "accepted", label: "Accepted" },
1377
- { id: "response", label: "Payer response" },
1378
- { id: "follow_up", label: "Follow-up" },
2023
+ { id: "processed", label: "Processed" },
1379
2024
  { id: "closed", label: "Closed" }
1380
2025
  ];
1381
2026
  function billLifecycleStage(state) {
1382
2027
  const value = state.toLowerCase();
1383
2028
  if (value.includes("closed") || value.includes("written_off")) return "closed";
1384
- if (value.includes("second_review") || value.includes("ibr") || value.includes("lien") || value.includes("appeal")) return "follow_up";
1385
- 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";
1386
2030
  if (value.includes("accepted")) return "accepted";
1387
- if (value.includes("submitted") || value.includes("queued") || value.includes("sent")) return "submitted";
1388
- return "created";
2031
+ return "submitted";
1389
2032
  }
1390
2033
  function BillLifecycleProgress({ state, nativeStatus, submittedAt, agingDays, appearance, className, style }) {
1391
2034
  const current = billLifecycleStage(state);
1392
2035
  const currentIndex = lifecycleStages.findIndex((stage) => stage.id === current);
1393
- return /* @__PURE__ */ jsxs3("section", { className: classes("mb-surface mb-progress", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill lifecycle", children: [
1394
- /* @__PURE__ */ jsx3("style", { children: lifecycleSurfaceStyles }),
1395
- /* @__PURE__ */ jsx3("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs3("div", { children: [
1396
- /* @__PURE__ */ jsx3("strong", { children: humanize(nativeStatus || state) }),
1397
- /* @__PURE__ */ jsxs3("span", { children: [
1398
- 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",
1399
2042
  typeof agingDays === "number" ? ` \xB7 ${agingDays} days old` : ""
1400
2043
  ] })
1401
2044
  ] }) }),
1402
- /* @__PURE__ */ jsx3("ol", { className: "mb-progress-list", children: lifecycleStages.map((stage, index) => {
2045
+ /* @__PURE__ */ jsx5("ol", { className: "mb-progress-list", children: lifecycleStages.map((stage, index) => {
1403
2046
  const status = index < currentIndex ? "complete" : index === currentIndex ? "current" : "upcoming";
1404
- return /* @__PURE__ */ jsxs3("li", { className: `is-${status}`, "aria-current": status === "current" ? "step" : void 0, children: [
1405
- /* @__PURE__ */ jsx3("span", { "aria-hidden": "true", children: status === "complete" ? "\u2713" : index + 1 }),
1406
- /* @__PURE__ */ jsx3("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 })
1407
2050
  ] }, stage.id);
1408
2051
  }) })
1409
2052
  ] });
@@ -1417,45 +2060,45 @@ function BillSnapshotSummary({ bill, patient, injury, delivery, appearance, clas
1417
2060
  ["Charged", currency(bill.totalCharge)],
1418
2061
  ["Balance", currency(bill.balanceDue)]
1419
2062
  ];
1420
- return /* @__PURE__ */ jsxs3("section", { className: classes("mb-surface mb-snapshot", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill snapshot", children: [
1421
- /* @__PURE__ */ jsx3("style", { children: lifecycleSurfaceStyles }),
1422
- /* @__PURE__ */ jsx3("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs3("div", { children: [
1423
- /* @__PURE__ */ jsx3("strong", { children: "Bill snapshot" }),
1424
- /* @__PURE__ */ jsxs3("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: [
1425
2068
  "Bill #",
1426
2069
  bill.billNumber
1427
2070
  ] })
1428
2071
  ] }) }),
1429
- /* @__PURE__ */ jsx3("dl", { children: values.map(([label, value]) => /* @__PURE__ */ jsxs3("div", { children: [
1430
- /* @__PURE__ */ jsx3("dt", { children: label }),
1431
- /* @__PURE__ */ jsx3("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 })
1432
2075
  ] }, label)) })
1433
2076
  ] });
1434
2077
  }
1435
2078
  function BillRemittanceCard({ remittance, appearance, className, style }) {
1436
- return /* @__PURE__ */ jsxs3("section", { className: classes("mb-surface mb-remittance", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Remittance summary", children: [
1437
- /* @__PURE__ */ jsx3("style", { children: lifecycleSurfaceStyles }),
1438
- /* @__PURE__ */ jsx3("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs3("div", { children: [
1439
- /* @__PURE__ */ jsx3("strong", { children: "Remittance" }),
1440
- /* @__PURE__ */ jsx3("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." })
1441
2084
  ] }) }),
1442
- /* @__PURE__ */ jsxs3("dl", { children: [
1443
- /* @__PURE__ */ jsxs3("div", { children: [
1444
- /* @__PURE__ */ jsx3("dt", { children: "Payer reported" }),
1445
- /* @__PURE__ */ jsx3("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) })
1446
2089
  ] }),
1447
- /* @__PURE__ */ jsxs3("div", { children: [
1448
- /* @__PURE__ */ jsx3("dt", { children: "Posted" }),
1449
- /* @__PURE__ */ jsx3("dd", { children: currency(remittance.totalPaid) })
2090
+ /* @__PURE__ */ jsxs5("div", { children: [
2091
+ /* @__PURE__ */ jsx5("dt", { children: "Posted" }),
2092
+ /* @__PURE__ */ jsx5("dd", { children: currency(remittance.totalPaid) })
1450
2093
  ] }),
1451
- /* @__PURE__ */ jsxs3("div", { children: [
1452
- /* @__PURE__ */ jsx3("dt", { children: "Balance" }),
1453
- /* @__PURE__ */ jsx3("dd", { children: currency(remittance.balanceDue) })
2094
+ /* @__PURE__ */ jsxs5("div", { children: [
2095
+ /* @__PURE__ */ jsx5("dt", { children: "Balance" }),
2096
+ /* @__PURE__ */ jsx5("dd", { children: currency(remittance.balanceDue) })
1454
2097
  ] })
1455
2098
  ] }),
1456
- remittance.denialReason ? /* @__PURE__ */ jsxs3("div", { className: "mb-denial", children: [
1457
- /* @__PURE__ */ jsx3("strong", { children: "Denial reason" }),
1458
- /* @__PURE__ */ jsx3("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 })
1459
2102
  ] }) : null
1460
2103
  ] });
1461
2104
  }
@@ -1470,42 +2113,42 @@ function BillPayerContactCard({ delivery, appearance, className, style }) {
1470
2113
  delivery.contacts.portalUrl ? ["Portal", "Open payer portal", delivery.contacts.portalUrl] : null
1471
2114
  ].filter(Boolean);
1472
2115
  if (!delivery.payerName && !contacts.length) return null;
1473
- return /* @__PURE__ */ jsxs3("section", { className: classes("mb-surface mb-contacts", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payer contact information", children: [
1474
- /* @__PURE__ */ jsx3("style", { children: lifecycleSurfaceStyles }),
1475
- /* @__PURE__ */ jsx3("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs3("div", { children: [
1476
- /* @__PURE__ */ jsx3("strong", { children: delivery.payerName || "Claims administrator" }),
1477
- /* @__PURE__ */ jsx3("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." })
1478
2121
  ] }) }),
1479
- !contacts.length ? /* @__PURE__ */ jsx3("p", { className: "mb-empty", children: "No payer contact details are available." }) : /* @__PURE__ */ jsx3("dl", { children: contacts.map(([label, value, href]) => /* @__PURE__ */ jsxs3("div", { children: [
1480
- /* @__PURE__ */ jsx3("dt", { children: label }),
1481
- /* @__PURE__ */ jsx3("dd", { children: href ? /* @__PURE__ */ jsx3("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 })
1482
2125
  ] }, label)) })
1483
2126
  ] });
1484
2127
  }
1485
2128
  function BillPaymentLedger({ payments, appearance, className, style }) {
1486
- return /* @__PURE__ */ jsxs3("section", { className: classes("mb-surface mb-payments", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payment ledger", children: [
1487
- /* @__PURE__ */ jsx3("style", { children: lifecycleSurfaceStyles }),
1488
- /* @__PURE__ */ jsxs3("header", { className: "mb-surface-heading", children: [
1489
- /* @__PURE__ */ jsxs3("div", { children: [
1490
- /* @__PURE__ */ jsx3("strong", { children: "Payments" }),
1491
- /* @__PURE__ */ jsx3("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." })
1492
2135
  ] }),
1493
- /* @__PURE__ */ jsx3("span", { children: payments.length })
2136
+ /* @__PURE__ */ jsx5("span", { children: payments.length })
1494
2137
  ] }),
1495
- !payments.length ? /* @__PURE__ */ jsx3("p", { className: "mb-empty", children: "No payments posted." }) : /* @__PURE__ */ jsx3("div", { className: "mb-payment-list", children: payments.map((payment) => /* @__PURE__ */ jsxs3("article", { children: [
1496
- /* @__PURE__ */ jsxs3("div", { children: [
1497
- /* @__PURE__ */ jsx3("strong", { children: currency(payment.amount) }),
1498
- /* @__PURE__ */ jsxs3("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: [
1499
2142
  humanize(payment.status || "posted"),
1500
2143
  " \xB7 ",
1501
2144
  payment.method.toUpperCase()
1502
2145
  ] })
1503
2146
  ] }),
1504
- /* @__PURE__ */ jsxs3("div", { children: [
1505
- /* @__PURE__ */ jsx3("span", { children: payment.checkNumber ? `#${payment.checkNumber}` : payment.source.toUpperCase() }),
1506
- /* @__PURE__ */ jsx3("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) })
1507
2150
  ] }),
1508
- payment.note ? /* @__PURE__ */ jsx3("p", { children: payment.note }) : null
2151
+ payment.note ? /* @__PURE__ */ jsx5("p", { children: payment.note }) : null
1509
2152
  ] }, payment.id)) })
1510
2153
  ] });
1511
2154
  }
@@ -1532,11 +2175,11 @@ var lifecycleSurfaceStyles = `
1532
2175
 
1533
2176
  // src/connected-bill-lifecycle.tsx
1534
2177
  import {
1535
- useCallback as useCallback2,
1536
- useEffect as useEffect3,
1537
- useMemo as useMemo3,
1538
- useRef as useRef3,
1539
- useState as useState3
2178
+ useCallback as useCallback3,
2179
+ useEffect as useEffect4,
2180
+ useMemo as useMemo4,
2181
+ useRef as useRef4,
2182
+ useState as useState4
1540
2183
  } from "react";
1541
2184
  import {
1542
2185
  DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL2,
@@ -1544,86 +2187,70 @@ import {
1544
2187
  createBillLifecycleClient
1545
2188
  } from "@mindbill/browser";
1546
2189
  import { createBillLifecycleClient as createBillLifecycleClient2 } from "@mindbill/browser";
1547
- import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
2190
+ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1548
2191
  var DEFAULT_REFRESH_INTERVAL2 = 6e4;
1549
- function openPdf(blob, filename) {
2192
+ function downloadBlob(blob, filename, open = false) {
1550
2193
  const url = URL.createObjectURL(blob);
1551
2194
  const link = document.createElement("a");
1552
2195
  link.href = url;
1553
- link.target = "_blank";
1554
2196
  link.rel = "noopener noreferrer";
1555
2197
  link.download = filename;
2198
+ if (open) link.target = "_blank";
1556
2199
  link.click();
1557
2200
  window.setTimeout(() => URL.revokeObjectURL(url), 6e4);
1558
2201
  }
1559
2202
  function useBillLifecycle({
1560
2203
  billId: providedBillId,
1561
- create,
1562
2204
  sessionEndpoint = DEFAULT_SESSION_ENDPOINT2,
1563
2205
  getSession,
1564
2206
  apiBaseUrl = DEFAULT_API_BASE_URL2,
1565
2207
  refreshInterval = DEFAULT_REFRESH_INTERVAL2,
1566
2208
  enabled = true,
1567
2209
  initialData = null,
1568
- onBillCreated,
1569
- onBillIdChange,
1570
2210
  fetch: fetchOverride
1571
2211
  }) {
1572
- const [billId, setBillId] = useState3(providedBillId ?? null);
1573
- const [data, setData] = useState3(initialData);
1574
- const [error, setError] = useState3(null);
1575
- const [isLoading, setIsLoading] = useState3(enabled && !initialData);
1576
- const [isRefreshing, setIsRefreshing] = useState3(false);
1577
- const [isMutating, setIsMutating] = useState3(false);
1578
- const mounted = useRef3(true);
1579
- useEffect3(() => {
1580
- setBillId(providedBillId ?? null);
1581
- setData(initialData);
1582
- setError(null);
1583
- }, [initialData, providedBillId]);
1584
- const client = useMemo3(() => createBillLifecycleClient({
1585
- ...providedBillId ? { billId: providedBillId } : {},
2212
+ const [data, setData] = useState4(initialData);
2213
+ const [error, setError] = useState4(null);
2214
+ const [isLoading, setIsLoading] = useState4(enabled && !initialData);
2215
+ const [isRefreshing, setIsRefreshing] = useState4(false);
2216
+ const [isMutating, setIsMutating] = useState4(false);
2217
+ const mounted = useRef4(true);
2218
+ const client = useMemo4(() => createBillLifecycleClient({
2219
+ billId: providedBillId,
1586
2220
  sessionEndpoint,
1587
2221
  getSession,
1588
2222
  apiBaseUrl,
1589
2223
  fetch: fetchOverride
1590
2224
  }), [apiBaseUrl, fetchOverride, getSession, providedBillId, sessionEndpoint]);
1591
- useEffect3(() => {
2225
+ useEffect4(() => {
2226
+ setData(initialData);
2227
+ setError(null);
2228
+ }, [initialData, providedBillId]);
2229
+ useEffect4(() => {
1592
2230
  mounted.current = true;
1593
2231
  return () => {
1594
2232
  mounted.current = false;
1595
2233
  client.clearSession();
1596
2234
  };
1597
2235
  }, [client]);
1598
- const refresh = useCallback2(async () => {
2236
+ const refresh = useCallback3(async () => {
1599
2237
  if (!enabled) return;
1600
2238
  setIsRefreshing(true);
1601
2239
  try {
1602
- let next;
1603
- if (!client.getBillId()) {
1604
- if (!create) throw new Error("Pass billId to open a bill or create to start a new one.");
1605
- const created = await client.createBill(create);
1606
- await onBillCreated?.(created.billId, created.data);
1607
- await onBillIdChange?.(created.billId, null);
1608
- if (mounted.current) setBillId(created.billId);
1609
- next = created.data;
1610
- } else {
1611
- next = await client.getLifecycle();
1612
- }
2240
+ const next = await client.getLifecycle();
1613
2241
  if (!mounted.current) return;
1614
2242
  setData(next);
1615
2243
  setError(null);
1616
2244
  } catch (cause) {
1617
- if (!mounted.current) return;
1618
- 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."));
1619
2246
  } finally {
1620
2247
  if (mounted.current) {
1621
2248
  setIsLoading(false);
1622
2249
  setIsRefreshing(false);
1623
2250
  }
1624
2251
  }
1625
- }, [client, create, enabled, onBillCreated, onBillIdChange]);
1626
- useEffect3(() => {
2252
+ }, [client, enabled]);
2253
+ useEffect4(() => {
1627
2254
  if (!enabled) return;
1628
2255
  void refresh();
1629
2256
  const interval = refreshInterval > 0 ? window.setInterval(() => void refresh(), refreshInterval) : null;
@@ -1634,7 +2261,7 @@ function useBillLifecycle({
1634
2261
  window.removeEventListener("focus", onFocus);
1635
2262
  };
1636
2263
  }, [enabled, refresh, refreshInterval]);
1637
- const mutate = useCallback2(async (task) => {
2264
+ const mutate = useCallback3(async (task) => {
1638
2265
  setIsMutating(true);
1639
2266
  setError(null);
1640
2267
  try {
@@ -1649,475 +2276,275 @@ function useBillLifecycle({
1649
2276
  if (mounted.current) setIsMutating(false);
1650
2277
  }
1651
2278
  }, []);
1652
- const saveReview = useCallback2(
1653
- (input) => mutate(() => client.saveReview(input)),
1654
- [client, mutate]
1655
- );
1656
- const searchClaimsAdministrators = useCallback2(
1657
- (query, claimNumber) => client.searchClaimsAdministrators(query, claimNumber),
1658
- [client]
1659
- );
1660
- const getDeliveryOptions = useCallback2(
1661
- () => client.getDeliveryOptions(),
1662
- [client]
1663
- );
1664
- const submitBill = useCallback2(
1665
- (input, submission) => mutate(() => client.submitBill(input, submission)),
1666
- [client, mutate]
1667
- );
1668
- const addAttachment = useCallback2(
1669
- (file, type, description) => mutate(() => client.addAttachment(file, type, description)),
1670
- [client, mutate]
1671
- );
1672
- const removeAttachment = useCallback2(
1673
- (attachmentId) => mutate(() => client.removeAttachment(attachmentId)),
1674
- [client, mutate]
1675
- );
1676
- const closeBill = useCallback2(
1677
- (input) => mutate(() => client.closeBill(input)),
1678
- [client, mutate]
1679
- );
1680
- const postPayment = useCallback2(
1681
- (input) => mutate(() => client.postPayment(input)),
1682
- [client, mutate]
1683
- );
1684
- const submitSecondReview = useCallback2(
1685
- (input) => mutate(() => client.submitSecondReview(input)),
1686
- [client, mutate]
1687
- );
1688
- const startCorrection = useCallback2(async () => {
1689
- setIsMutating(true);
1690
- setError(null);
1691
- try {
1692
- const result = await client.startCorrection();
1693
- const previousBillId = billId;
1694
- await onBillIdChange?.(result.replacementBillId, previousBillId);
1695
- setBillId(result.replacementBillId);
1696
- setData(result.data);
1697
- return result.data;
1698
- } catch (cause) {
1699
- const nextError = cause instanceof Error ? cause : new Error("The correction could not be created.");
1700
- setError(nextError);
1701
- throw nextError;
1702
- } finally {
1703
- setIsMutating(false);
1704
- }
1705
- }, [billId, client, onBillIdChange]);
1706
- const openAttachment = useCallback2(async (attachment) => {
1707
- openPdf(await client.getAttachment(attachment.id), attachment.filename);
2279
+ const openAttachment = useCallback3(async (attachment) => {
2280
+ downloadBlob(await client.getAttachment(attachment.id), attachment.filename, true);
1708
2281
  }, [client]);
1709
- const openEor = useCallback2(async (document2) => {
1710
- openPdf(await client.getEor(document2.id), document2.filename);
2282
+ const openEor = useCallback3(async (document2) => {
2283
+ downloadBlob(await client.getEor(document2.id), document2.filename, true);
1711
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]);
1712
2289
  return {
1713
- billId,
2290
+ billId: providedBillId,
1714
2291
  data,
1715
2292
  error,
1716
2293
  isLoading,
1717
2294
  isRefreshing,
1718
2295
  isMutating,
1719
2296
  refresh,
1720
- searchClaimsAdministrators,
1721
- getDeliveryOptions,
1722
- saveReview,
1723
- submitBill,
1724
- addAttachment,
1725
- removeAttachment,
2297
+ searchClaimsAdministrators: (query, claimNumber) => client.searchClaimsAdministrators(query, claimNumber),
2298
+ getDeliveryOptions: () => client.getDeliveryOptions(),
1726
2299
  openAttachment,
1727
2300
  openEor,
1728
- closeBill,
1729
- postPayment,
1730
- submitSecondReview,
1731
- startCorrection
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))
1732
2306
  };
1733
2307
  }
1734
- function LifecycleDialog({
1735
- children,
1736
- title,
1737
- onClose
1738
- }) {
1739
- const dialog = useRef3(null);
1740
- useEffect3(() => {
2308
+ function LifecycleDialog({ children, title, onClose }) {
2309
+ const dialog = useRef4(null);
2310
+ useEffect4(() => {
1741
2311
  const previous = document.activeElement;
1742
2312
  dialog.current?.focus();
1743
- const onKeyDown = (event) => {
1744
- if (event.key === "Escape") onClose();
1745
- };
2313
+ const onKeyDown = (event) => event.key === "Escape" && onClose();
1746
2314
  document.addEventListener("keydown", onKeyDown);
1747
2315
  return () => {
1748
2316
  document.removeEventListener("keydown", onKeyDown);
1749
2317
  previous?.focus();
1750
2318
  };
1751
2319
  }, [onClose]);
1752
- return /* @__PURE__ */ jsx4("div", { className: "mb-lifecycle-dialog-backdrop", onMouseDown: (event) => {
1753
- if (event.currentTarget === event.target) onClose();
1754
- }, children: /* @__PURE__ */ jsxs4("div", { ref: dialog, className: "mb-lifecycle-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, tabIndex: -1, children: [
1755
- /* @__PURE__ */ jsx4("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" }),
1756
2322
  children
1757
2323
  ] }) });
1758
2324
  }
1759
- function dateInputValue() {
2325
+ function today() {
1760
2326
  const now = /* @__PURE__ */ new Date();
1761
- const offset = now.getTimezoneOffset() * 6e4;
1762
- return new Date(now.getTime() - offset).toISOString().slice(0, 10);
2327
+ return new Date(now.getTime() - now.getTimezoneOffset() * 6e4).toISOString().slice(0, 10);
1763
2328
  }
1764
- function SupportingDocumentControl({
1765
- disabled,
1766
- onAdd
1767
- }) {
1768
- const [file, setFile] = useState3(null);
1769
- const [type, setType] = useState3("appeal");
1770
- const [busy, setBusy] = useState3(false);
1771
- return /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-upload", children: [
1772
- /* @__PURE__ */ jsxs4("select", { "aria-label": "Supporting document type", value: type, disabled: disabled || busy, onChange: (event) => setType(event.target.value), children: [
1773
- /* @__PURE__ */ jsx4("option", { value: "appeal", children: "Second Review support" }),
1774
- /* @__PURE__ */ jsx4("option", { value: "final_report", children: "Final report" }),
1775
- /* @__PURE__ */ jsx4("option", { value: "proof_of_service", children: "Proof of service" }),
1776
- /* @__PURE__ */ jsx4("option", { value: "letter_of_attestation", children: "Letter of attestation" }),
1777
- /* @__PURE__ */ jsx4("option", { value: "form_122", children: "DWC Form 122" }),
1778
- /* @__PURE__ */ jsx4("option", { value: "w9", children: "W-9" }),
1779
- /* @__PURE__ */ jsx4("option", { value: "other", children: "Other supporting document" })
1780
- ] }),
1781
- /* @__PURE__ */ jsx4("input", { "aria-label": "Choose supporting PDF", type: "file", accept: "application/pdf,.pdf", disabled: disabled || busy, onChange: (event) => setFile(event.target.files?.[0] ?? null) }),
1782
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button secondary", disabled: disabled || busy || !file, onClick: () => {
1783
- if (!file) return;
1784
- setBusy(true);
1785
- void onAdd(file, type).then(() => setFile(null)).catch(() => void 0).finally(() => setBusy(false));
1786
- }, children: busy ? "Attaching\u2026" : "Attach PDF" })
1787
- ] });
2329
+ function stateLabel(state) {
2330
+ return state.replace(/[._-]+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
1788
2331
  }
1789
- function ConnectedBillLifecycle({
1790
- appearance,
1791
- features,
1792
- className,
1793
- style,
1794
- loadingFallback,
1795
- errorFallback,
1796
- onChanged,
1797
- ...options
1798
- }) {
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 }) {
1799
2340
  const lifecycle = useBillLifecycle(options);
1800
2341
  const { data } = lifecycle;
1801
- const [panel, setPanel] = useState3("");
1802
- const [notice, setNotice] = useState3("");
1803
- const [closeReason, setCloseReason] = useState3("");
1804
- const [payment, setPayment] = useState3({
1805
- amount: 0,
1806
- method: "check",
1807
- checkNumber: "",
1808
- depositDate: dateInputValue(),
1809
- note: ""
1810
- });
1811
- const [review, setReview] = useState3({
1812
- reason: "",
1813
- payerClaimControlNumber: "",
1814
- disputedAmount: void 0,
1815
- attachmentIds: [],
1816
- route: "ebill"
1817
- });
1818
- const lastData = useRef3(null);
1819
- const closePanel = useCallback2(() => setPanel(""), []);
1820
- useEffect3(() => {
2342
+ const [tab, setTab] = useState4("details");
2343
+ const [panel, setPanel] = useState4("");
2344
+ const [notice, setNotice] = useState4("");
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);
2349
+ useEffect4(() => {
1821
2350
  if (!data || data === lastData.current) return;
1822
2351
  lastData.current = data;
1823
2352
  onChanged?.(data);
1824
- setPayment((current) => ({
1825
- ...current,
1826
- amount: current.amount > 0 ? current.amount : data.bill.balanceDue
1827
- }));
2353
+ setPayment((current) => ({ ...current, amount: current.amount > 0 ? current.amount : data.bill.balanceDue }));
1828
2354
  setReview((current) => ({
1829
2355
  ...current,
1830
2356
  disputedAmount: current.disputedAmount ?? data.bill.balanceDue,
1831
- 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)
1832
2358
  }));
1833
2359
  }, [data, onChanged]);
1834
- if (lifecycle.isLoading && !data) {
1835
- return /* @__PURE__ */ jsx4(Fragment3, { children: loadingFallback ?? /* @__PURE__ */ jsx4("div", { className: "mb-lifecycle-loading", children: "Loading billing\u2026" }) });
1836
- }
2360
+ if (lifecycle.isLoading && !data) return /* @__PURE__ */ jsx6(Fragment4, { children: loadingFallback ?? /* @__PURE__ */ jsx6("div", { className: "mb-lifecycle-loading", children: "Loading bill\u2026" }) });
1837
2361
  if (!data) {
1838
2362
  const error = lifecycle.error ?? new Error("Bill could not be loaded.");
1839
- return /* @__PURE__ */ jsx4(Fragment3, { children: errorFallback?.(error, lifecycle.refresh) ?? /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-error", role: "alert", children: [
1840
- /* @__PURE__ */ jsx4("strong", { children: "Billing is unavailable." }),
1841
- /* @__PURE__ */ jsx4("span", { children: error.message }),
1842
- /* @__PURE__ */ jsx4("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" })
1843
2367
  ] }) });
1844
2368
  }
1845
- const actionMap = new Map(data.lifecycle.actions.map((action) => [action.id, action]));
1846
- const has = (id) => actionMap.get(id);
1847
- const selectPanel = (next) => {
1848
- setNotice("");
1849
- setPanel((current) => current === next ? "" : next);
1850
- };
1851
2369
  const complete = async (message, task) => {
1852
2370
  setNotice("");
1853
2371
  try {
1854
2372
  await task();
1855
2373
  setPanel("");
2374
+ setReason("");
1856
2375
  setNotice(message);
1857
2376
  } catch {
1858
2377
  }
1859
2378
  };
1860
- const actionButtons = data.lifecycle.actions.filter((action) => action.id !== "edit_and_submit" && action.id !== "view_eor" && action.id !== "independent_bill_review").map((action) => ({
1861
- ...action,
1862
- onClick: () => {
1863
- if (!action.enabled) return;
1864
- if (action.id === "correct_and_resubmit") selectPanel("correction");
1865
- if (action.id === "second_review") selectPanel("second_review");
1866
- if (action.id === "post_payment") selectPanel("payment");
1867
- if (action.id === "close") selectPanel("close");
1868
- },
1869
- disabled: !action.enabled || lifecycle.isMutating
1870
- }));
1871
- const canEditAndSubmit = Boolean(has("edit_and_submit"));
1872
- return /* @__PURE__ */ jsxs4("section", { className: ["mb-connected-lifecycle", className].filter(Boolean).join(" "), style: mindBillAppearanceStyle(appearance, style), children: [
1873
- /* @__PURE__ */ jsx4("style", { children: CONNECTED_LIFECYCLE_STYLES }),
1874
- /* @__PURE__ */ jsx4("style", { children: CONNECTED_THEME_OVERRIDE_STYLES }),
1875
- /* @__PURE__ */ jsx4(
1876
- BillLifecycleProgress,
1877
- {
1878
- state: data.lifecycle.state,
1879
- nativeStatus: data.lifecycle.nativeStatus,
1880
- submittedAt: data.lifecycle.submittedAt ?? null,
1881
- agingDays: data.lifecycle.agingDays ?? null,
1882
- ...appearance ? { appearance } : {}
1883
- }
1884
- ),
1885
- /* @__PURE__ */ jsx4(
1886
- BillSnapshotSummary,
1887
- {
1888
- bill: data.bill,
1889
- patient: data.patient,
1890
- injury: data.injury,
1891
- delivery: data.delivery,
1892
- ...appearance ? { appearance } : {}
1893
- }
1894
- ),
1895
- canEditAndSubmit ? /* @__PURE__ */ jsx4(
1896
- BillReviewForm,
1897
- {
1898
- data,
1899
- ...appearance ? { appearance } : {},
1900
- ...features ? { features } : {},
1901
- disabled: lifecycle.isMutating,
1902
- onSearchClaimsAdministrators: lifecycle.searchClaimsAdministrators,
1903
- onGetDeliveryOptions: lifecycle.getDeliveryOptions,
1904
- onSave: lifecycle.saveReview,
1905
- onSubmit: async (input, submission) => {
1906
- await complete("Bill submitted.", () => lifecycle.submitBill(input, submission));
1907
- },
1908
- onAddAttachment: async (file, type, description) => {
1909
- await lifecycle.addAttachment(file, type, description);
1910
- },
1911
- onRemoveAttachment: async (attachmentId) => {
1912
- await lifecycle.removeAttachment(attachmentId);
1913
- },
1914
- onOpenAttachment: (attachment) => void lifecycle.openAttachment(attachment).catch(() => void 0)
1915
- }
1916
- ) : /* @__PURE__ */ jsx4(
1917
- BillStatusSummary,
1918
- {
1919
- status: data.lifecycle.state,
1920
- submittedAt: data.lifecycle.submittedAt ?? null,
1921
- agingDays: data.lifecycle.agingDays ?? null,
1922
- updatedAt: data.lifecycle.updatedAt ?? null,
1923
- totalCharge: data.bill.totalCharge,
1924
- totalPaid: data.bill.totalPaid,
1925
- balanceDue: data.bill.balanceDue,
1926
- actions: actionButtons,
1927
- ...appearance ? { appearance } : {}
1928
- }
1929
- ),
1930
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-toolbar", children: [
1931
- /* @__PURE__ */ jsxs4("div", { children: [
1932
- /* @__PURE__ */ jsxs4("strong", { children: [
1933
- "Bill #",
1934
- 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) })
1935
2393
  ] }),
1936
- /* @__PURE__ */ jsx4("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
+ ] })
1937
2399
  ] }),
1938
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-toolbar-actions", children: [
1939
- has("view_eor") ? /* @__PURE__ */ jsx4("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,
1940
- canEditAndSubmit && has("close") ? /* @__PURE__ */ jsx4("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 })
1941
2407
  ] })
1942
2408
  ] }),
1943
- data.eors.length ? /* @__PURE__ */ jsxs4("section", { className: "mb-lifecycle-card", id: `mb-eors-${data.bill.id}`, children: [
1944
- /* @__PURE__ */ jsxs4("header", { children: [
1945
- /* @__PURE__ */ jsxs4("div", { children: [
1946
- /* @__PURE__ */ jsx4("h3", { children: "Explanation of Review" }),
1947
- /* @__PURE__ */ jsx4("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 })
2418
+ ] }),
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." })
1948
2431
  ] }),
1949
- /* @__PURE__ */ jsxs4("span", { children: [
1950
- data.eors.length,
1951
- " PDF",
1952
- data.eors.length === 1 ? "" : "s"
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))
1953
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." })
1954
2445
  ] }),
1955
- /* @__PURE__ */ jsx4("ul", { className: "mb-lifecycle-documents", children: data.eors.map((eor) => /* @__PURE__ */ jsxs4("li", { children: [
1956
- /* @__PURE__ */ jsxs4("div", { children: [
1957
- /* @__PURE__ */ jsx4("strong", { children: eor.filename }),
1958
- /* @__PURE__ */ jsx4("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 })) })
1959
2450
  ] }),
1960
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => void lifecycle.openEor(eor).catch(() => void 0), children: "View PDF" })
1961
- ] }, eor.id)) })
1962
- ] }) : null,
1963
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-detail-grid", children: [
1964
- /* @__PURE__ */ jsx4(BillRemittanceCard, { remittance: data.remittance, ...appearance ? { appearance } : {} }),
1965
- /* @__PURE__ */ jsx4(BillPayerContactCard, { delivery: data.delivery, ...appearance ? { appearance } : {} }),
1966
- /* @__PURE__ */ jsx4(BillPaymentLedger, { payments: data.payments, ...appearance ? { appearance } : {} })
1967
- ] }),
1968
- /* @__PURE__ */ jsx4(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }),
1969
- has("independent_bill_review") ? /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-info", children: [
1970
- /* @__PURE__ */ jsx4("strong", { children: has("independent_bill_review")?.label }),
1971
- /* @__PURE__ */ jsx4("span", { children: has("independent_bill_review")?.reason })
1972
- ] }) : null,
1973
- panel === "correction" ? /* @__PURE__ */ jsx4(LifecycleDialog, { title: "Correct and resubmit", onClose: closePanel, children: /* @__PURE__ */ jsxs4("section", { className: "mb-lifecycle-panel", children: [
1974
- /* @__PURE__ */ jsxs4("div", { children: [
1975
- /* @__PURE__ */ jsx4("h3", { children: "Correct and resubmit" }),
1976
- /* @__PURE__ */ jsx4("p", { children: "The rejected bill stays in history. A copied correction opens here so you can fix the rejected values and resubmit." })
1977
- ] }),
1978
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-panel-actions", children: [
1979
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
1980
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating, onClick: () => void complete("Correction created.", lifecycle.startCorrection), children: lifecycle.isMutating ? "Creating\u2026" : "Create correction" })
1981
- ] })
1982
- ] }) }) : null,
1983
- panel === "second_review" ? /* @__PURE__ */ jsx4(LifecycleDialog, { title: "Submit Second Review", onClose: closePanel, children: /* @__PURE__ */ jsxs4("section", { className: "mb-lifecycle-panel wide", children: [
1984
- /* @__PURE__ */ jsxs4("div", { children: [
1985
- /* @__PURE__ */ jsx4("h3", { children: "Submit Second Review" }),
1986
- /* @__PURE__ */ jsx4("p", { children: "State why payment is disputed, confirm the payer control number, and choose the supporting documents to send." })
1987
- ] }),
1988
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-fields two", children: [
1989
- /* @__PURE__ */ jsxs4("label", { children: [
1990
- /* @__PURE__ */ jsx4("span", { children: "Reason for Second Review" }),
1991
- /* @__PURE__ */ jsx4("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 })) })
1992
2454
  ] }),
1993
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-fields", children: [
1994
- /* @__PURE__ */ jsxs4("label", { children: [
1995
- /* @__PURE__ */ jsx4("span", { children: "Payer claim control number" }),
1996
- /* @__PURE__ */ jsx4("input", { required: true, value: review.payerClaimControlNumber, onChange: (event) => setReview((current) => ({ ...current, payerClaimControlNumber: event.target.value })) })
1997
- ] }),
1998
- /* @__PURE__ */ jsxs4("label", { children: [
1999
- /* @__PURE__ */ jsx4("span", { children: "Disputed amount" }),
2000
- /* @__PURE__ */ jsx4("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 })) })
2001
- ] }),
2002
- /* @__PURE__ */ jsxs4("label", { children: [
2003
- /* @__PURE__ */ jsx4("span", { children: "Send via" }),
2004
- /* @__PURE__ */ jsxs4("select", { value: review.route, onChange: (event) => setReview((current) => ({ ...current, route: event.target.value })), children: [
2005
- /* @__PURE__ */ jsx4("option", { value: "ebill", children: "E-bill" }),
2006
- /* @__PURE__ */ jsx4("option", { value: "fax", children: "Fax" }),
2007
- /* @__PURE__ */ jsx4("option", { value: "mail", children: "Mail" }),
2008
- /* @__PURE__ */ jsx4("option", { value: "email", children: "Email" })
2009
- ] })
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" })
2010
2466
  ] })
2011
2467
  ] })
2012
2468
  ] }),
2013
- /* @__PURE__ */ jsxs4("fieldset", { className: "mb-lifecycle-packet", children: [
2014
- /* @__PURE__ */ jsx4("legend", { children: "Supporting packet" }),
2015
- data.bill.attachments.map((attachment) => /* @__PURE__ */ jsxs4("label", { children: [
2016
- /* @__PURE__ */ jsx4("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) })) }),
2017
- /* @__PURE__ */ jsxs4("span", { children: [
2018
- /* @__PURE__ */ jsx4("strong", { children: attachment.filename }),
2019
- /* @__PURE__ */ jsx4("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 })
2020
2476
  ] }),
2021
- /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => void lifecycle.openAttachment(attachment).catch(() => void 0), children: "View" }),
2022
- /* @__PURE__ */ jsx4("button", { type: "button", "aria-label": `Remove ${attachment.filename}`, onClick: () => void lifecycle.removeAttachment(attachment.id).catch(() => void 0), children: "\xD7" })
2477
+ /* @__PURE__ */ jsx6("button", { type: "button", onClick: () => void lifecycle.openAttachment(attachment).catch(() => void 0), children: "View" })
2023
2478
  ] }, attachment.id))
2024
2479
  ] }),
2025
- /* @__PURE__ */ jsx4(SupportingDocumentControl, { disabled: lifecycle.isMutating, onAdd: async (file, type, description) => {
2026
- const next = await lifecycle.addAttachment(file, type, description);
2027
- setReview((current) => ({
2028
- ...current,
2029
- attachmentIds: Array.from(/* @__PURE__ */ new Set([
2030
- ...current.attachmentIds,
2031
- ...next.bill.attachments.map((attachment) => attachment.id)
2032
- ]))
2033
- }));
2034
- } }),
2035
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-panel-actions", children: [
2036
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2037
- /* @__PURE__ */ jsx4("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" })
2038
2483
  ] })
2039
2484
  ] }) }) : null,
2040
- panel === "payment" ? /* @__PURE__ */ jsx4(LifecycleDialog, { title: "Post payment", onClose: closePanel, children: /* @__PURE__ */ jsxs4("section", { className: "mb-lifecycle-panel", children: [
2041
- /* @__PURE__ */ jsxs4("div", { children: [
2042
- /* @__PURE__ */ jsx4("h3", { children: "Post payment" }),
2043
- /* @__PURE__ */ jsx4("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." })
2044
2489
  ] }),
2045
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-fields two", children: [
2046
- /* @__PURE__ */ jsxs4("label", { children: [
2047
- /* @__PURE__ */ jsx4("span", { children: "Amount" }),
2048
- /* @__PURE__ */ jsx4("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) })) })
2049
2494
  ] }),
2050
- /* @__PURE__ */ jsxs4("label", { children: [
2051
- /* @__PURE__ */ jsx4("span", { children: "Method" }),
2052
- /* @__PURE__ */ jsxs4("select", { value: payment.method, onChange: (event) => setPayment((current) => ({ ...current, method: event.target.value })), children: [
2053
- /* @__PURE__ */ jsx4("option", { value: "check", children: "Check" }),
2054
- /* @__PURE__ */ jsx4("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" })
2055
2500
  ] })
2056
2501
  ] }),
2057
- /* @__PURE__ */ jsxs4("label", { children: [
2058
- /* @__PURE__ */ jsx4("span", { children: payment.method === "check" ? "Check number" : "EFT reference" }),
2059
- /* @__PURE__ */ jsx4("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 })) })
2060
2505
  ] }),
2061
- /* @__PURE__ */ jsxs4("label", { children: [
2062
- /* @__PURE__ */ jsx4("span", { children: "Deposit date" }),
2063
- /* @__PURE__ */ jsx4("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 })) })
2064
2509
  ] }),
2065
- /* @__PURE__ */ jsxs4("label", { className: "full", children: [
2066
- /* @__PURE__ */ jsxs4("span", { children: [
2067
- "Note ",
2068
- /* @__PURE__ */ jsx4("small", { children: "Optional" })
2069
- ] }),
2070
- /* @__PURE__ */ jsx4("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 })) })
2071
2513
  ] })
2072
2514
  ] }),
2073
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-panel-actions", children: [
2074
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2075
- /* @__PURE__ */ jsx4("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" })
2076
2518
  ] })
2077
2519
  ] }) }) : null,
2078
- panel === "close" ? /* @__PURE__ */ jsx4(LifecycleDialog, { title: "Close bill", onClose: closePanel, children: /* @__PURE__ */ jsxs4("section", { className: "mb-lifecycle-panel danger", children: [
2079
- /* @__PURE__ */ jsxs4("div", { children: [
2080
- /* @__PURE__ */ jsx4("h3", { children: "Close bill" }),
2081
- /* @__PURE__ */ jsx4("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." })
2082
2524
  ] }),
2083
- /* @__PURE__ */ jsxs4("label", { children: [
2084
- /* @__PURE__ */ jsx4("span", { children: "Reason for closing" }),
2085
- /* @__PURE__ */ jsx4("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) })
2086
2528
  ] }),
2087
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-panel-actions", children: [
2088
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2089
- /* @__PURE__ */ jsx4("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" })
2090
2532
  ] })
2091
2533
  ] }) }) : null,
2092
- notice ? /* @__PURE__ */ jsx4("div", { className: "mb-lifecycle-message success", role: "status", children: notice }) : null,
2093
- lifecycle.error ? /* @__PURE__ */ jsx4("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
2094
2536
  ] });
2095
2537
  }
2096
2538
  var CONNECTED_LIFECYCLE_STYLES = `
2097
- .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}}
2098
- `;
2099
- var CONNECTED_THEME_OVERRIDE_STYLES = `
2100
- .mb-connected-lifecycle{color:var(--mb-text);font-family:var(--mb-font,Inter,ui-sans-serif,system-ui,sans-serif)}
2101
- .mb-lifecycle-toolbar,.mb-lifecycle-card,.mb-lifecycle-panel{border-color:var(--mb-border);border-radius:var(--mb-radius);background:var(--mb-surface)}
2102
- .mb-lifecycle-panel{box-shadow:var(--mb-shadow)}
2103
- .mb-lifecycle-toolbar span,.mb-lifecycle-card p,.mb-lifecycle-panel p,.mb-lifecycle-info span{color:var(--mb-muted)}
2104
- .mb-lifecycle-button{border-color:var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text)}
2105
- .mb-lifecycle-button.primary{border-color:var(--mb-accent);background:var(--mb-accent);color:var(--mb-accent-contrast)}
2106
- .mb-lifecycle-button.primary:hover{filter:brightness(.96)}
2107
- .mb-lifecycle-button.danger{border-color:var(--mb-danger);background:var(--mb-danger);color:white}
2108
- .mb-lifecycle-card header>span,.mb-lifecycle-info,.mb-lifecycle-upload{background:var(--mb-soft)}
2109
- .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)}
2110
- .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)}
2111
- .mb-lifecycle-message,.mb-lifecycle-error,.mb-lifecycle-loading,.mb-lifecycle-upload{border-radius:var(--mb-control-radius)}
2112
- .mb-lifecycle-message.success{background:color-mix(in srgb,var(--mb-success) 10%,white);color:var(--mb-success)}
2113
- .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}}
2114
2541
  `;
2115
2542
 
2116
2543
  // src/index.tsx
2117
2544
  function widget(tagName, props) {
2118
- const ref = useRef4(null);
2545
+ const ref = useRef5(null);
2119
2546
  const { onMindBill, onMindBillError } = props;
2120
- useEffect4(() => {
2547
+ useEffect5(() => {
2121
2548
  const element = ref.current;
2122
2549
  if (!element) return;
2123
2550
  const handleEvent = (event) => onMindBill?.(event);
@@ -2154,30 +2581,39 @@ function MindBillBillReview(props) {
2154
2581
  return widget("mindbill-bill-review", props);
2155
2582
  }
2156
2583
  export {
2584
+ BILL_SUBMISSION_DOCUMENT_TYPES,
2585
+ BILL_SUBMISSION_REQUIRED_FIELDS,
2157
2586
  BillActivityTimeline,
2158
2587
  BillLifecycleActions,
2159
2588
  BillLifecycleProgress,
2160
2589
  BillPayerContactCard,
2161
2590
  BillPaymentLedger,
2591
+ BillReadOnlyForm,
2162
2592
  BillRemittanceCard,
2163
2593
  BillReviewForm,
2164
2594
  BillSnapshotSummary,
2165
2595
  BillStatusSummary,
2596
+ BillSubmissionForm,
2166
2597
  ConnectedBillLifecycle,
2167
2598
  ConnectedBillStatus,
2168
2599
  MindBillBillReview,
2169
2600
  MindBillBillTimeline,
2601
+ applyBillSubmissionEvaluationModifiers,
2170
2602
  billActivityEventLabel,
2171
2603
  billLifecycleStage,
2172
2604
  buildBillReviewSaveInput,
2173
2605
  createBillLifecycleClient2 as createBillLifecycleClient,
2174
2606
  createBillStatusClient,
2607
+ ensureTrailingBillSubmissionLine,
2175
2608
  ensureTrailingProcedureLine,
2609
+ formatBillSubmissionDate,
2176
2610
  mindBillAppearanceStyle,
2177
2611
  mindBillThemePresets,
2612
+ parseBillSubmissionDate,
2178
2613
  resolveMindBillAppearance,
2179
2614
  useBillLifecycle,
2180
2615
  useBillStatus,
2616
+ validateBillSubmission,
2181
2617
  visibleBillLifecycleActions
2182
2618
  };
2183
2619
  //# sourceMappingURL=index.js.map