@tesouro/embedded-components-react 0.11.9 → 0.11.10

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.
Files changed (51) hide show
  1. package/dist/index.css +12 -49
  2. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index3.js +8 -6
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +99 -94
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +3 -4
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index14.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index15.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +1 -1
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index33.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index34.js +2 -2
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index36.js +2 -1
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index37.js +110 -100
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index48.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index49.js +1 -1
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index5.js +1 -1
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/ui/dist/index4.js +45 -40
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +259 -210
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +190 -165
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index8.js +7 -1
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index2.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +151 -143
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index3.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillPayWidget.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index5.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index6.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +19 -17
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index10.js +13 -2
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index11.js +52 -2
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +2 -40
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +3 -2
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +39 -9
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +2 -77
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +10 -0
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +77 -2
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +2 -3
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +25 -26
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +3 -2
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +28 -5
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +2 -33
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +6 -2
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +33 -0
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +2 -0
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index6.js +9 -30
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index8.js +29 -11
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index9.js +1 -53
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/util/dist/index.js +2 -1
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/util/dist/lib/groupCollapse.js +22 -0
  48. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  49. package/dist/packages/shared-ui-shadcn/dist/index.js +1637 -1507
  50. package/package.json +1 -1
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +0 -28
@@ -14,34 +14,35 @@ import { DuplicateVerdict as a } from "../../../util/dist/lib/duplicateVerdict.j
14
14
  import { formatScheduledDateLabel as o } from "../../../util/dist/lib/formatScheduledDateLabel.js";
15
15
  import { hasSuspectedPayableDuplicate as s, suspectedPayableDuplicates as c } from "../../../util/dist/lib/payableDuplicates.js";
16
16
  import { compareByArrival as l, duplicateVerdictMatches as u, resolveDuplicateOriginalId as d } from "../../../util/dist/lib/groupDuplicates.js";
17
- import { isEditablePayableStatus as ee } from "../../../util/dist/lib/isEditablePayableStatus.js";
18
- import { payableRemoval as f } from "../../../util/dist/lib/payableRemoval.js";
19
- import { resolveVendorName as te } from "../../../util/dist/lib/resolveVendor.js";
17
+ import { isEditablePayableStatus as f } from "../../../util/dist/lib/isEditablePayableStatus.js";
18
+ import { payableRemoval as p } from "../../../util/dist/lib/payableRemoval.js";
19
+ import { resolveVendorName as ee } from "../../../util/dist/lib/resolveVendor.js";
20
+ import { buildGroupCollapse as m } from "../../../util/dist/lib/groupCollapse.js";
20
21
  import "../../../util/dist/index.js";
21
- import { derivePayableStatus as ne } from "../../../../shared/document-status/util/dist/lib/derivePayableStatus.js";
22
- import { useApplyDuplicateVerdictsMutation as p } from "../../../data-access/dist/lib/useApplyDuplicateVerdictsMutation.js";
22
+ import { derivePayableStatus as te } from "../../../../shared/document-status/util/dist/lib/derivePayableStatus.js";
23
+ import { useApplyDuplicateVerdictsMutation as h } from "../../../data-access/dist/lib/useApplyDuplicateVerdictsMutation.js";
23
24
  import "../../../data-access/dist/index.js";
24
- import { BillColumn as m } from "../../ui/dist/index19.js";
25
+ import { BillColumn as g } from "../../ui/dist/index19.js";
25
26
  import "../../ui/dist/index.js";
26
- import { BillQueue as h, DEFAULT_BILL_QUEUE as g, billQueueColumns as _, billQueueFilters as re, billQueueOffersAddPanel as ie, billSortColumnId as ae, billSortField as oe } from "./index5.js";
27
+ import { BillQueue as _, DEFAULT_BILL_QUEUE as ne, billQueueColumns as v, billQueueFilters as re, billQueueOffersAddPanel as ie, billSortColumnId as ae, billSortField as oe } from "./index5.js";
27
28
  import { duplicateRemovalPrompt as se } from "./index11.js";
28
29
  import { useBillsFilters as ce } from "./index14.js";
