@mindbill/react 0.17.0 → 0.18.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 useRef4 } 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,490 @@ 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-submission-form.tsx
1047
+ import { useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
1048
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1049
+ var BILL_SUBMISSION_DOCUMENT_TYPES = [
1050
+ "final_report",
1051
+ "proof_of_service",
1052
+ "letter_of_attestation",
1053
+ "form_122",
1054
+ "return_to_work_voucher",
1055
+ "w9",
1056
+ "medical_records",
1057
+ "appeal",
1058
+ "other"
1059
+ ];
1060
+ var BILL_SUBMISSION_REQUIRED_FIELDS = [
1061
+ "patient.firstName",
1062
+ "patient.lastName",
1063
+ "patient.address.line1",
1064
+ "patient.address.city",
1065
+ "patient.address.state",
1066
+ "patient.address.postalCode",
1067
+ "claim.claimNumber",
1068
+ "service.date",
1069
+ "serviceLines[].code",
1070
+ "serviceLines[].units"
1071
+ ];
1072
+ function validateBillSubmission(bill) {
1073
+ const errors = {};
1074
+ const required = (path, value) => {
1075
+ if (typeof value !== "string" || !value.trim()) errors[path] = "Required";
1076
+ };
1077
+ required("patient.firstName", bill.patient.firstName);
1078
+ required("patient.lastName", bill.patient.lastName);
1079
+ required("patient.address.line1", bill.patient.address.line1);
1080
+ required("patient.address.city", bill.patient.address.city);
1081
+ required("patient.address.state", bill.patient.address.state);
1082
+ required("patient.address.postalCode", bill.patient.address.postalCode);
1083
+ required("claim.claimNumber", bill.claim.claimNumber);
1084
+ required("service.date", bill.service.date);
1085
+ if (bill.patient.address.state.trim().length !== 2)
1086
+ errors["patient.address.state"] = "Use a 2-letter state code";
1087
+ if (!bill.serviceLines.length) errors.serviceLines = "Add at least one service line";
1088
+ bill.serviceLines.forEach((line, index) => {
1089
+ required(`serviceLines.${index}.code`, line.code);
1090
+ if (!Number.isInteger(line.units) || (line.units ?? 0) < 1)
1091
+ errors[`serviceLines.${index}.units`] = "Enter at least 1 unit";
1092
+ if (bill.billingMode === "professional" && (!Number.isFinite(line.charge) || (line.charge ?? 0) < 0))
1093
+ errors[`serviceLines.${index}.charge`] = "Enter the billed charge";
1094
+ });
1095
+ return { valid: Object.keys(errors).length === 0, fieldErrors: errors };
1096
+ }
1097
+ var MAX_PDF_BYTES = 25 * 1024 * 1024;
1098
+ var MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
1099
+ var MAX_DOCUMENTS = 25;
1100
+ var EMPTY_ATTACHMENTS = [];
1101
+ var documentLabels = {
1102
+ final_report: "Final report",
1103
+ proof_of_service: "Proof of service",
1104
+ letter_of_attestation: "Letter of attestation",
1105
+ form_122: "Form 122",
1106
+ return_to_work_voucher: "Return-to-work voucher",
1107
+ w9: "W-9",
1108
+ medical_records: "Medical records",
1109
+ appeal: "Appeal",
1110
+ other: "Other"
1111
+ };
1112
+ function cloneBill(bill) {
1113
+ return {
1114
+ ...bill,
1115
+ patient: { ...bill.patient, address: { ...bill.patient.address } },
1116
+ claim: {
1117
+ ...bill.claim,
1118
+ ...bill.claim.claimsAdministrator ? { claimsAdministrator: { ...bill.claim.claimsAdministrator } } : {}
1119
+ },
1120
+ service: { ...bill.service },
1121
+ ...bill.billingProvider ? {
1122
+ billingProvider: {
1123
+ ...bill.billingProvider,
1124
+ ...bill.billingProvider.address ? { address: { ...bill.billingProvider.address } } : {}
1125
+ }
1126
+ } : {},
1127
+ ...bill.renderingProvider ? { renderingProvider: { ...bill.renderingProvider } } : {},
1128
+ ...bill.serviceLocation ? {
1129
+ serviceLocation: {
1130
+ ...bill.serviceLocation,
1131
+ ...bill.serviceLocation.address ? { address: { ...bill.serviceLocation.address } } : {}
1132
+ }
1133
+ } : {},
1134
+ diagnoses: [...bill.diagnoses ?? []],
1135
+ serviceLines: bill.serviceLines.length ? bill.serviceLines.map((line) => ({
1136
+ ...line,
1137
+ modifiers: [...line.modifiers ?? []],
1138
+ diagnosisPointers: [...line.diagnosisPointers ?? []],
1139
+ units: line.units ?? 1
1140
+ })) : [{ code: "", modifiers: [], units: 1 }]
1141
+ };
1142
+ }
1143
+ var styles = {
1144
+ root: {
1145
+ display: "grid",
1146
+ gap: 18,
1147
+ color: "var(--mb-text)",
1148
+ fontFamily: "var(--mb-font)"
1149
+ },
1150
+ heading: {
1151
+ display: "flex",
1152
+ alignItems: "start",
1153
+ justifyContent: "space-between",
1154
+ gap: 20
1155
+ },
1156
+ title: { margin: 0, fontSize: 22, lineHeight: 1.2 },
1157
+ copy: { margin: "5px 0 0", color: "var(--mb-muted)", fontSize: 14 },
1158
+ requiredNote: { color: "var(--mb-muted)", fontSize: 13, whiteSpace: "nowrap" },
1159
+ section: {
1160
+ minWidth: 0,
1161
+ margin: 0,
1162
+ padding: 20,
1163
+ border: "1px solid var(--mb-border)",
1164
+ borderRadius: "var(--mb-radius)",
1165
+ background: "var(--mb-surface)",
1166
+ boxShadow: "var(--mb-shadow)"
1167
+ },
1168
+ legend: { padding: "0 8px", fontWeight: 700, fontSize: 15 },
1169
+ grid: {
1170
+ display: "grid",
1171
+ gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 210px), 1fr))",
1172
+ gap: 14
1173
+ },
1174
+ field: { display: "grid", alignContent: "start", gap: 6, minWidth: 0 },
1175
+ label: { color: "var(--mb-muted)", fontSize: 12, fontWeight: 700 },
1176
+ input: {
1177
+ boxSizing: "border-box",
1178
+ width: "100%",
1179
+ minHeight: 40,
1180
+ padding: "9px 11px",
1181
+ border: "1px solid var(--mb-border)",
1182
+ borderRadius: "var(--mb-control-radius)",
1183
+ background: "var(--mb-input)",
1184
+ color: "var(--mb-text)",
1185
+ font: "inherit"
1186
+ },
1187
+ tableWrap: { overflowX: "auto" },
1188
+ table: { width: "100%", minWidth: 610, borderCollapse: "collapse" },
1189
+ th: {
1190
+ padding: "0 8px 8px",
1191
+ color: "var(--mb-muted)",
1192
+ fontSize: 12,
1193
+ textAlign: "left"
1194
+ },
1195
+ td: { padding: "7px 8px", borderTop: "1px solid var(--mb-border)" },
1196
+ secondaryButton: {
1197
+ minHeight: 36,
1198
+ padding: "7px 11px",
1199
+ border: "1px solid var(--mb-border)",
1200
+ borderRadius: "var(--mb-control-radius)",
1201
+ background: "var(--mb-surface)",
1202
+ color: "var(--mb-text)",
1203
+ font: "inherit",
1204
+ fontWeight: 650,
1205
+ cursor: "pointer"
1206
+ },
1207
+ attachment: {
1208
+ display: "flex",
1209
+ alignItems: "center",
1210
+ justifyContent: "space-between",
1211
+ gap: 12,
1212
+ padding: "11px 0",
1213
+ borderBottom: "1px solid var(--mb-border)"
1214
+ },
1215
+ attachmentName: { display: "grid", gap: 2, minWidth: 0, flex: 1 },
1216
+ attachmentMeta: { color: "var(--mb-muted)", fontSize: 12 },
1217
+ error: {
1218
+ padding: "11px 13px",
1219
+ borderRadius: "var(--mb-control-radius)",
1220
+ background: "color-mix(in srgb, var(--mb-danger) 10%, transparent)",
1221
+ color: "var(--mb-danger)",
1222
+ fontSize: 13
1223
+ },
1224
+ actions: { display: "flex", justifyContent: "flex-end" },
1225
+ submit: {
1226
+ minWidth: 150,
1227
+ minHeight: 42,
1228
+ padding: "10px 20px",
1229
+ border: 0,
1230
+ borderRadius: "var(--mb-control-radius)",
1231
+ background: "var(--mb-accent)",
1232
+ color: "var(--mb-accent-contrast)",
1233
+ font: "inherit",
1234
+ fontWeight: 750,
1235
+ cursor: "pointer"
1236
+ }
1237
+ };
1238
+ function RequiredMark() {
1239
+ return /* @__PURE__ */ jsx2("span", { className: "required-mark", style: { color: "var(--mb-danger)" }, children: " *" });
1240
+ }
1241
+ function Field2({
1242
+ label,
1243
+ required,
1244
+ error,
1245
+ children
1246
+ }) {
1247
+ return /* @__PURE__ */ jsxs2("label", { style: styles.field, children: [
1248
+ /* @__PURE__ */ jsxs2("span", { style: styles.label, children: [
1249
+ label,
1250
+ required ? /* @__PURE__ */ jsx2(RequiredMark, {}) : null
1251
+ ] }),
1252
+ children,
1253
+ error ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: error }) : null
1254
+ ] });
1255
+ }
1256
+ function inputValue(value) {
1257
+ return value ?? "";
1258
+ }
1259
+ function BillSubmissionForm({
1260
+ initialBill,
1261
+ attachments = EMPTY_ATTACHMENTS,
1262
+ onSubmit,
1263
+ appearance,
1264
+ className = "bill-submission-form",
1265
+ style,
1266
+ disabled = false,
1267
+ submitLabel = "Submit bill",
1268
+ heading = "Bill information",
1269
+ description = "Review the bill details, add attachments, and submit."
1270
+ }) {
1271
+ const [bill, setBill] = useState2(() => cloneBill(initialBill));
1272
+ const [selectedIds, setSelectedIds] = useState2(
1273
+ () => attachments.filter((item) => item.selected !== false).map((item) => item.id)
1274
+ );
1275
+ const [uploads, setUploads] = useState2([]);
1276
+ const [errors, setErrors] = useState2({});
1277
+ const [formError, setFormError] = useState2(null);
1278
+ const [submitting, setSubmitting] = useState2(false);
1279
+ useEffect2(() => {
1280
+ setBill(cloneBill(initialBill));
1281
+ setSelectedIds(
1282
+ attachments.filter((item) => item.selected !== false).map((item) => item.id)
1283
+ );
1284
+ setUploads([]);
1285
+ setErrors({});
1286
+ setFormError(null);
1287
+ }, [initialBill, attachments]);
1288
+ const diagnoses = useMemo2(() => (bill.diagnoses ?? []).join(", "), [bill.diagnoses]);
1289
+ const locked = disabled || submitting;
1290
+ const setPatient = (patch) => setBill((current) => ({ ...current, patient: { ...current.patient, ...patch } }));
1291
+ const setOptionalPatient = (key, value) => setBill((current) => {
1292
+ const patient = { ...current.patient };
1293
+ if (value) patient[key] = value;
1294
+ else delete patient[key];
1295
+ return { ...current, patient };
1296
+ });
1297
+ const setAddress = (patch) => setBill((current) => ({
1298
+ ...current,
1299
+ patient: {
1300
+ ...current.patient,
1301
+ address: { ...current.patient.address, ...patch }
1302
+ }
1303
+ }));
1304
+ const setClaim = (patch) => setBill((current) => ({ ...current, claim: { ...current.claim, ...patch } }));
1305
+ const setOptionalClaim = (key, value) => setBill((current) => {
1306
+ const claim = { ...current.claim };
1307
+ if (value) claim[key] = value;
1308
+ else delete claim[key];
1309
+ return { ...current, claim };
1310
+ });
1311
+ const setService = (patch) => setBill((current) => ({ ...current, service: { ...current.service, ...patch } }));
1312
+ const setLine = (index, patch) => setBill((current) => ({
1313
+ ...current,
1314
+ serviceLines: current.serviceLines.map(
1315
+ (line, lineIndex) => lineIndex === index ? { ...line, ...patch } : line
1316
+ )
1317
+ }));
1318
+ const setOptionalLineNumber = (index, key, value) => setBill((current) => ({
1319
+ ...current,
1320
+ serviceLines: current.serviceLines.map((line, lineIndex) => {
1321
+ if (lineIndex !== index) return line;
1322
+ const next = { ...line };
1323
+ if (value === "") delete next[key];
1324
+ else next[key] = Number(value);
1325
+ return next;
1326
+ })
1327
+ }));
1328
+ const textInput = (value, onChange, options) => /* @__PURE__ */ jsx2(
1329
+ "input",
1330
+ {
1331
+ style: styles.input,
1332
+ value: inputValue(value),
1333
+ disabled: locked,
1334
+ onChange: (event) => onChange(event.target.value),
1335
+ ...options
1336
+ }
1337
+ );
1338
+ async function submit() {
1339
+ const validation = validateBillSubmission(bill);
1340
+ setErrors(validation.fieldErrors);
1341
+ setFormError(null);
1342
+ if (!validation.valid) {
1343
+ setFormError("Complete the required fields before submitting.");
1344
+ return;
1345
+ }
1346
+ if (selectedIds.length + uploads.length > MAX_DOCUMENTS) {
1347
+ setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1348
+ return;
1349
+ }
1350
+ setSubmitting(true);
1351
+ try {
1352
+ await onSubmit({ bill: cloneBill(bill), sourceAttachmentIds: selectedIds, uploads });
1353
+ } catch (caught) {
1354
+ setFormError(caught instanceof Error ? caught.message : "Unable to submit the bill.");
1355
+ } finally {
1356
+ setSubmitting(false);
1357
+ }
1358
+ }
1359
+ return /* @__PURE__ */ jsxs2(
1360
+ "form",
1361
+ {
1362
+ className,
1363
+ style: { ...mindBillAppearanceStyle(appearance), ...styles.root, ...style },
1364
+ onSubmit: (event) => {
1365
+ event.preventDefault();
1366
+ void submit();
1367
+ },
1368
+ noValidate: true,
1369
+ children: [
1370
+ /* @__PURE__ */ jsxs2("div", { style: styles.heading, children: [
1371
+ /* @__PURE__ */ jsxs2("div", { children: [
1372
+ /* @__PURE__ */ jsx2("h3", { style: styles.title, children: heading }),
1373
+ /* @__PURE__ */ jsx2("p", { style: styles.copy, children: description })
1374
+ ] }),
1375
+ /* @__PURE__ */ jsxs2("span", { style: styles.requiredNote, children: [
1376
+ /* @__PURE__ */ jsx2(RequiredMark, {}),
1377
+ " Required"
1378
+ ] })
1379
+ ] }),
1380
+ /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1381
+ /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Patient" }),
1382
+ /* @__PURE__ */ jsxs2("div", { style: styles.grid, children: [
1383
+ /* @__PURE__ */ jsx2(Field2, { label: "First name", required: true, error: errors["patient.firstName"], children: textInput(bill.patient.firstName, (firstName) => setPatient({ firstName }), { required: true }) }),
1384
+ /* @__PURE__ */ jsx2(Field2, { label: "Middle name", children: textInput(bill.patient.middleName, (middleName) => setPatient({ middleName })) }),
1385
+ /* @__PURE__ */ jsx2(Field2, { label: "Last name", required: true, error: errors["patient.lastName"], children: textInput(bill.patient.lastName, (lastName) => setPatient({ lastName }), { required: true }) }),
1386
+ /* @__PURE__ */ jsx2(Field2, { label: "Date of birth", children: textInput(bill.patient.dateOfBirth, (dateOfBirth) => setOptionalPatient("dateOfBirth", dateOfBirth), { type: "date" }) }),
1387
+ /* @__PURE__ */ jsx2(Field2, { label: "Phone", children: textInput(bill.patient.phone, (phone) => setPatient({ phone }), { type: "tel" }) }),
1388
+ /* @__PURE__ */ jsx2(Field2, { label: "Address", required: true, error: errors["patient.address.line1"], children: textInput(bill.patient.address.line1, (line1) => setAddress({ line1 }), { required: true }) }),
1389
+ /* @__PURE__ */ jsx2(Field2, { label: "City", required: true, error: errors["patient.address.city"], children: textInput(bill.patient.address.city, (city) => setAddress({ city }), { required: true }) }),
1390
+ /* @__PURE__ */ jsx2(Field2, { label: "State", required: true, error: errors["patient.address.state"], children: textInput(bill.patient.address.state, (state) => setAddress({ state }), { required: true, maxLength: 2 }) }),
1391
+ /* @__PURE__ */ jsx2(Field2, { label: "ZIP", required: true, error: errors["patient.address.postalCode"], children: textInput(bill.patient.address.postalCode, (postalCode) => setAddress({ postalCode }), { required: true }) })
1392
+ ] })
1393
+ ] }),
1394
+ /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1395
+ /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Claim & service" }),
1396
+ /* @__PURE__ */ jsxs2("div", { style: styles.grid, children: [
1397
+ /* @__PURE__ */ jsx2(Field2, { label: "Claim number", required: true, error: errors["claim.claimNumber"], children: textInput(bill.claim.claimNumber, (claimNumber) => setClaim({ claimNumber }), { required: true }) }),
1398
+ /* @__PURE__ */ jsx2(Field2, { label: "ADJ number", children: textInput(bill.claim.adjNumber, (adjNumber) => setClaim({ adjNumber })) }),
1399
+ /* @__PURE__ */ jsx2(Field2, { label: "Employer", children: textInput(bill.claim.employer, (employer) => setClaim({ employer })) }),
1400
+ /* @__PURE__ */ jsx2(Field2, { label: "Date of injury", children: textInput(bill.claim.dateOfInjury, (dateOfInjury) => setOptionalClaim("dateOfInjury", dateOfInjury), { type: "date" }) }),
1401
+ /* @__PURE__ */ jsx2(Field2, { label: "Claims administrator", children: textInput(bill.claim.claimsAdministrator?.name, (name) => setBill((current) => {
1402
+ const claim = { ...current.claim };
1403
+ if (name) claim.claimsAdministrator = { ...claim.claimsAdministrator, name };
1404
+ else delete claim.claimsAdministrator;
1405
+ return { ...current, claim };
1406
+ })) }),
1407
+ /* @__PURE__ */ jsx2(Field2, { label: "Service date", required: true, error: errors["service.date"], children: textInput(bill.service.date, (date) => setService({ date }), { type: "date", required: true }) }),
1408
+ /* @__PURE__ */ jsx2(Field2, { label: "Diagnoses", children: textInput(diagnoses, (value) => setBill((current) => ({ ...current, diagnoses: value.split(",").map((item) => item.trim()).filter(Boolean) })), { placeholder: "Comma-separated codes" }) })
1409
+ ] })
1410
+ ] }),
1411
+ /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1412
+ /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Providers & location" }),
1413
+ /* @__PURE__ */ jsxs2("div", { style: styles.grid, children: [
1414
+ /* @__PURE__ */ jsx2(Field2, { label: "Billing provider", children: textInput(bill.billingProvider?.name, (name) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, name } }))) }),
1415
+ /* @__PURE__ */ jsx2(Field2, { label: "Billing tax ID", children: textInput(bill.billingProvider?.taxId, (taxId) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, taxId } }))) }),
1416
+ /* @__PURE__ */ jsx2(Field2, { label: "Billing NPI", children: textInput(bill.billingProvider?.npi, (npi) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, npi } }))) }),
1417
+ /* @__PURE__ */ jsx2(Field2, { label: "Billing phone", children: textInput(bill.billingProvider?.phone, (phone) => setBill((current) => ({ ...current, billingProvider: { ...current.billingProvider, phone } }))) }),
1418
+ /* @__PURE__ */ jsx2(Field2, { label: "Rendering provider", children: textInput(bill.renderingProvider?.name, (name) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, name } }))) }),
1419
+ /* @__PURE__ */ jsx2(Field2, { label: "Specialty", children: textInput(bill.renderingProvider?.specialty, (specialty) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, specialty } }))) }),
1420
+ /* @__PURE__ */ jsx2(Field2, { label: "Rendering NPI", children: textInput(bill.renderingProvider?.npi, (npi) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, npi } }))) }),
1421
+ /* @__PURE__ */ jsx2(Field2, { label: "License number", children: textInput(bill.renderingProvider?.licenseNumber, (licenseNumber) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, licenseNumber } }))) }),
1422
+ /* @__PURE__ */ jsx2(Field2, { label: "License state", children: textInput(bill.renderingProvider?.licenseState, (licenseState) => setBill((current) => ({ ...current, renderingProvider: { ...current.renderingProvider, licenseState } })), { maxLength: 2 }) }),
1423
+ /* @__PURE__ */ jsx2(Field2, { label: "Service location", children: textInput(bill.serviceLocation?.name, (name) => setBill((current) => ({ ...current, serviceLocation: { ...current.serviceLocation, name } }))) }),
1424
+ /* @__PURE__ */ jsx2(Field2, { label: "Place of service", children: textInput(bill.serviceLocation?.placeOfServiceCode, (placeOfServiceCode) => setBill((current) => ({ ...current, serviceLocation: { ...current.serviceLocation, placeOfServiceCode } })), { maxLength: 2 }) })
1425
+ ] })
1426
+ ] }),
1427
+ /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1428
+ /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Service lines" }),
1429
+ /* @__PURE__ */ jsx2("div", { style: styles.tableWrap, children: /* @__PURE__ */ jsxs2("table", { "aria-label": "Service lines", style: styles.table, children: [
1430
+ /* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsxs2("tr", { children: [
1431
+ /* @__PURE__ */ jsxs2("th", { style: styles.th, children: [
1432
+ "Code",
1433
+ /* @__PURE__ */ jsx2(RequiredMark, {})
1434
+ ] }),
1435
+ /* @__PURE__ */ jsx2("th", { style: styles.th, children: "Modifiers" }),
1436
+ /* @__PURE__ */ jsxs2("th", { style: styles.th, children: [
1437
+ "Units",
1438
+ /* @__PURE__ */ jsx2(RequiredMark, {})
1439
+ ] }),
1440
+ bill.billingMode === "professional" ? /* @__PURE__ */ jsxs2("th", { style: styles.th, children: [
1441
+ "Charge",
1442
+ /* @__PURE__ */ jsx2(RequiredMark, {})
1443
+ ] }) : null,
1444
+ /* @__PURE__ */ jsx2("th", { style: styles.th, "aria-label": "Actions" })
1445
+ ] }) }),
1446
+ /* @__PURE__ */ jsx2("tbody", { children: bill.serviceLines.map((line, index) => /* @__PURE__ */ jsxs2("tr", { children: [
1447
+ /* @__PURE__ */ jsxs2("td", { style: styles.td, children: [
1448
+ textInput(line.code, (code) => setLine(index, { code }), { required: true }),
1449
+ errors[`serviceLines.${index}.code`] ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors[`serviceLines.${index}.code`] }) : null
1450
+ ] }),
1451
+ /* @__PURE__ */ jsx2("td", { style: styles.td, children: textInput((line.modifiers ?? []).join(", "), (value) => setLine(index, { modifiers: value.split(",").map((item) => item.trim()).filter(Boolean) })) }),
1452
+ /* @__PURE__ */ jsxs2("td", { style: styles.td, children: [
1453
+ /* @__PURE__ */ jsx2("input", { style: styles.input, type: "number", min: 1, required: true, value: line.units ?? 1, onChange: (event) => setLine(index, { units: Number(event.target.value) }) }),
1454
+ errors[`serviceLines.${index}.units`] ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors[`serviceLines.${index}.units`] }) : null
1455
+ ] }),
1456
+ bill.billingMode === "professional" ? /* @__PURE__ */ jsxs2("td", { style: styles.td, children: [
1457
+ /* @__PURE__ */ jsx2("input", { style: styles.input, type: "number", min: 0, step: "0.01", required: true, value: line.charge ?? "", onChange: (event) => setOptionalLineNumber(index, "charge", event.target.value) }),
1458
+ errors[`serviceLines.${index}.charge`] ? /* @__PURE__ */ jsx2("span", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors[`serviceLines.${index}.charge`] }) : null
1459
+ ] }) : null,
1460
+ /* @__PURE__ */ jsx2("td", { style: styles.td, children: /* @__PURE__ */ jsx2("button", { style: styles.secondaryButton, type: "button", disabled: locked || bill.serviceLines.length === 1, onClick: () => setBill((current) => ({ ...current, serviceLines: current.serviceLines.filter((_, lineIndex) => lineIndex !== index) })), children: "Remove" }) })
1461
+ ] }, index)) })
1462
+ ] }) }),
1463
+ errors.serviceLines ? /* @__PURE__ */ jsx2("p", { style: { color: "var(--mb-danger)", fontSize: 12 }, children: errors.serviceLines }) : null,
1464
+ /* @__PURE__ */ jsx2("button", { style: { ...styles.secondaryButton, marginTop: 12 }, type: "button", disabled: locked, onClick: () => setBill((current) => ({ ...current, serviceLines: [...current.serviceLines, { code: "", modifiers: [], units: 1 }] })), children: "+ Add service line" })
1465
+ ] }),
1466
+ /* @__PURE__ */ jsxs2("fieldset", { style: styles.section, disabled: locked, children: [
1467
+ /* @__PURE__ */ jsx2("legend", { style: styles.legend, children: "Attachments" }),
1468
+ attachments.map((attachment) => /* @__PURE__ */ jsxs2("label", { style: styles.attachment, children: [
1469
+ /* @__PURE__ */ jsx2("input", { type: "checkbox", checked: selectedIds.includes(attachment.id), onChange: (event) => {
1470
+ if (event.target.checked && selectedIds.length + uploads.length >= MAX_DOCUMENTS) {
1471
+ setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1472
+ return;
1473
+ }
1474
+ setSelectedIds((current) => event.target.checked ? [.../* @__PURE__ */ new Set([...current, attachment.id])] : current.filter((id) => id !== attachment.id));
1475
+ } }),
1476
+ /* @__PURE__ */ jsxs2("span", { style: styles.attachmentName, children: [
1477
+ /* @__PURE__ */ jsx2("strong", { children: attachment.fileName }),
1478
+ /* @__PURE__ */ jsx2("span", { style: styles.attachmentMeta, children: attachment.description || documentLabels[attachment.documentType] })
1479
+ ] })
1480
+ ] }, attachment.id)),
1481
+ uploads.map((upload, index) => /* @__PURE__ */ jsxs2("div", { style: styles.attachment, children: [
1482
+ /* @__PURE__ */ jsxs2("span", { style: styles.attachmentName, children: [
1483
+ /* @__PURE__ */ jsx2("strong", { children: upload.file.name }),
1484
+ /* @__PURE__ */ jsxs2("span", { style: styles.attachmentMeta, children: [
1485
+ (upload.file.size / 1024 / 1024).toFixed(1),
1486
+ " MB"
1487
+ ] })
1488
+ ] }),
1489
+ /* @__PURE__ */ jsx2("select", { style: { ...styles.input, width: 180 }, value: upload.documentType, onChange: (event) => setUploads((current) => current.map((item, itemIndex) => itemIndex === index ? { ...item, documentType: event.target.value } : item)), children: BILL_SUBMISSION_DOCUMENT_TYPES.map((type) => /* @__PURE__ */ jsx2("option", { value: type, children: documentLabels[type] }, type)) }),
1490
+ /* @__PURE__ */ jsx2("button", { style: styles.secondaryButton, type: "button", onClick: () => setUploads((current) => current.filter((_, itemIndex) => itemIndex !== index)), children: "Remove" })
1491
+ ] }, `${upload.file.name}-${index}`)),
1492
+ !attachments.length && !uploads.length ? /* @__PURE__ */ jsx2("p", { style: styles.copy, children: "No attachments added." }) : null,
1493
+ /* @__PURE__ */ jsxs2("label", { style: { ...styles.secondaryButton, display: "inline-flex", alignItems: "center", marginTop: 14 }, children: [
1494
+ "Add PDF attachments",
1495
+ /* @__PURE__ */ jsx2("input", { hidden: true, type: "file", accept: "application/pdf,.pdf", multiple: true, onChange: (event) => {
1496
+ const files = Array.from(event.target.files ?? []);
1497
+ event.target.value = "";
1498
+ setFormError(null);
1499
+ const invalid = files.find((file) => file.type !== "application/pdf" && !file.name.toLowerCase().endsWith(".pdf"));
1500
+ if (invalid) return setFormError(`${invalid.name} is not a PDF.`);
1501
+ const oversized = files.find((file) => file.size > MAX_PDF_BYTES);
1502
+ if (oversized) return setFormError(`${oversized.name} is larger than 25 MB.`);
1503
+ const nextBytes = [...uploads.map((item) => item.file), ...files].reduce((sum, file) => sum + file.size, 0);
1504
+ if (nextBytes > MAX_UPLOAD_BYTES) return setFormError("Attachments exceed the 100 MB upload limit.");
1505
+ if (selectedIds.length + uploads.length + files.length > MAX_DOCUMENTS) return setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1506
+ setUploads((current) => [...current, ...files.map((file) => ({ file, documentType: "other" }))]);
1507
+ } })
1508
+ ] })
1509
+ ] }),
1510
+ formError ? /* @__PURE__ */ jsx2("div", { style: styles.error, role: "alert", children: formError }) : null,
1511
+ /* @__PURE__ */ jsx2("div", { style: styles.actions, children: /* @__PURE__ */ jsx2("button", { style: { ...styles.submit, opacity: locked ? 0.65 : 1 }, type: "submit", disabled: locked, children: submitting ? "Submitting\u2026" : submitLabel }) })
1512
+ ]
1513
+ }
1514
+ );
1515
+ }
1516
+
1038
1517
  // src/connected-bill-status.tsx
