@mindbill/react 0.44.1 → 0.45.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/README.md CHANGED
@@ -95,6 +95,24 @@ import { BillReadOnlyForm } from "@mindbill/react";
95
95
 
96
96
  `ConnectedBillLifecycle` composes this component with the Details / Bill history switch, so most partners should not assemble these pieces themselves.
97
97
 
98
+ `ConnectedBillingWorkspace` is the complete task, search, procedure,
99
+ productivity, and bill-detail experience. It measures the space remaining in
100
+ the browser viewport and owns vertical scrolling, so dashboard shells cannot
101
+ trap content below the fold. Hosts can still give it an explicit height:
102
+
103
+ ```tsx
104
+ <main style={{ height: "100dvh", minHeight: 0 }}>
105
+ <ConnectedBillingWorkspace
106
+ sessionEndpoint="/api/mindbill/session"
107
+ onCreateBill={() => router.push("/billing/new")}
108
+ />
109
+ </main>
110
+ ```
111
+
112
+ For flex or grid shells, setting `min-height: 0` on the workspace's ancestors
113
+ remains a useful layout default. An explicit `height` or `maxHeight` in the
114
+ component's `style` prop continues to take precedence.
115
+
98
116
  `BillRejectionNotice` is also exported for custom lifecycle layouts. It presents every API-provided rejection issue in order, keeps technical acknowledgement codes alongside the actionable descriptions, and shows when the bill was sent and rejected. The connected lifecycle includes it automatically whenever the current state is `rejected`.
99
117
 
100
118
  ```tsx
@@ -344,7 +362,15 @@ attempt's latest acknowledgement or payment state — for example `277 Reject`
344
362
  or `Payment in 30 working days` — plus delivery, sent date, and the relevant
345
363
  reject/effective date. `billSubmissionsRibbonFromHistory` derives those chips
346
364
  from one unified history across every attempt. In `ConnectedBillLifecycle`, a
347
- chip click opens that shared history and highlights the selected submission.
365
+ chip click keeps the Details tab open and shows that transmission's receipt,
366
+ delivery, sent date, and status. The immutable bill detail remains below it;
367
+ the complete cross-attempt audit trail is available only through the explicit
368
+ Bill history tab.
369
+
370
+ The connected lifecycle also renders server-owned bill notes and an **Add note**
371
+ control. Custom compositions can call `useBillLifecycle({ billId }).addNote({
372
+ note, actorName })`; note activity is shared with other authorized partner and
373
+ MindBill users.
348
374
 
349
375
  `ReportBillStatusDialog` records the outcome of a payment-status phone call to the Claims Administrator / Bill Review vendor: payer contacts, the host-rendered submission receipt (for example a `BillHistoryTable`), and the five standard reported statuses (`REPORT_BILL_STATUS_OPTIONS`). The host posts the resulting `ReportBillStatusInput` through its own lifecycle action call.
350
376
 
package/dist/index.d.ts CHANGED
@@ -1144,6 +1144,7 @@ type UseBillLifecycleResult = {
1144
1144
  openAttachment: (attachment: Pick<BillReviewAttachment, "id">) => Promise<void>;
1145
1145
  openEor: (document: BillEorDocument) => Promise<void>;
1146
1146
  downloadPacket: () => Promise<void>;
1147
+ addNote: BillLifecycleClient["addNote"];
1147
1148
  closeBill: BillLifecycleClient["closeBill"];
1148
1149
  reopenBill: BillLifecycleClient["reopenBill"];
1149
1150
  postPayment: BillLifecycleClient["postPayment"];
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 useEffect12, useRef as useRef7 } from "react";
5
+ import { createElement, useEffect as useEffect12, useRef as useRef8 } from "react";
6
6
 
7
7
  // src/appearance.ts
8
8
  var mindBillThemePresets = {
@@ -3972,12 +3972,12 @@ function billSubmissionsRibbonFromHistory(history, attempts = []) {
3972
3972
  var css7 = `
3973
3973
  .mbsr{display:flex;gap:10px;overflow-x:auto;padding-bottom:4px;color:var(--mb-text);font-family:var(--mb-font);font-size:13px}
3974
3974
  .mbsr *{box-sizing:border-box}
3975
- .mbsr-chip{flex:0 0 auto;display:grid;gap:7px;min-width:180px;max-width:280px;padding:11px 13px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface);color:inherit;font:inherit;text-align:left;text-decoration:none;cursor:pointer}
3975
+ .mbsr-chip{flex:0 0 240px;display:grid;gap:7px;width:240px;min-width:min(240px,85vw);max-width:280px;padding:11px 13px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface);color:inherit;font:inherit;text-align:left;text-decoration:none;cursor:pointer}
3976
3976
  .mbsr-chip:hover{border-color:var(--mb-accent)}
3977
3977
  .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}
3978
- .mbsr-top{display:flex;align-items:center;gap:8px;min-width:0}
3979
- .mbsr-label{font-size:13.5px;font-weight:760;line-height:1.3;overflow-wrap:anywhere}
3980
- .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}
3978
+ .mbsr-top{display:grid;grid-template-columns:minmax(0,1fr);gap:6px;min-width:0}
3979
+ .mbsr-label{min-width:0;font-size:13.5px;font-weight:760;line-height:1.3;overflow-wrap:normal;word-break:normal}
3980
+ .mbsr-badge{justify-self:start;max-width:100%;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:normal}
3981
3981
  .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}
3982
3982
  .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))}
3983
3983
  .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)}
@@ -5568,16 +5568,16 @@ var SECOND_REVIEW_REASON_TEMPLATES = [
5568
5568
  }
5569
5569
  ];
