@tesouro/embedded-components-react 0.5.214 → 0.5.215

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 (74) hide show
  1. package/dist/index.d.ts +88 -1
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +88 -1
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/shared/util-validation/dist/index5.js +7 -0
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +63 -67
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +160 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +6 -0
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +32 -25
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +25 -200
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +175 -1
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +1 -101
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +92 -71
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +44 -100
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +93 -421
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +442 -112
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +166 -157
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +150 -204
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +202 -31
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +32 -145
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +145 -37
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +44 -58
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +113 -87
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +58 -116
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +83 -357
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +111 -65
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +449 -99
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +68 -281
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +115 -0
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +314 -0
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +34 -23
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +444 -92
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +113 -52
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +18 -14
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +2 -92
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +95 -3
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +3 -24
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +24 -1
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -3
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +3 -18
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +18 -1
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +0 -3
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +0 -8
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +11 -0
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +1 -264
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +258 -42
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +38 -62
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +61 -463
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +457 -89
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +91 -234
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +89 -82
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +22 -338
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +236 -0
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +26 -204
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +3 -0
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +249 -0
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +93 -0
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +344 -0
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +208 -32
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +29 -202
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +183 -137
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +157 -12
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +10 -19
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +23 -2
  69. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  70. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +167 -156
  71. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +66 -34
  72. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  73. package/dist/packages/shared-ui-shadcn/dist/index.js +13 -13
  74. package/package.json +1 -1
@@ -1,118 +1,470 @@
1
- import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as e, RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as t } from "../../ui/dist/index9.js";
1
+ import { isEmail as e } from "../../../../shared/util-validation/dist/index5.js";
2
+ import { RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as t } from "../../ui/dist/index10.js";
2
3
  import "../../ui/dist/index.js";