29
- import { BillVendorLookup as v, useBillVendorNames as le } from "./index15.js";
30
- import { useFirstPayablesPagesQuery as ue } from "../../data-access/dist/index2.js";
31
- import { usePayablesQuery as de } from "../../data-access/dist/index4.js";
32
- import { usePayablesTotalCountQuery as fe } from "../../data-access/dist/index5.js";
30
+ import { BillVendorLookup as le, useBillVendorNames as ue } from "./index15.js";
31
+ import { useFirstPayablesPagesQuery as de } from "../../data-access/dist/index2.js";
32
+ import { usePayablesQuery as fe } from "../../data-access/dist/index4.js";
33
+ import { usePayablesTotalCountQuery as pe } from "../../data-access/dist/index5.js";
33
34
  import "../../data-access/dist/index.js";
34
- import { useCallback as y, useEffect as pe, useMemo as b, useState as x } from "react";
35
- import { BanIcon as me, FileCheckIcon as he, Trash2Icon as ge } from "lucide-react";
35
+ import { useCallback as y, useEffect as me, useMemo as b, useState as x } from "react";
36
+ import { BanIcon as he, FileCheckIcon as ge, Trash2Icon as _e } from "lucide-react";
36
37
  // ../../libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js
37
- var _e = 10, S = 100, ve = 3, ye = [{
38
+ var ve = 10, S = 100, ye = 3, be = [{
38
39
  id: "addedOnLabel",
39
40
  desc: !0
40
41
  }], C = {
41
42
  AllBills: "allBills",
42
43
  PossibleDuplicates: "possibleDuplicates"
43
44
  };
44
- function be(e, t) {
45
+ function xe(e, t) {
45
46
  let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Map(), i = (e) => {
46
47
  r.has(e) || r.set(e, /* @__PURE__ */ new Set());
47
48
  }, a = (e, t) => {
@@ -54,7 +55,7 @@ function be(e, t) {
54
55
  for (let n of e) a(t.id, n.matched_payable_id);
55
56
  }
56
57
  }
57
- let o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
58
+ let o = [], s = /* @__PURE__ */ new Set();
58
59
  for (let e of r.keys()) {
59
60
  if (s.has(e)) continue;
60
61
  let i = [], a = [e];
@@ -64,95 +65,113 @@ function be(e, t) {
64
65
  for (let t of r.get(e) ?? []) s.has(t) || (s.add(t), a.push(t));
65
66
  }
66
67
  if (i.length === 0) continue;
67
- let c = i.map((e) => n.get(e)).filter((e) => !!e).sort(l), u = d(c), [ee] = c, f = {
68
- key: `duplicate-group:${[...i].sort().join(":")}`,
69
- label: t.groupHeader({
70
- vendorLabel: te(ee),
71
- invoiceNumberLabel: ee?.document_id ?? ""
72
- }),
73
- originalPayableId: u
68
+ let c = i.map((e) => n.get(e)).filter((e) => !!e).sort(l), u = d(c), [f] = c, p = ee(f), m = f?.document_id ?? "", te = u ?? f?.id ?? e, h = `duplicate-group:${p || m ? `${p}|${m}` : te}`;
69
+ o.push({
70
+ componentIds: i,
71
+ baseKey: h,
72
+ anchorId: te,
73
+ group: {
74
+ label: t.groupHeader({
75
+ vendorLabel: p,
76
+ invoiceNumberLabel: m
77
+ }),
78
+ title: p,
79
+ meta: m ? t.groupInvoice(m) : void 0,
80
+ invoiceNumberLabel: m,
81
+ vendorCounterpartId: f?.counterpart_id ?? void 0,
82
+ originalPayableId: u
83
+ }
84
+ });
85
+ }
86
+ let u = /* @__PURE__ */ new Map();
87
+ for (let { baseKey: e } of o) u.set(e, (u.get(e) ?? 0) + 1);
88
+ let f = /* @__PURE__ */ new Map();
89
+ for (let { componentIds: e, baseKey: t, anchorId: n, group: r } of o) {
90
+ let i = (u.get(t) ?? 0) > 1 ? `${t}:${n}` : t, a = {
91
+ ...r,
92
+ key: i
74
93
  };
75
- for (let e of i) o.set(e, f);
94
+ for (let t of e) f.set(t, a);
76
95
  }
77
- return o;
96
+ return f;
78
97
  }
79
- function xe({ enabled: c = !0, canPay: l, canReadVendors: d = !0, isVendorFilterPaused: v = !1, filterLabels: xe, onOpenBill: we, duplicateRowNote: Te, attachmentLabel: Ee, duplicateGroupLabels: w, canManageDuplicates: De = !1, duplicateView: T = C.AllBills, scheduledRelativeDayLabels: Oe }) {
80
- let ke = i(), [E, Ae] = x(g), [je, Me] = x(ye), [D, Ne] = x(_e), [Pe, O] = x(), [Fe, Ie] = x(l);
81
- l !== void 0 && Fe !== l && (Ie(l), O(void 0));
82
- let k = l ?? Fe, [Le, A] = x(0), [j, M] = x(""), [N, Re] = x(""), [P, F] = x(), [I, L] = x(), R = y(() => {
98
+ function Se({ enabled: c = !0, canPay: d, canReadVendors: m = !0, isVendorFilterPaused: le = !1, filterLabels: Se, onOpenBill: Ee, duplicateRowNote: De, attachmentLabel: Oe, duplicateGroupLabels: w, canManageDuplicates: ke = !1, duplicateView: T = C.AllBills, scheduledRelativeDayLabels: Ae }) {
99
+ let je = i(), [E, Me] = x(ne), [Ne, Pe] = x(be), [D, Fe] = x(ve), [Ie, O] = x(), [Le, Re] = x(d);
100
+ d !== void 0 && Le !== d && (Re(d), O(void 0));
101
+ let k = d ?? Le, [ze, A] = x(0), [j, M] = x(""), [N, Be] = x(""), [P, F] = x(), [I, Ve] = x(), L = y(() => {
83
102
  O(void 0), A(0);
84
103
  }, []);
85
- pe(() => {
104
+ me(() => {
86
105
  if (j === N) return;
87
106
  let e = setTimeout(() => {
88
- Re(j), R();
107
+ Be(j), L();
89
108
  }, 300);
90
109
  return () => clearTimeout(e);
91
110
  }, [
92
111
  j,
93
112
  N,
94
- R
95
- ]), pe(() => {
96
- R();
97
- }, [T, R]);
98
- let z = T === C.PossibleDuplicates, B = ce({
99
- offersStatusFilter: E === h.All && !z,
100
- offersVendorFilter: d,
101
- isVendorFilterPaused: v,
102
- labels: xe,
103
- onFiltersChange: R
104
- }), { clearAll: ze, filterByVendor: Be } = B, Ve = je[0], He = oe(Ve?.id), Ue = He ? Ve?.desc ? "desc" : "asc" : void 0, V = z ? h.All : E, We = b(() => {
105
- let e = re(V, k ?? !1);
113
+ L
114
+ ]), me(() => {
115
+ L();
116
+ }, [T, L]);
117
+ let R = T === C.PossibleDuplicates, z = ce({
118
+ offersStatusFilter: E === _.All && !R,
119
+ offersVendorFilter: m,
120
+ isVendorFilterPaused: le,
121
+ labels: Se,
122
+ onFiltersChange: L
123
+ }), { clearAll: He, filterByVendor: Ue } = z, We = Ne[0], Ge = oe(We?.id), Ke = Ge ? We?.desc ? "desc" : "asc" : void 0, B = R ? _.All : E, qe = b(() => {
124
+ let e = re(B, k ?? !1);
106
125
  return {
107
- ...B.query,
126
+ ...z.query,
108
127
  ...e,
109
- limit: z ? S : D,
110
- pagination_token: z ? void 0 : Pe,
111
- status__in: z ? void 0 : e.status__in ?? B.query.status__in,
112
- duplicate_match_status: z ? "suspected" : void 0,
128
+ limit: R ? S : D,
129
+ pagination_token: R ? void 0 : Ie,
130
+ status__in: R ? void 0 : e.status__in ?? z.query.status__in,
131
+ duplicate_match_status: R ? "suspected" : void 0,
113
132
  counterpart_name__icontains: N || void 0,
114
- sort: He,
115
- order: Ue
133
+ sort: Ge,
134
+ order: Ke
116
135
  };
117
136
  }, [
118
- B.query,
137
+ z.query,
119
138
  D,
120
- Pe,
121
- z,
122
- V,
139
+ Ie,
140
+ R,
141
+ B,
123
142
  k,
124
143
  N,
125
- He,
126
- Ue
127
- ]), { organizationId: Ge } = r(), H = JSON.stringify([Ge, We]), U = de({
128
- ...We,
129
- enabled: c && l !== void 0 && !z,
144
+ Ge,
145
+ Ke
146
+ ]), { organizationId: Je } = r(), V = JSON.stringify([Je, qe]), H = fe({
147
+ ...qe,
148
+ enabled: c && d !== void 0 && !R,
130
149
  pollWhileOcrProcessing: !0
131
- }), W = ue({
132
- ...We,
133
- enabled: c && z,
134
- maxPages: ve
135
- }), G = z ? {
136
- ...W,
137
- data: { data: W.payables },
138
- isLoading: W.isResolving,
139
- isFetching: W.isFetching || W.isResolving
140
- } : U, K = (G.data?.data ?? []).filter((e) => e.ocr_status !== "processing"), q = p(), J = y(async (t, n, r, i) => {
150
+ }), U = de({
151
+ ...qe,
152
+ enabled: c && R,
153
+ maxPages: ye
154
+ }), W = R ? {
155
+ ...U,
156
+ data: { data: U.payables },
157
+ isLoading: U.isResolving,
158
+ isFetching: U.isFetching || U.isResolving
159
+ } : H, G = (W.data?.data ?? []).filter((e) => e.ocr_status !== "processing"), K = h(), q = y(async (t, n, r, i) => {
141
160
  let a = u(t, n, i);
142
161
  if (a.length) try {
143
- await q.mutateAsync({
162
+ await K.mutateAsync({
144
163
  verdict: n,
145
164
  targets: a.map((e) => ({
146
165
  payableId: t.id,
147
166
  duplicateId: e.id,
148
167
  matchedPayableId: e.matched_payable_id,
149
- removeBy: f(t.status)
168
+ removeBy: p(t.status)
150
169
  }))
151
170
  }), e.success(r);
152
171
  } catch {
153
172
  e.error(w.actionFailedToast);
154
173
  }
155
- }, [q, w.actionFailedToast]), Y = b(() => ({
174
+ }, [K, w.actionFailedToast]), J = b(() => ({
156
175
  delete: {
157
176
  action: w.deleteAction,
158
177
  title: w.deleteConfirmTitle,
@@ -177,70 +196,77 @@ function xe({ enabled: c = !0, canPay: l, canReadVendors: d = !0, isVendorFilter
177
196
  backButton: w.cancelConfirmBackButton,
178
197
  toast: w.confirmedToast
179
198
  }
180
- }), [w]), Ke = P?.removeBy ?? "cancel", qe = y(async () => {
181
- P && (await J(P.payable, a.Remove, Y[P.removeBy].toast), F(void 0));
199
+ }), [w]), Ye = P?.removeBy ?? "cancel", Xe = y(async () => {
200
+ P && (await q(P.payable, a.Remove, J[P.removeBy].toast), F(void 0));
182
201
  }, [
183
- J,
202
+ q,
184
203
  P,
185
- Y
186
- ]), Je = y(async () => {
187
- I && (await J(I.payable, a.Keep, w.dismissedToast, I.originalPayableId), L(void 0));
204
+ J
205
+ ]), Ze = y(async () => {
206
+ I && (await q(I.payable, a.Keep, w.dismissedToast, I.originalPayableId), Ve(void 0));
188
207
  }, [
189
- J,
208
+ q,
190
209
  w.dismissedToast,
191
210
  I
192
- ]), [Ye, Xe] = x(H);
193
- pe(() => {
194
- G.isFetching || Xe(H);
195
- }, [G.isFetching, H]);
196
- let Ze = G.data?.data.length, Qe = Ze === 0, $e = fe({ enabled: c && Qe }), et = !Qe || ($e.data?.count ?? 1) > 0, X = b(() => T === C.PossibleDuplicates ? be(K, w) : /* @__PURE__ */ new Map(), [
211
+ ]), [Qe, $e] = x(V);
212
+ me(() => {
213
+ W.isFetching || $e(V);
214
+ }, [W.isFetching, V]);
215
+ let et = W.data?.data.length, tt = et === 0, nt = pe({ enabled: c && tt }), rt = !tt || (nt.data?.count ?? 1) > 0, Y = b(() => T === C.PossibleDuplicates ? xe(G, w) : /* @__PURE__ */ new Map(), [
197
216
  T,
198
- K,
217
+ G,
199
218
  w
200
- ]), tt = b(() => {
201
- if (X.size === 0) return K;
219
+ ]), it = b(() => {
220
+ if (Y.size === 0) return G;
202
221
  let e = /* @__PURE__ */ new Map();
203
- return K.forEach((t, n) => {
204
- let r = X.get(t.id)?.key;
222
+ return G.forEach((t, n) => {
223
+ let r = Y.get(t.id)?.key;
205
224
  r !== void 0 && !e.has(r) && e.set(r, n);
206
- }), K.map((t, n) => {
207
- let r = X.get(t.id);
208
- return {
209
- payable: t,
210
- index: n,
211
- order: e.get(r?.key ?? "") ?? n,
212
- leads: r?.originalPayableId === t.id ? 0 : 1
213
- };
214
- }).sort((e, t) => e.order - t.order || e.leads - t.leads || e.index - t.index).map(({ payable: e }) => e);
215
- }, [K, X]), { vendorNames: nt, lookup: rt } = le({
216
- payables: G.data?.data,
225
+ }), G.map((t, n) => ({
226
+ payable: t,
227
+ index: n,
228
+ order: e.get(Y.get(t.id)?.key ?? "") ?? n
229
+ })).sort((e, t) => e.order - t.order || l(e.payable, t.payable) || e.index - t.index).map(({ payable: e }) => e);
230
+ }, [G, Y]), { vendorNames: X, lookup: at } = ue({
231
+ payables: W.data?.data,
217
232
  enabled: c,
218
- canReadVendors: d,
219
- isPaused: v
220
- }), Z = b(() => tt.map((e) => {
221
- let r = ne({
233
+ canReadVendors: m,
234
+ isPaused: le
235
+ }), ot = y((e) => {
236
+ let t = e.title || (e.vendorCounterpartId ? X.get(e.vendorCounterpartId) ?? "" : "");
237
+ return {
238
+ key: e.key,
239
+ label: t === e.title ? e.label : w.groupHeader({
240
+ vendorLabel: t,
241
+ invoiceNumberLabel: e.invoiceNumberLabel
242
+ }),
243
+ title: t,
244
+ meta: e.meta
245
+ };
246
+ }, [X, w]), Z = b(() => Ce(it.map((e) => {
247
+ let r = te({
222
248
  apiStatus: e.status,
223
249
  dueDate: e.due_date,
224
250
  scheduledPaymentDate: e.scheduled_payment_date
225
- }), i = e.amount_due ?? e.total_amount, a = e.status === "partially_paid" || e.status === "paid", c = (t) => t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" }), l = o(e.scheduled_payment_date, Oe, ke), u = X.get(e.id), d = s(e), p = te(e) || (e.counterpart_id ? nt.get(e.counterpart_id) ?? "" : ""), m = e.document_id ?? "", g = f(e.status), _ = u?.originalPayableId !== void 0 && u.originalPayableId === e.id, re = z && d && De && u ? {
251
+ }), i = e.amount_due ?? e.total_amount, a = e.status === "partially_paid" || e.status === "paid", c = (t) => t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" }), l = o(e.scheduled_payment_date, Ae, je), u = Y.get(e.id), d = s(e), m = ee(e) || (e.counterpart_id ? X.get(e.counterpart_id) ?? "" : ""), h = e.document_id ?? "", g = p(e.status), ne = u?.originalPayableId !== void 0 && u.originalPayableId === e.id, v = R && d && ke && u ? {
226
252
  triggerLabel: w.menuTrigger({
227
- vendorLabel: p,
228
- invoiceNumberLabel: m
253
+ vendorLabel: m,
254
+ invoiceNumberLabel: h
229
255
  }),
230
256
  items: [{
231
257
  id: "not-duplicate",
232
258
  label: w.notDuplicateAction,
233
- icon: he,
234
- disabled: q.isPending,
235
- onSelect: () => L({
259
+ icon: ge,
260
+ disabled: K.isPending,
261
+ onSelect: () => Ve({
236
262
  payable: e,
237
- originalPayableId: _ ? void 0 : u.originalPayableId
263
+ originalPayableId: ne ? void 0 : u.originalPayableId
238
264
  })
239
265
  }, ...g ? [{
240
266
  id: "cancel-duplicate",
241
- label: Y[g].action,
242
- icon: g === "delete" ? ge : me,
243
- disabled: q.isPending,
267
+ label: J[g].action,
268
+ icon: g === "delete" ? _e : he,
269
+ disabled: K.isPending,
244
270
  onSelect: () => F({
245
271
  payable: e,
246
272
  removeBy: g
@@ -249,126 +275,122 @@ function xe({ enabled: c = !0, canPay: l, canReadVendors: d = !0, isVendorFilter
249
275
  } : void 0;
250
276
  return {
251
277
  rowKey: e.id,
252
- vendorLabel: p,
253
- vendorLookup: p || !e.counterpart_id ? void 0 : Ce(rt),
254
- invoiceNumberLabel: m,
278
+ vendorLabel: m,
279
+ vendorLookup: m || !e.counterpart_id ? void 0 : Te(at),
280
+ invoiceNumberLabel: h,
255
281
  issueDateLabel: t(e.issued_at),
256
282
  dueDateLabel: t(e.due_date),
257
283
  dueDateTone: r.isOverdue ? "danger" : "default",
258
284
  scheduledDateLabel: l.label,
259
285
  scheduledDateExact: l.absoluteLabel,
260
- scheduledDateIsGap: V === h.Scheduled,
286
+ scheduledDateIsGap: B === _.Scheduled,
261
287
  paidDateLabel: t(e.paid_at?.slice(0, 10)),
262
288
  amountDueLabel: c(i),
263
289
  amountPaidLabel: a ? c(e.amount_paid) : "",
264
- amountPaidIsGap: V === h.Paid,
290
+ amountPaidIsGap: B === _.Paid,
265
291
  amountScheduledLabel: c(e.amount_to_pay ?? i),
266
292
  totalAmountLabel: c(e.total_amount),
267
- attachment: e.file_id ? { label: Ee } : void 0,
293
+ attachment: e.file_id ? { label: Oe } : void 0,
268
294
  status: r.status,
269
295
  statusTone: r.tone,
270
296
  addedOnLabel: t(e.created_at?.slice(0, 10)),
271
- ...u ? {
272
- group: {
273
- key: u.key,
274
- label: u.label
275
- },
276
- ...u.originalPayableId !== void 0 && !_ ? {
277
- isNested: !0,
278
- groupedRowLabel: w.copyRow
279
- } : {}
280
- } : {},
281
- ...re ? { menu: re } : {},
282
- ...!z && !u && d ? {
283
- rowTone: "warning",
284
- rowNote: Te
297
+ ...u ? { group: ot(u) } : {},
298
+ ...v ? { menu: v } : {},
299
+ ...!R && !u && d ? {
300
+ marker: "duplicate",
301
+ rowNote: De
285
302
  } : {},
286
- onOpen: () => we(e.id, ee(e.status))
303
+ onOpen: () => Ee(e.id, f(e.status))
287
304
  };
288
- }), [
289
- tt,
290
- X,
291
- w,
305
+ }), w), [
306
+ it,
292
307
  Y,
293
- q.isPending,
308
+ w,
309
+ J,
310
+ K.isPending,
311
+ ke,
312
+ R,
294
313
  De,
295
- z,
296
- Te,
297
- Ee,
298
314
  Oe,
299
- ke,
300
- we,
301
- V,
302
- nt,
303
- rt
304
- ]), it = b(() => z ? Se(Z, S) : [], [Z, z]), Q = Math.min(Le, Math.max(0, it.length - 1)), at = z ? it[Q] ?? [] : Z, $ = y((e) => {
315
+ Ae,
316
+ je,
317
+ Ee,
318
+ B,
319
+ X,
320
+ at,
321
+ ot
322
+ ]), st = b(() => R ? we(Z, S) : [], [Z, R]), Q = Math.min(ze, Math.max(0, st.length - 1)), ct = R ? st[Q] ?? [] : Z, $ = y((e) => {
305
323
  let t = e;
306
- Ae(t), Me((e) => {
324
+ Me(t), Pe((e) => {
307
325
  let n = e[0]?.id;
308
- return n ? _(t).some((e) => ae(e) === n) ? e : ye : e;
309
- }), R();
310
- }, [R]), ot = y((e) => {
311
- $(h.All), M(""), Be(e);
312
- }, [Be, $]), st = y(() => {
313
- M(""), Re(""), ze(), R();
314
- }, [ze, R]), ct = y((e) => {
315
- Me((t) => typeof e == "function" ? e(t) : e), R();
316
- }, [R]), lt = y((e) => {
317
- Ne(e), R();
318
- }, [R]), ut = y(() => {
319
- z ? A(Q + 1) : O(U.data?.next_pagination_token ?? void 0);
326
+ return n ? v(t).some((e) => ae(e) === n) ? e : be : e;
327
+ }), L();
328
+ }, [L]), lt = y((e) => {
329
+ $(_.All), M(""), Ue(e);
330
+ }, [Ue, $]), ut = y(() => {
331
+ M(""), Be(""), He(), L();
332
+ }, [He, L]), dt = y((e) => {
333
+ Pe((t) => typeof e == "function" ? e(t) : e), L();
334
+ }, [L]), ft = y((e) => {
335
+ Fe(e), L();
336
+ }, [L]), pt = y(() => {
337
+ R ? A(Q + 1) : O(H.data?.next_pagination_token ?? void 0);
320
338
  }, [
321
339
  Q,
322
- z,
323
- U.data?.next_pagination_token
324
- ]), dt = y(() => {
325
- z ? A(Math.max(0, Q - 1)) : O(U.data?.prev_pagination_token ?? void 0);
340
+ R,
341
+ H.data?.next_pagination_token
342
+ ]), mt = y(() => {
343
+ R ? A(Math.max(0, Q - 1)) : O(H.data?.prev_pagination_token ?? void 0);
326
344
  }, [
327
345
  Q,
328
- z,
329
- U.data?.prev_pagination_token
330
- ]), ft = y(() => {
331
- G.refetch();
332
- }, [G.refetch]);
346
+ R,
347
+ H.data?.prev_pagination_token
348
+ ]), ht = y(() => {
349
+ W.refetch();
350
+ }, [W.refetch]);
333
351
  return {
334
- rows: at,
335
- isLoading: G.isLoading || !z && k === void 0 || H !== Ye || Qe && $e.isLoading || (Ze ?? 0) > 0 && at.length === 0,
336
- isError: G.isError,
337
- onRetry: ft,
352
+ rows: ct,
353
+ isLoading: W.isLoading || !R && k === void 0 || V !== Qe || tt && nt.isLoading || (et ?? 0) > 0 && ct.length === 0,
354
+ isError: W.isError,
355
+ onRetry: ht,
338
356
  selectedFilterTabId: E,
339
357
  onFilterTabChange: $,
340
- showVendorBills: ot,
341
- clearQueryConstraints: st,
358
+ showVendorBills: lt,
359
+ clearQueryConstraints: ut,
342
360
  searchValue: j,
343
361
  onSearchChange: M,
344
- hasAnyBills: et,
345
- isSearchActive: N.length > 0 || B.isFilterActive,
346
- filterBarProps: B.filterBarProps,
347
- visibleColumns: z ? [
348
- m.Vendor,
349
- m.InvoiceNumber,
350
- m.AmountDue,
351
- m.DueDate,
352
- m.AddedOn,
353
- m.Status
354
- ] : _(E),
355
- showAddPanelWhenEmpty: !z && ie(E),
356
- sorting: je,
357
- onSortingChange: ct,
358
- pageSize: z ? S : D,
359
- pageSizeOptions: z ? [S] : void 0,
360
- onPageSizeChange: lt,
361
- hasNextPage: z ? Q < it.length - 1 : !!U.data?.next_pagination_token,
362
- hasPrevPage: z ? Q > 0 : !!U.data?.prev_pagination_token,
363
- onNextPage: ut,
364
- onPrevPage: dt,
362
+ hasAnyBills: rt,
363
+ isSearchActive: N.length > 0 || z.isFilterActive,
364
+ filterBarProps: z.filterBarProps,
365
+ visibleColumns: R ? [
366
+ g.AddedOn,
367
+ g.DueDate,
368
+ g.AmountDue,
369
+ g.Status
370
+ ] : v(E),
371
+ keepsColumnOrder: R,
372
+ isSortable: !R,
373
+ pageInfo: R ? w.pageInfo({
374
+ billCount: Z.length,
375
+ invoiceCount: new Set(Z.map((e) => e.group?.key ?? e.rowKey)).size
376
+ }) : void 0,
377
+ showAddPanelWhenEmpty: !R && ie(E),
378
+ sorting: Ne,
379
+ onSortingChange: dt,
380
+ pageSize: R ? S : D,
381
+ pageSizeOptions: R ? [S] : void 0,
382
+ onPageSizeChange: ft,
383
+ hasNextPage: R ? Q < st.length - 1 : !!H.data?.next_pagination_token,
384
+ hasPrevPage: R ? Q > 0 : !!H.data?.prev_pagination_token,
385
+ onNextPage: pt,
386
+ onPrevPage: mt,
365
387
  cancelConfirmation: {
366
388
  open: !!P,
367
- copy: se(Y[Ke], Ke),
368
- onConfirm: () => void qe(),
389
+ copy: se(J[Ye], Ye),
390
+ onConfirm: () => void Xe(),
369
391
  onCancel: () => F(void 0),
370
- isPending: q.isPending,
371
- cancelButtonLabel: Y[Ke].backButton
392
+ isPending: K.isPending,
393
+ cancelButtonLabel: J[Ye].backButton
372
394
  },
373
395
  keepConfirmation: {
374
396
  open: !!I,
@@ -378,25 +400,52 @@ function xe({ enabled: c = !0, canPay: l, canReadVendors: d = !0, isVendorFilter
378
400
  confirmButton: w.notDuplicateConfirmButton,
379
401
  presentation: {
380
402
  alignment: "center",
381
- icon: he,
403
+ icon: ge,
382
404
  actionWidth: "equal"
383
405
  }
384
406
  },
385
- onConfirm: () => void Je(),
386
- onCancel: () => L(void 0),
387
- isPending: q.isPending,
407
+ onConfirm: () => void Ze(),
408
+ onCancel: () => Ve(void 0),
409
+ isPending: K.isPending,
388
410
  cancelButtonLabel: w.notDuplicateConfirmBackButton
389
411
  }
390
412
  };
391
413
  }
392
- function Se(e, t) {
414
+ function Ce(e, t) {
415
+ let n = /* @__PURE__ */ new Map();
416
+ for (let t of e) {
417
+ if (!t.group) continue;
418
+ let e = n.get(t.group.key) ?? [];
419
+ e.push(t.status), n.set(t.group.key, e);
420
+ }
421
+ return e.map((e) => {
422
+ if (!e.group) return e;
423
+ let r = m({
424
+ statuses: n.get(e.group.key) ?? [],
425
+ statusLabels: t.statusLabels,
426
+ labels: {
427
+ showMore: t.showMore,
428
+ showLess: t.showLess,
429
+ statusSummary: t.statusSummary
430
+ }
431
+ });
432
+ return r ? {
433
+ ...e,
434
+ group: {
435
+ ...e.group,
436
+ collapse: r
437
+ }
438
+ } : e;
439
+ });
440
+ }
441
+ function we(e, t) {
393
442
  let n = [], r = [];
394
443
  return e.forEach((i, a) => {
395
444
  let o = i.group !== void 0 && i.group.key === e[a - 1]?.group?.key;
396
445
  r.length >= t && !o && (n.push(r), r = []), r.push(i);
397
446
  }), r.length && n.push(r), n;
398
447
  }
399
- function Ce(e) {
400
- return e === v.Settled ? void 0 : e;
448
+ function Te(e) {
449
+ return e === le.Settled ? void 0 : e;
401
450
  }
402
- export { C as BillDuplicateView, xe as useBillsTable };
451
+ export { C as BillDuplicateView, Se as useBillsTable };