5570
5570
  var css10 = `
5571
- .mbsr{display:grid;gap:18px;color:var(--mb-text);font-family:var(--mb-font)}
5572
- .mbsr *{box-sizing:border-box}.mbsr h3{margin:0;font-size:22px}.mbsr p{margin:4px 0 0;color:var(--mb-muted)}
5573
- .mbsr-deadline{padding:12px 14px;border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-warning) 10%,var(--mb-surface));color:var(--mb-text)!important}
5574
- .mbsr-template,.mbsr-field{display:grid;gap:6px}.mbsr-label{font-size:13px;font-weight:720}.mbsr-select,.mbsr-textarea{width:100%;padding:10px 12px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text);font:inherit}.mbsr-textarea{min-height:86px;resize:vertical}.mbsr-select:focus,.mbsr-textarea:focus{outline:3px solid color-mix(in srgb,var(--mb-accent) 20%,transparent);border-color:var(--mb-accent)}
5575
- .mbsr-lines{display:grid;gap:10px}.mbsr-line{display:grid;gap:12px;padding:14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface)}.mbsr-line[data-selected=true]{border-color:color-mix(in srgb,var(--mb-accent) 65%,var(--mb-border));background:color-mix(in srgb,var(--mb-accent) 4%,var(--mb-surface))}.mbsr-line-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.mbsr-check{display:flex;align-items:center;gap:9px;font-weight:750}.mbsr-check input{width:18px;height:18px;accent-color:var(--mb-accent)}.mbsr-metrics{display:flex;gap:14px;color:var(--mb-muted);font-size:12px}.mbsr-auth{display:flex;align-items:center;flex-wrap:wrap;gap:8px;font-size:13px}.mbsr-auth strong{margin-right:4px}.mbsr-auth label{display:flex;align-items:center;gap:5px}.mbsr-auth input{accent-color:var(--mb-accent)}
5576
- .mbsr-packet{display:grid;gap:10px;padding:0;border:0}.mbsr-packet legend{margin-bottom:8px;font-weight:750}.mbsr-document{display:flex;align-items:center;gap:10px;padding:10px 0;border-top:1px solid var(--mb-border)}.mbsr-document input{width:18px;height:18px;accent-color:var(--mb-accent)}.mbsr-document span{display:grid;min-width:0;flex:1}.mbsr-document small{color:var(--mb-muted)}.mbsr-link{border:0;background:transparent;color:var(--mb-accent);font:inherit;font-weight:700;cursor:pointer}
5577
- .mbsr-upload{display:grid;place-items:center;min-height:82px;padding:16px;border:1px dashed color-mix(in srgb,var(--mb-accent) 55%,var(--mb-border));border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-accent) 3%,var(--mb-surface));cursor:pointer}.mbsr-upload input{position:absolute;width:1px;height:1px;opacity:0}.mbsr-upload strong{color:var(--mb-accent)}
5578
- .mbsr-uploaded{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 11px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius)}
5579
- .mbsr-error{padding:10px 12px;border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-danger) 10%,transparent);color:var(--mb-danger);font-size:13px}.mbsr-actions{display:flex;justify-content:flex-end;gap:10px}.mbsr-button{min-height:42px;padding:9px 16px;border-radius:var(--mb-control-radius);font:inherit;font-weight:740;cursor:pointer}.mbsr-button.secondary{border:1px solid var(--mb-border);background:var(--mb-surface);color:var(--mb-text)}.mbsr-button.primary{border:0;background:var(--mb-accent);color:var(--mb-accent-contrast)}.mbsr-button:disabled{opacity:.55;cursor:not-allowed}
5580
- @media(max-width:680px){.mbsr-line-head{align-items:flex-start;flex-direction:column}.mbsr-metrics{flex-wrap:wrap}}
5571
+ .mb-second-review{display:grid;gap:18px;padding:22px;color:var(--mb-text);font-family:var(--mb-font);background:var(--mb-surface);border:1px solid var(--mb-border);border-radius:var(--mb-radius);box-shadow:var(--mb-shadow)}
5572
+ .mb-second-review *{box-sizing:border-box}.mb-second-review h3{margin:0;font-size:22px}.mb-second-review p{margin:4px 0 0;color:var(--mb-muted)}
5573
+ .mb-second-review-deadline{padding:12px 14px;border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-warning) 10%,var(--mb-surface));color:var(--mb-text)!important}
5574
+ .mb-second-review-template,.mb-second-review-field{display:grid;gap:6px}.mb-second-review-label{font-size:13px;font-weight:720}.mb-second-review-select,.mb-second-review-textarea{width:100%;padding:10px 12px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text);font:inherit}.mb-second-review-textarea{min-height:86px;resize:vertical}.mb-second-review-select:focus,.mb-second-review-textarea:focus{outline:3px solid color-mix(in srgb,var(--mb-accent) 20%,transparent);border-color:var(--mb-accent)}
5575
+ .mb-second-review-lines{display:grid;gap:10px}.mb-second-review-line{display:grid;gap:12px;padding:14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface)}.mb-second-review-line[data-selected=true]{border-color:color-mix(in srgb,var(--mb-accent) 65%,var(--mb-border));background:color-mix(in srgb,var(--mb-accent) 4%,var(--mb-surface))}.mb-second-review-line-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.mb-second-review-check{display:flex;align-items:center;gap:9px;font-weight:750}.mb-second-review-check input{width:18px;height:18px;accent-color:var(--mb-accent)}.mb-second-review-metrics{display:flex;gap:14px;color:var(--mb-muted);font-size:12px}.mb-second-review-auth{display:flex;align-items:center;flex-wrap:wrap;gap:8px;font-size:13px}.mb-second-review-auth strong{margin-right:4px}.mb-second-review-auth label{display:flex;align-items:center;gap:5px}.mb-second-review-auth input{accent-color:var(--mb-accent)}
5576
+ .mb-second-review-packet{display:grid;gap:10px;padding:0;border:0}.mb-second-review-packet legend{margin-bottom:8px;font-weight:750}.mb-second-review-document{display:flex;align-items:center;gap:10px;padding:10px 0;border-top:1px solid var(--mb-border)}.mb-second-review-document input{width:18px;height:18px;accent-color:var(--mb-accent)}.mb-second-review-document span{display:grid;min-width:0;flex:1}.mb-second-review-document small{color:var(--mb-muted)}.mb-second-review-link{border:0;background:transparent;color:var(--mb-accent);font:inherit;font-weight:700;cursor:pointer}
5577
+ .mb-second-review-upload{display:grid;place-items:center;min-height:82px;padding:16px;border:1px dashed color-mix(in srgb,var(--mb-accent) 55%,var(--mb-border));border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-accent) 3%,var(--mb-surface));cursor:pointer}.mb-second-review-upload input{position:absolute;width:1px;height:1px;opacity:0}.mb-second-review-upload strong{color:var(--mb-accent)}
5578
+ .mb-second-review-uploaded{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 11px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius)}
5579
+ .mb-second-review-error{padding:10px 12px;border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-danger) 10%,transparent);color:var(--mb-danger);font-size:13px}.mb-second-review-actions{display:flex;justify-content:flex-end;gap:10px}.mb-second-review-button{min-height:42px;padding:9px 16px;border-radius:var(--mb-control-radius);font:inherit;font-weight:740;cursor:pointer}.mb-second-review-button.secondary{border:1px solid var(--mb-border);background:var(--mb-surface);color:var(--mb-text)}.mb-second-review-button.primary{border:0;background:var(--mb-accent);color:var(--mb-accent-contrast)}.mb-second-review-button:disabled{opacity:.55;cursor:not-allowed}
5580
+ @media(max-width:680px){.mb-second-review{padding:16px}.mb-second-review-line-head{align-items:flex-start;flex-direction:column}.mb-second-review-metrics{flex-wrap:wrap}}
5581
5581
  `;
