@mindbill/react 0.42.3 → 0.43.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 useEffect10, useRef as useRef6 } from "react";
5
+ import { createElement, useEffect as useEffect11, useRef as useRef7 } from "react";
6
6
 
7
7
  // src/appearance.ts
8
8
  var mindBillThemePresets = {
@@ -2260,6 +2260,18 @@ function cloneInitialBill(bill) {
2260
2260
  cloned.diagnoses = applyBillSubmissionEvaluationDiagnoses(cloned.diagnoses, initialEvaluationType(bill));
2261
2261
  return cloned;
2262
2262
  }
2263
+ function stableInitializationValue(value) {
2264
+ if (Array.isArray(value)) return value.map(stableInitializationValue);
2265
+ if (!value || typeof value !== "object") return typeof value === "function" ? void 0 : value;
2266
+ return Object.fromEntries(Object.entries(value).filter(([, entry]) => typeof entry !== "function").sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, stableInitializationValue(entry)]));
2267
+ }
2268
+ function billSubmissionInitializationKey(initialBill, attachments = EMPTY_ATTACHMENTS, sourceClaimsAdministratorName = "") {
2269
+ return JSON.stringify(stableInitializationValue({
2270
+ attachments,
2271
+ initialBill,
2272
+ sourceClaimsAdministratorName
2273
+ }));
2274
+ }
2263
2275
  function submittedLines(lines) {
2264
2276
  return lines.filter(lineHasContent).map((line) => ({ ...line, code: line.code.trim(), modifiers: [...line.modifiers ?? []] }));
2265
2277
  }