1039
1518
  import {
1040
1519
  useCallback,
1041
- useEffect as useEffect2,
1042
- useMemo as useMemo2,
1520
+ useEffect as useEffect3,
1521
+ useMemo as useMemo3,
1043
1522
  useRef as useRef2,
1044
- useState as useState2
1523
+ useState as useState3
1045
1524
  } from "react";
1046
1525
  import {
1047
1526
  DEFAULT_API_BASE_URL,
1048
1527
  DEFAULT_SESSION_ENDPOINT
1049
1528
  } from "@mindbill/browser";
1050
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1529
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1051
1530
  var DEFAULT_REFRESH_INTERVAL = 6e4;
1052
1531
  async function responseError(response, fallback) {
1053
1532
  const body = await response.json().catch(() => null);
@@ -1180,23 +1659,23 @@ function useBillStatus({
1180
1659
  initialData = null,
1181
1660
  fetch: fetchOverride
1182
1661
  }) {
1183
- const client = useMemo2(() => createBillStatusClient({
1662
+ const client = useMemo3(() => createBillStatusClient({
1184
1663
  billId,
1185
1664
  sessionEndpoint,
1186
1665
  ...getSession ? { getSession } : {},
1187
1666
  apiBaseUrl,
1188
1667
  ...fetchOverride ? { fetch: fetchOverride } : {}
1189
1668
  }), [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);
1669
+ const [data, setData] = useState3(initialData);
1670
+ const [error, setError] = useState3(null);
1671
+ const [isLoading, setIsLoading] = useState3(enabled && !initialData);
1672
+ const [isRefreshing, setIsRefreshing] = useState3(false);
1194
1673
  const dataRef = useRef2(initialData);
1195
1674
  const initialDataRef = useRef2(initialData);
1196
1675
  initialDataRef.current = initialData;
1197
1676
  const activeControllerRef = useRef2(null);
1198
1677
  const requestSequence = useRef2(0);
1199
- useEffect2(() => {
1678
+ useEffect3(() => {
1200
1679
  const seed = initialDataRef.current;
1201
1680
  dataRef.current = seed;
1202
1681
  setData(seed);
@@ -1237,10 +1716,10 @@ function useBillStatus({
1237
1716
  }
1238
1717
  }
1239
1718
  }, [billId, client, enabled]);
1240
- useEffect2(() => {
1719
+ useEffect3(() => {
1241
1720
  if (enabled) void load();
1242
1721
  }, [enabled, load]);
1243
- useEffect2(() => {
1722
+ useEffect3(() => {
1244
1723
  if (!enabled || refreshInterval <= 0) return;
1245
1724
  const timer = window.setInterval(() => void load(), refreshInterval);
1246
1725
  const onFocus = () => void load();
@@ -1268,17 +1747,17 @@ function ConnectedBillStatus({
1268
1747
  }) {
1269
1748
  const status = useBillStatus(options);
1270
1749
  if (status.isLoading && !status.data) {
1271
- return /* @__PURE__ */ jsx2(Fragment2, { children: loadingFallback ?? /* @__PURE__ */ jsx2("div", { role: "status", children: "Loading bill status\u2026" }) });
1750
+ return /* @__PURE__ */ jsx3(Fragment2, { children: loadingFallback ?? /* @__PURE__ */ jsx3("div", { role: "status", children: "Loading bill status\u2026" }) });
1272
1751
  }
1273
1752
  if (status.error && !status.data) {
1274
- return /* @__PURE__ */ jsx2(Fragment2, { children: errorFallback?.(status.error, status.refresh) ?? /* @__PURE__ */ jsxs2("div", { role: "alert", children: [
1753
+ return /* @__PURE__ */ jsx3(Fragment2, { children: errorFallback?.(status.error, status.refresh) ?? /* @__PURE__ */ jsxs3("div", { role: "alert", children: [
1275
1754
  status.error.message,
1276
1755
  " ",
1277
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => void status.refresh(), children: "Retry" })
1756
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => void status.refresh(), children: "Retry" })
1278
1757
  ] }) });
1279
1758
  }
1280
1759
  if (!status.data) return null;
1281
- return /* @__PURE__ */ jsx2(
1760
+ return /* @__PURE__ */ jsx3(
1282
1761
  BillStatusSummary,
1283
1762
  {
1284
1763
  status: status.data.state,
@@ -1297,7 +1776,7 @@ function ConnectedBillStatus({
1297
1776
  }
1298
1777
 
1299
1778
  // src/bill-lifecycle-surfaces.tsx
1300
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1779
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1301
1780
  function visibleBillLifecycleActions(actions, showUnavailable = false) {
1302
1781
  return actions.filter((action) => action.enabled || showUnavailable);
1303
1782
  }
@@ -1312,11 +1791,11 @@ function BillLifecycleActions({
1312
1791
  }) {
1313
1792
  const visible = visibleBillLifecycleActions(actions, showUnavailable);
1314
1793
  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
1794
+ return /* @__PURE__ */ jsxs4("div", { className: classes("mb-lifecycle-actions", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill actions", children: [
1795
+ /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1796
+ visible.map((action) => /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-action", children: [
1797
+ /* @__PURE__ */ jsx4("button", { type: "button", className: action.primary ? "mb-action-button is-primary" : "mb-action-button", disabled: disabled || !action.enabled, onClick: () => onAction(action), children: action.label }),
1798
+ !action.enabled && action.reason ? /* @__PURE__ */ jsx4("span", { className: "mb-action-reason", children: action.reason }) : null
1320
1799
  ] }, action.id))
1321
1800
  ] });
1322
1801
  }
@@ -1348,21 +1827,21 @@ function defaultFormatDate(createdAt) {
1348
1827
  return new Intl.DateTimeFormat(void 0, { dateStyle: "medium", timeStyle: "short" }).format(parsed);
1349
1828
  }
1350
1829
  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." })
1830
+ return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-activity", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill activity", children: [
1831
+ /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1832
+ /* @__PURE__ */ jsxs4("header", { className: "mb-surface-heading", children: [
1833
+ /* @__PURE__ */ jsxs4("div", { children: [
1834
+ /* @__PURE__ */ jsx4("strong", { children: "Bill history" }),
1835
+ /* @__PURE__ */ jsx4("span", { children: "Submission, payer responses, follow-up, and payments." })
1357
1836
  ] }),
1358
- /* @__PURE__ */ jsx3("span", { children: events.length })
1837
+ /* @__PURE__ */ jsx4("span", { children: events.length })
1359
1838
  ] }),
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: [
1839
+ !events.length ? /* @__PURE__ */ jsx4("p", { className: "mb-activity-empty", children: emptyLabel }) : /* @__PURE__ */ jsx4("ol", { className: "mb-activity-list", children: events.map((event) => /* @__PURE__ */ jsxs4("li", { className: "mb-activity-item", children: [
1840
+ /* @__PURE__ */ jsx4("span", { className: "mb-activity-marker", "aria-hidden": "true" }),
1841
+ /* @__PURE__ */ jsxs4("div", { className: "mb-activity-content", children: [
1842
+ /* @__PURE__ */ jsx4("strong", { children: event.title ?? billActivityEventLabel(event.type) }),
1843
+ event.description ? /* @__PURE__ */ jsx4("p", { children: event.description }) : null,
1844
+ /* @__PURE__ */ jsxs4("span", { children: [
1366
1845
  formatDate(event.createdAt),
1367
1846
  event.actor ? ` \xB7 ${event.actor}` : ""
1368
1847
  ] })
@@ -1390,20 +1869,20 @@ function billLifecycleStage(state) {
1390
1869
  function BillLifecycleProgress({ state, nativeStatus, submittedAt, agingDays, appearance, className, style }) {
1391
1870
  const current = billLifecycleStage(state);
1392
1871
  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: [
1872
+ return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-progress", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill lifecycle", children: [
1873
+ /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1874
+ /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1875
+ /* @__PURE__ */ jsx4("strong", { children: humanize(nativeStatus || state) }),
1876
+ /* @__PURE__ */ jsxs4("span", { children: [
1398
1877
  submittedAt ? `Submitted ${defaultFormatDate(submittedAt)}` : "Not submitted",
1399
1878
  typeof agingDays === "number" ? ` \xB7 ${agingDays} days old` : ""
1400
1879
  ] })
1401
1880
  ] }) }),
1402
- /* @__PURE__ */ jsx3("ol", { className: "mb-progress-list", children: lifecycleStages.map((stage, index) => {
1881
+ /* @__PURE__ */ jsx4("ol", { className: "mb-progress-list", children: lifecycleStages.map((stage, index) => {
1403
1882
  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 })
1883
+ return /* @__PURE__ */ jsxs4("li", { className: `is-${status}`, "aria-current": status === "current" ? "step" : void 0, children: [
1884
+ /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: status === "complete" ? "\u2713" : index + 1 }),
1885
+ /* @__PURE__ */ jsx4("b", { children: stage.label })
1407
1886
  ] }, stage.id);
1408
1887
  }) })
1409
1888
  ] });
@@ -1417,45 +1896,45 @@ function BillSnapshotSummary({ bill, patient, injury, delivery, appearance, clas
1417
1896
  ["Charged", currency(bill.totalCharge)],
1418
1897
  ["Balance", currency(bill.balanceDue)]
1419
1898
  ];
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: [
1899
+ return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-snapshot", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill snapshot", children: [
1900
+ /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1901
+ /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1902
+ /* @__PURE__ */ jsx4("strong", { children: "Bill snapshot" }),
1903
+ /* @__PURE__ */ jsxs4("span", { children: [
1425
1904
  "Bill #",
1426
1905
  bill.billNumber
1427
1906
  ] })
1428
1907
  ] }) }),
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 })
1908
+ /* @__PURE__ */ jsx4("dl", { children: values.map(([label, value]) => /* @__PURE__ */ jsxs4("div", { children: [
1909
+ /* @__PURE__ */ jsx4("dt", { children: label }),
1910
+ /* @__PURE__ */ jsx4("dd", { children: value })
1432
1911
  ] }, label)) })
1433
1912
  ] });
1434
1913
  }
1435
1914
  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." })
1915
+ return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-remittance", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Remittance summary", children: [
1916
+ /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1917
+ /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1918
+ /* @__PURE__ */ jsx4("strong", { children: "Remittance" }),
1919
+ /* @__PURE__ */ jsx4("span", { children: "Amounts reported by the payer and posted to the bill." })
1441
1920
  ] }) }),
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) })
1921
+ /* @__PURE__ */ jsxs4("dl", { children: [
1922
+ /* @__PURE__ */ jsxs4("div", { children: [
1923
+ /* @__PURE__ */ jsx4("dt", { children: "Payer reported" }),
1924
+ /* @__PURE__ */ jsx4("dd", { children: remittance.payerReportedPaid === null ? "\u2014" : currency(remittance.payerReportedPaid) })
1446
1925
  ] }),
1447
- /* @__PURE__ */ jsxs3("div", { children: [
1448
- /* @__PURE__ */ jsx3("dt", { children: "Posted" }),
1449
- /* @__PURE__ */ jsx3("dd", { children: currency(remittance.totalPaid) })
1926
+ /* @__PURE__ */ jsxs4("div", { children: [
1927
+ /* @__PURE__ */ jsx4("dt", { children: "Posted" }),
1928
+ /* @__PURE__ */ jsx4("dd", { children: currency(remittance.totalPaid) })
1450
1929
  ] }),
1451
- /* @__PURE__ */ jsxs3("div", { children: [
1452
- /* @__PURE__ */ jsx3("dt", { children: "Balance" }),
1453
- /* @__PURE__ */ jsx3("dd", { children: currency(remittance.balanceDue) })
1930
+ /* @__PURE__ */ jsxs4("div", { children: [
1931
+ /* @__PURE__ */ jsx4("dt", { children: "Balance" }),
1932
+ /* @__PURE__ */ jsx4("dd", { children: currency(remittance.balanceDue) })
1454
1933
  ] })
1455
1934
  ] }),
1456
- remittance.denialReason ? /* @__PURE__ */ jsxs3("div", { className: "mb-denial", children: [
1457
- /* @__PURE__ */ jsx3("strong", { children: "Denial reason" }),
1458
- /* @__PURE__ */ jsx3("p", { children: remittance.denialReason })
1935
+ remittance.denialReason ? /* @__PURE__ */ jsxs4("div", { className: "mb-denial", children: [
1936
+ /* @__PURE__ */ jsx4("strong", { children: "Denial reason" }),
1937
+ /* @__PURE__ */ jsx4("p", { children: remittance.denialReason })
1459
1938
  ] }) : null
1460
1939
  ] });
1461
1940
  }
@@ -1470,42 +1949,42 @@ function BillPayerContactCard({ delivery, appearance, className, style }) {
1470
1949
  delivery.contacts.portalUrl ? ["Portal", "Open payer portal", delivery.contacts.portalUrl] : null
1471
1950
  ].filter(Boolean);
1472
1951
  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." })
1952
+ return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-contacts", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payer contact information", children: [
1953
+ /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1954
+ /* @__PURE__ */ jsx4("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs4("div", { children: [
1955
+ /* @__PURE__ */ jsx4("strong", { children: delivery.payerName || "Claims administrator" }),
1956
+ /* @__PURE__ */ jsx4("span", { children: "Billing and follow-up contacts." })
1478
1957
  ] }) }),
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 })
1958
+ !contacts.length ? /* @__PURE__ */ jsx4("p", { className: "mb-empty", children: "No payer contact details are available." }) : /* @__PURE__ */ jsx4("dl", { children: contacts.map(([label, value, href]) => /* @__PURE__ */ jsxs4("div", { children: [
1959
+ /* @__PURE__ */ jsx4("dt", { children: label }),
1960
+ /* @__PURE__ */ jsx4("dd", { children: href ? /* @__PURE__ */ jsx4("a", { href, target: label === "Portal" ? "_blank" : void 0, rel: label === "Portal" ? "noreferrer noopener" : void 0, children: value }) : value })
1482
1961
  ] }, label)) })
1483
1962
  ] });
1484
1963
  }
1485
1964
  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." })
1965
+ return /* @__PURE__ */ jsxs4("section", { className: classes("mb-surface mb-payments", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Payment ledger", children: [
1966
+ /* @__PURE__ */ jsx4("style", { children: lifecycleSurfaceStyles }),
1967
+ /* @__PURE__ */ jsxs4("header", { className: "mb-surface-heading", children: [
1968
+ /* @__PURE__ */ jsxs4("div", { children: [
1969
+ /* @__PURE__ */ jsx4("strong", { children: "Payments" }),
1970
+ /* @__PURE__ */ jsx4("span", { children: "Payments posted to this bill." })
1492
1971
  ] }),
1493
- /* @__PURE__ */ jsx3("span", { children: payments.length })
1972
+ /* @__PURE__ */ jsx4("span", { children: payments.length })
1494
1973
  ] }),
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: [
1974
+ !payments.length ? /* @__PURE__ */ jsx4("p", { className: "mb-empty", children: "No payments posted." }) : /* @__PURE__ */ jsx4("div", { className: "mb-payment-list", children: payments.map((payment) => /* @__PURE__ */ jsxs4("article", { children: [
1975
+ /* @__PURE__ */ jsxs4("div", { children: [
1976
+ /* @__PURE__ */ jsx4("strong", { children: currency(payment.amount) }),
1977
+ /* @__PURE__ */ jsxs4("span", { children: [
1499
1978
  humanize(payment.status || "posted"),
1500
1979
  " \xB7 ",
1501
1980
  payment.method.toUpperCase()
1502
1981
  ] })
1503
1982
  ] }),
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) })
1983
+ /* @__PURE__ */ jsxs4("div", { children: [
1984
+ /* @__PURE__ */ jsx4("span", { children: payment.checkNumber ? `#${payment.checkNumber}` : payment.source.toUpperCase() }),
1985
+ /* @__PURE__ */ jsx4("span", { children: payment.depositDate || defaultFormatDate(payment.postedAt) })
1507
1986
  ] }),
1508
- payment.note ? /* @__PURE__ */ jsx3("p", { children: payment.note }) : null
1987
+ payment.note ? /* @__PURE__ */ jsx4("p", { children: payment.note }) : null
1509
1988
  ] }, payment.id)) })
1510
1989
  ] });
1511
1990
  }
@@ -1533,10 +2012,10 @@ var lifecycleSurfaceStyles = `
1533
2012
  // src/connected-bill-lifecycle.tsx
1534
2013
  import {
1535
2014
  useCallback as useCallback2,
1536
- useEffect as useEffect3,
1537
- useMemo as useMemo3,
2015
+ useEffect as useEffect4,
2016
+ useMemo as useMemo4,
1538
2017
  useRef as useRef3,
1539
- useState as useState3
2018
+ useState as useState4
1540
2019
  } from "react";
1541
2020
  import {
1542
2021
  DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL2,
@@ -1544,7 +2023,7 @@ import {
1544
2023
  createBillLifecycleClient
1545
2024
  } from "@mindbill/browser";
1546
2025
  import { createBillLifecycleClient as createBillLifecycleClient2 } from "@mindbill/browser";
1547
- import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
2026
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1548
2027
  var DEFAULT_REFRESH_INTERVAL2 = 6e4;
1549
2028
  function openPdf(blob, filename) {
1550
2029
  const url = URL.createObjectURL(blob);
@@ -1558,37 +2037,33 @@ function openPdf(blob, filename) {
1558
2037
  }
1559
2038
  function useBillLifecycle({
1560
2039
  billId: providedBillId,
1561
- create,
1562
2040
  sessionEndpoint = DEFAULT_SESSION_ENDPOINT2,
1563
2041
  getSession,
1564
2042
  apiBaseUrl = DEFAULT_API_BASE_URL2,
1565
2043
  refreshInterval = DEFAULT_REFRESH_INTERVAL2,
1566
2044
  enabled = true,
1567
2045
  initialData = null,
1568
- onBillCreated,
1569
- onBillIdChange,
1570
2046
  fetch: fetchOverride
1571
2047
  }) {
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);
2048
+ const billId = providedBillId;
2049
+ const [data, setData] = useState4(initialData);
2050
+ const [error, setError] = useState4(null);
2051
+ const [isLoading, setIsLoading] = useState4(enabled && !initialData);
2052
+ const [isRefreshing, setIsRefreshing] = useState4(false);
2053
+ const [isMutating, setIsMutating] = useState4(false);
1578
2054
  const mounted = useRef3(true);
1579
- useEffect3(() => {
1580
- setBillId(providedBillId ?? null);
2055
+ useEffect4(() => {
1581
2056
  setData(initialData);
1582
2057
  setError(null);
1583
2058
  }, [initialData, providedBillId]);
1584
- const client = useMemo3(() => createBillLifecycleClient({
1585
- ...providedBillId ? { billId: providedBillId } : {},
2059
+ const client = useMemo4(() => createBillLifecycleClient({
2060
+ billId: providedBillId,
1586
2061
  sessionEndpoint,
1587
2062
  getSession,
1588
2063
  apiBaseUrl,
1589
2064
  fetch: fetchOverride
1590
2065
  }), [apiBaseUrl, fetchOverride, getSession, providedBillId, sessionEndpoint]);
1591
- useEffect3(() => {
2066
+ useEffect4(() => {
1592
2067
  mounted.current = true;
1593
2068
  return () => {
1594
2069
  mounted.current = false;
@@ -1599,17 +2074,7 @@ function useBillLifecycle({
1599
2074
  if (!enabled) return;
1600
2075
  setIsRefreshing(true);
1601
2076
  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
- }
2077
+ const next = await client.getLifecycle();
1613
2078
  if (!mounted.current) return;
1614
2079
  setData(next);
1615
2080
  setError(null);
@@ -1622,8 +2087,8 @@ function useBillLifecycle({
1622
2087
  setIsRefreshing(false);
1623
2088
  }
1624
2089
  }
1625
- }, [client, create, enabled, onBillCreated, onBillIdChange]);
1626
- useEffect3(() => {
2090
+ }, [client, enabled]);
2091
+ useEffect4(() => {
1627
2092
  if (!enabled) return;
1628
2093
  void refresh();
1629
2094
  const interval = refreshInterval > 0 ? window.setInterval(() => void refresh(), refreshInterval) : null;
@@ -1649,10 +2114,6 @@ function useBillLifecycle({
1649
2114
  if (mounted.current) setIsMutating(false);
1650
2115
  }
1651
2116
  }, []);
1652
- const saveReview = useCallback2(
1653
- (input) => mutate(() => client.saveReview(input)),
1654
- [client, mutate]
1655
- );
1656
2117
  const searchClaimsAdministrators = useCallback2(
1657
2118
  (query, claimNumber) => client.searchClaimsAdministrators(query, claimNumber),
1658
2119
  [client]
@@ -1661,18 +2122,6 @@ function useBillLifecycle({
1661
2122
  () => client.getDeliveryOptions(),
1662
2123
  [client]
1663
2124
  );
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
2125
  const closeBill = useCallback2(
1677
2126
  (input) => mutate(() => client.closeBill(input)),
1678
2127
  [client, mutate]
@@ -1685,24 +2134,6 @@ function useBillLifecycle({
1685
2134
  (input) => mutate(() => client.submitSecondReview(input)),
1686
2135
  [client, mutate]
1687
2136
  );
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
2137
  const openAttachment = useCallback2(async (attachment) => {
1707
2138
  openPdf(await client.getAttachment(attachment.id), attachment.filename);
1708
2139
  }, [client]);
@@ -1719,16 +2150,11 @@ function useBillLifecycle({
1719
2150
  refresh,
1720
2151
  searchClaimsAdministrators,
1721
2152
  getDeliveryOptions,
1722
- saveReview,
1723
- submitBill,
1724
- addAttachment,
1725
- removeAttachment,
1726
2153
  openAttachment,
1727
2154
  openEor,
1728
2155
  closeBill,
1729
2156
  postPayment,
1730
- submitSecondReview,
1731
- startCorrection
2157
+ submitSecondReview
1732
2158
  };
1733
2159
  }
1734
2160
  function LifecycleDialog({
@@ -1737,7 +2163,7 @@ function LifecycleDialog({
1737
2163
  onClose
1738
2164
  }) {
1739
2165
  const dialog = useRef3(null);
1740
- useEffect3(() => {
2166
+ useEffect4(() => {
1741
2167
  const previous = document.activeElement;
1742
2168
  dialog.current?.focus();
1743
2169
  const onKeyDown = (event) => {
@@ -1749,10 +2175,10 @@ function LifecycleDialog({
1749
2175
  previous?.focus();
1750
2176
  };
1751
2177
  }, [onClose]);
1752
- return /* @__PURE__ */ jsx4("div", { className: "mb-lifecycle-dialog-backdrop", onMouseDown: (event) => {
2178
+ return /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-dialog-backdrop", onMouseDown: (event) => {
1753
2179
  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" }),
2180
+ }, children: /* @__PURE__ */ jsxs5("div", { ref: dialog, className: "mb-lifecycle-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, tabIndex: -1, children: [
2181
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-dialog-close", "aria-label": "Close", onClick: onClose, children: "\xD7" }),
1756
2182
  children
1757
2183
  ] }) });
1758
2184
  }
@@ -1761,34 +2187,8 @@ function dateInputValue() {
1761
2187
  const offset = now.getTimezoneOffset() * 6e4;
1762
2188
  return new Date(now.getTime() - offset).toISOString().slice(0, 10);
1763
2189
  }
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
- ] });
1788
- }
1789
2190
  function ConnectedBillLifecycle({
1790
2191
  appearance,
1791
- features,
1792
2192
  className,
1793
2193
  style,
1794
2194
  loadingFallback,
@@ -1798,17 +2198,17 @@ function ConnectedBillLifecycle({
1798
2198
  }) {
1799
2199
  const lifecycle = useBillLifecycle(options);
1800
2200
  const { data } = lifecycle;
1801
- const [panel, setPanel] = useState3("");
1802
- const [notice, setNotice] = useState3("");
1803
- const [closeReason, setCloseReason] = useState3("");
1804
- const [payment, setPayment] = useState3({
2201
+ const [panel, setPanel] = useState4("");
2202
+ const [notice, setNotice] = useState4("");
2203
+ const [closeReason, setCloseReason] = useState4("");
2204
+ const [payment, setPayment] = useState4({
1805
2205
  amount: 0,
1806
2206
  method: "check",
1807
2207
  checkNumber: "",
1808
2208
  depositDate: dateInputValue(),
1809
2209
  note: ""
1810
2210
  });
1811
- const [review, setReview] = useState3({
2211
+ const [review, setReview] = useState4({
1812
2212
  reason: "",
1813
2213
  payerClaimControlNumber: "",
1814
2214
  disputedAmount: void 0,
@@ -1817,7 +2217,7 @@ function ConnectedBillLifecycle({
1817
2217
  });
1818
2218
  const lastData = useRef3(null);
1819
2219
  const closePanel = useCallback2(() => setPanel(""), []);
1820
- useEffect3(() => {
2220
+ useEffect4(() => {
1821
2221
  if (!data || data === lastData.current) return;
1822
2222
  lastData.current = data;
1823
2223
  onChanged?.(data);
@@ -1832,14 +2232,14 @@ function ConnectedBillLifecycle({
1832
2232
  }));
1833
2233
  }, [data, onChanged]);
1834
2234
  if (lifecycle.isLoading && !data) {
1835
- return /* @__PURE__ */ jsx4(Fragment3, { children: loadingFallback ?? /* @__PURE__ */ jsx4("div", { className: "mb-lifecycle-loading", children: "Loading billing\u2026" }) });
2235
+ return /* @__PURE__ */ jsx5(Fragment3, { children: loadingFallback ?? /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-loading", children: "Loading billing\u2026" }) });
1836
2236
  }
1837
2237
  if (!data) {
1838
2238
  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" })
2239
+ return /* @__PURE__ */ jsx5(Fragment3, { children: errorFallback?.(error, lifecycle.refresh) ?? /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-error", role: "alert", children: [
2240
+ /* @__PURE__ */ jsx5("strong", { children: "Billing is unavailable." }),
2241
+ /* @__PURE__ */ jsx5("span", { children: error.message }),
2242
+ /* @__PURE__ */ jsx5("button", { type: "button", onClick: () => void lifecycle.refresh(), children: "Try again" })
1843
2243
  ] }) });
1844
2244
  }
1845
2245
  const actionMap = new Map(data.lifecycle.actions.map((action) => [action.id, action]));
@@ -1857,22 +2257,20 @@ function ConnectedBillLifecycle({
1857
2257
  } catch {
1858
2258
  }
1859
2259
  };
1860
- const actionButtons = data.lifecycle.actions.filter((action) => action.id !== "edit_and_submit" && action.id !== "view_eor" && action.id !== "independent_bill_review").map((action) => ({
2260
+ const actionButtons = data.lifecycle.actions.filter((action) => action.id !== "view_eor" && action.id !== "independent_bill_review").map((action) => ({
1861
2261
  ...action,
1862
2262
  onClick: () => {
1863
2263
  if (!action.enabled) return;
1864
- if (action.id === "correct_and_resubmit") selectPanel("correction");
1865
2264
  if (action.id === "second_review") selectPanel("second_review");
1866
2265
  if (action.id === "post_payment") selectPanel("payment");
1867
2266
  if (action.id === "close") selectPanel("close");
1868
2267
  },
1869
2268
  disabled: !action.enabled || lifecycle.isMutating
1870
2269
  }));
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(
2270
+ return /* @__PURE__ */ jsxs5("section", { className: ["mb-connected-lifecycle", className].filter(Boolean).join(" "), style: mindBillAppearanceStyle(appearance, style), children: [
2271
+ /* @__PURE__ */ jsx5("style", { children: CONNECTED_LIFECYCLE_STYLES }),
2272
+ /* @__PURE__ */ jsx5("style", { children: CONNECTED_THEME_OVERRIDE_STYLES }),
2273
+ /* @__PURE__ */ jsx5(
1876
2274
  BillLifecycleProgress,
1877
2275
  {
1878
2276
  state: data.lifecycle.state,
@@ -1882,7 +2280,7 @@ function ConnectedBillLifecycle({
1882
2280
  ...appearance ? { appearance } : {}
1883
2281
  }
1884
2282
  ),
1885
- /* @__PURE__ */ jsx4(
2283
+ /* @__PURE__ */ jsx5(
1886
2284
  BillSnapshotSummary,
1887
2285
  {
1888
2286
  bill: data.bill,
@@ -1892,28 +2290,7 @@ function ConnectedBillLifecycle({
1892
2290
  ...appearance ? { appearance } : {}
1893
2291
  }
1894
2292
  ),
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(
2293
+ /* @__PURE__ */ jsx5(
1917
2294
  BillStatusSummary,
1918
2295
  {
1919
2296
  status: data.lifecycle.state,
@@ -1927,170 +2304,149 @@ function ConnectedBillLifecycle({
1927
2304
  ...appearance ? { appearance } : {}
1928
2305
  }
1929
2306
  ),
1930
- /* @__PURE__ */ jsxs4("div", { className: "mb-lifecycle-toolbar", children: [
1931
- /* @__PURE__ */ jsxs4("div", { children: [
1932
- /* @__PURE__ */ jsxs4("strong", { children: [
2307
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-toolbar", children: [
2308
+ /* @__PURE__ */ jsxs5("div", { children: [
2309
+ /* @__PURE__ */ jsxs5("strong", { children: [
1933
2310
  "Bill #",
1934
2311
  data.bill.billNumber
1935
2312
  ] }),
1936
- /* @__PURE__ */ jsx4("span", { children: lifecycle.isRefreshing ? "Refreshing\u2026" : "Status and actions update automatically." })
2313
+ /* @__PURE__ */ jsx5("span", { children: lifecycle.isRefreshing ? "Refreshing\u2026" : "Status and actions update automatically." })
1937
2314
  ] }),
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
2315
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-toolbar-actions", children: [
2316
+ has("view_eor") ? /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => document.getElementById(`mb-eors-${data.bill.id}`)?.scrollIntoView({ behavior: "smooth", block: "center" }), children: "View EOR" }) : null,
2317
+ has("close") ? /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button quiet", onClick: () => selectPanel("close"), children: "Close bill" }) : null
1941
2318
  ] })
1942
2319
  ] }),
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." })
2320
+ data.eors.length ? /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-card", id: `mb-eors-${data.bill.id}`, children: [
2321
+ /* @__PURE__ */ jsxs5("header", { children: [
2322
+ /* @__PURE__ */ jsxs5("div", { children: [
2323
+ /* @__PURE__ */ jsx5("h3", { children: "Explanation of Review" }),
2324
+ /* @__PURE__ */ jsx5("p", { children: "Review the payer response and original PDF before posting payment." })
1948
2325
  ] }),
1949
- /* @__PURE__ */ jsxs4("span", { children: [
2326
+ /* @__PURE__ */ jsxs5("span", { children: [
1950
2327
  data.eors.length,
1951
2328
  " PDF",
1952
2329
  data.eors.length === 1 ? "" : "s"
1953
2330
  ] })
1954
2331
  ] }),
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()}` })
2332
+ /* @__PURE__ */ jsx5("ul", { className: "mb-lifecycle-documents", children: data.eors.map((eor) => /* @__PURE__ */ jsxs5("li", { children: [
2333
+ /* @__PURE__ */ jsxs5("div", { children: [
2334
+ /* @__PURE__ */ jsx5("strong", { children: eor.filename }),
2335
+ /* @__PURE__ */ jsx5("span", { children: eor.description || `Added ${new Date(eor.addedAt).toLocaleDateString()}` })
1959
2336
  ] }),
1960
- /* @__PURE__ */ jsx4("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => void lifecycle.openEor(eor).catch(() => void 0), children: "View PDF" })
2337
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => void lifecycle.openEor(eor).catch(() => void 0), children: "View PDF" })
1961
2338
  ] }, eor.id)) })
