@tesouro/embedded-components-react 0.5.107 → 0.5.108

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.
@@ -22,99 +22,99 @@ import "../../data-access/dist/index.js";
22
22
  import { hasUnpaidBalance as ue } from "./index7.js";
23
23
  import { resolveVendor as de } from "./index8.js";
24
24
  import { BillCreateScreen as fe } from "../../ui/dist/index57.js";
25
- import { BillDecisionDialog as pe } from "../../ui/dist/index63.js";
26
- import { DiscardChangesDialog as me } from "../../ui/dist/index67.js";
27
- import { BillDuplicateNotice as he } from "../../ui/dist/index72.js";
28
- import { BillRejectedBanner as ge } from "../../ui/dist/index75.js";
29
- import { ExtractionNotice as _e } from "../../ui/dist/index93.js";
30
- import { MarkAsPaidDialog as ve } from "../../ui/dist/index102.js";
31
- import { UnsavedBillDialog as ye } from "../../ui/dist/index112.js";
25
+ import { BillDecisionDialog as i } from "../../ui/dist/index63.js";
26
+ import { DiscardChangesDialog as pe } from "../../ui/dist/index67.js";
27
+ import { BillDuplicateNotice as me } from "../../ui/dist/index72.js";
28
+ import { BillRejectedBanner as he } from "../../ui/dist/index75.js";
29
+ import { ExtractionNotice as ge } from "../../ui/dist/index93.js";
30
+ import { MarkAsPaidDialog as _e } from "../../ui/dist/index102.js";
31
+ import { UnsavedBillDialog as ve } from "../../ui/dist/index112.js";
32
32
  import "../../ui/dist/index.js";
33
- import { usePayableDuplicateReview as be } from "./index13.js";
33
+ import { usePayableDuplicateReview as ye } from "./index13.js";
34
34
  import "./index14.js";
35
- import { isEditablePayableStatus as xe } from "./index19.js";
36
- import { canOverrideApprovalPolicy as Se, canReadCounterpartBankAccounts as Ce } from "./index20.js";
37
- import { resolveAmountDueMinorUnits as we } from "./index21.js";
38
- import { usePayableAchInstructions as Te } from "../../../shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js";
35
+ import { isEditablePayableStatus as be } from "./index19.js";
36
+ import { canOverrideApprovalPolicy as xe, canReadCounterpartBankAccounts as Se } from "./index20.js";
37
+ import { resolveAmountDueMinorUnits as Ce } from "./index21.js";
38
+ import { usePayableAchInstructions as we } from "../../../shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js";
39
39
  import "../../../shared/counterpart-management/feature/dist/index.js";
40
- import { PayBillFlow as Ee } from "./index27.js";
40
+ import { PayBillFlow as Te } from "./index27.js";
41
41
  import "./index28.js";
42
- import { useMarkAsPaidFlow as De } from "./index17.js";
42
+ import { useMarkAsPaidFlow as Ee } from "./index17.js";
43
43
  import "./index18.js";