5582
5582
  function money5(value) {
5583
5583
  return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(value);
@@ -5691,14 +5691,14 @@ function SecondReviewForm({
5691
5691
  };
5692
5692
  return /* @__PURE__ */ jsxs14(Fragment12, { children: [
5693
5693
  /* @__PURE__ */ jsx14("style", { children: css10 }),
5694
- /* @__PURE__ */ jsxs14("section", { className: "mbsr", children: [
5694
+ /* @__PURE__ */ jsxs14("section", { className: "mb-second-review", children: [
5695
5695
  /* @__PURE__ */ jsxs14("div", { children: [
5696
5696
  /* @__PURE__ */ jsx14("h3", { children: "Submit Second Review" }),
5697
5697
  /* @__PURE__ */ jsx14("p", { children: "Select each disputed service and explain why it should be reconsidered." })
5698
5698
  ] }),
5699
- /* @__PURE__ */ jsxs14("label", { className: "mbsr-template", children: [
5700
- /* @__PURE__ */ jsx14("span", { className: "mbsr-label", children: "Apply a saved reason to selected lines" }),
5701
- /* @__PURE__ */ jsxs14("select", { className: "mbsr-select", defaultValue: "", onChange: (event) => {
5699
+ /* @__PURE__ */ jsxs14("label", { className: "mb-second-review-template", children: [
5700
+ /* @__PURE__ */ jsx14("span", { className: "mb-second-review-label", children: "Apply a saved reason to selected lines" }),
5701
+ /* @__PURE__ */ jsxs14("select", { className: "mb-second-review-select", defaultValue: "", onChange: (event) => {
5702
5702
  applyTemplate(event.target.value);
5703
5703
  event.target.value = "";
5704
5704
  }, children: [
@@ -5706,19 +5706,19 @@ function SecondReviewForm({
5706
5706
  SECOND_REVIEW_REASON_TEMPLATES.map((template) => /* @__PURE__ */ jsx14("option", { value: template.value, children: template.label }, template.label))
5707
5707
  ] })
5708
5708
  ] }),
5709
- /* @__PURE__ */ jsxs14("section", { className: "mbsr-lines", "aria-label": "Service lines in dispute", children: [
5709
+ /* @__PURE__ */ jsxs14("section", { className: "mb-second-review-lines", "aria-label": "Service lines in dispute", children: [
5710
5710
  selectableLines.map((line) => {
5711
5711
  const draft = lines[line.id];
5712
- return /* @__PURE__ */ jsxs14("article", { className: "mbsr-line", "data-selected": draft?.selected, children: [
5713
- /* @__PURE__ */ jsxs14("div", { className: "mbsr-line-head", children: [
5714
- /* @__PURE__ */ jsxs14("label", { className: "mbsr-check", children: [
5712
+ return /* @__PURE__ */ jsxs14("article", { className: "mb-second-review-line", "data-selected": draft?.selected, children: [
5713
+ /* @__PURE__ */ jsxs14("div", { className: "mb-second-review-line-head", children: [
5714
+ /* @__PURE__ */ jsxs14("label", { className: "mb-second-review-check", children: [
5715
5715
  /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: Boolean(draft?.selected), onChange: (event) => patchLine(line.id, { selected: event.target.checked }) }),
5716
5716
  /* @__PURE__ */ jsxs14("span", { children: [
5717
5717
  line.code,
5718
5718
  line.modifiers.length ? `-${line.modifiers.join("-")}` : ""
5719
5719
  ] })
5720
5720
  ] }),
5721
- /* @__PURE__ */ jsxs14("span", { className: "mbsr-metrics", children: [
5721
+ /* @__PURE__ */ jsxs14("span", { className: "mb-second-review-metrics", children: [
5722
5722
  /* @__PURE__ */ jsxs14("span", { children: [
5723
5723
  line.units,
5724
5724
  " unit",
@@ -5728,11 +5728,11 @@ function SecondReviewForm({
5728
5728
  ] })
5729
5729
  ] }),
5730
5730
  draft?.selected ? /* @__PURE__ */ jsxs14(Fragment12, { children: [
5731
- /* @__PURE__ */ jsxs14("label", { className: "mbsr-field", children: [
5732
- /* @__PURE__ */ jsx14("span", { className: "mbsr-label", children: "Reason for requesting Second Review" }),
5733
- /* @__PURE__ */ jsx14("textarea", { className: "mbsr-textarea", required: true, value: draft.reason, onChange: (event) => patchLine(line.id, { reason: event.target.value }) })
5731
+ /* @__PURE__ */ jsxs14("label", { className: "mb-second-review-field", children: [
5732
+ /* @__PURE__ */ jsx14("span", { className: "mb-second-review-label", children: "Reason for requesting Second Review" }),
5733
+ /* @__PURE__ */ jsx14("textarea", { className: "mb-second-review-textarea", required: true, value: draft.reason, onChange: (event) => patchLine(line.id, { reason: event.target.value }) })
5734
5734
  ] }),
5735
- /* @__PURE__ */ jsxs14("div", { className: "mbsr-auth", role: "radiogroup", "aria-label": `Service or good ${line.code} authorized`, children: [
5735
+ /* @__PURE__ */ jsxs14("div", { className: "mb-second-review-auth", role: "radiogroup", "aria-label": `Service or good ${line.code} authorized`, children: [
5736
5736
  /* @__PURE__ */ jsx14("strong", { children: "Service/Good Authorized?" }),
5737
5737
  [["yes", "Yes"], ["no", "No"], ["", "Not specified"]].map(([value, label]) => /* @__PURE__ */ jsxs14("label", { children: [
5738
5738
  /* @__PURE__ */ jsx14("input", { type: "radio", name: `authorized-${line.id}`, checked: draft.serviceAuthorized === value, onChange: () => patchLine(line.id, { serviceAuthorized: value }) }),
@@ -5742,34 +5742,34 @@ function SecondReviewForm({
5742
5742
  ] }) : null
5743
5743
  ] }, line.id);
5744
5744
  }),
5745
- !selectableLines.length ? /* @__PURE__ */ jsx14("div", { className: "mbsr-error", children: "This bill has no stable service-line identifiers. Refresh the bill before submitting a Second Review." }) : null
5745
+ !selectableLines.length ? /* @__PURE__ */ jsx14("div", { className: "mb-second-review-error", children: "This bill has no stable service-line identifiers. Refresh the bill before submitting a Second Review." }) : null
5746
5746
  ] }),
5747
- /* @__PURE__ */ jsxs14("fieldset", { className: "mbsr-packet", children: [
5747
+ /* @__PURE__ */ jsxs14("fieldset", { className: "mb-second-review-packet", children: [
5748
5748
  /* @__PURE__ */ jsx14("legend", { children: "Supporting packet" }),
5749
- data.bill.attachments.map((attachment) => /* @__PURE__ */ jsxs14("label", { className: "mbsr-document", children: [
5749
+ data.bill.attachments.map((attachment) => /* @__PURE__ */ jsxs14("label", { className: "mb-second-review-document", children: [
5750
5750
  /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: attachmentIds.includes(attachment.id), onChange: (event) => setAttachmentIds((current) => event.target.checked ? [...current, attachment.id] : current.filter((id) => id !== attachment.id)) }),
5751
5751
  /* @__PURE__ */ jsxs14("span", { children: [
5752
5752
  /* @__PURE__ */ jsx14("strong", { children: attachment.filename }),
5753
5753
  /* @__PURE__ */ jsx14("small", { children: attachment.description || attachment.documentType })
5754
5754
  ] }),
5755
- /* @__PURE__ */ jsx14("button", { className: "mbsr-link", type: "button", onClick: () => void openAttachment(attachment).catch(() => void 0), children: "View" })
5755
+ /* @__PURE__ */ jsx14("button", { className: "mb-second-review-link", type: "button", onClick: () => void openAttachment(attachment).catch(() => void 0), children: "View" })
5756
5756
  ] }, attachment.id)),
5757
- /* @__PURE__ */ jsxs14("label", { className: "mbsr-upload", children: [
5757
+ /* @__PURE__ */ jsxs14("label", { className: "mb-second-review-upload", children: [
5758
5758
  /* @__PURE__ */ jsx14("input", { type: "file", accept: "application/pdf,.pdf", multiple: true, onChange: addUploads }),
5759
5759
  /* @__PURE__ */ jsxs14("span", { children: [
5760
5760
  /* @__PURE__ */ jsx14("strong", { children: "Choose one or more PDF files" }),
5761
5761
  " to attach"
5762
5762
  ] })
5763
5763
  ] }),
5764
- uploads.map((upload, index) => /* @__PURE__ */ jsxs14("div", { className: "mbsr-uploaded", children: [
5764
+ uploads.map((upload, index) => /* @__PURE__ */ jsxs14("div", { className: "mb-second-review-uploaded", children: [
5765
5765
  /* @__PURE__ */ jsx14("span", { children: upload.file.name }),
5766
- /* @__PURE__ */ jsx14("button", { className: "mbsr-link", type: "button", onClick: () => setUploads((current) => current.filter((_, itemIndex) => itemIndex !== index)), children: "Remove" })
5766
+ /* @__PURE__ */ jsx14("button", { className: "mb-second-review-link", type: "button", onClick: () => setUploads((current) => current.filter((_, itemIndex) => itemIndex !== index)), children: "Remove" })
5767
5767
  ] }, `${upload.file.name}-${index}`))
5768
5768
  ] }),
5769
- formError || error?.message ? /* @__PURE__ */ jsx14("div", { className: "mbsr-error", role: "alert", children: formError || error?.message }) : null,
5770
- /* @__PURE__ */ jsxs14("div", { className: "mbsr-actions", children: [
5771
- /* @__PURE__ */ jsx14("button", { className: "mbsr-button secondary", type: "button", disabled: submitting || preparing, onClick: onCancel, children: "Cancel" }),
5772
- /* @__PURE__ */ jsx14("button", { className: "mbsr-button primary", type: "button", disabled: submitting || preparing || !selected.length || invalidReason, onClick: () => void continueToDelivery(), children: preparing ? "Preparing\u2026" : "Continue to delivery" })
5769
+ formError || error?.message ? /* @__PURE__ */ jsx14("div", { className: "mb-second-review-error", role: "alert", children: formError || error?.message }) : null,
5770
+ /* @__PURE__ */ jsxs14("div", { className: "mb-second-review-actions", children: [
5771
+ /* @__PURE__ */ jsx14("button", { className: "mb-second-review-button secondary", type: "button", disabled: submitting || preparing, onClick: onCancel, children: "Cancel" }),
5772
+ /* @__PURE__ */ jsx14("button", { className: "mb-second-review-button primary", type: "button", disabled: submitting || preparing || !selected.length || invalidReason, onClick: () => void continueToDelivery(), children: preparing ? "Preparing\u2026" : "Continue to delivery" })
5773
5773
  ] })
5774
5774
  ] }),
5775
5775
  delivery ? /* @__PURE__ */ jsx14(SendRouteDialog, { title: "Confirm Second Review delivery", delivery, submitting: submitting || preparing, error: formError || error?.message || null, onCancel: () => setDelivery(null), onConfirm: (route) => void submit(route) }) : null
@@ -5925,6 +5925,7 @@ function useBillLifecycle({
5925
5925
  openAttachment,
5926
5926
  openEor,
5927
5927
  downloadPacket,
5928
+ addNote: (input) => mutate(() => client.addNote(input)),
5928
5929
  closeBill: (input) => mutate(() => client.closeBill(input)),
5929
5930
  reopenBill: (input) => mutate(() => client.reopenBill(input)),
5930
5931
  postPayment: (input) => mutate(() => client.postPayment(input)),
@@ -6175,6 +6176,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6175
6176
  const [selectedSubmissionId, setSelectedSubmissionId] = useState12();
6176
6177
  const [panel, setPanel] = useState12("");
6177
6178
  const [notice, setNotice] = useState12("");
6179
+ const [note, setNote] = useState12("");
6178
6180
  const [reason, setReason] = useState12("");
6179
6181
  const [correctionError, setCorrectionError] = useState12("");
6180
6182
  const [newBillError, setNewBillError] = useState12("");
@@ -6228,6 +6230,17 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6228
6230
  } catch {
6229
6231
  }
6230
6232
  };
6233
+ const addNote = async () => {
6234
+ const value = note.trim();
6235
+ if (!value) return;
6236
+ setNotice("");
6237
+ try {
6238
+ await lifecycle.addNote({ note: value, ...actor });
6239
+ setNote("");
6240
+ setNotice("Note added.");
6241
+ } catch {
6242
+ }
6243
+ };
6231
6244
  const submitCorrection = async (value) => {
6232
6245
  setNotice("");
6233
6246
  setCorrectionError("");
@@ -6318,7 +6331,8 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6318
6331
  const mappedRibbonItems = data.history ? billSubmissionsRibbonFromHistory(data.history, data.attempts) : [];
6319
6332
  const activeSubmissionId = selectedSubmissionId ?? mappedRibbonItems.find((item) => item.active)?.id ?? mappedRibbonItems[mappedRibbonItems.length - 1]?.id;
6320
6333
  const ribbonItems = mappedRibbonItems.map((item) => ({ ...item, active: item.id === activeSubmissionId }));
6321
- const selectedHistoryEntryId = ribbonItems.find((item) => item.id === activeSubmissionId)?.historyEntryId;
6334
+ const selectedAttempt = data.attempts?.find((attempt) => attempt.id === activeSubmissionId);
6335
+ const billNotes = (data.history ?? []).filter((entry) => entry.kind === "note").slice().reverse();
6322
6336
  const statusContacts = reportBillStatusContacts(data.delivery);
6323
6337
  const receiptEntries = (data.history ?? []).filter((entry) => entry.kind === "submission" || entry.kind === "ack");
6324
6338
  const reviewDeadline = secondReviewDeadline(data.eors);
@@ -6326,7 +6340,7 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6326
6340
  /* @__PURE__ */ jsx15("style", { children: CONNECTED_LIFECYCLE_STYLES }),
6327
6341
  ribbonItems.length >= 2 ? /* @__PURE__ */ jsx15(BillSubmissionsRibbon, { items: ribbonItems, onSelect: (item) => {
6328
6342
  setSelectedSubmissionId(item.id);
6329
- setTab("history");
6343
+ setTab("details");
6330
6344
  }, ...appearance ? { appearance } : {} }) : null,
6331
6345
  data.lifecycle.state.toLowerCase() === "rejected" && data.rejection ? /* @__PURE__ */ jsx15(BillRejectionNotice, { rejection: data.rejection, submittedAt: data.lifecycle.submittedAt ?? null, ...appearance ? { appearance } : {} }) : /* @__PURE__ */ jsx15(BillLifecycleProgress, { state: data.lifecycle.state, nativeStatus: data.lifecycle.nativeStatus, submittedAt: data.lifecycle.submittedAt ?? null, agingDays: data.lifecycle.agingDays ?? null, ...appearance ? { appearance } : {} }),
6332
6346
  /* @__PURE__ */ jsxs15("header", { className: "mb-lifecycle-head", children: [
@@ -6348,6 +6362,40 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6348
6362
  /* @__PURE__ */ jsx15("button", { type: "button", role: "tab", "aria-selected": tab === "history", onClick: () => setTab("history"), children: "Bill history" })
6349
6363
  ] }),
6350
6364
  tab === "details" ? /* @__PURE__ */ jsxs15("div", { className: "mb-lifecycle-tabpanel", role: "tabpanel", children: [
6365
+ selectedAttempt && ribbonItems.length >= 2 ? /* @__PURE__ */ jsxs15("section", { className: "mb-lifecycle-attempt-detail", "aria-label": "Selected submission detail", children: [
6366
+ /* @__PURE__ */ jsxs15("header", { children: [
6367
+ /* @__PURE__ */ jsxs15("div", { children: [
6368
+ /* @__PURE__ */ jsx15("span", { children: "Selected submission" }),
6369
+ /* @__PURE__ */ jsx15("h3", { children: selectedAttempt.label })
6370
+ ] }),
6371
+ /* @__PURE__ */ jsx15("strong", { children: selectedAttempt.isCurrent ? "Current" : "Previous" })
6372
+ ] }),
6373
+ /* @__PURE__ */ jsxs15("dl", { children: [
6374
+ /* @__PURE__ */ jsxs15("div", { children: [
6375
+ /* @__PURE__ */ jsx15("dt", { children: "Bill" }),
6376
+ /* @__PURE__ */ jsxs15("dd", { children: [
6377
+ "#",
6378
+ selectedAttempt.billNumber || data.bill.billNumber
6379
+ ] })
6380
+ ] }),
6381
+ /* @__PURE__ */ jsxs15("div", { children: [
6382
+ /* @__PURE__ */ jsx15("dt", { children: "Delivery" }),
6383
+ /* @__PURE__ */ jsx15("dd", { children: selectedAttempt.deliveryLabel || "\u2014" })
6384
+ ] }),
6385
+ /* @__PURE__ */ jsxs15("div", { children: [
6386
+ /* @__PURE__ */ jsx15("dt", { children: "Sent" }),
6387
+ /* @__PURE__ */ jsx15("dd", { children: selectedAttempt.sentAt ? new Date(selectedAttempt.sentAt).toLocaleString() : "\u2014" })
6388
+ ] }),
6389
+ /* @__PURE__ */ jsxs15("div", { children: [
6390
+ /* @__PURE__ */ jsx15("dt", { children: "Status" }),
6391
+ /* @__PURE__ */ jsx15("dd", { children: selectedAttempt.ackLabel || selectedAttempt.status || "Submitted" })
6392
+ ] }),
6393
+ selectedAttempt.complianceLabel ? /* @__PURE__ */ jsxs15("div", { children: [
6394
+ /* @__PURE__ */ jsx15("dt", { children: selectedAttempt.complianceLabel }),
6395
+ /* @__PURE__ */ jsx15("dd", { children: selectedAttempt.complianceAt ? new Date(selectedAttempt.complianceAt).toLocaleDateString() : "\u2014" })
6396
+ ] }) : null
6397
+ ] })
6398
+ ] }) : null,
6351
6399
  data.eors.length || data.payments.length || ["processed", "denied", "partially_paid"].includes(data.lifecycle.state) ? /* @__PURE__ */ jsx15(BillExplanationOfReview, { remittance: data.remittance, eors: data.eors, payments: data.payments, submittedAt: data.lifecycle.submittedAt ?? null, onOpenEor: lifecycle.openEor, ...appearance ? { appearance } : {} }) : null,
6352
6400
  showSandboxControls ? /* @__PURE__ */ jsxs15("section", { className: "mb-lifecycle-simulator", "aria-label": "Sandbox lifecycle simulator", children: [
6353
6401
  /* @__PURE__ */ jsxs15("div", { children: [
@@ -6360,8 +6408,35 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6360
6408
  /* @__PURE__ */ jsx15("span", { children: scenario.detail })
6361
6409
  ] }, scenario.id)) }) : /* @__PURE__ */ jsx15("p", { className: "mb-lifecycle-simulator-idle", children: "No simulated payer transition is needed at this stage. Use the bill action below to continue." })
6362
6410
  ] }) : null,
6363
- /* @__PURE__ */ jsx15(BillReadOnlyForm, { data, onOpenAttachment: lifecycle.openAttachment, ...appearance ? { appearance } : {} })
6364
- ] }) : /* @__PURE__ */ jsx15("div", { className: "mb-lifecycle-tabpanel", role: "tabpanel", children: data.history?.length ? /* @__PURE__ */ jsx15(BillHistoryTable, { entries: data.history, ...selectedHistoryEntryId ? { selectedEntryId: selectedHistoryEntryId } : {}, onOpenDocument: lifecycle.openAttachment, ...appearance ? { appearance } : {} }) : /* @__PURE__ */ jsx15(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }) }),
6411
+ /* @__PURE__ */ jsx15(BillReadOnlyForm, { data, onOpenAttachment: lifecycle.openAttachment, ...appearance ? { appearance } : {} }),
6412
+ /* @__PURE__ */ jsxs15("section", { className: "mb-lifecycle-notes", "aria-label": "Bill notes", children: [
6413
+ /* @__PURE__ */ jsxs15("header", { children: [
6414
+ /* @__PURE__ */ jsxs15("div", { children: [
6415
+ /* @__PURE__ */ jsx15("h3", { children: "Bill notes" }),
6416
+ /* @__PURE__ */ jsx15("p", { children: "Shared with everyone working this bill through the Partner API." })
6417
+ ] }),
6418
+ /* @__PURE__ */ jsx15("span", { children: billNotes.length })
6419
+ ] }),
6420
+ billNotes.length ? /* @__PURE__ */ jsx15("ol", { children: billNotes.map((entry) => /* @__PURE__ */ jsxs15("li", { children: [
6421
+ /* @__PURE__ */ jsx15("p", { children: entry.summary }),
6422
+ /* @__PURE__ */ jsxs15("small", { children: [
6423
+ entry.actor || "System",
6424
+ " \xB7 ",
6425
+ usDate(entry.date)
6426
+ ] })
6427
+ ] }, entry.id)) }) : /* @__PURE__ */ jsx15("p", { className: "mb-lifecycle-notes-empty", children: "No notes yet." }),
6428
+ /* @__PURE__ */ jsxs15("form", { onSubmit: (event) => {
6429
+ event.preventDefault();
6430
+ void addNote();
6431
+ }, children: [
6432
+ /* @__PURE__ */ jsxs15("label", { children: [
6433
+ /* @__PURE__ */ jsx15("span", { children: "Add a note" }),
6434
+ /* @__PURE__ */ jsx15("textarea", { value: note, maxLength: 2e3, placeholder: "Add context for the billing team\u2026", onChange: (event) => setNote(event.target.value) })
6435
+ ] }),
6436
+ /* @__PURE__ */ jsx15("button", { type: "submit", className: "mb-lifecycle-button primary", disabled: lifecycle.isMutating || !note.trim(), children: lifecycle.isMutating ? "Adding\u2026" : "Add note" })
6437
+ ] })
6438
+ ] })
6439
+ ] }) : /* @__PURE__ */ jsx15("div", { className: "mb-lifecycle-tabpanel", role: "tabpanel", children: data.history?.length ? /* @__PURE__ */ jsx15(BillHistoryTable, { entries: data.history, onOpenDocument: lifecycle.openAttachment, ...appearance ? { appearance } : {} }) : /* @__PURE__ */ jsx15(BillActivityTimeline, { events: data.activity, ...appearance ? { appearance } : {} }) }),
6365
6440
  viewEor || actions.length ? /* @__PURE__ */ jsxs15("aside", { className: "mb-lifecycle-actions-sheet", "aria-label": "Bill actions", children: [
6366
6441
  viewEor && data.eors[0] ? /* @__PURE__ */ jsx15("button", { type: "button", className: "mb-lifecycle-button secondary", onClick: () => void lifecycle.openEor(data.eors[0]).catch(() => void 0), children: viewEor.label }) : null,
6367
6442
  actions.map((action) => /* @__PURE__ */ jsx15("button", { type: "button", className: action.primary ? "mb-lifecycle-button primary" : "mb-lifecycle-button secondary", onClick: () => {
@@ -6591,19 +6666,23 @@ function ConnectedBillLifecycle({ appearance, actorName, claimsAdministratorHint
6591
6666
  ] });
6592
6667
  }
6593
6668
  var CONNECTED_LIFECYCLE_STYLES = `
6669
+ .mb-lifecycle-attempt-detail{display:grid;gap:15px;padding:18px;border:1px solid color-mix(in srgb,var(--mb-accent) 38%,var(--mb-border));border-radius:var(--mb-radius,14px);background:color-mix(in srgb,var(--mb-accent) 5%,var(--mb-surface))}.mb-lifecycle-attempt-detail>header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.mb-lifecycle-attempt-detail>header span{color:var(--mb-accent);font-size:.72rem;font-weight:850;letter-spacing:.08em;text-transform:uppercase}.mb-lifecycle-attempt-detail h3{margin:3px 0 0;font-size:1.08rem}.mb-lifecycle-attempt-detail>header>strong{padding:4px 9px;border:1px solid color-mix(in srgb,var(--mb-accent) 35%,var(--mb-border));border-radius:999px;background:var(--mb-surface);color:var(--mb-accent);font-size:.75rem}.mb-lifecycle-attempt-detail dl{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:0}.mb-lifecycle-attempt-detail dl>div{display:grid;gap:2px;min-width:0}.mb-lifecycle-attempt-detail dt{color:var(--mb-muted);font-size:.7rem;font-weight:800;letter-spacing:.06em;text-transform:uppercase}.mb-lifecycle-attempt-detail dd{min-width:0;margin:0;font-weight:700;overflow-wrap:anywhere}
6670
+ .mb-lifecycle-notes{display:grid;gap:14px;padding:20px;border:1px solid var(--mb-border);border-radius:var(--mb-radius,14px);background:var(--mb-surface)}.mb-lifecycle-notes>header{display:flex;align-items:center;justify-content:space-between;gap:16px}.mb-lifecycle-notes h3{margin:0;font-size:1.08rem}.mb-lifecycle-notes header p{margin:3px 0 0;color:var(--mb-muted)}.mb-lifecycle-notes>header>span{display:grid;place-items:center;min-width:28px;height:28px;border-radius:999px;background:var(--mb-soft);font-weight:750}.mb-lifecycle-notes ol{display:grid;gap:9px;margin:0;padding:0;list-style:none}.mb-lifecycle-notes li{padding:11px 13px;border-left:3px solid color-mix(in srgb,var(--mb-accent) 52%,var(--mb-border));border-radius:0 8px 8px 0;background:var(--mb-soft)}.mb-lifecycle-notes li p{margin:0;white-space:pre-wrap}.mb-lifecycle-notes li small{display:block;margin-top:4px;color:var(--mb-muted)}.mb-lifecycle-notes-empty{margin:0;color:var(--mb-muted)}.mb-lifecycle-notes form{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px}.mb-lifecycle-notes label{display:grid;gap:6px;font-size:.82rem;font-weight:750}.mb-lifecycle-notes textarea{width:100%;min-height:76px;padding:10px 12px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius,8px);background:var(--mb-input,#fff);color:var(--mb-text);font:inherit;resize:vertical}
6594
6671
  .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)}
6595
6672
  .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}
6596
6673
  .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}
6597
6674
  .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}
6598
6675
  .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}
6599
- @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}}
6676
+ @media(max-width:700px){.mb-lifecycle-attempt-detail dl{grid-template-columns:repeat(2,minmax(0,1fr))}.mb-lifecycle-notes form{grid-template-columns:1fr}.mb-lifecycle-notes form button{width:100%}.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}}
6600
6677
  `;
6601
6678
 
6602
6679
  // src/connected-billing-workspace.tsx
6603
6680
  import {
6604
6681
  useCallback as useCallback5,
6605
6682
  useEffect as useEffect11,
6683
+ useLayoutEffect,
6606
6684
  useMemo as useMemo10,
6685
+ useRef as useRef7,
6607
6686
  useState as useState13
6608
6687
  } from "react";
6609
6688
 
@@ -6735,6 +6814,7 @@ function createBillingOperationsClient({
6735
6814
  import { Fragment as Fragment14, jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
6736
6815
  var css11 = `
6737
6816
  .mbow{color:var(--mb-text);font:14px/1.45 var(--mb-font);background:var(--mb-soft);border-radius:var(--mb-radius);padding:20px}.mbow *{box-sizing:border-box}.mbow h2,.mbow h3,.mbow p{margin:0}.mbow a{color:var(--mb-accent)}
6817
+ .mbow-workspace{width:100%;height:100%;max-height:var(--mbow-available-height,100dvh);min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
6738
6818
  .mbow-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:18px}.mbow-head h2{font-size:24px;line-height:1.2}.mbow-sub{color:var(--mb-muted);margin-top:4px!important}.mbow-actions{display:flex;gap:8px;flex-wrap:wrap}
6739
6819
  .mbow-button,.mbow-input,.mbow-select{min-height:38px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text);font:inherit}.mbow-button{padding:7px 12px;cursor:pointer;font-weight:650}.mbow-button:hover{border-color:var(--mb-accent)}.mbow-button.primary{background:var(--mb-accent);border-color:var(--mb-accent);color:var(--mb-accent-contrast)}.mbow-button:disabled{opacity:.55;cursor:not-allowed}.mbow-input,.mbow-select{padding:7px 10px}.mbow-input{min-width:260px;flex:1}
6740
6820
  .mbow-tabs{display:flex;gap:4px;border-bottom:1px solid var(--mb-border);margin-bottom:18px;overflow:auto}.mbow-tab{border:0;border-bottom:3px solid transparent;background:transparent;color:var(--mb-muted);padding:10px 13px;font:inherit;font-weight:700;white-space:nowrap;cursor:pointer}.mbow-tab.active{color:var(--mb-text);border-bottom-color:var(--mb-accent)}
@@ -6759,12 +6839,40 @@ function defaultRange(days = 29) {
6759
6839
  const iso = (date2) => date2.toISOString().slice(0, 10);
6760
6840
  return { from: iso(from), to: iso(to) };
6761
6841
  }
6762
- function Surface({ appearance, className = "", style, children }) {
6763
- return /* @__PURE__ */ jsxs16("div", { className: `mbow ${className}`.trim(), style: mindBillAppearanceStyle(appearance, style), children: [
6842
+ function Surface({ appearance, className = "", style, children, surfaceRef }) {
6843
+ return /* @__PURE__ */ jsxs16("div", { ref: surfaceRef, className: `mbow ${className}`.trim(), style: mindBillAppearanceStyle(appearance, style), children: [
6764
6844
  /* @__PURE__ */ jsx16("style", { children: css11 }),
6765
6845
  children
6766
6846
  ] });
6767
6847
  }
6848
+ function useAvailableViewportHeight() {
6849
+ const workspaceRef = useRef7(null);
6850
+ const [availableHeight, setAvailableHeight] = useState13(null);
6851
+ useLayoutEffect(() => {
6852
+ const element = workspaceRef.current;
6853
+ if (!element || typeof window === "undefined") return;
6854
+ let frame = 0;
6855
+ const update = () => {
6856
+ window.cancelAnimationFrame(frame);
6857
+ frame = window.requestAnimationFrame(() => {
6858
+ const viewportHeight = window.visualViewport?.height ?? window.innerHeight;
6859
+ const top = Math.max(0, element.getBoundingClientRect().top);
6860
+ setAvailableHeight(Math.max(240, viewportHeight - top - 16));
6861
+ });
6862
+ };
6863
+ update();
6864
+ window.addEventListener("resize", update);
6865
+ window.addEventListener("scroll", update, true);
6866
+ window.visualViewport?.addEventListener("resize", update);
6867
+ return () => {
6868
+ window.cancelAnimationFrame(frame);
6869
+ window.removeEventListener("resize", update);
6870
+ window.removeEventListener("scroll", update, true);
6871
+ window.visualViewport?.removeEventListener("resize", update);
6872
+ };
6873
+ }, []);
6874
+ return { workspaceRef, availableHeight };
6875
+ }
6768
6876
  function useClient(options) {
6769
6877
  return useMemo10(() => createBillingOperationsClient(options), [options.apiBaseUrl, options.fetch, options.getSession, options.sessionEndpoint]);
6770
6878
  }
@@ -7089,7 +7197,11 @@ function ConnectedBillingWorkspace({ appearance, className, style, initialView =
7089
7197
  const [view, setView] = useState13(initialView);
7090
7198
  const [billQuery, setBillQuery] = useState13({ status: "all" });
7091
7199
  const [selectedBillId, setSelectedBillId] = useState13(null);
7092
- if (selectedBillId) return /* @__PURE__ */ jsxs16(Surface, { appearance, className, style, children: [
7200
+ const { workspaceRef, availableHeight } = useAvailableViewportHeight();
7201
+ const workspaceClassName = ["mbow-workspace", className].filter(Boolean).join(" ");
7202
+ const hasExplicitHeight = style?.height != null || style?.maxHeight != null;
7203
+ const workspaceStyle = availableHeight == null || hasExplicitHeight ? style : { ...style, maxHeight: availableHeight };
7204
+ if (selectedBillId) return /* @__PURE__ */ jsxs16(Surface, { surfaceRef: workspaceRef, appearance, className: workspaceClassName, style: workspaceStyle, children: [
7093
7205
  /* @__PURE__ */ jsx16("button", { className: "mbow-button mbow-back", type: "button", onClick: () => setSelectedBillId(null), children: "\u2190 Back to bills" }),
7094
7206
  /* @__PURE__ */ jsx16(ConnectedBillLifecycle, { billId: selectedBillId, ...options, ...appearance ? { appearance } : {} })
7095
7207
  ] });
@@ -7098,7 +7210,7 @@ function ConnectedBillingWorkspace({ appearance, className, style, initialView =
7098
7210
  setSelectedBillId(null);
7099
7211
  };
7100
7212
  const appearanceProps = appearance ? { appearance } : {};
7101
- return /* @__PURE__ */ jsxs16(Surface, { appearance, className, style, children: [
7213
+ return /* @__PURE__ */ jsxs16(Surface, { surfaceRef: workspaceRef, appearance, className: workspaceClassName, style: workspaceStyle, children: [
7102
7214
  /* @__PURE__ */ jsxs16("div", { className: "mbow-head", children: [
7103
7215
  /* @__PURE__ */ jsxs16("div", { children: [
7104
7216
  /* @__PURE__ */ jsx16("h2", { children: "Billing" }),
@@ -7116,7 +7228,7 @@ function ConnectedBillingWorkspace({ appearance, className, style, initialView =
7116
7228
 
7117
7229
  // src/index.tsx
7118
7230
  function widget(tagName, props) {
7119
- const ref = useRef7(null);
7231
+ const ref = useRef8(null);
7120
7232
  const { onMindBill, onMindBillError } = props;
7121
7233
  useEffect12(() => {
7122
7234
  const element = ref.current;