1962
2339
  ] }) : 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 } : {} })
2340
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-detail-grid", children: [
2341
+ /* @__PURE__ */ jsx5(BillRemittanceCard, { remittance: data.remittance, ...appearance ? { appearance } : {} }),
2342
+ /* @__PURE__ */ jsx5(BillPayerContactCard, { delivery: data.delivery, ...appearance ? { appearance } : {} }),
2343
+ /* @__PURE__ */ jsx5(BillPaymentLedger, { payments: data.payments, ...appearance ? { appearance } : {} })
1967
2344
  ] }),
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 })
2345
+ /* @__PURE__ */ jsx5(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }),
2346
+ has("independent_bill_review") ? /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-info", children: [
2347
+ /* @__PURE__ */ jsx5("strong", { children: has("independent_bill_review")?.label }),
2348
+ /* @__PURE__ */ jsx5("span", { children: has("independent_bill_review")?.reason })
1972
2349
  ] }) : 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." })
2350
+ panel === "second_review" ? /* @__PURE__ */ jsx5(LifecycleDialog, { title: "Submit Second Review", onClose: closePanel, children: /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-panel wide", children: [
2351
+ /* @__PURE__ */ jsxs5("div", { children: [
2352
+ /* @__PURE__ */ jsx5("h3", { children: "Submit Second Review" }),
2353
+ /* @__PURE__ */ jsx5("p", { children: "State why payment is disputed, confirm the payer control number, and choose the supporting documents to send." })
1977
2354
  ] }),
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 })) })
2355
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-fields two", children: [
2356
+ /* @__PURE__ */ jsxs5("label", { children: [
2357
+ /* @__PURE__ */ jsx5("span", { children: "Reason for Second Review" }),
2358
+ /* @__PURE__ */ jsx5("textarea", { required: true, value: review.reason, onChange: (event) => setReview((current) => ({ ...current, reason: event.target.value })) })
1992
2359
  ] }),
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 })) })
2360
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-fields", children: [
2361
+ /* @__PURE__ */ jsxs5("label", { children: [
2362
+ /* @__PURE__ */ jsx5("span", { children: "Payer claim control number" }),
2363
+ /* @__PURE__ */ jsx5("input", { required: true, value: review.payerClaimControlNumber, onChange: (event) => setReview((current) => ({ ...current, payerClaimControlNumber: event.target.value })) })
1997
2364
  ] }),
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 })) })
2365
+ /* @__PURE__ */ jsxs5("label", { children: [
2366
+ /* @__PURE__ */ jsx5("span", { children: "Disputed amount" }),
2367
+ /* @__PURE__ */ jsx5("input", { type: "number", min: "0.01", step: "0.01", value: review.disputedAmount ?? "", onChange: (event) => setReview((current) => ({ ...current, disputedAmount: event.target.value ? Number(event.target.value) : void 0 })) })
2001
2368
  ] }),
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" })
2369
+ /* @__PURE__ */ jsxs5("label", { children: [
2370
+ /* @__PURE__ */ jsx5("span", { children: "Send via" }),
2371
+ /* @__PURE__ */ jsxs5("select", { value: review.route, onChange: (event) => setReview((current) => ({ ...current, route: event.target.value })), children: [
2372
+ /* @__PURE__ */ jsx5("option", { value: "ebill", children: "E-bill" }),
2373
+ /* @__PURE__ */ jsx5("option", { value: "fax", children: "Fax" }),
2374
+ /* @__PURE__ */ jsx5("option", { value: "mail", children: "Mail" }),
2375
+ /* @__PURE__ */ jsx5("option", { value: "email", children: "Email" })
2009
2376
  ] })
2010
2377
  ] })