44
- import { BILL_CREATE_MESSAGE_LABELS_EN as Oe, mergeBillCreateScreenCopy as ke } from "./index48.js";
45
- import { useBillCreateController as Ae } from "./index56.js";
46
- import { useBillForm as je } from "./index58.js";
47
- import { buildPaymentHistory as Me } from "./index3.js";
48
- import { currentApprovalRound as Ne } from "./index4.js";
49
- import { usePayableApprovalRoundStart as Pe } from "./index32.js";
50
- import { useApprovalPolicyCardView as Fe } from "./index33.js";
51
- import { resolveBillRejectionNotice as Ie } from "./index34.js";
52
- import { useCurrentApprovalRequestId as Le } from "./index35.js";
53
- import { usePayableDetailActions as Re } from "./index36.js";
54
- import { useScheduledPayment as ze } from "./index37.js";
55
- import { useDraftDelete as Be } from "./index38.js";
56
- import { buildBillDetailView as Ve } from "./index43.js";
57
- import { resolveEditorDismissal as He } from "./index44.js";
58
- import { SourceDocumentContainer as Ue } from "./index49.js";
59
- import { useVendorSectionProps as We } from "./index52.js";
60
- import { billCreateTestIds as i } from "./index59.js";
61
- import { cloneElement as Ge, isValidElement as Ke, useCallback as a, useEffect as qe, useMemo as o, useRef as Je, useState as s } from "react";
62
- import { Fragment as Ye, jsx as c, jsxs as Xe } from "react/jsx-runtime";
63
- import { Trash2Icon as Ze } from "lucide-react";
44
+ import { BILL_CREATE_MESSAGE_LABELS_EN as De, mergeBillCreateScreenCopy as Oe } from "./index48.js";
45
+ import { useBillCreateController as ke } from "./index56.js";
46
+ import { useBillForm as Ae } from "./index58.js";
47
+ import { buildPaymentHistory as je } from "./index3.js";
48
+ import { currentApprovalRound as Me } from "./index4.js";
49
+ import { usePayableApprovalRoundStart as Ne } from "./index32.js";
50
+ import { useApprovalPolicyCardView as Pe } from "./index33.js";
51
+ import { resolveBillRejectionNotice as Fe } from "./index34.js";
52
+ import { useCurrentApprovalRequestId as Ie } from "./index35.js";
53
+ import { usePayableDetailActions as Le } from "./index36.js";
54
+ import { useScheduledPayment as Re } from "./index37.js";
55
+ import { useDraftDelete as ze } from "./index38.js";
56
+ import { buildBillDetailView as Be } from "./index43.js";
57
+ import { resolveEditorDismissal as Ve } from "./index44.js";
58
+ import { SourceDocumentContainer as He } from "./index49.js";
59
+ import { useVendorSectionProps as Ue } from "./index52.js";
60
+ import { billCreateTestIds as a } from "./index59.js";
61
+ import { cloneElement as We, isValidElement as Ge, useCallback as o, useEffect as Ke, useMemo as s, useRef as qe, useState as c } from "react";
62
+ import { Fragment as Je, jsx as l, jsxs as Ye } from "react/jsx-runtime";
63
+ import { Trash2Icon as Xe } from "lucide-react";
64
64
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js
65
- function Qe(e) {
65
+ function Ze(e) {
66
66
  let t = [...new Set(e)];
67
67
  return t.length > 0 ? t : void 0;
68
68
  }
69
- function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et, onCollapse: f, onEdit: tt, poweredByBankName: nt }) {
70
- let p = o(() => ke(et), [et]), [m, rt] = s(), [h, it] = s(!1), [at, ot] = s(!1), [g, _] = s(!1), [st, v] = s(), ct = a((e) => {
71
- v(() => e);
72
- }, []), [lt, ut] = s(), y = $e ?? lt, b = le(y, { pollWhileOcrProcessing: !0 }), x = se(y), { initResponse: S } = re(), dt = !!S, ft = t(S?.scopes, [n.AccountingConfigReadOrg]), C = r({ enabled: ft }), w = b.data, T = !y || !!w, E = !d && T && !!y && w?.status !== "draft", pt = !d && !!w && !xe(w?.status), D = d || pt, O = je({
69
+ function Qe({ open: Qe, onOpenChange: u, payableId: d, initialCounterpartId: $e, readOnly: f = !1, copy: et, onCollapse: p, onEdit: tt, poweredByBankName: nt }) {
70
+ let m = s(() => Oe(et), [et]), rt = d ? void 0 : $e, [it, at] = c(rt), [ot, st] = c(!!rt), [ct, lt] = c(!1), [h, g] = c(!1), [ut, _] = c(), v = o((e) => {
71
+ _(() => e);
72
+ }, []), [dt, ft] = c(), y = d ?? dt, b = le(y, { pollWhileOcrProcessing: !0 }), x = se(y), { initResponse: S } = re(), pt = !!S, mt = t(S?.scopes, [n.AccountingConfigReadOrg]), C = r({ enabled: mt }), w = b.data, T = !y || !!w, E = !f && T && !!y && w?.status !== "draft", ht = !f && !!w && !be(w?.status), D = f || ht, O = Ae({
73
73
  payable: w,
74
74
  lineItems: x.lineItems
75
75
  }), k = w?.counterpart_id;
76
- qe(() => {
77
- h || k && (rt(k), it(!0));
78
- }, [h, k]);
79
- let mt = a((e) => {
80
- it(!0), rt(e);
81
- }, []), A = ze({
76
+ Ke(() => {
77
+ ot || k && (at(k), st(!0));
78
+ }, [ot, k]);
79
+ let gt = o((e) => {
80
+ st(!0), at(e);
81
+ }, []), A = Re({
82
82
  payableId: y,
83
83
  scheduledPaymentDate: w?.scheduled_payment_date,
84
- enabled: d || E
85
- }), j = Ce(S?.scopes), ht = t(S?.scopes, [n.PayableWriteOrg]), M = t(S?.scopes, [n.CounterpartWriteOrg]) && ht, N = M && ue(w?.status) && !A.hasScheduledPayment && !A.isResolving, gt = N && j, _t = N || M && w?.status === "rejected", vt = !d && T && (!y || w?.status === "draft") && !A.hasScheduledPayment && !A.isResolving, P = We({
84
+ enabled: f || E
85
+ }), j = Se(S?.scopes), _t = t(S?.scopes, [n.PayableWriteOrg]), vt = t(S?.scopes, [n.CounterpartWriteOrg]) && _t, M = vt && ue(w?.status) && !A.hasScheduledPayment && !A.isResolving, yt = M && j, bt = M || vt && w?.status === "rejected", xt = !f && T && (!y || w?.status === "draft") && !A.hasScheduledPayment && !A.isResolving, N = Ue({
86
86
  payableId: y,
87
- counterpartId: d ? k : m,
87
+ counterpartId: f ? k : it,
88
88
  payableCounterpartId: k,
89
- isVendorKnown: d ? !!w : T,
90
- onCounterpartChange: mt,
89
+ isVendorKnown: f ? !!w : T,
90
+ onCounterpartChange: gt,
91
91
  requiredError: O.errors?.vendor,
92
92
  payableCounterpartBankAccountId: w?.counterpart_bank_account_id ?? void 0,
93
93
  extractedVendor: w?.counterpart_raw_data ?? void 0,
94
- readOnly: d,
95
- canEditVendor: !d || gt,
96
- canEditPaymentInstructions: !d || N,
97
- canAddPaymentInstructions: !d || _t,
98
- confirmDiscard: ct
99
- }), F = P.activePayToOperation === "missingInstructions" ? vt || _t : P.activePayToOperation === "existingInstructions" ? vt || N : P.activePayToOperation === "vendor" && d ? gt : !1, yt = !!(y && h) && !m, I = b.refetch, bt = a(async () => {
100
- let { data: e } = await I();
94
+ readOnly: f,
95
+ canEditVendor: !f || yt,
96
+ canEditPaymentInstructions: !f || M,
97
+ canAddPaymentInstructions: !f || bt,
98
+ confirmDiscard: v
99
+ }), P = N.activePayToOperation === "missingInstructions" ? xt || bt : N.activePayToOperation === "existingInstructions" ? xt || M : N.activePayToOperation === "vendor" && f ? yt : !1, St = !!(y && ot) && !it, F = b.refetch, Ct = o(async () => {
100
+ let { data: e } = await F();
101
101
  return e?.status ?? void 0;
102
- }, [I]), xt = ce(), [L, St] = s(!1), R = Je(void 0), Ct = a(async () => {
102
+ }, [F]), I = ce(), [L, wt] = c(!1), R = qe(void 0), z = o(async () => {
103
103
  if (R.current) return R.current;
104
104
  let t = (async () => {
105
- if (F) {
106
- St(!0);
105
+ if (P) {
106
+ wt(!0);
107
107
  try {
108
108
  let t;
109
109
  try {
110
- t = await P.prepareVendorForSave({ closeOnSuccess: !1 });
110
+ t = await N.prepareVendorForSave({ closeOnSuccess: !1 });
111
111
  } catch {
112
- e.error(p.detail.paymentInstructionsSaveError);
112
+ e.error(m.detail.paymentInstructionsSaveError);
113
113
  return;
114
114
  }
115
115
  if (!t.ok) return;
116
116
  if (!y) {
117
- P.finalizePayToSave();
117
+ N.finalizePayToSave();
118
118
  return;
119
119
  }
120
120
  let n = t.counterpartId && t.counterpartId !== w?.counterpart_id ? t.counterpartId : void 0, r = t.counterpartBankAccountId && t.counterpartBankAccountId !== w?.counterpart_bank_account_id ? t.counterpartBankAccountId : void 0;
@@ -127,21 +127,21 @@ function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et
127
127
  }
128
128
  };
129
129
  try {
130
- await xt.mutateAsync(t);
130
+ await I.mutateAsync(t);
131
131
  } catch {
132
132
  try {
133
- await xt.mutateAsync(t);
133
+ await I.mutateAsync(t);
134
134
  } catch {
135
- e.error(p.detail.paymentInstructionsLinkError);
135
+ e.error(m.detail.paymentInstructionsLinkError);
136
136
  return;
137
137
  }
138
138
  }
139
- P.finalizePayToSave();
139
+ N.finalizePayToSave();
140
140
  return;
141
141
  }
142
- P.finalizePayToSave(), await I();
142
+ N.finalizePayToSave(), await F();
143
143
  } finally {
144
- St(!1);
144
+ wt(!1);
145
145
  }
146
146
  }
147
147
  })();
@@ -152,118 +152,118 @@ function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et
152
152
  R.current = void 0;
153
153
  }
154
154
  }, [
155
- F,
156
- p.detail.paymentInstructionsLinkError,
157
- p.detail.paymentInstructionsSaveError,
158
- xt,
155
+ P,
156
+ m.detail.paymentInstructionsLinkError,
157
+ m.detail.paymentInstructionsSaveError,
158
+ I,
159
159
  w?.counterpart_bank_account_id,
160
160
  w?.counterpart_id,
161
161
  y,
162
- I,
163
- P
164
- ]), z = o(() => F ? P.mode === "creating" && Ke(P.newVendorForm) ? {
165
- ...P,
166
- newVendorForm: Ge(P.newVendorForm, {
167
- onSave: Ct,
162
+ F,
163
+ N
164
+ ]), B = s(() => P ? N.mode === "creating" && Ge(N.newVendorForm) ? {
165
+ ...N,
166
+ newVendorForm: We(N.newVendorForm, {
167
+ onSave: z,
168
168
  isSaving: L
169
169
  })
170
- } : P.mode === "resolved" && P.paymentInstructions ? {
171
- ...P,
170
+ } : N.mode === "resolved" && N.paymentInstructions ? {
171
+ ...N,
172
172
  paymentInstructions: {
173
- ...P.paymentInstructions,
174
- onSave: Ct,
173
+ ...N.paymentInstructions,
174
+ onSave: z,
175
175
  isSaving: L
176
176
  }
177
- } : P : P, [
178
- F,
177
+ } : N : N, [
178
+ P,
179
179
  L,
180
- Ct,
181
- P
180
+ z,
181
+ N
182
182
  ]);
183
- qe(() => {
184
- d && P.isEditingPayTo && !F && P.discardPayToEdits();
183
+ Ke(() => {
184
+ f && N.isEditingPayTo && !P && N.discardPayToEdits();
185
185
  }, [
186
- F,
187
- d,
188
- P.discardPayToEdits,
189
- P.isEditingPayTo
186
+ P,
187
+ f,
188
+ N.discardPayToEdits,
189
+ N.isEditingPayTo
190
190
  ]);
191
- let wt = o(() => E ? { draftSaved: Oe.submittedSaved } : void 0, [E]), B = Ae({
192
- payableId: $e,
191
+ let Tt = s(() => E ? { draftSaved: De.submittedSaved } : void 0, [E]), V = ke({
192
+ payableId: d,
193
193
  form: O,
194
- labels: wt,
195
- counterpartId: m,
196
- isVendorPending: P.mode === "creating" || P.isPendingVendor,
197
- clearCounterpart: yt,
198
- prepareVendorForSave: P.prepareVendorForSave,
199
- onPayableCreated: ut,
200
- onSaved: ut,
194
+ labels: Tt,
195
+ counterpartId: it,
196
+ isVendorPending: N.mode === "creating" || N.isPendingVendor,
197
+ clearCounterpart: St,
198
+ prepareVendorForSave: N.prepareVendorForSave,
199
+ onPayableCreated: ft,
200
+ onSaved: ft,
201
201
  onDraftSaved: () => u(!1),
202
202
  onFinalized: () => u(!1),
203
- readSavedStatus: E ? bt : void 0
204
- }), Tt = !!(B.isSavingDraft || B.isFinalizing || P.isVendorSavePending), V = d ? y : void 0, H = Le({
205
- payableId: V,
203
+ readSavedStatus: E ? Ct : void 0
204
+ }), Et = !!(V.isSavingDraft || V.isFinalizing || N.isVendorSavePending), H = f ? y : void 0, U = Ie({
205
+ payableId: H,
206
206
  status: w?.status
207
- }), Et = Je(null), Dt = de(w), U = Te({
208
- counterpartId: d ? k : void 0,
207
+ }), Dt = qe(null), Ot = de(w), W = we({
208
+ counterpartId: f ? k : void 0,
209
209
  currency: w?.currency,
210
- currentBankAccountId: d ? w?.counterpart_bank_account_id ?? void 0 : void 0,
211
- enabled: j && d
212
- }), Ot = De({
213
- payableId: V,
214
- amountDueMinorUnits: we(w) ?? 0,
210
+ currentBankAccountId: f ? w?.counterpart_bank_account_id ?? void 0 : void 0,
211
+ enabled: j && f
212
+ }), kt = Ee({
213
+ payableId: H,
214
+ amountDueMinorUnits: Ce(w) ?? 0,
215
215
  amountToPayMinorUnits: w?.amount_to_pay ?? void 0,
216
216
  currencyCode: w?.currency ?? void 0,
217
217
  dueDate: w?.due_date,
218
218
  hasScheduledPayment: A.hasScheduledPayment,
219
- labels: p.markAsPaid
220
- }), W = Fe({
221
- payableId: V,
219
+ labels: m.markAsPaid
220
+ }), G = Pe({
221
+ payableId: H,
222
222
  approvalPolicyId: w?.approval_policy_id,
223
- enabled: d,
224
- copy: p.approvalPolicyCopy
225
- }), kt = Se({
223
+ enabled: f,
224
+ copy: m.approvalPolicyCopy
225
+ }), At = xe({
226
226
  status: w?.status,
227
227
  scopes: S?.scopes,
228
- arePendingApproversUnknown: W.isLoading,
228
+ arePendingApproversUnknown: G.isLoading,
229
229
  hasApprovalPolicy: !!w?.approval_policy_id,
230
- hasWaitingRequest: H.hasWaitingRequest
231
- }), At = !!H.id, jt = H.isLoading || W.isLoading, Mt = o(() => Qe(W.pendingApprovers.flatMap((e) => e.names)), [W.pendingApprovers]), Nt = d || E ? y : void 0, Pt = d ? tt : void 0, G = a((e) => {
230
+ hasWaitingRequest: U.hasWaitingRequest
231
+ }), jt = !!U.id, Mt = U.isLoading || G.isLoading, Nt = s(() => Ze(G.pendingApprovers.flatMap((e) => e.names)), [G.pendingApprovers]), Pt = f || E ? y : void 0, Ft = f ? tt : void 0, K = o((e) => {
232
232
  let t = () => {
233
- P.discardPayToEdits(), e?.();
233
+ N.discardPayToEdits(), e?.();
234
234
  };
235
- P.hasUnsavedVendorChanges ? ct(t) : t();
236
- }, [ct, P]), { actions: Ft, decisionDialog: It, isActionPending: Lt } = Re({
237
- payableId: Nt,
235
+ N.hasUnsavedVendorChanges ? v(t) : t();
236
+ }, [v, N]), { actions: It, decisionDialog: Lt, isActionPending: Rt } = Le({
237
+ payableId: Pt,
238
238
  status: w?.status,
239
- currentApprovalRequestId: H.id,
240
- arePendingApproversUnknown: W.isLoading,
239
+ currentApprovalRequestId: U.id,
240
+ arePendingApproversUnknown: G.isLoading,
241
241
  hasScheduledPayment: A.hasScheduledPayment,
242
242
  scheduledPaymentIntentId: A.scheduledPaymentIntentId,
243
243
  isScheduledPaymentUnknown: A.isResolving,
244
- isPayabilityUnknown: U.isLoading,
244
+ isPayabilityUnknown: W.isLoading,
245
245
  hasApprovalPolicy: !!w?.approval_policy_id,
246
- hasWaitingRequest: H.hasWaitingRequest,
247
- pendingApprovers: W.pendingApprovers,
248
- labels: p.actions,
249
- isMarkAsPaidPending: Ot.isPending,
250
- onMarkAsPaidSelect: Ot.open,
251
- onPayBillSelect: () => G(() => Et.current?.open()),
252
- onEditSelect: Pt,
246
+ hasWaitingRequest: U.hasWaitingRequest,
247
+ pendingApprovers: G.pendingApprovers,
248
+ labels: m.actions,
249
+ isMarkAsPaidPending: kt.isPending,
250
+ onMarkAsPaidSelect: kt.open,
251
+ onPayBillSelect: () => K(() => Dt.current?.open()),
252
+ onEditSelect: Ft,
253
253
  onActionSucceeded: (e) => {
254
254
  if (e === "reopen") {
255
- Pt?.();
255
+ Ft?.();
256
256
  return;
257
257
  }
258
258
  E && u(!1);
259
259
  }
260
- }), Rt = Be({
260
+ }), zt = ze({
261
261
  payableId: y,
262
262
  status: w?.status,
263
- enabled: !d,
264
- labels: p.deleteDraft,
263
+ enabled: !f,
264
+ labels: m.deleteDraft,
265
265
  onDeleted: () => u(!1)
266
- }), zt = Tt || Lt, Bt = w?.ocr_status === "processing", Vt = b.isLoading || x.isResolving || Bt, Ht = b.isLoading || x.isResolving || C.isResolving || U.isLoading, Ut = b.isError || x.isError || C.isError, Wt = o(() => [...Rt.menuItems, ...E || d && !Ht && !Ut ? Ft.menu.map((e) => ({
266
+ }), Bt = Et || Rt, Vt = w?.ocr_status === "processing", Ht = b.isLoading || x.isResolving || Vt, Ut = b.isLoading || x.isResolving || C.isResolving || W.isLoading, Wt = b.isError || x.isError || C.isError, Gt = s(() => [...zt.menuItems, ...E || f && !Ut && !Wt ? It.menu.map((e) => ({
267
267
  id: e.id,
268
268
  label: e.label,
269
269
  onSelect: e.onSelect,
@@ -271,177 +271,177 @@ function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et
271
271
  icon: e.icon,
272
272
  sectionHeading: e.sectionHeading
273
273
  })) : []], [
274
- Ft.menu,
275
- Rt.menuItems,
274
+ It.menu,
275
+ zt.menuItems,
276
276
  E,
277
- d,
278
- Ht,
279
- Ut
280
- ]), K = o(() => (C.data?.data ?? []).map((e) => ({
277
+ f,
278
+ Ut,
279
+ Wt
280
+ ]), q = s(() => (C.data?.data ?? []).map((e) => ({
281
281
  value: e.id,
282
282
  label: [e.nominal_code, e.name].filter(Boolean).join(" — ")
283
- })), [C.data]), q;
284
- dt && (ft ? C.isError ? q = p.lineItemsGlCodeUnavailable.loadError : !C.isResolving && K.length === 0 && (q = p.lineItemsGlCodeUnavailable.empty) : q = p.lineItemsGlCodeUnavailable.noAccess);
285
- let Gt = !dt || !!q || C.isResolving, Kt = ft && !C.isResolving && !C.isError, J = oe(V), qt = w?.status === "rejected" || !d && E, Jt = t(S?.scopes, [n.ApprovalRequestReadOrg]), Yt = qt && Jt, Xt = t(S?.scopes, [n.UserReadOrg]), { userNames: Y, isError: Zt, isResolving: Qt } = ie({ enabled: (d || qt) && Xt }), $t = o(() => te(J.data?.data ?? [], Y, p.history), [
286
- J.data,
287
- Y,
288
- p.history
289
- ]), en = Xt && Zt && ne(J.data?.data ?? [], $t, Y), tn = Pe({
283
+ })), [C.data]), J;
284
+ pt && (mt ? C.isError ? J = m.lineItemsGlCodeUnavailable.loadError : !C.isResolving && q.length === 0 && (J = m.lineItemsGlCodeUnavailable.empty) : J = m.lineItemsGlCodeUnavailable.noAccess);
285
+ let Kt = !pt || !!J || C.isResolving, qt = mt && !C.isResolving && !C.isError, Y = oe(H), Jt = w?.status === "rejected" || !f && E, Yt = t(S?.scopes, [n.ApprovalRequestReadOrg]), Xt = Jt && Yt, Zt = t(S?.scopes, [n.UserReadOrg]), { userNames: X, isError: Qt, isResolving: $t } = ie({ enabled: (f || Jt) && Zt }), en = s(() => te(Y.data?.data ?? [], X, m.history), [
286
+ Y.data,
287
+ X,
288
+ m.history
289
+ ]), tn = Zt && Qt && ne(Y.data?.data ?? [], en, X), nn = Ne({
290
290
  payableId: y,
291
- enabled: Yt
292
- }), nn = ae(y, { enabled: Yt }), rn = o(() => Ne(nn.data?.data, tn.roundStartedAt), [nn.data, tn.roundStartedAt]), X = o(() => Ie({
291
+ enabled: Xt
292
+ }), rn = ae(y, { enabled: Xt }), an = s(() => Me(rn.data?.data, nn.roundStartedAt), [rn.data, nn.roundStartedAt]), Z = s(() => Fe({
293
293
  payableStatus: w?.status,
294
- approvalRequests: rn,
295
- userNames: Y,
294
+ approvalRequests: an,
295
+ userNames: X,
296
296
  payableUpdatedAt: w?.updated_at,
297
- labels: p.detail
297
+ labels: m.detail
298
298
  }), [
299
299
  w?.status,
300
300
  w?.updated_at,
301
- rn,
302
- Y,
303
- p.detail
304
- ]), an = o(() => Me({
301
+ an,
302
+ X,
303
+ m.detail
304
+ ]), on = s(() => je({
305
305
  records: A.paymentRecords,
306
- events: J.data?.data ?? [],
306
+ events: Y.data?.data ?? [],
307
307
  currencyCode: w?.currency,
308
- labels: p.detail
308
+ labels: m.detail
309
309
  }), [
310
310
  A.paymentRecords,
311
- J.data,
311
+ Y.data,
312
312
  w?.currency,
313
- p.detail
314
- ]), on = o(() => {
315
- if (!d || !w) return;
316
- let e = Ve({
313
+ m.detail
314
+ ]), sn = s(() => {
315
+ if (!f || !w) return;
316
+ let e = Be({
317
317
  payable: w,
318
318
  lineItems: x.lineItems,
319
- glCodeOptions: K,
320
- glCodeRosterAvailable: Kt,
321
- history: $t,
322
- paymentHistory: an,
323
- approvalPolicy: W.view,
324
- labels: p.detail,
319
+ glCodeOptions: q,
320
+ glCodeRosterAvailable: qt,
321
+ history: en,
322
+ paymentHistory: on,
323
+ approvalPolicy: G.view,
324
+ labels: m.detail,
325
325
  hasScheduledPayment: A.hasScheduledPayment,
326
- rejection: X,
327
- payableAchInstructions: U.achInstructions,
328
- payableAchInstructionsReadable: j && !U.isError
326
+ rejection: Z,
327
+ payableAchInstructions: W.achInstructions,
328
+ payableAchInstructionsReadable: j && !W.isError
329
329
  });
330
- return P.mode === "resolved" && P.summary ? {
330
+ return N.mode === "resolved" && N.summary ? {
331
331
  ...e,
332
- payTo: P.summary
332
+ payTo: N.summary
333
333
  } : e;
334
334
  }, [
335
335
  A.hasScheduledPayment,
336
- W.view,
336
+ G.view,
337
337
  j,
338
- p.detail,
339
- K,
340
- Kt,
341
- $t,
338
+ m.detail,
339
+ q,
340
+ qt,
341
+ en,
342
342
  x.lineItems,
343
343
  w,
344
- U.achInstructions,
345
- U.isError,
346
- an,
347
- d,
348
- X,
349
- P.mode,
350
- P.summary
351
- ]), sn = w?.source_of_payable_data === "ocr", Z = Dt?.name, cn = d ? Z ? p.viewTitle(Z) : p.readOnlyTitle : Z && (sn || E) ? p.extractedTitle(Z) : p.newTitle, ln = d && w?.created_at ? p.addedOn(ee(w.created_at.slice(0, 10))) : void 0, un = a(() => {
352
- if (d && P.isEditingPayTo) {
353
- G(() => u(!1));
344
+ W.achInstructions,
345
+ W.isError,
346
+ on,
347
+ f,
348
+ Z,
349
+ N.mode,
350
+ N.summary
351
+ ]), cn = w?.source_of_payable_data === "ocr", Q = Ot?.name, ln = f ? Q ? m.viewTitle(Q) : m.readOnlyTitle : Q && (cn || E) ? m.extractedTitle(Q) : m.newTitle, un = f && w?.created_at ? m.addedOn(ee(w.created_at.slice(0, 10))) : void 0, dn = o(() => {
352
+ if (f && N.isEditingPayTo) {
353
+ K(() => u(!1));
354
354
  return;
355
355
  }
356
- let e = O.isDirty || P.hasUnsavedVendorChanges || !!B.stagedFile || B.isFileDeletionPending;
357
- switch (He({
358
- isUnsavedPromptOpen: g,
356
+ let e = O.isDirty || N.hasUnsavedVendorChanges || !!V.stagedFile || V.isFileDeletionPending;
357
+ switch (Ve({
358
+ isUnsavedPromptOpen: h,
359
359
  isLocked: D,
360
360
  isDirty: e
361
361
  })) {
362
362
  case "dismiss-prompt":
363
- _(!1);
363
+ g(!1);
364
364
  return;
365
365
  case "prompt":
366
- _(!0);
366
+ g(!0);
367
367
  return;
368
368
  default: u(!1);
369
369
  }
370
370
  }, [
371
- B.isFileDeletionPending,
372
- B.stagedFile,
371
+ V.isFileDeletionPending,
372
+ V.stagedFile,
373
373
  O.isDirty,
374
374
  D,
375
- g,
376
- G,
375
+ h,
376
+ K,
377
377
  u,
378
- d,
379
- P.hasUnsavedVendorChanges,
380
- P.isEditingPayTo
381
- ]), dn = a(() => {
382
- if (P.isEditingPayTo) {
383
- G(f);
378
+ f,
379
+ N.hasUnsavedVendorChanges,
380
+ N.isEditingPayTo
381
+ ]), fn = o(() => {
382
+ if (N.isEditingPayTo) {
383
+ K(p);
384
384
  return;
385
385
  }
386
- f?.();
386
+ p?.();
387
387
  }, [
388
- G,
389
- f,
390
- P.isEditingPayTo
391
- ]), fn = a(() => {
392
- _(!1), u(!1);
393
- }, [u]), Q = Vt || P.mode === "creating", pn = a(async () => {
394
- if (Q) return;
395
- let e = await B.saveDraft();
396
- _(!1), e && u(!1);
388
+ K,
389
+ p,
390
+ N.isEditingPayTo
391
+ ]), pn = o(() => {
392
+ g(!1), u(!1);
393
+ }, [u]), mn = Ht || N.mode === "creating", hn = o(async () => {
394
+ if (mn) return;
395
+ let e = await V.saveDraft();
396
+ g(!1), e && u(!1);
397
397
  }, [
398
- B,
399
- Q,
398
+ V,
399
+ mn,
400
400
  u
401
- ]), $ = be({
401
+ ]), $ = ye({
402
402
  payable: w,
403
403
  onRemoved: () => u(!1),
404
- canManage: ht
405
- }), mn = a((e) => {
406
- if (!(zt || $.isBusy)) return e ? u(!0) : un();
404
+ canManage: _t
405
+ }), gn = o((e) => {
406
+ if (!(Bt || $.isBusy)) return e ? u(!0) : dn();
407
407
  }, [
408
408
  $.isBusy,
409
- zt,
410
- un,
409
+ Bt,
410
+ dn,
411
411
  u
412
- ]), hn = $.isPossibleDuplicate, gn = !d && sn && !at, _n = !d && !!X, vn = _n || hn || gn ? /* @__PURE__ */ Xe(Ye, { children: [
413
- _n && X ? /* @__PURE__ */ c(ge, {
414
- ...X,
415
- labels: p.rejectedBanner
412
+ ]), _n = $.isPossibleDuplicate, vn = !f && cn && !ct, yn = !f && !!Z, bn = yn || _n || vn ? /* @__PURE__ */ Ye(Je, { children: [
413
+ yn && Z ? /* @__PURE__ */ l(he, {
414
+ ...Z,
415
+ labels: m.rejectedBanner
416
416
  }) : null,
417
- hn ? /* @__PURE__ */ c(he, {
417
+ _n ? /* @__PURE__ */ l(me, {
418
418
  onNotADuplicate: $.onNotADuplicate,
419
419
  onRemoveBill: $.onRemoveBill,
420
420
  isActionDisabled: $.isBusy,
421
421
  labels: $.removeBillLabel ? { removeBillButton: $.removeBillLabel } : void 0,
422
- testId: i.duplicateNotice
422
+ testId: a.duplicateNotice
423
423
  }) : null,
424
- gn ? /* @__PURE__ */ c(_e, { onDismiss: () => ot(!0) }) : null
424
+ vn ? /* @__PURE__ */ l(ge, { onDismiss: () => lt(!0) }) : null
425
425
  ] }) : void 0;
426
- return /* @__PURE__ */ Xe(Ye, { children: [
427
- /* @__PURE__ */ c(fe, {
428
- open: l,
429
- onOpenChange: mn,
430
- title: cn,
431
- subtitle: ln,
432
- notice: vn,
426
+ return /* @__PURE__ */ Ye(Je, { children: [
427
+ /* @__PURE__ */ l(fe, {
428
+ open: Qe,
429
+ onOpenChange: gn,
430
+ title: ln,
431
+ subtitle: un,
432
+ notice: bn,
433
433
  vendor: {
434
- ...z,
435
- testId: i.vendorSection
434
+ ...B,
435
+ testId: a.vendorSection
436
436
  },
437
437
  values: O.values,
438
438
  errors: O.errors,
439
439
  onChange: O.onChange,
440
440
  lineItems: {
441
441
  items: O.lineItemRows,
442
- glCodeOptions: K,
443
- glCodeDisabled: Gt,
444
- glCodeUnavailableMessage: q,
442
+ glCodeOptions: q,
443
+ glCodeDisabled: Kt,
444
+ glCodeUnavailableMessage: J,
445
445
  discount: O.discount,
446
446
  onDiscountChange: O.onDiscountChange,
447
447
  onDiscountBlur: O.onDiscountBlur,
@@ -454,9 +454,9 @@ function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et
454
454
  onAddLineItem: O.onAddLineItem,
455
455
  errors: O.lineItemErrors,
456
456
  totalsErrors: O.totalsErrors,
457
- testId: i.lineItems
457
+ testId: a.lineItems
458
458
  },
459
- documentPanel: /* @__PURE__ */ c(Ue, {
459
+ documentPanel: /* @__PURE__ */ l(He, {
460
460
  payableId: y,
461
461
  readOnly: D,
462
462
  isDocumentPending: !!y && !w?.file && (b.isLoading || w?.ocr_status === "processing"),
@@ -467,111 +467,111 @@ function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et
467
467
  mimetype: w.file.mimetype
468
468
  } : void 0,
469
469
  staging: {
470
- stagedFile: B.stagedFile,
471
- onFileStaged: B.stageFile,
472
- onClearStagedFile: B.clearStagedFile,
473
- isSaving: Tt
470
+ stagedFile: V.stagedFile,
471
+ onFileStaged: V.stageFile,
472
+ onClearStagedFile: V.clearStagedFile,
473
+ isSaving: Et
474
474
  },
475
475
  deletion: {
476
- isPending: B.isFileDeletionPending,
477
- onRequest: B.requestFileDeletion,
478
- onDetachNow: B.detachFileNow,
479
- isDeleting: B.isDeletingFile,
480
- hasFailed: B.hasFileDeletionFailed
476
+ isPending: V.isFileDeletionPending,
477
+ onRequest: V.requestFileDeletion,
478
+ onDetachNow: V.detachFileNow,
479
+ isDeleting: V.isDeletingFile,
480
+ hasFailed: V.hasFileDeletionFailed
481
481
  }
482
482
  }),
483
- menuItems: Wt,
483
+ menuItems: Gt,
484
484
  readOnly: D,
485
- detail: d ? {
486
- view: on,
487
- actions: Ft,
488
- scheduledSummary: A.hasScheduledPayment && A.scheduledDateLabel ? p.scheduledSummary(A.scheduledDateLabel) : void 0,
489
- scheduledStatusLabel: A.hasScheduledPayment && A.scheduledDateLabel ? p.scheduledStatusBadge(A.scheduledDateLabel) : void 0,
490
- showApprovalOverrideNotice: !jt && kt,
491
- awaitingApprovalNotice: !jt && !At && !kt && w?.status === "approve_in_progress" && w?.approval_policy_id ? Mt ? p.awaitingApprovalNotice(Mt) : p.awaitingApprovalUnknownNotice : void 0,
485
+ detail: f ? {
486
+ view: sn,
487
+ actions: It,
488
+ scheduledSummary: A.hasScheduledPayment && A.scheduledDateLabel ? m.scheduledSummary(A.scheduledDateLabel) : void 0,
489
+ scheduledStatusLabel: A.hasScheduledPayment && A.scheduledDateLabel ? m.scheduledStatusBadge(A.scheduledDateLabel) : void 0,
490
+ showApprovalOverrideNotice: !Mt && At,
491
+ awaitingApprovalNotice: !Mt && !jt && !At && w?.status === "approve_in_progress" && w?.approval_policy_id ? Nt ? m.awaitingApprovalNotice(Nt) : m.awaitingApprovalUnknownNotice : void 0,
492
492
  payTo: {
493
- onEdit: z.mode === "resolved" ? z.onEdit : void 0,
494
- paymentInstructions: z.paymentInstructions,
495
- editForm: z.mode === "creating" ? z.newVendorForm : void 0
493
+ onEdit: B.mode === "resolved" ? B.onEdit : void 0,
494
+ paymentInstructions: B.paymentInstructions,
495
+ editForm: B.mode === "creating" ? B.newVendorForm : void 0
496
496
  },
497
497
  hideMissingPaymentInstructions: w?.status === "paid" || w?.status === "canceled",
498
- isLoading: Ht,
499
- isError: Ut,
500
- paymentHistoryError: A.isError || J.isError,
501
- paymentHistoryLoading: A.isResolving || J.isLoading,
502
- historyError: J.isError,
503
- historyLoading: J.isLoading || Qt,
504
- historyNamesError: en
498
+ isLoading: Ut,
499
+ isError: Wt,
500
+ paymentHistoryError: A.isError || Y.isError,
501
+ paymentHistoryLoading: A.isResolving || Y.isLoading,
502
+ historyError: Y.isError,
503
+ historyLoading: Y.isLoading || $t,
504
+ historyNamesError: tn
505
505
  } : void 0,
506
- isLineItemsLoading: Vt,
507
- isSaving: zt || L,
508
- isSavingDraft: B.isSavingDraft,
509
- isSubmitting: B.isFinalizing,
510
- onCancel: un,
511
- onCollapse: d ? dn : void 0,
512
- onSaveDraft: B.saveDraft,
513
- onFinalize: B.finalize,
514
- scrollToErrorToken: B.scrollToErrorToken,
506
+ isLineItemsLoading: Ht,
507
+ isSaving: Bt || L,
508
+ isSavingDraft: V.isSavingDraft,
509
+ isSubmitting: V.isFinalizing,
510
+ onCancel: dn,
511
+ onCollapse: f ? fn : void 0,
512
+ onSaveDraft: V.saveDraft,
513
+ onFinalize: V.finalize,
514
+ scrollToErrorToken: V.scrollToErrorToken,
515
515
  showSubmit: !D && T,
516
- testId: i.dialog
516
+ testId: a.dialog
517
517
  }),
518
- /* @__PURE__ */ c(ye, {
519
- open: g,
520
- onSaveDraft: pn,
521
- onDiscard: fn,
522
- onCancel: () => _(!1),
523
- isSaving: B.isSavingDraft,
524
- isSaveDraftDisabled: Q,
525
- labels: p.unsavedChanges,
526
- testId: i.unsavedDialog,
527
- saveDraftTestId: i.unsavedSaveDraft,
528
- discardTestId: i.unsavedDiscard,
529
- closeTestId: i.unsavedClose
518
+ /* @__PURE__ */ l(ve, {
519
+ open: h,
520
+ onSaveDraft: hn,
521
+ onDiscard: pn,
522
+ onCancel: () => g(!1),
523
+ isSaving: V.isSavingDraft,
524
+ isSaveDraftDisabled: mn,
525
+ labels: m.unsavedChanges,
526
+ testId: a.unsavedDialog,
527
+ saveDraftTestId: a.unsavedSaveDraft,
528
+ discardTestId: a.unsavedDiscard,
529
+ closeTestId: a.unsavedClose
530
530
  }),
531
- /* @__PURE__ */ c(me, {
532
- open: !!st,
531
+ /* @__PURE__ */ l(pe, {
532
+ open: !!ut,
533
533
  onDiscard: () => {
534
- let e = st;
535
- v(void 0), e?.();
534
+ let e = ut;
535
+ _(void 0), e?.();
536
536
  },
537
- onKeepEditing: () => v(void 0),
538
- labels: p.discardChanges,
539
- testId: i.discardDialog,
540
- discardTestId: i.discardConfirm
537
+ onKeepEditing: () => _(void 0),
538
+ labels: m.discardChanges,
539
+ testId: a.discardDialog,
540
+ discardTestId: a.discardConfirm
541
541
  }),
542
- /* @__PURE__ */ c(pe, {
543
- ...It,
544
- labels: { cancelButton: p.actions.decisionDialog.cancelButton },
545
- testId: i.decisionDialog,
546
- confirmTestId: i.decisionConfirm,
547
- reasonTestId: i.decisionReason
542
+ /* @__PURE__ */ l(i, {
543
+ ...Lt,
544
+ labels: { cancelButton: m.actions.decisionDialog.cancelButton },
545
+ testId: a.decisionDialog,
546
+ confirmTestId: a.decisionConfirm,
547
+ reasonTestId: a.decisionReason
548
548
  }),
549
- /* @__PURE__ */ c(pe, {
550
- ...Rt.dialog,
551
- labels: { cancelButton: p.actions.decisionDialog.cancelButton },
552
- testId: i.deleteDraftDialog,
553
- confirmTestId: i.deleteDraftConfirm
549
+ /* @__PURE__ */ l(i, {
550
+ ...zt.dialog,
551
+ labels: { cancelButton: m.actions.decisionDialog.cancelButton },
552
+ testId: a.deleteDraftDialog,
553
+ confirmTestId: a.deleteDraftConfirm
554
554
  }),
555
- /* @__PURE__ */ c(pe, {
555
+ /* @__PURE__ */ l(i, {
556
556
  open: $.removeConfirmation.open,
557
557
  copy: $.removeConfirmation.copy,
558
558
  onConfirm: $.removeConfirmation.onConfirm,
559
559
  onCancel: $.removeConfirmation.onCancel,
560
560
  isPending: $.removeConfirmation.isPending,
561
- confirmIcon: /* @__PURE__ */ c(Ze, {}),
561
+ confirmIcon: /* @__PURE__ */ l(Xe, {}),
562
562
  labels: { cancelButton: $.removeConfirmation.cancelButtonLabel },
563
- testId: i.duplicateRemoveDialog,
564
- confirmTestId: i.duplicateRemoveConfirm
563
+ testId: a.duplicateRemoveDialog,
564
+ confirmTestId: a.duplicateRemoveConfirm
565
565
  }),
566
- /* @__PURE__ */ c(ve, { ...Ot.dialogProps }),
567
- d && w ? /* @__PURE__ */ c(Ee, {
568
- ref: Et,
566
+ /* @__PURE__ */ l(_e, { ...kt.dialogProps }),
567
+ f && w ? /* @__PURE__ */ l(Te, {
568
+ ref: Dt,
569
569
  payable: w,
570
- onMissingAchInstructions: M ? P.openPaymentInstructions : void 0,
570
+ onMissingAchInstructions: vt ? N.openPaymentInstructions : void 0,
571
571
  poweredByBankName: nt,
572
- labels: p.payBill
572
+ labels: m.payBill
573
573
  }) : null
574
574
  ] });
575
575
  }
576
576
  //#endregion
577
- export { l as BillCreateDialog, l as default };
577
+ export { Qe as BillCreateDialog, Qe as default };