@@ -2548,6 +2560,7 @@ function BillSubmissionForm({
2548
2560
  modifierOptions,
2549
2561
  taxonomyOptions,
2550
2562
  deliveryRoutePicker = "auto",
2563
+ deliveryRouteDialogTitle = "Send bill",
2551
2564
  attachmentReportTypeMode = "auto",
2552
2565
  attachmentReportTypes = BILL_SUBMISSION_REPORT_TYPES,
2553
2566
  defaultAttachmentReportType,
@@ -2600,6 +2613,11 @@ function BillSubmissionForm({
2600
2613
  const procedures = useMemo3(() => mergeOptions(DEFAULT_BILL_SUBMISSION_PROCEDURES, procedureOptions), [procedureOptions]);
2601
2614
  const orderedClaimsAdministratorSources = useMemo3(() => [...claimsAdministratorSources ?? []].filter((source) => source.name.trim()).sort((left, right) => Number(right.source.toLowerCase() === "eams") - Number(left.source.toLowerCase() === "eams")), [claimsAdministratorSources]);
2602
2615
  const sourceClaimsAdministratorName = orderedClaimsAdministratorSources[0]?.name.trim() ?? "";
2616
+ const initializationKey = useMemo3(
2617
+ () => billSubmissionInitializationKey(initialBill, attachments, sourceClaimsAdministratorName),
2618
+ [initialBill, attachments, sourceClaimsAdministratorName]
2619
+ );
2620
+ const previousInitializationKey = useRef2(initializationKey);
2603
2621
  const modifiers = useMemo3(() => mergeOptions(DEFAULT_BILL_SUBMISSION_MODIFIERS, modifierOptions), [modifierOptions]);
2604
2622
  const taxonomies = useMemo3(() => mergeOptions(DEFAULT_BILL_SUBMISSION_TAXONOMIES, taxonomyOptions), [taxonomyOptions]);
2605
2623
  const [evaluationType, setEvaluationType] = useState5(() => initialEvaluationType(initialBill));
@@ -2612,6 +2630,8 @@ function BillSubmissionForm({
2612
2630
  const reportTypeOptions = useMemo3(() => attachmentReportTypes.map((item) => ({ id: item.code, label: item.code.replace(/^OZ:/, ""), detail: item.label })), [attachmentReportTypes]);
2613
2631
  const missingAttachmentReportType = showAttachmentReportTypes && (selectedIds.some((id) => !(sourceAttachmentReportTypes[id] || attachments.find((item) => item.id === id)?.reportTypeCode || defaultAttachmentReportType)) || uploads.some((upload) => !(upload.reportTypeCode || defaultAttachmentReportType)));
2614
2632
  useEffect5(() => {
2633
+ if (previousInitializationKey.current === initializationKey) return;
2634
+ previousInitializationKey.current = initializationKey;
2615
2635
  setBill(cloneInitialBill(initialBill));
2616
2636
  setEvaluationType(initialEvaluationType(initialBill));
2617
2637
  setSelectedIds(attachments.map((item) => item.id));
@@ -2633,7 +2653,7 @@ function BillSubmissionForm({
2633
2653
  setPayerHasMore(true);
2634
2654
  payerRequest.current += 1;
2635
2655
  payerAppendPending.current = false;
2636
- }, [initialBill, attachments, sourceClaimsAdministratorName]);
2656
+ }, [initialBill, attachments, initializationKey]);
2637
2657
  useEffect5(() => {
2638
2658
  if (!validationActive) return;
2639
2659
  const next = validateBillSubmission(bill).fieldErrors;
@@ -2835,37 +2855,42 @@ function BillSubmissionForm({
2835
2855
  ...administrator2 ? { claimsAdministrator: submittedClaimsAdministrator(administrator2) } : {}
2836
2856
  }
2837
2857
  };
2838
- if (onSubmit) {
2839
- setSubmitting(true);
2840
- try {
2841
- await onSubmit({ bill: complete, sourceAttachmentIds: selectedIds, sourceAttachmentReportTypes, uploads });
2842
- } catch (caught) {
2843
- setFormError(caught instanceof Error ? caught.message : "Unable to submit the bill.");
2844
- } finally {
2845
- setSubmitting(false);
2846
- }
2847
- return;
2848
- }
2858
+ const value = { bill: complete, sourceAttachmentIds: selectedIds, sourceAttachmentReportTypes, uploads };
2849
2859
  if (deliveryRoutePicker !== "off" && referenceClient) {
2850
2860
  setSubmitting(true);
2851
2861
  try {
2852
2862
  const delivery = await referenceClient.getDeliveryPreview({
2853
2863
  claimsAdministratorId: complete.claim.claimsAdministrator.id,
2864
+ ...complete.claim.claimsAdministrator.payerId ? { payerId: complete.claim.claimsAdministrator.payerId } : {},
2854
2865
  ...complete.claim.injuryState ? { injuryState: complete.claim.injuryState } : {}
2855
2866
  });
2856
2867
  setSubmitting(false);
2857
2868
  setRouteError(null);
2858
- setRouteDialog({ delivery, complete });
2869
+ setRouteDialog({ delivery, value });
2859
2870
  return;
2860
- } catch {
2871
+ } catch (caught) {
2861
2872
  setSubmitting(false);
2873
+ if (deliveryRoutePicker === "required") {
2874
+ setFormError(caught instanceof Error ? caught.message : "Delivery routes could not be loaded. Nothing was sent.");
2875
+ return;
2876
+ }
2862
2877
  }
2863
2878
  }
2864
- await performConnectedSubmit(complete, void 0);
2879
+ if (deliveryRoutePicker === "required") {
2880
+ setFormError("Delivery confirmation is unavailable. Nothing was sent.");
2881
+ return;
2882
+ }
2883
+ await performSubmit(value);
2865
2884
  }
2866
- async function performConnectedSubmit(complete, submission) {
2885
+ async function performSubmit(value) {
2867
2886
  setSubmitting(true);
2868
2887
  try {
2888
+ if (onSubmit) {
2889
+ await onSubmit(value);
2890
+ setRouteDialog(null);
2891
+ setRouteError(null);
2892
+ return;
2893
+ }
2869
2894
  if (!submissionClient) throw new Error("The connected billing client is unavailable.");
2870
2895
  const documents = await prepareBillSubmissionDocuments({
2871
2896
  attachments,
@@ -2876,8 +2901,8 @@ function BillSubmissionForm({
2876
2901
  ...fetchOverride ? { fetch: fetchOverride } : {}
2877
2902
  });
2878
2903
  const result = await submissionClient.submitBill({
2879
- bill: complete,
2880
- ...submission ? { submission } : {},
2904
+ bill: value.bill,
2905
+ ...value.submission ? { submission: value.submission } : {},
2881
2906
  documents
2882
2907
  });
2883
2908
  setRouteDialog(null);
@@ -2885,7 +2910,7 @@ function BillSubmissionForm({
2885
2910
  await onSubmitted?.(result);
2886
2911
  } catch (caught) {
2887
2912
  const message = caught instanceof Error ? caught.message : "Unable to submit the bill.";
2888
- if (submission) setRouteError(message);
2913
+ if (value.submission) setRouteError(message);
2889
2914
  else setFormError(message);
2890
2915
  } finally {
2891
2916
  setSubmitting(false);
@@ -3218,7 +3243,7 @@ function BillSubmissionForm({
3218
3243
  routeDialog ? /* @__PURE__ */ jsx5(
3219
3244
  SendRouteDialog,
3220
3245
  {
3221
- title: "Send bill",
3246
+ title: deliveryRouteDialogTitle,
3222
3247
  delivery: routeDialog.delivery,
3223
3248
  submitting,
3224
3249
  error: routeError,
@@ -3229,7 +3254,7 @@ function BillSubmissionForm({
3229
3254
  }
3230
3255
  },
3231
3256
  onConfirm: (submission) => {
3232
- void performConnectedSubmit(routeDialog.complete, submission);
3257
+ void performSubmit({ ...routeDialog.value, submission });
3233
3258
  }
3234
3259
  }
3235
3260
  ) : null
@@ -3842,15 +3867,90 @@ function ribbonDate(iso) {
3842
3867
  if (Number.isNaN(parsed.getTime())) return iso;
3843
3868
  return new Intl.DateTimeFormat("en-US", { month: "2-digit", day: "2-digit", year: "numeric" }).format(parsed);
3844
3869
  }
3845
- function billSubmissionsRibbonFromHistory(history) {
3846
- return history.filter((entry) => entry.kind === "submission").map((entry) => ({
3847
- id: entry.id,
3848
- label: entry.action,
3849
- meta: [
3850
- { label: "Delivery", value: billSubmissionsRibbonDeliveryLabel(entry.summary) },
3851
- { label: "Sent", value: ribbonDate(entry.date) }
3852
- ]
3853
- }));
3870
+ function attemptStatus(entries, attempt) {
3871
+ const rejected = [...entries].reverse().find(
3872
+ (entry) => entry.kind === "ack" && (/reject|deni|error/i.test(entry.action) || entry.tone === "problem")
3873
+ );
3874
+ if (rejected) return {
3875
+ badge: rejected.action,
3876
+ badgeTone: "danger",
3877
+ meta: [{ label: "Rejected", value: ribbonDate(rejected.date) }]
3878
+ };
3879
+ const complianceDueDate = entries.flatMap((entry) => entry.details?.complianceDueDates ?? []).find((due) => /payment|working day/i.test(due.text));
3880
+ if (complianceDueDate) return {
3881
+ badge: complianceDueDate.text,
3882
+ badgeTone: "warning",
3883
+ meta: [{ label: "Effective date", value: ribbonDate(complianceDueDate.date) }]
3884
+ };
3885
+ const processed = [...entries].reverse().find((entry) => entry.kind === "eor" || entry.kind === "payment");
3886
+ if (processed) return {
3887
+ badge: "Processed",
3888
+ badgeTone: "success",
3889
+ meta: [{ label: "Processed", value: ribbonDate(processed.date) }]
3890
+ };
3891
+ const accepted = [...entries].reverse().find(
3892
+ (entry) => entry.kind === "ack" && (/accept/i.test(entry.action) || entry.tone === "success")
3893
+ );
3894
+ if (accepted) return {
3895
+ badge: accepted.action,
3896
+ badgeTone: "success",
3897
+ meta: [{ label: "Accepted", value: ribbonDate(accepted.date) }]
3898
+ };
3899
+ const closed = [...entries].reverse().find((entry) => entry.kind === "close");
3900
+ if (closed) return {
3901
+ badge: "Closed",
3902
+ badgeTone: "neutral",
3903
+ meta: [{ label: "Closed", value: ribbonDate(closed.date) }]
3904
+ };
3905
+ if (attempt?.ackLabel) return {
3906
+ badge: attempt.ackLabel,
3907
+ badgeTone: /reject|deni|error/i.test(attempt.ackLabel) ? "danger" : /accept/i.test(attempt.ackLabel) ? "success" : "neutral",
3908
+ ...attempt.ackAt ? { meta: [{ label: /reject|deni|error/i.test(attempt.ackLabel) ? "Rejected" : "Acknowledged", value: ribbonDate(attempt.ackAt) }] } : {}
3909
+ };
3910
+ if (attempt?.status) return {
3911
+ badge: attempt.status.replaceAll("_", " "),
3912
+ badgeTone: "neutral"
3913
+ };
3914
+ return {};
3915
+ }
3916
+ function billSubmissionsRibbonFromHistory(history, attempts = []) {
3917
+ if (attempts.length) {
3918
+ return attempts.map((attempt) => {
3919
+ const attemptEntries = history.filter((entry) => entry.attemptId === attempt.id);
3920
+ const submission = attemptEntries.find((entry) => entry.kind === "submission");
3921
+ const status = attemptStatus(attemptEntries, attempt);
3922
+ return {
3923
+ id: attempt.id,
3924
+ ...submission ? { historyEntryId: submission.id } : {},
3925
+ label: attempt.label,
3926
+ ...status.badge ? { badge: status.badge } : {},
3927
+ ...status.badgeTone ? { badgeTone: status.badgeTone } : {},
3928
+ meta: [
3929
+ { label: "Delivery", value: attempt.deliveryLabel ?? (submission ? billSubmissionsRibbonDeliveryLabel(submission.summary) : "\u2014") },
3930
+ { label: "Sent", value: attempt.sentAt ? ribbonDate(attempt.sentAt) : submission ? ribbonDate(submission.date) : "\u2014" },
3931
+ ...status.meta ?? []
3932
+ ],
3933
+ active: attempt.isCurrent
3934
+ };
3935
+ });
3936
+ }
3937
+ const submissions = history.map((entry, index) => ({ entry, index })).filter(({ entry }) => entry.kind === "submission");
3938
+ return submissions.map(({ entry, index }, submissionIndex) => {
3939
+ const nextSubmissionIndex = submissions[submissionIndex + 1]?.index ?? history.length;
3940
+ const status = attemptStatus(history.slice(index, nextSubmissionIndex));
3941
+ return {
3942
+ id: entry.id,
3943
+ historyEntryId: entry.id,
3944
+ label: entry.action,
3945
+ ...status.badge ? { badge: status.badge } : {},
3946
+ ...status.badgeTone ? { badgeTone: status.badgeTone } : {},
3947
+ meta: [
3948
+ { label: "Delivery", value: billSubmissionsRibbonDeliveryLabel(entry.summary) },
3949
+ { label: "Sent", value: ribbonDate(entry.date) },
3950
+ ...status.meta ?? []
3951
+ ]
3952
+ };
3953
+ });
3854
3954
  }
3855
3955
  var css7 = `
3856
3956
  .mbsr{display:flex;gap:10px;overflow-x:auto;padding-bottom:4px;color:var(--mb-text);font-family:var(--mb-font);font-size:13px}
@@ -3860,7 +3960,10 @@ var css7 = `
3860
3960
  .mbsr-chip[data-active=true]{border-color:var(--mb-accent);background:color-mix(in srgb,var(--mb-accent) 7%,var(--mb-surface));box-shadow:0 0 0 1px var(--mb-accent) inset}
3861
3961
  .mbsr-top{display:flex;align-items:center;gap:8px;min-width:0}
3862
3962
  .mbsr-label{font-size:13.5px;font-weight:760;line-height:1.3;overflow-wrap:anywhere}
3863
- .mbsr-badge{flex:0 0 auto;padding:2px 8px;border:1px solid color-mix(in srgb,var(--mb-warning) 55%,var(--mb-border));border-radius:999px;background:color-mix(in srgb,var(--mb-warning) 12%,var(--mb-surface));font-size:11px;font-weight:700;white-space:nowrap}
3963
+ .mbsr-badge{flex:0 0 auto;padding:2px 8px;border:1px solid color-mix(in srgb,var(--mb-muted) 45%,var(--mb-border));border-radius:999px;background:var(--mb-soft);font-size:11px;font-weight:700;white-space:nowrap}
3964
+ .mbsr-badge[data-tone=success]{border-color:color-mix(in srgb,#23876f 52%,var(--mb-border));background:color-mix(in srgb,#23876f 11%,var(--mb-surface));color:#176452}
3965
+ .mbsr-badge[data-tone=warning]{border-color:color-mix(in srgb,var(--mb-warning) 55%,var(--mb-border));background:color-mix(in srgb,var(--mb-warning) 12%,var(--mb-surface))}
3966
+ .mbsr-badge[data-tone=danger]{border-color:color-mix(in srgb,var(--mb-danger) 45%,var(--mb-border));background:color-mix(in srgb,var(--mb-danger) 9%,var(--mb-surface));color:var(--mb-danger)}
3864
3967
  .mbsr-meta{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,auto);gap:2px 14px;justify-content:start}
3865
3968
  .mbsr-meta>span{display:grid;gap:1px;min-width:0}
3866
3969
  .mbsr-meta i{color:var(--mb-muted);font-size:10.5px;font-style:normal;font-weight:800;letter-spacing:.05em;text-transform:uppercase;white-space:nowrap}
@@ -3886,7 +3989,7 @@ function BillSubmissionsRibbon({
3886
3989
  const content = /* @__PURE__ */ jsxs9(Fragment7, { children: [
3887
3990
  /* @__PURE__ */ jsxs9("span", { className: "mbsr-top", children: [
3888
3991
  /* @__PURE__ */ jsx9("span", { className: "mbsr-label", children: item.label }),
3889
- item.badge ? /* @__PURE__ */ jsx9("span", { className: "mbsr-badge", children: item.badge }) : null
3992
+ item.badge ? /* @__PURE__ */ jsx9("span", { className: "mbsr-badge", "data-tone": item.badgeTone ?? "neutral", children: item.badge }) : null
3890
3993
  ] }),
3891
3994
  item.meta?.length ? /* @__PURE__ */ jsx9("span", { className: "mbsr-meta", children: item.meta.slice(0, 3).map((pair) => /* @__PURE__ */ jsxs9("span", { children: [
3892
3995
  /* @__PURE__ */ jsx9("i", { children: pair.label }),
@@ -3898,6 +4001,7 @@ function BillSubmissionsRibbon({
3898
4001
  {
3899
4002
  className: "mbsr-chip",
3900
4003
  "data-active": Boolean(item.active),
4004
+ "aria-current": item.active ? "true" : void 0,
3901
4005
  href: item.href,
3902
4006
  role: "listitem",
3903
4007
  onClick: () => onSelect?.(item),
@@ -3910,6 +4014,7 @@ function BillSubmissionsRibbon({
3910
4014
  type: "button",
3911
4015
  className: "mbsr-chip",
3912
4016
  "data-active": Boolean(item.active),
4017
+ "aria-pressed": Boolean(item.active),
3913
4018
  role: "listitem",
3914
4019
  onClick: () => onSelect?.(item),
3915
4020
  children: content
@@ -4653,7 +4758,7 @@ function ConnectedBillStatus({
4653
4758
  }
4654
4759
 
4655
4760
  // src/bill-lifecycle-surfaces.tsx
4656
- import { useState as useState10 } from "react";
4761
+ import { useEffect as useEffect9, useRef as useRef5, useState as useState10 } from "react";
4657
4762
  import { Fragment as Fragment10, jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
4658
4763
  function visibleBillLifecycleActions(actions, showUnavailable = false) {
4659
4764
  return actions.filter((action) => action.enabled || showUnavailable);
@@ -4727,8 +4832,15 @@ function historyDate(iso) {
4727
4832
  if (Number.isNaN(parsed.getTime())) return iso;
4728
4833
  return new Intl.DateTimeFormat("en-US", { month: "2-digit", day: "2-digit", year: "numeric" }).format(parsed);
4729
4834
  }
4730
- function BillHistoryTable({ entries, emptyLabel = "No bill history yet.", appearance, className, style, formatDate = historyDate, documentHref, onOpenDocument }) {
4835
+ function BillHistoryTable({ entries, selectedEntryId, emptyLabel = "No bill history yet.", appearance, className, style, formatDate = historyDate, documentHref, onOpenDocument }) {
4731
4836
  const [expanded, setExpanded] = useState10({});
4837
+ const selectedRowRef = useRef5(null);
4838
+ useEffect9(() => {
4839
+ if (!selectedEntryId) return;
4840
+ const selected = entries.find((entry) => entry.id === selectedEntryId);
4841
+ if (selected?.details) setExpanded((current) => current[selectedEntryId] ? current : { ...current, [selectedEntryId]: true });
4842
+ selectedRowRef.current?.scrollIntoView({ behavior: "smooth", block: "center" });
4843
+ }, [entries, selectedEntryId]);
4732
4844
  return /* @__PURE__ */ jsxs13("section", { className: classes("mb-surface mb-history", className), style: mindBillAppearanceStyle(appearance, style), "aria-label": "Bill history", children: [
4733
4845
  /* @__PURE__ */ jsx13("style", { children: lifecycleSurfaceStyles }),
4734
4846
  /* @__PURE__ */ jsx13("header", { className: "mb-surface-heading", children: /* @__PURE__ */ jsxs13("div", { children: [
@@ -4743,6 +4855,7 @@ function BillHistoryTable({ entries, emptyLabel = "No bill history yet.", appear
4743
4855
  /* @__PURE__ */ jsx13("span", { children: "Details" })
4744
4856
  ] }),
4745
4857
  /* @__PURE__ */ jsx13("ul", { className: "mb-history-rows", children: entries.map((entry) => {
4858
+ const isSelected = entry.id === selectedEntryId;
4746
4859
  const expandable = Boolean(entry.details);
4747
4860
  const isOpen = expandable && Boolean(expanded[entry.id]);
4748
4861
  const details = entry.details;
@@ -4755,43 +4868,52 @@ function BillHistoryTable({ entries, emptyLabel = "No bill history yet.", appear
4755
4868
  entry.summary
4756
4869
  ] })
4757
4870
  ] });
4758
- return /* @__PURE__ */ jsxs13("li", { className: `mb-history-row is-${entry.tone}`, children: [
4759
- expandable ? /* @__PURE__ */ jsx13(
4760
- "button",
4761
- {
4762
- type: "button",
4763
- className: "mb-history-line is-expandable",
4764
- "aria-expanded": isOpen,
4765
- onClick: () => setExpanded((current) => ({ ...current, [entry.id]: !current[entry.id] })),
4766
- children: lineContents
4767
- }
4768
- ) : /* @__PURE__ */ jsx13("div", { className: "mb-history-line", children: lineContents }),
4769
- isOpen && details ? /* @__PURE__ */ jsxs13("div", { className: "mb-history-details", children: [
4770
- details.rows?.length ? /* @__PURE__ */ jsx13("dl", { className: "mb-history-kv", children: details.rows.map((row) => /* @__PURE__ */ jsxs13("div", { children: [
4771
- /* @__PURE__ */ jsx13("dt", { children: row.label }),
4772
- /* @__PURE__ */ jsx13("dd", { children: row.value })
4773
- ] }, `${row.label}-${row.value}`)) }) : null,
4774
- details.documents?.length ? /* @__PURE__ */ jsx13("div", { className: "mb-history-kv", children: /* @__PURE__ */ jsxs13("div", { children: [
4775
- /* @__PURE__ */ jsx13("dt", { children: "Documents" }),
4776
- /* @__PURE__ */ jsx13("dd", { children: details.documents.map((doc) => {
4777
- const href = documentHref?.(doc) ?? null;
4778
- return href ? /* @__PURE__ */ jsx13("a", { className: "mb-history-doc", href, target: "_blank", rel: "noreferrer", children: doc.filename }, doc.id) : onOpenDocument ? /* @__PURE__ */ jsx13("button", { type: "button", className: "mb-history-doc", onClick: () => void onOpenDocument(doc), children: doc.filename }, doc.id) : /* @__PURE__ */ jsx13("span", { className: "mb-history-doc", children: doc.filename }, doc.id);
4779
- }) })
4780
- ] }) }) : null,
4781
- details.codes?.length ? /* @__PURE__ */ jsx13("dl", { className: "mb-history-codes", children: details.codes.map((code) => /* @__PURE__ */ jsxs13("div", { children: [
4782
- /* @__PURE__ */ jsx13("dt", { children: code.code }),
4783
- /* @__PURE__ */ jsx13("dd", { children: code.text })
4784
- ] }, code.code)) }) : null,
4785
- details.complianceDueDates?.length ? /* @__PURE__ */ jsxs13("div", { className: "mb-history-due", children: [
4786
- /* @__PURE__ */ jsx13("em", { children: "Compliance Due Dates" }),
4787
- /* @__PURE__ */ jsx13("dl", { children: details.complianceDueDates.map((due) => /* @__PURE__ */ jsxs13("div", { children: [
4788
- /* @__PURE__ */ jsx13("dt", { children: formatDate(due.date) }),
4789
- /* @__PURE__ */ jsx13("dd", { children: due.text })
4790
- ] }, `${due.date}-${due.text}`)) })
4791
- ] }) : null,
4792
- details.text ? /* @__PURE__ */ jsx13("p", { className: "mb-history-text", children: details.text }) : null
4793
- ] }) : null
4794
- ] }, entry.id);
4871
+ return /* @__PURE__ */ jsxs13(
4872
+ "li",
4873
+ {
4874
+ ref: isSelected ? selectedRowRef : void 0,
4875
+ className: `mb-history-row is-${entry.tone}${isSelected ? " is-selected" : ""}`,
4876
+ "aria-current": isSelected ? "true" : void 0,
4877
+ children: [
4878
+ expandable ? /* @__PURE__ */ jsx13(
4879
+ "button",
4880
+ {
4881
+ type: "button",
4882
+ className: "mb-history-line is-expandable",
4883
+ "aria-expanded": isOpen,
4884
+ onClick: () => setExpanded((current) => ({ ...current, [entry.id]: !current[entry.id] })),
4885
+ children: lineContents
4886
+ }
4887
+ ) : /* @__PURE__ */ jsx13("div", { className: "mb-history-line", children: lineContents }),
4888
+ isOpen && details ? /* @__PURE__ */ jsxs13("div", { className: "mb-history-details", children: [
4889
+ details.rows?.length ? /* @__PURE__ */ jsx13("dl", { className: "mb-history-kv", children: details.rows.map((row) => /* @__PURE__ */ jsxs13("div", { children: [
4890
+ /* @__PURE__ */ jsx13("dt", { children: row.label }),
4891
+ /* @__PURE__ */ jsx13("dd", { children: row.value })
4892
+ ] }, `${row.label}-${row.value}`)) }) : null,
4893
+ details.documents?.length ? /* @__PURE__ */ jsx13("div", { className: "mb-history-kv", children: /* @__PURE__ */ jsxs13("div", { children: [
4894
+ /* @__PURE__ */ jsx13("dt", { children: "Documents" }),
4895
+ /* @__PURE__ */ jsx13("dd", { children: details.documents.map((doc) => {
4896
+ const href = documentHref?.(doc) ?? null;
4897
+ return href ? /* @__PURE__ */ jsx13("a", { className: "mb-history-doc", href, target: "_blank", rel: "noreferrer", children: doc.filename }, doc.id) : onOpenDocument ? /* @__PURE__ */ jsx13("button", { type: "button", className: "mb-history-doc", onClick: () => void onOpenDocument(doc), children: doc.filename }, doc.id) : /* @__PURE__ */ jsx13("span", { className: "mb-history-doc", children: doc.filename }, doc.id);
4898
+ }) })
4899
+ ] }) }) : null,
4900
+ details.codes?.length ? /* @__PURE__ */ jsx13("dl", { className: "mb-history-codes", children: details.codes.map((code) => /* @__PURE__ */ jsxs13("div", { children: [
4901
+ /* @__PURE__ */ jsx13("dt", { children: code.code }),
4902
+ /* @__PURE__ */ jsx13("dd", { children: code.text })
4903
+ ] }, code.code)) }) : null,
4904
+ details.complianceDueDates?.length ? /* @__PURE__ */ jsxs13("div", { className: "mb-history-due", children: [
4905
+ /* @__PURE__ */ jsx13("em", { children: "Compliance Due Dates" }),
4906
+ /* @__PURE__ */ jsx13("dl", { children: details.complianceDueDates.map((due) => /* @__PURE__ */ jsxs13("div", { children: [
4907
+ /* @__PURE__ */ jsx13("dt", { children: formatDate(due.date) }),
4908
+ /* @__PURE__ */ jsx13("dd", { children: due.text })
4909
+ ] }, `${due.date}-${due.text}`)) })
4910
+ ] }) : null,
4911
+ details.text ? /* @__PURE__ */ jsx13("p", { className: "mb-history-text", children: details.text }) : null
4912
+ ] }) : null
4913
+ ]
4914
+ },
4915
+ entry.id
4916
+ );
4795
4917
  }) })
4796
4918
  ] })
4797
4919
  ] });
@@ -5195,6 +5317,7 @@ var lifecycleSurfaceStyles = `
5195
5317
  .mb-history-rows{list-style:none;margin:0;padding:0}.mb-history-row{border-top:1px solid var(--mb-border)}
5196
5318
  .mb-history-row.is-submission{background:color-mix(in srgb,var(--mb-accent) 9%,var(--mb-surface))}
5197
5319
  .mb-history-row.is-note{background:color-mix(in srgb,#f2c344 13%,var(--mb-surface))}
5320
+ .mb-history-row.is-selected{position:relative;background:color-mix(in srgb,var(--mb-accent) 15%,var(--mb-surface));box-shadow:inset 4px 0 0 var(--mb-accent),inset 0 0 0 1px color-mix(in srgb,var(--mb-accent) 44%,transparent)}
5198
5321
  .mb-history-line{display:grid;grid-template-columns:96px 160px 140px minmax(0,1fr);gap:12px;width:100%;padding:10px 14px;border:0;background:transparent;color:inherit;font:inherit;text-align:left}
5199
5322
  .mb-history-line.is-expandable{cursor:pointer}.mb-history-line.is-expandable:hover .mb-history-summary{text-decoration:underline}
5200
5323
  .mb-history-date{color:var(--mb-muted);font-size:13px}.mb-history-action{font-size:13.5px;font-weight:750}
@@ -5219,9 +5342,9 @@ var lifecycleSurfaceStyles = `
5219
5342
  // src/connected-bill-lifecycle.tsx
5220
5343
  import {
5221
5344
  useCallback as useCallback4,
5222
- useEffect as useEffect9,
5345
+ useEffect as useEffect10,
5223
5346
  useMemo as useMemo8,
5224
- useRef as useRef5,
5347
+ useRef as useRef6,
5225
5348
  useState as useState11
5226
5349
  } from "react";
5227
5350
  import {
@@ -5286,7 +5409,7 @@ function useBillLifecycle({
5286
5409
  const [isLoading, setIsLoading] = useState11(enabled);
5287
5410
  const [isRefreshing, setIsRefreshing] = useState11(false);
5288
5411
  const [isMutating, setIsMutating] = useState11(false);
5289
- const mounted = useRef5(true);
5412
+ const mounted = useRef6(true);
5290
5413
  const client = useMemo8(() => createBillLifecycleClient({
5291
5414
  billId: providedBillId,
5292
5415
  sessionEndpoint,
@@ -5294,12 +5417,12 @@ function useBillLifecycle({
5294
5417
  apiBaseUrl,
5295
5418
  fetch: fetchOverride
5296
5419
  }), [apiBaseUrl, fetchOverride, getSession, providedBillId, sessionEndpoint]);
5297
- useEffect9(() => {
5420
+ useEffect10(() => {
5298
5421
  setData(null);
5299
5422
  setError(null);
5300
5423
  setIsLoading(enabled);
5301
5424
  }, [enabled, providedBillId]);
5302
- useEffect9(() => {
5425
+ useEffect10(() => {
5303
5426
  mounted.current = true;
5304
5427
  return () => {
5305
5428
  mounted.current = false;
@@ -5323,7 +5446,7 @@ function useBillLifecycle({
5323
5446
  }
5324
5447
  }
5325
5448
  }, [client, enabled]);
5326
- useEffect9(() => {
5449
+ useEffect10(() => {
5327
5450
  if (!enabled) return;
5328
5451
  void refresh();
5329
5452
  const interval = refreshInterval > 0 ? window.setInterval(() => void refresh(), refreshInterval) : null;
@@ -5392,10 +5515,10 @@ function useBillLifecycle({
5392
5515
  };
5393
5516
  }
5394
5517
  function LifecycleDialog({ children, title, wide = false, onClose }) {
5395
- const dialog = useRef5(null);
5396
- const onCloseRef = useRef5(onClose);
5518
+ const dialog = useRef6(null);
5519
+ const onCloseRef = useRef6(onClose);
5397
5520
  onCloseRef.current = onClose;
5398
- useEffect9(() => {
5521
+ useEffect10(() => {
5399
5522
  const previous = document.activeElement;
5400
5523
  dialog.current?.focus();
5401
5524
  const onKeyDown = (event) => event.key === "Escape" && onCloseRef.current();
@@ -5424,6 +5547,46 @@ function uniqueContactValues(values) {
5424
5547
  return [trimmed];
5425
5548
  });
5426
5549
  }
5550
+ function correctionRejectionSummary(rejection) {
5551
+ const reason = rejection.reason.trim();
5552
+ const encodedReason = reason.match(/^([A-Z0-9]+:[A-Z0-9-]+)(?:\s+(\d{8}\s+[A-Z]\s+\d{4}))?\s*[:-]?\s+(.+)$/i);
5553
+ if (encodedReason?.[1] && encodedReason[3]) {
5554
+ return {
5555
+ code: encodedReason[1],
5556
+ clearinghouseDetail: encodedReason[2]?.trim() || null,
5557
+ description: encodedReason[3].trim()
5558
+ };
5559
+ }
5560
+ const code = rejection.code?.trim() || null;
5561
+ const description = code && reason.toLocaleLowerCase().startsWith(code.toLocaleLowerCase()) ? reason.slice(code.length).replace(/^\s*[:-]?\s*/, "").trim() : reason;
5562
+ return {
5563
+ code,
5564
+ clearinghouseDetail: null,
5565
+ description: description || reason || "The clearinghouse rejected this submission."
5566
+ };
5567
+ }
5568
+ function CorrectionRejectionReason({ rejection }) {
5569
+ const summary = correctionRejectionSummary(rejection);
5570
+ const details = rejection.issues?.filter((issue) => issue.description.trim() !== summary.description || Boolean(issue.code?.trim() && issue.code.trim() !== summary.code)) ?? [];
5571
+ return /* @__PURE__ */ jsxs14("div", { className: "mb-lifecycle-correction-reason", role: "alert", children: [
5572
+ summary.code ? /* @__PURE__ */ jsxs14("div", { className: "mb-lifecycle-correction-reason-code", children: [
5573
+ /* @__PURE__ */ jsx14("span", { children: "Rejection code" }),
5574
+ /* @__PURE__ */ jsx14("code", { children: summary.code }),
5575
+ summary.clearinghouseDetail ? /* @__PURE__ */ jsxs14("small", { children: [
5576
+ /* @__PURE__ */ jsx14("span", { children: "Clearinghouse detail" }),
5577
+ summary.clearinghouseDetail
5578
+ ] }) : null
5579
+ ] }) : null,
5580
+ /* @__PURE__ */ jsxs14("div", { className: "mb-lifecycle-correction-reason-description", children: [
5581
+ /* @__PURE__ */ jsx14("span", { children: "Reason" }),
5582
+ /* @__PURE__ */ jsx14("strong", { children: summary.description })
5583
+ ] }),
5584
+ details.length ? /* @__PURE__ */ jsx14("ul", { "aria-label": "Additional rejection details", children: details.map((issue, index) => /* @__PURE__ */ jsxs14("li", { children: [
5585
+ issue.code ? /* @__PURE__ */ jsx14("code", { children: issue.code }) : null,
5586
+ /* @__PURE__ */ jsx14("span", { children: issue.description })
5587
+ ] }, `${issue.code || "issue"}-${index}`)) }) : null
5588
+ ] });
5589
+ }
5427
5590
  function CorrectionVerificationContact({ delivery }) {
5428
5591
  const directory = delivery.directory;
5429
5592
  const billReview = directory?.billReview ?? [];
@@ -5470,10 +5633,7 @@ function CorrectionVerificationContact({ delivery }) {
5470
5633
  ] }),
5471
5634
  /* @__PURE__ */ jsx14("dl", { children: methods.map((method) => /* @__PURE__ */ jsxs14("div", { children: [
5472
5635
  /* @__PURE__ */ jsx14("dt", { children: method.label }),
5473
- /* @__PURE__ */ jsx14("dd", { children: method.values.map((value, index) => /* @__PURE__ */ jsxs14("span", { children: [
5474
- index ? " \xB7 " : "",
5475
- method.href ? /* @__PURE__ */ jsx14("a", { href: method.href(value), ...method.label === "Portal" ? { target: "_blank", rel: "noreferrer" } : {}, children: value }) : value
5476
- ] }, value)) })
5636
+ /* @__PURE__ */ jsx14("dd", { children: /* @__PURE__ */ jsx14("ul", { children: method.values.map((value) => /* @__PURE__ */ jsx14("li", { children: method.href ? /* @__PURE__ */ jsx14("a", { href: method.href(value), ...method.label === "Portal" ? { target: "_blank", rel: "noreferrer" } : {}, children: value }) : value }, value)) }) })
5477
5637
  ] }, method.label)) })
5478
5638
  ] });
5479
5639
  }
@@ -5590,6 +5750,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5590
5750
  const lifecycle = useBillLifecycle(options);
5591
5751
  const { data } = lifecycle;
5592
5752
  const [tab, setTab] = useState11("details");
5753
+ const [selectedSubmissionId, setSelectedSubmissionId] = useState11();
5593
5754
  const [panel, setPanel] = useState11("");
5594
5755
  const [notice, setNotice] = useState11("");
5595
5756
  const [reason, setReason] = useState11("");
@@ -5600,7 +5761,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5600
5761
  const [duplicateDelivery, setDuplicateDelivery] = useState11(null);
5601
5762
  const [duplicateDeliveryError, setDuplicateDeliveryError] = useState11("");
5602
5763
  const actor = actorName?.trim() ? { actorName: actorName.trim() } : {};
5603
- const lastData = useRef5(null);
5764
+ const lastData = useRef6(null);
5604
5765
  const correctionInitialBill = useMemo8(() => data ? correctionBill(data) : null, [data]);
5605
5766
  const correctionAttachments = useMemo8(() => data ? data.bill.attachments.map((attachment) => {
5606
5767
  const documentType = correctionDocumentType(attachment.documentType);
@@ -5616,7 +5777,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5616
5777
  };
5617
5778
  }) : [], [data, lifecycle]);
5618
5779
  const correctionAttentionFields = useMemo8(() => data?.rejection?.issues?.flatMap((issue) => issue.fieldPaths || []).filter((path, index, fields) => fields.indexOf(path) === index) || [], [data]);
5619
- useEffect9(() => {
5780
+ useEffect10(() => {
5620
5781
  if (!data || data === lastData.current) return;
5621
5782
  lastData.current = data;
5622
5783
  onChanged?.(data);
@@ -5665,6 +5826,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5665
5826
  });
5666
5827
  await lifecycle.resubmitBill({
5667
5828
  bill: value.bill,
5829
+ ...value.submission ? { submission: value.submission } : {},
5668
5830
  ...documents.length ? { documents } : {},
5669
5831
  ...reason.trim() ? { reason: reason.trim() } : {},
5670
5832
  ...actor
@@ -5673,7 +5835,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5673
5835
  setCorrectionError(
5674
5836
  cause instanceof Error && cause.message ? cause.message : "The corrected bill could not be resubmitted."
5675
5837
  );
5676
- return;
5838
+ throw cause;
5677
5839
  }
5678
5840
  setPanel("");
5679
5841
  setReason("");
@@ -5692,6 +5854,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5692
5854
  });
5693
5855
  await lifecycle.submitNewBill({
5694
5856
  bill: value.bill,
5857
+ ...value.submission ? { submission: value.submission } : {},
5695
5858
  ...documents.length ? { documents } : {},
5696
5859
  ...reason.trim() ? { reason: reason.trim() } : {},
5697
5860
  ...actor
@@ -5700,7 +5863,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5700
5863
  setNewBillError(
5701
5864
  cause instanceof Error && cause.message ? cause.message : "The new bill could not be submitted."
5702
5865
  );
5703
- return;
5866
+ throw cause;
5704
5867
  }
5705
5868
  setPanel("");
5706
5869
  setReason("");
@@ -5716,13 +5879,19 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5716
5879
  const actions = data.lifecycle.actions.filter((action) => action.enabled && supportedActions.has(action.id));
5717
5880
  const showSandboxControls = shouldShowSandboxControls(data.environment, sandboxControls);
5718
5881
  const simulations = showSandboxControls ? sandboxScenarios(data.lifecycle.state) : [];
5719
- const ribbonItems = data.history ? billSubmissionsRibbonFromHistory(data.history) : [];
5882
+ const mappedRibbonItems = data.history ? billSubmissionsRibbonFromHistory(data.history, data.attempts) : [];
5883
+ const activeSubmissionId = selectedSubmissionId ?? mappedRibbonItems.find((item) => item.active)?.id ?? mappedRibbonItems[mappedRibbonItems.length - 1]?.id;
5884
+ const ribbonItems = mappedRibbonItems.map((item) => ({ ...item, active: item.id === activeSubmissionId }));
5885
+ const selectedHistoryEntryId = ribbonItems.find((item) => item.id === activeSubmissionId)?.historyEntryId;
5720
5886
  const statusContacts = reportBillStatusContacts(data.delivery);
5721
5887
  const receiptEntries = (data.history ?? []).filter((entry) => entry.kind === "submission" || entry.kind === "ack");
5722
5888
  const reviewDeadline = secondReviewDeadline(data.eors);
5723
5889
  return /* @__PURE__ */ jsxs14("section", { className: ["mb-connected-lifecycle", className].filter(Boolean).join(" "), style: mindBillAppearanceStyle(appearance, style), children: [
5724
5890
  /* @__PURE__ */ jsx14("style", { children: CONNECTED_LIFECYCLE_STYLES }),
5725
- ribbonItems.length >= 2 ? /* @__PURE__ */ jsx14(BillSubmissionsRibbon, { items: ribbonItems, onSelect: () => setTab("history"), ...appearance ? { appearance } : {} }) : null,
5891
+ ribbonItems.length >= 2 ? /* @__PURE__ */ jsx14(BillSubmissionsRibbon, { items: ribbonItems, onSelect: (item) => {
5892
+ setSelectedSubmissionId(item.id);
5893
+ setTab("history");
5894
+ }, ...appearance ? { appearance } : {} }) : null,
5726
5895
  data.lifecycle.state.toLowerCase() === "rejected" && data.rejection ? /* @__PURE__ */ jsx14(BillRejectionNotice, { rejection: data.rejection, submittedAt: data.lifecycle.submittedAt ?? null, ...appearance ? { appearance } : {} }) : /* @__PURE__ */ jsx14(BillLifecycleProgress, { state: data.lifecycle.state, nativeStatus: data.lifecycle.nativeStatus, submittedAt: data.lifecycle.submittedAt ?? null, agingDays: data.lifecycle.agingDays ?? null, ...appearance ? { appearance } : {} }),
5727
5896
  /* @__PURE__ */ jsxs14("header", { className: "mb-lifecycle-head", children: [
5728
5897
  /* @__PURE__ */ jsxs14("div", { children: [
@@ -5756,7 +5925,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5756
5925
  ] }, scenario.id)) }) : /* @__PURE__ */ jsx14("p", { className: "mb-lifecycle-simulator-idle", children: "No simulated payer transition is needed at this stage. Use the bill action below to continue." })
5757
5926
  ] }) : null,
5758
5927
  /* @__PURE__ */ jsx14(BillReadOnlyForm, { data, onOpenAttachment: lifecycle.openAttachment, ...appearance ? { appearance } : {} })
5759
- ] }) : /* @__PURE__ */ jsx14("div", { className: "mb-lifecycle-tabpanel", role: "tabpanel", children: data.history?.length ? /* @__PURE__ */ jsx14(BillHistoryTable, { entries: data.history, onOpenDocument: lifecycle.openAttachment, ...appearance ? { appearance } : {} }) : /* @__PURE__ */ jsx14(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }) }),
5928
+ ] }) : /* @__PURE__ */ jsx14("div", { className: "mb-lifecycle-tabpanel", role: "tabpanel", children: data.history?.length ? /* @__PURE__ */ jsx14(BillHistoryTable, { entries: data.history, ...selectedHistoryEntryId ? { selectedEntryId: selectedHistoryEntryId } : {}, onOpenDocument: lifecycle.openAttachment, ...appearance ? { appearance } : {} }) : /* @__PURE__ */ jsx14(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }) }),
5760
5929
  viewEor || actions.length ? /* @__PURE__ */ jsxs14("aside", { className: "mb-lifecycle-actions-sheet", "aria-label": "Bill actions", children: [
5761
5930
  viewEor && data.eors[0] ? /* @__PURE__ */ jsx14("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => void lifecycle.openEor(data.eors[0]).catch(() => void 0), children: viewEor.label }) : null,
5762
5931
  actions.map((action) => /* @__PURE__ */ jsx14("button", { type: "button", className: action.primary ? "mb-lifecycle-button primary" : "mb-lifecycle-button secondary", onClick: () => {
@@ -5778,13 +5947,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5778
5947
  /* @__PURE__ */ jsx14("strong", { children: "Live clearinghouse submission" }),
5779
5948
  /* @__PURE__ */ jsx14("span", { children: "Resubmitting sends a real bill. Confirm the corrected information before continuing." })
5780
5949
  ] }) : null,
5781
- data.rejection ? /* @__PURE__ */ jsxs14("div", { className: "mb-lifecycle-correction-reason", children: [
5782
- /* @__PURE__ */ jsx14("strong", { children: data.rejection.reason }),
5783
- data.rejection.issues?.map((issue, index) => /* @__PURE__ */ jsxs14("span", { children: [
5784
- issue.code ? `${issue.code}: ` : "",
5785
- issue.description
5786
- ] }, `${issue.code || "issue"}-${index}`))
5787
- ] }) : null,
5950
+ data.rejection ? /* @__PURE__ */ jsx14(CorrectionRejectionReason, { rejection: data.rejection }) : null,
5788
5951
  /* @__PURE__ */ jsx14(CorrectionVerificationContact, { delivery: data.delivery }),
5789
5952
  /* @__PURE__ */ jsxs14("label", { className: "mb-lifecycle-correction-note", children: [
5790
5953
  /* @__PURE__ */ jsx14("span", { children: "Correction note (optional)" }),
@@ -5804,6 +5967,8 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5804
5967
  attentionFields: correctionAttentionFields,
5805
5968
  attentionMessage: correctionAttentionFields.length ? "The rejected response points to the highlighted fields. Confirm every required value before resubmitting." : "Confirm the bill information below before resubmitting.",
5806
5969
  submitLabel: lifecycle.isMutating ? "Resubmitting\u2026" : "Resubmit bill",
5970
+ deliveryRoutePicker: "required",
5971
+ deliveryRouteDialogTitle: "Confirm corrected bill delivery",
5807
5972
  heading: "Corrected bill information",
5808
5973
  description: "The original submission stays unchanged. This form creates the next submission attempt.",
5809
5974
  disabled: lifecycle.isMutating,
@@ -5838,6 +6003,8 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
5838
6003
  ...claimsAdministratorSources ? { claimsAdministratorSources } : {},
5839
6004
  attentionMessage: "Confirm every value carried over from the closed bill before submitting the new bill.",
5840
6005
  submitLabel: lifecycle.isMutating ? "Submitting\u2026" : "Submit New Bill",
6006
+ deliveryRoutePicker: "required",
6007
+ deliveryRouteDialogTitle: "Confirm new bill delivery",
5841
6008
  heading: "New bill information",
5842
6009
  description: "The closed bill stays unchanged. This form submits a fresh bill linked to it.",
5843
6010
  disabled: lifecycle.isMutating,
@@ -6002,17 +6169,17 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6002
6169
  var CONNECTED_LIFECYCLE_STYLES = `
6003
6170
  .mb-lifecycle-simulator{display:grid;gap:14px;padding:18px;border:1px solid #b8dadd;border-radius:var(--mb-radius,14px);background:#f2fbfb}.mb-lifecycle-simulator>div:first-child>span{color:var(--mb-accent);font-size:.72rem;font-weight:850;letter-spacing:.09em;text-transform:uppercase}.mb-lifecycle-simulator h3{margin:3px 0 0;font-size:1.05rem}.mb-lifecycle-simulator p{margin:4px 0 0;color:var(--mb-muted)}.mb-lifecycle-simulator-actions{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px}.mb-lifecycle-simulator-actions button{min-height:76px;border:1px solid #a9cccf;border-radius:10px;background:var(--mb-surface);color:var(--mb-text);cursor:pointer;padding:12px 14px;text-align:left;font:inherit}.mb-lifecycle-simulator-actions button:hover{border-color:var(--mb-accent);box-shadow:0 3px 14px rgba(23,108,112,.1)}.mb-lifecycle-simulator-actions button:disabled{cursor:not-allowed;opacity:.55}.mb-lifecycle-simulator-actions button strong,.mb-lifecycle-simulator-actions button span{display:block}.mb-lifecycle-simulator-actions button span{margin-top:3px;color:var(--mb-muted);font-size:.83rem}.mb-lifecycle-simulator-idle{padding:10px 12px;border-radius:8px;background:rgba(255,255,255,.72)}
6004
6171
  .mb-connected-lifecycle{--mb-accent:#176c70;--mb-text:#17282d;--mb-muted:#607176;--mb-border:#d7e0df;--mb-soft:#f4f7f6;--mb-surface:#fff;display:grid;gap:18px;color:var(--mb-text);font:14px/1.45 var(--mb-font,Inter,ui-sans-serif,system-ui,sans-serif)}.mb-connected-lifecycle *{box-sizing:border-box}.mb-lifecycle-head{display:flex;align-items:center;justify-content:space-between;gap:20px}.mb-lifecycle-title{display:flex;align-items:center;flex-wrap:wrap;gap:10px}.mb-lifecycle-title h2{margin:0;font-size:1.7rem}.mb-lifecycle-head p{margin:3px 0 0;color:var(--mb-muted)}.mb-lifecycle-tabs{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--mb-border);border-radius:12px;background:var(--mb-surface);padding:6px}.mb-lifecycle-tabs button{min-height:46px;border:0;border-radius:8px;background:transparent;color:var(--mb-muted);font:inherit;font-size:1rem;font-weight:750;cursor:pointer}.mb-lifecycle-tabs button[aria-selected=true]{background:var(--mb-accent);color:white}.mb-lifecycle-tabpanel{display:grid;gap:18px}.mb-lifecycle-button{min-height:40px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-input,#fff);color:var(--mb-text);cursor:pointer;font:inherit;font-weight:750;padding:9px 14px}.mb-lifecycle-button.primary{border-color:var(--mb-accent);background:var(--mb-accent);color:var(--mb-accent-contrast,#fff)}.mb-lifecycle-button:disabled{cursor:not-allowed;opacity:.5}.mb-lifecycle-actions-sheet{position:sticky;bottom:12px;z-index:24;display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:9px;padding:10px;border:1px solid var(--mb-border);border-radius:12px;background:color-mix(in srgb,var(--mb-surface) 94%,transparent);box-shadow:0 10px 34px rgba(18,35,43,.16);backdrop-filter:blur(12px)}.mb-lifecycle-card,.mb-lifecycle-panel{padding:20px;border:1px solid var(--mb-border);border-radius:var(--mb-radius,14px);background:var(--mb-surface)}.mb-lifecycle-card header{display:flex;align-items:center;justify-content:space-between;gap:20px}.mb-lifecycle-card h3,.mb-lifecycle-panel h3{margin:0;font-size:1.08rem}.mb-lifecycle-card p,.mb-lifecycle-panel p{margin:3px 0 0;color:var(--mb-muted)}.mb-lifecycle-card header>span{display:grid;place-items:center;min-width:28px;height:28px;border-radius:999px;background:var(--mb-soft);font-weight:750}.mb-lifecycle-documents{list-style:none;margin:14px 0 0;padding:0}.mb-lifecycle-documents li{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:12px 0;border-top:1px solid var(--mb-border)}.mb-lifecycle-documents li>div{display:grid;gap:3px;min-width:0}.mb-lifecycle-documents li span{color:var(--mb-muted);font-size:.85rem}.mb-lifecycle-dialog-backdrop{position:fixed;z-index:2147483000;inset:0;display:grid;place-items:center;padding:20px;background:rgba(18,35,43,.56);backdrop-filter:blur(3px)}.mb-lifecycle-dialog{position:relative;width:min(760px,100%);max-height:calc(100dvh - 40px);overflow:auto;outline:0}.mb-lifecycle-dialog-close{position:absolute;z-index:1;top:12px;right:12px;width:44px;height:44px;border:1px solid var(--mb-border);border-radius:10px;background:var(--mb-surface);color:var(--mb-text);cursor:pointer;font:24px/1 inherit}.mb-lifecycle-panel{display:grid;gap:17px;padding-top:24px;box-shadow:0 24px 70px rgba(18,35,43,.22)}.mb-lifecycle-panel label{display:grid;gap:6px;font-size:.85rem;font-weight:750}.mb-lifecycle-panel label small{color:var(--mb-muted);font-weight:500}.mb-lifecycle-panel input,.mb-lifecycle-panel select,.mb-lifecycle-panel textarea{width:100%;min-height:44px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-input,#fff);color:var(--mb-text);font:inherit;padding:10px 12px}.mb-lifecycle-panel textarea{min-height:100px;resize:vertical}.mb-lifecycle-fields{display:grid;gap:13px}.mb-lifecycle-fields.two{grid-template-columns:repeat(2,minmax(0,1fr))}.mb-lifecycle-fields .full{grid-column:1/-1}.mb-lifecycle-panel-actions{display:flex;justify-content:flex-end;gap:8px}.mb-lifecycle-packet{display:grid;gap:0;margin:0;padding:0;border:0}.mb-lifecycle-packet legend{margin-bottom:7px;font-size:.85rem;font-weight:800}.mb-lifecycle-packet>label{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:10px;padding:10px 2px;border-top:1px solid var(--mb-border)}.mb-lifecycle-packet>label>input{width:16px;min-height:16px}.mb-lifecycle-packet>label>span{display:grid}.mb-lifecycle-packet button{border:0;background:transparent;color:var(--mb-accent);cursor:pointer;font:inherit}.mb-lifecycle-message,.mb-lifecycle-error,.mb-lifecycle-loading{padding:12px 14px;border-radius:9px}.mb-lifecycle-message.success{background:#edf9f2;color:#217449}.mb-lifecycle-message.error,.mb-lifecycle-error{background:#fff0ef;color:#9d3029}.mb-lifecycle-error{display:flex;align-items:center;gap:12px}.mb-lifecycle-error span{flex:1}.mb-lifecycle-error button{border:1px solid currentColor;border-radius:7px;background:transparent;color:inherit;padding:7px 10px}
6005
- .mb-lifecycle-dialog.wide{width:min(1280px,100%)}.mb-lifecycle-correction{display:grid;gap:16px;padding:22px;border-radius:var(--mb-radius,14px);background:var(--mb-surface);box-shadow:0 24px 70px rgba(18,35,43,.22)}.mb-lifecycle-correction>header{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;padding-right:56px}.mb-lifecycle-correction h3{margin:0;font-size:1.2rem}.mb-lifecycle-correction header p{margin:4px 0 0;color:var(--mb-muted)}.mb-lifecycle-live-warning,.mb-lifecycle-correction-reason,.mb-lifecycle-correction-contact{display:grid;gap:4px;padding:13px 15px;border-radius:10px}.mb-lifecycle-live-warning{border-left:4px solid #b97716;background:#fff8e8;color:#6f470e}.mb-lifecycle-correction-reason{border-left:4px solid #c5443f;background:#fff2f1;color:#812d29}.mb-lifecycle-correction-contact{border:1px solid color-mix(in srgb,var(--mb-accent) 35%,var(--mb-border));background:color-mix(in srgb,var(--mb-accent) 7%,var(--mb-surface))}.mb-lifecycle-correction-contact dl{display:grid;gap:7px;margin:8px 0 0}.mb-lifecycle-correction-contact dl>div{display:grid;grid-template-columns:58px minmax(0,1fr);gap:10px}.mb-lifecycle-correction-contact dt{color:var(--mb-muted);font-size:.78rem;font-weight:800;text-transform:uppercase}.mb-lifecycle-correction-contact dd{min-width:0;margin:0;overflow-wrap:anywhere}.mb-lifecycle-correction-contact a{color:var(--mb-accent);text-underline-offset:2px}.mb-lifecycle-correction-note{display:grid;gap:6px;font-size:.85rem;font-weight:750}.mb-lifecycle-correction-note textarea{min-height:76px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-input,#fff);color:var(--mb-text);font:inherit;padding:10px 12px;resize:vertical}
6172
+ .mb-lifecycle-dialog.wide{width:min(1280px,100%)}.mb-lifecycle-correction{display:grid;gap:16px;padding:22px;border-radius:var(--mb-radius,14px);background:var(--mb-surface);box-shadow:0 24px 70px rgba(18,35,43,.22)}.mb-lifecycle-correction>header{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;padding-right:56px}.mb-lifecycle-correction h3{margin:0;font-size:1.2rem}.mb-lifecycle-correction header p{margin:4px 0 0;color:var(--mb-muted)}.mb-lifecycle-live-warning,.mb-lifecycle-correction-reason,.mb-lifecycle-correction-contact{display:grid;gap:4px;padding:13px 15px;border-radius:10px}.mb-lifecycle-live-warning{border-left:4px solid #b97716;background:#fff8e8;color:#6f470e}.mb-lifecycle-correction-reason{grid-template-columns:max-content minmax(0,1fr);align-items:start;column-gap:18px;row-gap:10px;border-left:4px solid #c5443f;background:#fff2f1;color:#812d29}.mb-lifecycle-correction-reason-code,.mb-lifecycle-correction-reason-description{display:grid;gap:4px}.mb-lifecycle-correction-reason-code>span,.mb-lifecycle-correction-reason-description>span,.mb-lifecycle-correction-reason-code small>span{color:#9b514d;font-size:.7rem;font-weight:850;letter-spacing:.07em;text-transform:uppercase}.mb-lifecycle-correction-reason code{width:max-content;border:1px solid #e8b4b0;border-radius:6px;background:rgba(255,255,255,.66);color:#812d29;font:750 .84rem/1.35 ui-monospace,SFMono-Regular,Menlo,monospace;padding:3px 7px}.mb-lifecycle-correction-reason-code small{display:grid;gap:1px;margin-top:3px;color:#9b514d;font:500 .72rem/1.35 ui-monospace,SFMono-Regular,Menlo,monospace}.mb-lifecycle-correction-reason-description strong{font-size:.94rem}.mb-lifecycle-correction-reason>ul{grid-column:1/-1;display:grid;gap:5px;margin:0;padding:8px 0 0 18px;border-top:1px solid #ecc7c4}.mb-lifecycle-correction-reason li{padding-left:3px}.mb-lifecycle-correction-reason li code{margin-right:7px}.mb-lifecycle-correction-contact{border:1px solid color-mix(in srgb,var(--mb-accent) 35%,var(--mb-border));background:color-mix(in srgb,var(--mb-accent) 7%,var(--mb-surface))}.mb-lifecycle-correction-contact dl{display:grid;gap:10px;margin:8px 0 0}.mb-lifecycle-correction-contact dl>div{display:grid;grid-template-columns:68px minmax(0,1fr);gap:10px}.mb-lifecycle-correction-contact dt{padding-top:2px;color:var(--mb-muted);font-size:.78rem;font-weight:800;text-transform:uppercase}.mb-lifecycle-correction-contact dd{min-width:0;margin:0;overflow-wrap:anywhere}.mb-lifecycle-correction-contact dd ul{display:grid;gap:4px;margin:0;padding:0;list-style:none}.mb-lifecycle-correction-contact dd li{min-width:0}.mb-lifecycle-correction-contact a{color:var(--mb-accent);text-underline-offset:2px}.mb-lifecycle-correction-note{display:grid;gap:6px;font-size:.85rem;font-weight:750}.mb-lifecycle-correction-note textarea{min-height:76px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-input,#fff);color:var(--mb-text);font:inherit;padding:10px 12px;resize:vertical}
6006
6173
  .mb-payment-total{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 14px;border-radius:9px;background:var(--mb-soft)}.mb-payment-total strong{font-size:1.12rem}
6007
6174
  .mb-lifecycle-deadline-hint{margin:0;padding:10px 12px;border-radius:9px;background:color-mix(in srgb,var(--mb-warning,#8a5c17) 10%,var(--mb-surface));color:var(--mb-warning,#8a5c17);font-size:.85rem}
6008
- @media(max-width:700px){.mb-lifecycle-head,.mb-lifecycle-card header{align-items:stretch;flex-direction:column}.mb-lifecycle-head>.mb-lifecycle-button{width:100%}.mb-lifecycle-actions-sheet{bottom:calc(var(--mb-host-bottom-offset,72px) + env(safe-area-inset-bottom) + 8px);grid-template-columns:repeat(2,minmax(0,1fr))}.mb-lifecycle-actions-sheet .mb-lifecycle-button:last-child:nth-child(odd){grid-column:1/-1}.mb-lifecycle-fields.two{grid-template-columns:1fr}.mb-lifecycle-fields .full{grid-column:auto}.mb-lifecycle-dialog-backdrop{align-items:end;padding:0}.mb-lifecycle-dialog{max-height:calc(100dvh - 12px)}.mb-lifecycle-dialog .mb-lifecycle-panel,.mb-lifecycle-correction{border-radius:18px 18px 0 0}.mb-lifecycle-correction{padding:18px 12px calc(18px + env(safe-area-inset-bottom))}.mb-lifecycle-correction>header{align-items:stretch;flex-direction:column;padding-right:56px}.mb-lifecycle-correction-contact dl>div{grid-template-columns:1fr;gap:2px}.mb-lifecycle-tabs button{font-size:.9rem}.mb-lifecycle-title h2{font-size:1.4rem}}
6175
+ @media(max-width:700px){.mb-lifecycle-head,.mb-lifecycle-card header{align-items:stretch;flex-direction:column}.mb-lifecycle-head>.mb-lifecycle-button{width:100%}.mb-lifecycle-actions-sheet{bottom:calc(var(--mb-host-bottom-offset,72px) + env(safe-area-inset-bottom) + 8px);grid-template-columns:repeat(2,minmax(0,1fr))}.mb-lifecycle-actions-sheet .mb-lifecycle-button:last-child:nth-child(odd){grid-column:1/-1}.mb-lifecycle-fields.two{grid-template-columns:1fr}.mb-lifecycle-fields .full{grid-column:auto}.mb-lifecycle-dialog-backdrop{align-items:end;padding:0}.mb-lifecycle-dialog{max-height:calc(100dvh - 12px)}.mb-lifecycle-dialog .mb-lifecycle-panel,.mb-lifecycle-correction{border-radius:18px 18px 0 0}.mb-lifecycle-correction{padding:18px 12px calc(18px + env(safe-area-inset-bottom))}.mb-lifecycle-correction>header{align-items:stretch;flex-direction:column;padding-right:56px}.mb-lifecycle-correction-reason{grid-template-columns:1fr}.mb-lifecycle-correction-reason>ul{grid-column:auto}.mb-lifecycle-correction-contact dl>div{grid-template-columns:1fr;gap:2px}.mb-lifecycle-tabs button{font-size:.9rem}.mb-lifecycle-title h2{font-size:1.4rem}}
6009
6176
  `;
6010
6177
 
6011
6178
  // src/index.tsx
6012
6179
  function widget(tagName, props) {
6013
- const ref = useRef6(null);
6180
+ const ref = useRef7(null);
6014
6181
  const { onMindBill, onMindBillError } = props;
6015
- useEffect10(() => {
6182
+ useEffect11(() => {
6016
6183
  const element = ref.current;
6017
6184
  if (!element) return;
6018
6185
  const handleEvent = (event) => onMindBill?.(event);