2011
2378
  ] })
2012
2379
  ] }),
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 })
2380
+ /* @__PURE__ */ jsxs5("fieldset", { className: "mb-lifecycle-packet", children: [
2381
+ /* @__PURE__ */ jsx5("legend", { children: "Supporting packet" }),
2382
+ data.bill.attachments.map((attachment) => /* @__PURE__ */ jsxs5("label", { children: [
2383
+ /* @__PURE__ */ jsx5("input", { type: "checkbox", checked: review.attachmentIds.includes(attachment.id), onChange: (event) => setReview((current) => ({ ...current, attachmentIds: event.target.checked ? [...current.attachmentIds, attachment.id] : current.attachmentIds.filter((id) => id !== attachment.id) })) }),
2384
+ /* @__PURE__ */ jsxs5("span", { children: [
2385
+ /* @__PURE__ */ jsx5("strong", { children: attachment.filename }),
2386
+ /* @__PURE__ */ jsx5("small", { children: attachment.description || attachment.documentType })
2020
2387
  ] }),
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" })
2388
+ /* @__PURE__ */ jsx5("button", { type: "button", onClick: () => void lifecycle.openAttachment(attachment).catch(() => void 0), children: "View" })
2023
2389
  ] }, attachment.id))
2024
2390
  ] }),
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" })
2391
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-panel-actions", children: [
2392
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2393
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || !review.reason.trim() || !review.payerClaimControlNumber.trim(), onClick: () => void complete("Second Review submitted.", () => lifecycle.submitSecondReview(review)), children: lifecycle.isMutating ? "Submitting\u2026" : "Submit Second Review" })
2038
2394
  ] })