3
- import { addDays as n, addYears as r, format as i, max as a, min as o, parseISO as s, subYears as c } from "date-fns";
4
+ import { addDays as n, format as r, parseISO as i, startOfDay as a } from "date-fns";
4
5
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js
5
- var l = "MMM d, yyyy", u = "yyyy-MM-dd", d = 10, f = 5;
6
- function p(e) {
7
- let t = (e) => e ? {
8
- number_of_days: e.number_of_days ?? null,
9
- discount: e.discount ?? null
10
- } : null;
11
- return JSON.stringify({
12
- name: e.name,
13
- description: e.description ?? null,
14
- term_final: { number_of_days: e.term_final?.number_of_days ?? null },
15
- term_1: t(e.term_1),
16
- term_2: t(e.term_2)
17
- });
6
+ var o = "issue", s = "yyyy-MM-dd", c = 1e3, l = new Date(2050, 11, 31), u = [
7
+ "day",
8
+ "week",
9
+ "month"
10
+ ], d = [
11
+ "mo",
12
+ "tu",
13
+ "we",
14
+ "th",
15
+ "fr",
16
+ "sa",
17
+ "su"
18
+ ], f = {
19
+ su: 0,
20
+ mo: 1,
21
+ tu: 2,
22
+ we: 3,
23
+ th: 4,
24
+ fr: 5,
25
+ sa: 6
26
+ }, p = [
27
+ "su",
28
+ "mo",
29
+ "tu",
30
+ "we",
31
+ "th",
32
+ "fr",
33
+ "sa"
34
+ ];
35
+ function m() {
36
+ return {
37
+ frequency: "once",
38
+ recurrenceStartDate: "",
39
+ recurrenceEndDate: "",
40
+ recurrenceIssueMode: "first_day",
41
+ recurrenceDayOfWeek: "",
42
+ recurrenceEndMode: "after",
43
+ recurrenceMaxOccurrences: "",
44
+ recurrenceAutomationLevel: o,
45
+ recurrenceSubject: "",
46
+ recurrenceBody: "",
47
+ recurrenceRecipientsTo: void 0,
48
+ recurrenceRecipientsCc: [],
49
+ recurrenceRecipientsBcc: []
50
+ };
18
51
  }
19
- function m(e) {
20
- let t = /* @__PURE__ */ new Set();
21
- return e.filter((e) => {
22
- let n = p(e);
23
- return !t.has(n) && (t.add(n), !0);
24
- });
52
+ function h(e) {
53
+ return e.frequency !== "once";
25
54
  }
26
- function h(e, t) {
27
- let r = e.term_final?.number_of_days;
28
- return r ? n(t, r) : void 0;
55
+ function g({ to: t = [], cc: n = [], bcc: r = [], subject: i, body: a }) {
56
+ return t.length > 0 && [
57
+ ...t,
58
+ ...n,
59
+ ...r
60
+ ].every((t) => e(t)) && !!(i?.trim() && a?.trim());
29
61
  }
30
- function g(e, t) {
31
- let n = h(e, t);
62
+ function _(e) {
63
+ return e ? i(e) : void 0;
64
+ }
65
+ function v(e) {
66
+ return e ? r(e, s) : "";
67
+ }
68
+ function y(e) {
69
+ return n(a(e), 1);
70
+ }
71
+ function b(e, t) {
72
+ let r = a(t), i = (f[e] - r.getDay() + 7) % 7 || 7;
73
+ return n(r, i);
74
+ }
75
+ var x = {
76
+ recurrenceStartDate: "",
77
+ recurrenceEndDate: "",
78
+ recurrenceIssueMode: "",
79
+ recurrenceDayOfWeek: "",
80
+ recurrenceEndMode: "",
81
+ recurrenceMaxOccurrences: ""
82
+ };
83
+ function S(e, n) {
84
+ let r = {
85
+ ...e,
86
+ ...x,
87
+ frequency: n
88
+ };
89
+ return u.includes(n) ? {
90
+ ...r,
91
+ paymentTermsId: t,
92
+ paymentTermsCustomDate: "",
93
+ paymentReminderId: ""
94
+ } : n !== "once" && e.paymentTermsId === "custom" ? {
95
+ ...r,
96
+ paymentTermsId: "",
97
+ paymentTermsCustomDate: ""
98
+ } : r;
99
+ }
100
+ function C(e, t, { lockSchedule: n }) {
32
101
  return {
33
- value: e.id,
34
- label: e.name,
35
- ...n ? { dueDateLabel: i(n, l) } : {}
102
+ ...e,
103
+ recurrenceIssueMode: t,
104
+ ...n ? {} : { recurrenceStartDate: "" }
36
105
  };
37
106
  }
38
- function _(e) {
39
- return e ? s(e) : void 0;
40
- }
41
- function v({ terms: e, isLoading: t, fields: n, customDatePickerOpen: r, messages: a, today: o = /* @__PURE__ */ new Date() }) {
42
- if (t) return { kind: "loading" };
43
- let s = m(e ?? []).map((e) => g(e, o)), c = _(n.paymentTermsCustomDate), u;
44
- if (n.paymentTermsId === "receipt_due") u = { kind: "receiptDue" };
45
- else if (n.paymentTermsId === "custom") u = {
46
- kind: "customDate",
47
- hasDate: !!c,
48
- dateLabel: c ? i(c, l) : a.paymentTermsCustomDatePlaceholder
49
- };
50
- else {
51
- let e = s.find((e) => e.value === n.paymentTermsId);
52
- e && (u = {
53
- kind: "term",
54
- option: e
55
- });
56
- }
107
+ function w(e, t, { lockSchedule: n, today: r = /* @__PURE__ */ new Date() }) {
108
+ return n || e.recurrenceDayOfWeek === t ? e : {
109
+ ...e,
110
+ recurrenceDayOfWeek: t,
111
+ recurrenceStartDate: v(b(t, r))
112
+ };
113
+ }
114
+ function T(e, t) {
115
+ return t === "after" ? {
116
+ ...e,
117
+ recurrenceEndMode: t,
118
+ recurrenceEndDate: ""
119
+ } : {
120
+ ...e,
121
+ recurrenceEndMode: t,
122
+ recurrenceMaxOccurrences: ""
123
+ };
124
+ }
125
+ function E(e, t, n) {
57
126
  return {
58
- kind: "ready",
59
- value: n.paymentTermsId,
60
- options: s,
61
- selection: u,
62
- customDatePicker: { open: r }
127
+ ...e,
128
+ [t]: v(n)
63
129
  };
64
130
  }
65
- function y(e, t = /* @__PURE__ */ new Date()) {
66
- let n = _(e), i = c(t, d), s = r(t, f);
131
+ function D(e) {
67
132
  return {
68
- selected: n,
69
- startMonth: n ? o([i, n]) : i,
70
- endMonth: n ? a([s, n]) : s
133
+ ...e,
134
+ recurrenceRecipientsTo: void 0,
135
+ recurrenceRecipientsCc: [],
136
+ recurrenceRecipientsBcc: []
71
137
  };
72
138
  }
73
- function b(e, t) {
74
- return t === "custom" ? {
75
- paymentTermsId: t,
76
- paymentTermsCustomDate: e.paymentTermsId === "custom" ? e.paymentTermsCustomDate : ""
77
- } : {
78
- paymentTermsId: t,
79
- paymentTermsCustomDate: ""
139
+ function O(e, t) {
140
+ return {
141
+ to: e.recurrenceRecipientsTo ?? (t ? [t] : []),
142
+ toInput: "",
143
+ cc: e.recurrenceRecipientsCc,
144
+ ccInput: "",
145
+ bcc: e.recurrenceRecipientsBcc,
146
+ bccInput: "",
147
+ subject: e.recurrenceSubject,
148
+ message: e.recurrenceBody
80
149
  };
81
150
  }
82
- function x(e) {
83
- return e.paymentTermsId === "custom" && !e.paymentTermsCustomDate ? {
84
- paymentTermsId: "",
85
- paymentTermsCustomDate: ""
86
- } : e;
151
+ function k(e) {
152
+ let t = e.toInput.trim();
153
+ return t ? [...e.to, t] : e.to;
87
154
  }
88
- function S(e) {
89
- return e ? i(e, u) : "";
155
+ function A(e) {
156
+ return g({
157
+ to: k(e),
158
+ cc: e.cc,
159
+ bcc: e.bcc,
160
+ subject: e.subject,
161
+ body: e.message
162
+ });
90
163
  }
91
- function C(e) {
92
- return e.paymentTermsId === "custom" ? e.paymentTermsCustomDate ? { payment_terms: { term_final: { end_date: e.paymentTermsCustomDate } } } : { payment_terms: { term_final: { number_of_days: 0 } } } : e.paymentTermsId === "receipt_due" ? { payment_terms: { term_final: { number_of_days: 0 } } } : e.paymentTermsId ? { payment_terms_id: e.paymentTermsId } : {};
164
+ function j(e, t) {
165
+ return {
166
+ ...e,
167
+ recurrenceRecipientsTo: k(t),
168
+ recurrenceRecipientsCc: t.cc,
169
+ recurrenceRecipientsBcc: t.bcc,
170
+ recurrenceSubject: t.subject,
171
+ recurrenceBody: t.message
172
+ };
93
173
  }
94
- function w(e) {
95
- return e.paymentTermsId ? C(e) : {
96
- payment_terms_id: null,
97
- payment_terms: null
174
+ function M(e, t) {
175
+ return t === "issue_and_send" && !g({
176
+ to: e.recurrenceRecipientsTo,
177
+ cc: e.recurrenceRecipientsCc,
178
+ bcc: e.recurrenceRecipientsBcc,
179
+ subject: e.recurrenceSubject,
180
+ body: e.recurrenceBody
181
+ });
182
+ }
183
+ function N({ open: e, ready: t, draft: n, messages: r }) {
184
+ return {
185
+ open: e,
186
+ ready: t,
187
+ to: n.to,
188
+ toInput: n.toInput,
189
+ cc: n.cc,
190
+ ccInput: n.ccInput,
191
+ bcc: n.bcc,
192
+ bccInput: n.bccInput,
193
+ subject: n.subject,
194
+ message: n.message,
195
+ showToPlaceholder: n.to.length === 0,
196
+ saveDisabled: !A(n),
197
+ removeRecipientLabel: (e) => r.recurrenceRemoveRecipient.replace("{recipient}", e)
98
198
  };
99
199
  }
100
- function T(n) {
101
- if (n?.id) return {
102
- paymentTermsId: n.id,
103
- paymentTermsCustomDate: ""
200
+ var P = [
201
+ "th",
202
+ "st",
203
+ "nd",
204
+ "rd"
205
+ ];
206
+ function F(e) {
207
+ let t = e % 100;
208
+ return `${e}${P[(t - 20) % 10] ?? P[t] ?? P[0]}`;
209
+ }
210
+ function I(e, t) {
211
+ let [n, r] = {
212
+ day: [t.recurrenceUnitDay, t.recurrenceUnitDays],
213
+ week: [t.recurrenceUnitWeek, t.recurrenceUnitWeeks],
214
+ month: [t.recurrenceUnitMonth, t.recurrenceUnitMonths],
215
+ quarter: [t.recurrenceUnitQuarter, t.recurrenceUnitQuarters],
216
+ year: [t.recurrenceUnitYear, t.recurrenceUnitYears]
217
+ }[e];
218
+ return {
219
+ singular: n,
220
+ plural: r
104
221
  };
105
- let r = n?.term_final?.end_date;
106
- return r ? {
107
- paymentTermsId: e,
108
- paymentTermsCustomDate: r.slice(0, 10)
109
- } : n?.term_final?.number_of_days === 0 ? {
110
- paymentTermsId: t,
111
- paymentTermsCustomDate: ""
222
+ }
223
+ function L(e, t, n = /* @__PURE__ */ new Date()) {
224
+ if (t < y(n)) return !0;
225
+ if (e.frequency === "week") return e.recurrenceDayOfWeek ? t.getDay() !== f[e.recurrenceDayOfWeek] : !1;
226
+ if (e.frequency !== "month" || !e.recurrenceIssueMode) return !1;
227
+ let r = t.getDate(), i = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
228
+ if (e.recurrenceIssueMode === "first_day") return r !== 1;
229
+ if (e.recurrenceIssueMode === "last_day") return r !== i;
230
+ let a = Number(e.recurrenceIssueMode);
231
+ return !Number.isNaN(a) && r !== Math.min(a, i);
232
+ }
233
+ function R({ fields: e, errors: t, lockSchedule: n, messages: r, today: i = /* @__PURE__ */ new Date() }) {
234
+ let { frequency: a } = e, o = _(e.recurrenceStartDate), s = _(e.recurrenceEndDate), c = y(i), u = (t) => L(e, t, i), f = { frequency: {
235
+ value: a,
236
+ disabled: n,
237
+ options: [
238
+ {
239
+ value: "once",
240
+ label: r.recurrenceFrequencyOnce
241
+ },
242
+ {
243
+ value: "day",
244
+ label: r.recurrenceFrequencyDaily
245
+ },
246
+ {
247
+ value: "week",
248
+ label: r.recurrenceFrequencyWeekly
249
+ },
250
+ {
251
+ value: "month",
252
+ label: r.recurrenceFrequencyMonthly
253
+ },
254
+ {
255
+ value: "quarter",
256
+ label: r.recurrenceFrequencyQuarterly
257
+ },
258
+ {
259
+ value: "year",
260
+ label: r.recurrenceFrequencyAnnually
261
+ }
262
+ ]
263
+ } };
264
+ if (a === "month" && (f.monthDay = {
265
+ value: e.recurrenceIssueMode,
266
+ disabled: n,
267
+ invalid: !!t?.recurrenceIssueMode,
268
+ edgeOptions: [{
269
+ value: "first_day",
270
+ label: r.recurrenceFirstDay
271
+ }, {
272
+ value: "last_day",
273
+ label: r.recurrenceLastDay
274
+ }],
275
+ dayOptions: Array.from({ length: 31 }, (e, t) => ({
276
+ value: String(t + 1),
277
+ label: F(t + 1)
278
+ }))
279
+ }), a === "week") {
280
+ let i = {
281
+ mo: r.recurrenceWeekdayMo,
282
+ tu: r.recurrenceWeekdayTu,
283
+ we: r.recurrenceWeekdayWe,
284
+ th: r.recurrenceWeekdayTh,
285
+ fr: r.recurrenceWeekdayFr,
286
+ sa: r.recurrenceWeekdaySa,
287
+ su: r.recurrenceWeekdaySu
288
+ };
289
+ f.weekday = {
290
+ disabled: n,
291
+ invalid: !!t?.recurrenceDayOfWeek,
292
+ options: d.map((t) => ({
293
+ value: t,
294
+ label: i[t],
295
+ pressed: e.recurrenceDayOfWeek === t
296
+ }))
297
+ };
298
+ }
299
+ if (a === "once") return f;
300
+ let p = {
301
+ value: o,
302
+ disabled: n || a === "week" && !e.recurrenceDayOfWeek,
303
+ invalid: !!t?.recurrenceStartDate,
304
+ minDate: c,
305
+ maxDate: s ?? l,
306
+ isDateDisabled: u
307
+ }, m = I(a, r), h = {
308
+ value: e.recurrenceMaxOccurrences,
309
+ unitLabel: Number(e.recurrenceMaxOccurrences) === 1 ? m.singular : m.plural,
310
+ invalid: !!t?.recurrenceMaxOccurrences
311
+ };
312
+ f.schedule = {
313
+ start: p,
314
+ end: a === "day" ? {
315
+ kind: "choice",
316
+ mode: {
317
+ value: e.recurrenceEndMode,
318
+ invalid: !!t?.recurrenceEndMode,
319
+ options: [{
320
+ value: "after",
321
+ label: r.recurrenceEndAfter
322
+ }, {
323
+ value: "on",
324
+ label: r.recurrenceEndOn
325
+ }]
326
+ },
327
+ ...e.recurrenceEndMode === "on" ? { date: {
328
+ value: s,
329
+ disabled: !1,
330
+ invalid: !!t?.recurrenceEndDate,
331
+ minDate: o && o > c ? o : c,
332
+ maxDate: l,
333
+ isDateDisabled: u
334
+ } } : { occurrences: h }
335
+ } : {
336
+ kind: "count",
337
+ occurrences: h
338
+ },
339
+ maxOccurrencesError: t?.recurrenceMaxOccurrences
340
+ }, (a === "month" || a === "quarter" || a === "year") && (f.lastDayCaption = r.recurrenceLastDayCaption);
341
+ let g = t?.recurrenceSubject ?? t?.recurrenceBody ?? t?.recurrenceRecipientsTo ?? t?.recurrenceRecipientsCc ?? t?.recurrenceRecipientsBcc;
342
+ return f.creationMode = {
343
+ value: e.recurrenceAutomationLevel,
344
+ options: [
345
+ {
346
+ value: "issue_and_send",
347
+ title: r.recurrenceModeIssueAndSendTitle,
348
+ description: r.recurrenceModeIssueAndSendDescription
349
+ },
350
+ {
351
+ value: "issue",
352
+ title: r.recurrenceModeIssueTitle,
353
+ description: r.recurrenceModeIssueDescription
354
+ },
355
+ {
356
+ value: "draft",
357
+ title: r.recurrenceModeDraftTitle,
358
+ description: r.recurrenceModeDraftDescription
359
+ }
360
+ ],
361
+ ...e.recurrenceAutomationLevel === "issue_and_send" ? { emailSummary: e.recurrenceRecipientsTo?.length ? e.recurrenceRecipientsTo.join(", ") : r.recurrenceNoRecipients } : {},
362
+ emailError: g
363
+ }, f;
364
+ }
365
+ function z(e, t, n) {
366
+ let { singular: r, plural: i } = I(t, n), a = (e) => e.replace("{unit}", r).replace("{units}", i);
367
+ if (!e) return a(n.recurrenceOccurrencesRequired);
368
+ let o = Number(e);
369
+ if (o < 1) return a(n.recurrenceOccurrencesTooFew);
370
+ if (o > c) return a(n.recurrenceOccurrencesTooMany);
371
+ if (!Number.isInteger(o)) return n.recurrenceOccurrencesWhole;
372
+ }
373
+ function B({ fields: t, issuedCount: n = 0, messages: r }) {
374
+ let { frequency: i } = t;
375
+ if (i === "once") return {};
376
+ let a = {};
377
+ t.recurrenceStartDate || (a.recurrenceStartDate = r.recurrenceStartDateRequired);
378
+ let o = i !== "day" || t.recurrenceEndMode === "after";
379
+ if (i === "month" && !t.recurrenceIssueMode && (a.recurrenceIssueMode = r.recurrenceDayOfMonthRequired), i === "week" && !t.recurrenceDayOfWeek && (a.recurrenceDayOfWeek = r.recurrenceDayOfWeekRequired), i === "day" && !t.recurrenceEndMode && (a.recurrenceEndMode = r.recurrenceEndConditionRequired), i === "day" && t.recurrenceEndMode === "on" && !t.recurrenceEndDate && (a.recurrenceEndDate = r.recurrenceEndDateRequired), o) {
380
+ let e = z(t.recurrenceMaxOccurrences, i, r);
381
+ e && (a.recurrenceMaxOccurrences = e);
382
+ }
383
+ let s = i === "day" && t.recurrenceEndMode === "on";
384
+ if (!a.recurrenceMaxOccurrences && n > 0 && !s && t.recurrenceMaxOccurrences && Number(t.recurrenceMaxOccurrences) <= n && (a.recurrenceMaxOccurrences = r.recurrenceOccurrencesBelowIssued.replace("{count}", String(n))), t.recurrenceAutomationLevel === "issue_and_send") {
385
+ t.recurrenceSubject.trim() || (a.recurrenceSubject = r.recurrenceSubjectRequired), t.recurrenceBody.trim() || (a.recurrenceBody = r.recurrenceMessageRequired), t.recurrenceRecipientsTo?.length || (a.recurrenceRecipientsTo = r.recurrenceRecipientRequired);
386
+ let n = (t) => {
387
+ let n = t?.find((t) => !e(t));
388
+ return n ? r.recurrenceInvalidEmail.replace("{address}", n) : void 0;
389
+ }, i = n(t.recurrenceRecipientsTo);
390
+ i && !a.recurrenceRecipientsTo && (a.recurrenceRecipientsTo = i);
391
+ let o = n(t.recurrenceRecipientsCc);
392
+ o && (a.recurrenceRecipientsCc = o);
393
+ let s = n(t.recurrenceRecipientsBcc);
394
+ s && (a.recurrenceRecipientsBcc = s);
395
+ }
396
+ return a;
397
+ }
398
+ function V(e) {
399
+ let t = e.recurrenceAutomationLevel;
400
+ if (t !== "issue_and_send") return {
401
+ automation_level: t,
402
+ subject_text: null,
403
+ body_text: null,
404
+ recipients: null
405
+ };
406
+ let n = {
407
+ to: e.recurrenceRecipientsTo?.length ? e.recurrenceRecipientsTo : void 0,
408
+ cc: e.recurrenceRecipientsCc.length ? e.recurrenceRecipientsCc : void 0,
409
+ bcc: e.recurrenceRecipientsBcc.length ? e.recurrenceRecipientsBcc : void 0
410
+ };
411
+ return {
412
+ automation_level: t,
413
+ subject_text: e.recurrenceSubject || void 0,
414
+ body_text: e.recurrenceBody || void 0,
415
+ recipients: Object.values(n).some(Boolean) ? n : void 0
416
+ };
417
+ }
418
+ function H(e, { hasExistingRecurrence: t }) {
419
+ let n = e.frequency === "day" && e.recurrenceEndMode === "on" && !!e.recurrenceEndDate, r = t ? null : void 0;
420
+ return {
421
+ frequency: e.frequency,
422
+ start_date: e.recurrenceStartDate,
423
+ max_occurrences: n ? r : Number(e.recurrenceMaxOccurrences) || void 0,
424
+ end_date: n ? e.recurrenceEndDate : r
425
+ };
426
+ }
427
+ function U(e, t) {
428
+ return {
429
+ ...H(e, { hasExistingRecurrence: !1 }),
430
+ ...V(e),
431
+ invoice_id: t,
432
+ interval: 1
433
+ };
434
+ }
435
+ function W(e, { lockSchedule: t }) {
436
+ let n = H(e, { hasExistingRecurrence: !0 });
437
+ return t ? {
438
+ max_occurrences: n.max_occurrences,
439
+ end_date: n.end_date,
440
+ ...V(e)
112
441
  } : {
113
- paymentTermsId: "",
114
- paymentTermsCustomDate: ""
442
+ ...n,
443
+ ...V(e)
444
+ };
445
+ }
446
+ function G(e) {
447
+ return e?.iterations.filter((e) => e.issued_invoice_id).length ?? 0;
448
+ }
449
+ function K(e) {
450
+ let t = m();
451
+ if (!e) return t;
452
+ let n = _(e.start_date);
453
+ return {
454
+ frequency: e.frequency,
455
+ recurrenceStartDate: e.start_date.slice(0, 10),
456
+ recurrenceEndDate: e.end_date?.slice(0, 10) ?? "",
457
+ recurrenceEndMode: e.end_date ? "on" : "after",
458
+ recurrenceMaxOccurrences: e.max_occurrences == null ? "" : String(e.max_occurrences),
459
+ recurrenceIssueMode: n ? String(n.getDate()) : "first_day",
460
+ recurrenceDayOfWeek: n ? p[n.getDay()] : "",
461
+ recurrenceAutomationLevel: e.automation_level ?? "issue",
462
+ recurrenceSubject: e.subject_text ?? "",
463
+ recurrenceBody: e.body_text ?? "",
464
+ recurrenceRecipientsTo: e.recipients?.to ?? void 0,
465
+ recurrenceRecipientsCc: e.recipients?.cc ?? [],
466
+ recurrenceRecipientsBcc: e.recipients?.bcc ?? []
115
467
  };
116
468
  }
117
469
  //#endregion
118
- export { y as buildCustomDateCalendar, C as buildPaymentTermsPayload, w as buildPaymentTermsUpdatePayload, v as buildPaymentTermsView, x as closeCustomDatePickerFields, m as dedupePaymentTerms, T as paymentTermsToFormFields, b as selectPaymentTermsFields, S as toCustomDateValue };
470
+ export { o as DEFAULT_RECURRENCE_AUTOMATION_LEVEL, j as applyRecurrenceEmailDraft, U as buildCreateRecurrencePayload, V as buildRecurrenceDeliveryPayload, N as buildRecurrenceEmailView, R as buildRecurrenceView, W as buildUpdateRecurrencePayload, D as clearRecurrenceRecipients, G as countIssuedIterations, m as createEmptyRecurrenceFields, O as createRecurrenceEmailDraft, L as isRecurrenceDateDisabled, g as isRecurrenceEmailComplete, A as isRecurrenceEmailDraftComplete, h as isRecurring, K as recurrenceToFormFields, E as selectRecurrenceDate, w as selectRecurrenceDayOfWeek, T as selectRecurrenceEndMode, S as selectRecurrenceFrequency, C as selectRecurrenceIssueMode, M as shouldOpenRecurrenceEmail, B as validateRecurrence };