2039
2395
  ] }) }) : 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." })
2396
+ panel === "payment" ? /* @__PURE__ */ jsx5(LifecycleDialog, { title: "Post payment", onClose: closePanel, children: /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-panel", children: [
2397
+ /* @__PURE__ */ jsxs5("div", { children: [
2398
+ /* @__PURE__ */ jsx5("h3", { children: "Post payment" }),
2399
+ /* @__PURE__ */ jsx5("p", { children: "Record funds shown on the EOR. The balance updates and the bill closes automatically when configured." })
2044
2400
  ] }),
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) })) })
2401
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-fields two", children: [
2402
+ /* @__PURE__ */ jsxs5("label", { children: [
2403
+ /* @__PURE__ */ jsx5("span", { children: "Amount" }),
2404
+ /* @__PURE__ */ jsx5("input", { type: "number", min: "0.01", max: data.bill.balanceDue, step: "0.01", required: true, value: payment.amount || "", onChange: (event) => setPayment((current) => ({ ...current, amount: Number(event.target.value) })) })
2049
2405
  ] }),
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" })
2406
+ /* @__PURE__ */ jsxs5("label", { children: [
2407
+ /* @__PURE__ */ jsx5("span", { children: "Method" }),
2408
+ /* @__PURE__ */ jsxs5("select", { value: payment.method, onChange: (event) => setPayment((current) => ({ ...current, method: event.target.value })), children: [
2409
+ /* @__PURE__ */ jsx5("option", { value: "check", children: "Check" }),
2410
+ /* @__PURE__ */ jsx5("option", { value: "eft", children: "EFT" })
2055
2411
  ] })
2056
2412
  ] }),
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 })) })
2413
+ /* @__PURE__ */ jsxs5("label", { children: [
2414
+ /* @__PURE__ */ jsx5("span", { children: payment.method === "check" ? "Check number" : "EFT reference" }),
2415
+ /* @__PURE__ */ jsx5("input", { value: payment.checkNumber, onChange: (event) => setPayment((current) => ({ ...current, checkNumber: event.target.value })) })
2060
2416
  ] }),
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 })) })
2417
+ /* @__PURE__ */ jsxs5("label", { children: [
2418
+ /* @__PURE__ */ jsx5("span", { children: "Deposit date" }),
2419
+ /* @__PURE__ */ jsx5("input", { type: "date", required: true, value: payment.depositDate, onChange: (event) => setPayment((current) => ({ ...current, depositDate: event.target.value })) })
2064
2420
  ] }),
2065
- /* @__PURE__ */ jsxs4("label", { className: "full", children: [
2066
- /* @__PURE__ */ jsxs4("span", { children: [
2421
+ /* @__PURE__ */ jsxs5("label", { className: "full", children: [
2422
+ /* @__PURE__ */ jsxs5("span", { children: [
2067
2423
  "Note ",
2068
- /* @__PURE__ */ jsx4("small", { children: "Optional" })
2424
+ /* @__PURE__ */ jsx5("small", { children: "Optional" })
2069
2425
  ] }),
2070
- /* @__PURE__ */ jsx4("input", { value: payment.note, onChange: (event) => setPayment((current) => ({ ...current, note: event.target.value })) })
2426
+ /* @__PURE__ */ jsx5("input", { value: payment.note, onChange: (event) => setPayment((current) => ({ ...current, note: event.target.value })) })
2071
2427
  ] })
2072
2428
  ] }),
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" })
2429
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-panel-actions", children: [
2430
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2431
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || payment.amount <= 0 || payment.amount > data.bill.balanceDue || !payment.depositDate, onClick: () => void complete("Payment posted.", () => lifecycle.postPayment(payment)), children: lifecycle.isMutating ? "Posting\u2026" : "Post payment" })
2076
2432
  ] })
2077
2433
  ] }) }) : 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." })
2434
+ panel === "close" ? /* @__PURE__ */ jsx5(LifecycleDialog, { title: "Close bill", onClose: closePanel, children: /* @__PURE__ */ jsxs5("section", { className: "mb-lifecycle-panel danger", children: [
2435
+ /* @__PURE__ */ jsxs5("div", { children: [
2436
+ /* @__PURE__ */ jsx5("h3", { children: "Close bill" }),
2437
+ /* @__PURE__ */ jsx5("p", { children: "Closing removes this bill from active A/R. Any remaining balance will be written off and the original lifecycle is preserved." })
2082
2438
  ] }),
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) })
2439
+ /* @__PURE__ */ jsxs5("label", { children: [
2440
+ /* @__PURE__ */ jsx5("span", { children: "Reason for closing" }),
2441
+ /* @__PURE__ */ jsx5("textarea", { required: true, value: closeReason, onChange: (event) => setCloseReason(event.target.value) })
2086
2442
  ] }),
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" })
2443
+ /* @__PURE__ */ jsxs5("div", { className: "mb-lifecycle-panel-actions", children: [
2444
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: closePanel, children: "Cancel" }),
2445
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "mb-lifecycle-button danger", disabled: lifecycle.isMutating || !closeReason.trim(), onClick: () => void complete("Bill closed.", () => lifecycle.closeBill({ reason: closeReason })), children: lifecycle.isMutating ? "Closing\u2026" : "Close bill" })
2090
2446
  ] })
2091
2447
  ] }) }) : 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
2448
+ notice ? /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-message success", role: "status", children: notice }) : null,
2449
+ lifecycle.error ? /* @__PURE__ */ jsx5("div", { className: "mb-lifecycle-message error", role: "alert", children: lifecycle.error.message }) : null
2094
2450
  ] });
2095
2451
  }
2096
2452
  var CONNECTED_LIFECYCLE_STYLES = `
@@ -2117,7 +2473,7 @@ var CONNECTED_THEME_OVERRIDE_STYLES = `
2117
2473
  function widget(tagName, props) {
2118
2474
  const ref = useRef4(null);
2119
2475
  const { onMindBill, onMindBillError } = props;
2120
- useEffect4(() => {
2476
+ useEffect5(() => {
2121
2477
  const element = ref.current;
2122
2478
  if (!element) return;
2123
2479
  const handleEvent = (event) => onMindBill?.(event);
@@ -2154,6 +2510,8 @@ function MindBillBillReview(props) {
2154
2510
  return widget("mindbill-bill-review", props);
2155
2511
  }
2156
2512
  export {
2513
+ BILL_SUBMISSION_DOCUMENT_TYPES,
2514
+ BILL_SUBMISSION_REQUIRED_FIELDS,
2157
2515
  BillActivityTimeline,
2158
2516
  BillLifecycleActions,
2159
2517
  BillLifecycleProgress,
@@ -2163,6 +2521,7 @@ export {
2163
2521
  BillReviewForm,
2164
2522
  BillSnapshotSummary,
2165
2523
  BillStatusSummary,
2524
+ BillSubmissionForm,
2166
2525
  ConnectedBillLifecycle,
2167
2526
  ConnectedBillStatus,
2168
2527
  MindBillBillReview,
@@ -2178,6 +2537,7 @@ export {
2178
2537
  resolveMindBillAppearance,
2179
2538
  useBillLifecycle,
2180
2539
  useBillStatus,
2540
+ validateBillSubmission,
2181
2541
  visibleBillLifecycleActions
2182
2542
  };
2183
2543
  //# sourceMappingURL=index.js.map