@bash-app/bash-common 30.447.0 → 30.449.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.
Files changed (51) hide show
  1. package/dist/__tests__/partnerBookingAgreement.test.d.ts +2 -0
  2. package/dist/__tests__/partnerBookingAgreement.test.d.ts.map +1 -0
  3. package/dist/__tests__/partnerBookingAgreement.test.js +62 -0
  4. package/dist/__tests__/partnerBookingAgreement.test.js.map +1 -0
  5. package/dist/__tests__/vendorBookingAgreement.test.d.ts +2 -0
  6. package/dist/__tests__/vendorBookingAgreement.test.d.ts.map +1 -0
  7. package/dist/__tests__/vendorBookingAgreement.test.js +32 -0
  8. package/dist/__tests__/vendorBookingAgreement.test.js.map +1 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/partnerBookingAgreement.d.ts +55 -0
  14. package/dist/partnerBookingAgreement.d.ts.map +1 -0
  15. package/dist/partnerBookingAgreement.js +251 -0
  16. package/dist/partnerBookingAgreement.js.map +1 -0
  17. package/dist/utils/__tests__/recurrenceUtils.test.js +51 -0
  18. package/dist/utils/__tests__/recurrenceUtils.test.js.map +1 -1
  19. package/dist/utils/__tests__/slugUtils.test.js +17 -0
  20. package/dist/utils/__tests__/slugUtils.test.js.map +1 -1
  21. package/dist/utils/recurrenceUtils.d.ts +2 -2
  22. package/dist/utils/recurrenceUtils.d.ts.map +1 -1
  23. package/dist/utils/recurrenceUtils.js +50 -32
  24. package/dist/utils/recurrenceUtils.js.map +1 -1
  25. package/dist/utils/service/__tests__/serviceUtils.test.js +5 -1
  26. package/dist/utils/service/__tests__/serviceUtils.test.js.map +1 -1
  27. package/dist/utils/service/serviceUtils.d.ts +2 -0
  28. package/dist/utils/service/serviceUtils.d.ts.map +1 -1
  29. package/dist/utils/service/serviceUtils.js +7 -0
  30. package/dist/utils/service/serviceUtils.js.map +1 -1
  31. package/dist/utils/slugUtils.d.ts +1 -1
  32. package/dist/utils/slugUtils.d.ts.map +1 -1
  33. package/dist/utils/slugUtils.js +17 -5
  34. package/dist/utils/slugUtils.js.map +1 -1
  35. package/dist/vendorBookingAgreement.d.ts +25 -0
  36. package/dist/vendorBookingAgreement.d.ts.map +1 -0
  37. package/dist/vendorBookingAgreement.js +114 -0
  38. package/dist/vendorBookingAgreement.js.map +1 -0
  39. package/package.json +1 -1
  40. package/prisma/schema.prisma +26 -2
  41. package/src/__tests__/partnerBookingAgreement.test.ts +84 -0
  42. package/src/__tests__/vendorBookingAgreement.test.ts +53 -0
  43. package/src/index.ts +2 -0
  44. package/src/partnerBookingAgreement.ts +429 -0
  45. package/src/utils/__tests__/recurrenceUtils.test.ts +54 -0
  46. package/src/utils/__tests__/slugUtils.test.ts +19 -0
  47. package/src/utils/recurrenceUtils.ts +55 -34
  48. package/src/utils/service/__tests__/serviceUtils.test.ts +10 -0
  49. package/src/utils/service/serviceUtils.ts +12 -0
  50. package/src/utils/slugUtils.ts +16 -5
  51. package/src/vendorBookingAgreement.ts +158 -0
@@ -104,30 +104,35 @@ export function recurrenceHasOccurrenceExceptions(
104
104
 
105
105
  export function getRecurringBashEventPossibleDateTimes(
106
106
  startDateTime: DateTimeArgType,
107
- recurrence: Recurrence | undefined | null
107
+ recurrence: Recurrence | undefined | null,
108
+ timezone?: string
108
109
  ): Date[] {
109
110
  return getRecurringBashEventPossibleDatesTimesInternal(
110
111
  startDateTime,
111
112
  recurrence,
112
- true
113
+ true,
114
+ timezone
113
115
  ) as Date[];
114
116
  }
115
117
 
116
118
  export function getRecurringBashEventPossibleLuxonTimes(
117
119
  startDateTime: DateTimeArgType,
118
- recurrence: Recurrence | undefined | null
120
+ recurrence: Recurrence | undefined | null,
121
+ timezone?: string
119
122
  ): DateTime[] {
120
123
  return getRecurringBashEventPossibleDatesTimesInternal(
121
124
  startDateTime,
122
125
  recurrence,
123
- false
126
+ false,
127
+ timezone
124
128
  ) as DateTime[];
125
129
  }
126
130
 
127
131
  function getRecurringBashEventPossibleDatesTimesInternal(
128
132
  startDateTime: DateTimeArgType,
129
133
  recurrence: Recurrence | undefined | null,
130
- toDate: boolean
134
+ toDate: boolean,
135
+ timezone?: string
131
136
  ): (DateTime | Date)[] {
132
137
  if (
133
138
  !recurrence ||
@@ -145,10 +150,12 @@ function getRecurringBashEventPossibleDatesTimesInternal(
145
150
  recurrence.frequency === RecurringFrequency.Monthly ||
146
151
  recurrence.frequency === RecurringFrequency.Yearly;
147
152
 
148
- const beginningDate = shouldUseEventDate
153
+ const unzonedBeginningDate = shouldUseEventDate
149
154
  ? (startDateTime ? dateTimeFromDate(startDateTime) as DateTime : DateTime.local())
150
155
  : findEarliestPossibleBashEventDate(startDateTime) as DateTime;
151
156
 
157
+ const beginningDate = timezone ? unzonedBeginningDate.setZone(timezone) : unzonedBeginningDate;
158
+
152
159
  switch (recurrence.frequency) {
153
160
  case RecurringFrequency.Daily:
154
161
  recurrenceDates = getDailyRecurringDates(beginningDate, recurrence);
@@ -166,6 +173,8 @@ function getRecurringBashEventPossibleDatesTimesInternal(
166
173
  console.error(`Unsupported frequency: ${recurrence.frequency}`);
167
174
  }
168
175
 
176
+ recurrenceDates.sort((a, b) => a.toMillis() - b.toMillis());
177
+
169
178
  // If repeatCount is specified, limit to that many occurrences
170
179
  if (recurrence.repeatCount && recurrence.repeatCount > 0) {
171
180
  recurrenceDates = recurrenceDates.slice(0, recurrence.repeatCount);
@@ -176,11 +185,13 @@ function getRecurringBashEventPossibleDatesTimesInternal(
176
185
  // 2) move occurrences the host rescheduled (occurrenceOverrides)
177
186
  recurrenceDates = applyOccurrenceExceptions(recurrenceDates, recurrence);
178
187
 
188
+ if (timezone) return recurrenceDates.sort((a, b) => a.toMillis() - b.toMillis()).map(date => toDate ? date.toJSDate() : date);
189
+
179
190
  return recurrenceDates
180
191
  .map((date: DateTime): string =>
181
192
  date.toFormat(LUXON_DATETIME_FORMAT_ISO_LIKE)
182
193
  )
183
- .sort()
194
+ .sort((a, b) => DateTime.fromFormat(a, LUXON_DATETIME_FORMAT_ISO_LIKE).toMillis() - DateTime.fromFormat(b, LUXON_DATETIME_FORMAT_ISO_LIKE).toMillis())
184
195
  .map((dateStr: string): DateTime | Date => {
185
196
  const luxonDate = DateTime.fromFormat(
186
197
  dateStr,
@@ -218,7 +229,7 @@ function applyOccurrenceExceptions(
218
229
 
219
230
  const result: DateTime[] = [];
220
231
  for (const occ of occurrences) {
221
- const key = occurrenceOverrideKey(occ);
232
+ const key = occurrenceOverrideKey(occ.toJSDate());
222
233
  if (excludedKeys.has(key)) continue;
223
234
  const override = overrides[key];
224
235
  if (override?.startDateTime) {
@@ -250,10 +261,10 @@ function getDailyRecurringDates(
250
261
 
251
262
  const interval = recurrence.interval ?? 1;
252
263
 
253
- // Default to 1 year from now if no end date specified
264
+ // Default to one year from the series start if no end date is specified
254
265
  const recurrenceEnds = recurrence.ends
255
- ? dateTimeFromDate(recurrence.ends).endOf("day")
256
- : DateTime.local().plus({ years: 1 }).endOf("day");
266
+ ? dateTimeFromDate(recurrence.ends).setZone(beginningDateTime.zoneName || "local").endOf("day")
267
+ : beginningDateTime.plus({ years: 1 }).endOf("day");
257
268
 
258
269
  const numberOfDays = recurrenceEnds.diff(beginningDateTime, "days").days;
259
270
  const numberOfOccurrences = Math.ceil(numberOfDays / interval);
@@ -265,7 +276,7 @@ function getDailyRecurringDates(
265
276
  if (currentDate >= beginningDateTime) {
266
277
  recurrenceDates.push(currentDate);
267
278
  }
268
- currentDate = currentDate.plus({ days: interval });
279
+ currentDate = dateTimeSetTime(currentDate.plus({ days: interval }), beginningDateTime);
269
280
  }
270
281
 
271
282
  return recurrenceDates;
@@ -288,8 +299,8 @@ function getWeeklyRecurringDates(
288
299
 
289
300
  const interval = recurrence.interval ?? 1;
290
301
  const recurrenceEnds = recurrence.ends
291
- ? dateTimeFromDate(recurrence.ends).endOf("day")
292
- : DateTime.local().plus({ years: 1 }).endOf("day");
302
+ ? dateTimeFromDate(recurrence.ends).setZone(beginningDateTime.zoneName || "local").endOf("day")
303
+ : beginningDateTime.plus({ years: 1 }).endOf("day");
293
304
  const numberOfDays = recurrenceEnds.diff(beginningDateTime, "days").days;
294
305
  const numberOfWeeks = Math.ceil(numberOfDays / 7 / interval); // Get the number of days and then round up so that we include the ending date
295
306
 
@@ -352,8 +363,24 @@ function getMonthlyRecurringDates(
352
363
 
353
364
  const interval = recurrence.interval ?? 1;
354
365
  const recurrenceEnds = recurrence.ends
355
- ? dateTimeFromDate(recurrence.ends).endOf("day")
356
- : DateTime.local().plus({ years: 1 }).endOf("day");
366
+ ? dateTimeFromDate(recurrence.ends).setZone(beginningDateTime.zoneName || "local").endOf("day")
367
+ : beginningDateTime.plus({ years: 1 }).endOf("day");
368
+ // Monthly nth-weekday rules use repeatOnDays with no day-of-month.
369
+ if (recurrence.repeatOnDayOfMonth == null && recurrence.repeatOnDays?.length) {
370
+ const weekday = dayOfWeekGetIdx(recurrence.repeatOnDays[0]);
371
+ const ordinal = Math.ceil(beginningDateTime.day / 7);
372
+ const dates: DateTime[] = [];
373
+ let month = beginningDateTime.startOf("month");
374
+ for (let i = 0; i < 100 && month <= recurrenceEnds; i++) {
375
+ const day = 1 + ((weekday - month.weekday + 7) % 7) + (ordinal - 1) * 7;
376
+ if (day <= (month.daysInMonth ?? 31)) {
377
+ const occurrence = dateTimeSetTime(month.set({ day }), beginningDateTime);
378
+ if (occurrence >= beginningDateTime && occurrence <= recurrenceEnds) dates.push(occurrence);
379
+ }
380
+ month = month.plus({ months: interval });
381
+ }
382
+ return dates;
383
+ }
357
384
  const dayOfMonth = recurrence.repeatOnDayOfMonth ?? beginningDateTime.day;
358
385
 
359
386
  const recurrenceDates: DateTime[] = [];
@@ -399,7 +426,7 @@ function getYearlyRecurringDates(
399
426
 
400
427
  const interval = recurrence.interval ?? 1;
401
428
  const recurrenceEnds = recurrence.ends
402
- ? dateTimeFromDate(recurrence.ends).endOf("day")
429
+ ? dateTimeFromDate(recurrence.ends).setZone(beginningDateTime.zoneName || "local").endOf("day")
403
430
  : DateTime.local().plus({ years: 20 }).endOf("day");
404
431
 
405
432
  // Use the repeatYearlyDate if provided, otherwise use the beginning date
@@ -408,23 +435,17 @@ function getYearlyRecurringDates(
408
435
  : beginningDateTime;
409
436
 
410
437
  const recurrenceDates: DateTime[] = [];
411
- let currentDate = baseDate.set({
412
- year: beginningDateTime.year,
413
- hour: beginningDateTime.hour,
414
- minute: beginningDateTime.minute,
415
- second: beginningDateTime.second
416
- });
417
-
418
- // If we've already passed this date this year, start from next year
419
- if (currentDate < beginningDateTime) {
420
- currentDate = currentDate.plus({ years: interval });
421
- }
422
-
423
- while (currentDate <= recurrenceEnds) {
424
- if (currentDate >= beginningDateTime) {
425
- recurrenceDates.push(currentDate);
426
- }
427
- currentDate = currentDate.plus({ years: interval });
438
+ // Rebuild from the original month/day every year. Luxon's plus({ years: 1 })
439
+ // clamps Feb 29 to Feb 28 and otherwise loses the leap-day rule forever.
440
+ const zonedBase = baseDate.setZone(beginningDateTime.zoneName || "local");
441
+ for (let year = beginningDateTime.year, i = 0; year <= recurrenceEnds.year && i < 100; year += Math.max(1, interval), i++) {
442
+ const occurrence = DateTime.fromObject({
443
+ year, month: zonedBase.month, day: zonedBase.day,
444
+ hour: beginningDateTime.hour, minute: beginningDateTime.minute,
445
+ second: beginningDateTime.second,
446
+ }, { zone: beginningDateTime.zoneName || "local" });
447
+ // Feb 29 occurs only in leap years; non-leap years have no occurrence.
448
+ if (occurrence.isValid && occurrence >= beginningDateTime && occurrence <= recurrenceEnds) recurrenceDates.push(occurrence);
428
449
  }
429
450
 
430
451
  return recurrenceDates;
@@ -5,6 +5,7 @@ import {
5
5
  serviceGetSpecificType,
6
6
  serviceDetailUrl,
7
7
  serviceWizardUrl,
8
+ serviceWizardEditEntryUrl,
8
9
  partnerServiceProfileWizardPaymentMethodUrl,
9
10
  venueWizardLoyaltyBuilderUrl,
10
11
  serviceCheckoutUrl,
@@ -66,6 +67,15 @@ describe("serviceUtils", () => {
66
67
  );
67
68
  });
68
69
 
70
+ test("serviceWizardEditEntryUrl opens Who for marketplace types", () => {
71
+ expect(serviceWizardEditEntryUrl("s1", "Vendors", "v1")).toBe(
72
+ "/wz/services/s1/Vendors/v1/1/0"
73
+ );
74
+ expect(serviceWizardEditEntryUrl("s1", "Volunteers", "vol-1")).toBe(
75
+ "/wz/services/s1/Volunteers/vol-1/0/0"
76
+ );
77
+ });
78
+
69
79
  test("partnerServiceProfileWizardPaymentMethodUrl uses payment step constants", () => {
70
80
  expect(partnerServiceProfileWizardPaymentMethodUrl("s1", "Vendors", "v1")).toBe(
71
81
  `/wz/services/s1/Vendors/v1/${PARTNER_SERVICE_PROFILE_WIZARD_PAYMENT_METHOD_MAJOR_STEP}/3`
@@ -457,6 +457,18 @@ export function serviceWizardUrl(
457
457
  return `/wz/services/${serviceId}/${serviceType}/${specificId}/${step}/${substep}`;
458
458
  }
459
459
 
460
+ /** Re-open a draft from My Services at Who (skip Quick Listing). Volunteers stay at step 0. */
461
+ export function serviceWizardEditEntryUrl(
462
+ serviceId: string,
463
+ serviceType: string,
464
+ specificId: string
465
+ ): string {
466
+ if (serviceType === ServiceTypes.Volunteers) {
467
+ return serviceWizardUrl(serviceId, serviceType, specificId, 0, 0);
468
+ }
469
+ return serviceWizardUrl(serviceId, serviceType, specificId, 1, 0);
470
+ }
471
+
460
472
  /**
461
473
  * Vendor, Exhibitor, and Sponsor profile wizards share this layout: major step 6 = "How",
462
474
  * sub-step 3 = "Payment method" (partner profile wizard payment step).
@@ -165,6 +165,14 @@ export function parseBashUrlParams(param: string): { id: string; slug: string |
165
165
  return param.length > 0 ? { id: param, slug: null } : null;
166
166
  }
167
167
 
168
+ const dashCount = (param.match(/-/g) ?? []).length;
169
+ if (dashCount === 1) {
170
+ const head = param.slice(0, dashIndex);
171
+ const tail = param.slice(dashIndex + 1);
172
+ if (!head) return null;
173
+ return { id: head, slug: tail || null };
174
+ }
175
+
168
176
  const head = param.slice(0, dashIndex);
169
177
  if (!head) return null;
170
178
  const tail = param.slice(dashIndex + 1);
@@ -176,10 +184,11 @@ export function parseBashUrlParams(param: string): { id: string; slug: string |
176
184
 
177
185
  // Short legacy ids (no hyphens in head): `abc123-summer-bash`
178
186
  if (
187
+ !param.startsWith("qa-") &&
179
188
  !head.includes("-") &&
180
- head.length >= 4 &&
189
+ head.length >= 2 &&
181
190
  head.length <= 12 &&
182
- /^[a-z0-9]+$/i.test(head)
191
+ /^[a-z0-9_]+$/i.test(head)
183
192
  ) {
184
193
  return { id: head, slug: tail || null };
185
194
  }
@@ -188,9 +197,11 @@ export function parseBashUrlParams(param: string): { id: string; slug: string |
188
197
  }
189
198
 
190
199
  /** Id portion of a `/bash/:bashEventIdSlug` segment. */
191
- export function eventIdFromBashSlug(segment: string): string {
192
- const parsed = parseBashUrlParams(segment);
193
- return parsed?.id || segment;
200
+ export function eventIdFromBashSlug(segment: string | null | undefined): string {
201
+ const param = (segment ?? "").trim();
202
+ if (!param) return "";
203
+ const parsed = parseBashUrlParams(param);
204
+ return parsed?.id || param;
194
205
  }
195
206
 
196
207
  export function validateSlug(slug: string): boolean {
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Standard vendor booking agreement for Bash marketplace introductions.
3
+ * Force majeure is one section within this document — not a separate contract.
4
+ * Not legal advice; vendors may customize via listing preferences.
5
+ */
6
+ export const STANDARD_VENDOR_BOOKING_AGREEMENT = `STANDARD VENDOR BOOKING AGREEMENT (Bash Marketplace)
7
+
8
+ 1. Scope. This agreement applies when a host books the vendor for an event through Bash. It governs the relationship between the vendor and the host for that booking. Bash facilitates the introduction and booking tools; the performance obligation is between host and vendor unless Bash is explicitly a party in writing.
9
+
10
+ 2. Booking confirmation. The confirmed booking details (date, time, location, fees, deliverables, and special requirements) are those shown in the booking confirmation and the vendor's listing at the time of booking. Changes must be agreed by both parties in writing (including in-app messages or email).
11
+
12
+ 3. Fees and payment. The vendor charges the fees stated in the listing or booking confirmation. Payment timing follows the booking checkout terms and any host cancellation policy published for the event. The vendor is responsible for its own taxes on amounts received unless otherwise required by law.
13
+
14
+ 4. Vendor obligations. The vendor will perform professionally, comply with applicable laws and permits, maintain any insurance represented on its profile, and meet the space, utility, and setup requirements stated on its listing.
15
+
16
+ 5. Host obligations. The host will provide the agreed venue access, load-in window, and utilities represented in the booking, and will communicate material event changes promptly.
17
+
18
+ 6. Cancellations and schedule changes. If the host cancels for reasons other than vendor breach, the vendor receives any cancellation fee or minimum guarantee stated in the booking or listing. If the vendor cannot perform, the vendor must notify the host as soon as practicable and cooperate on rescheduling or refund handling per the booking payment terms. Material changes to date, time, location, or scope may be declined by either party if the change makes performance unreasonable, when notice is given as stated in the booking confirmation.
19
+
20
+ 7. Force majeure. Neither party is liable for failure or delay caused by a Force Majeure Event — circumstances beyond reasonable control, including severe weather, natural disaster, epidemic, governmental order, utility failure, terrorism, civil unrest, or venue closure not caused by the vendor. The affected party must notify the other promptly and use reasonable efforts to mitigate. Deposits and prepaid amounts are handled under Section 6 and the host's published cancellation policy. Neither party owes indirect, consequential, or punitive damages for force majeure.
21
+
22
+ 8. Limitation of liability. Except for fraud or willful misconduct, each party's total liability arising from the booking is limited to the fees paid or payable for that booking. This limitation does not apply where prohibited by law.
23
+
24
+ 9. Independent contractor. The vendor is an independent contractor, not an employee or agent of the host or Bash.
25
+
26
+ 10. Entire agreement. This standard agreement applies to the booking unless the host and vendor supersede it with a signed written contract. Custom text saved on the vendor's Bash listing replaces this standard text for hosts reviewing that listing.
27
+
28
+ By accepting, the vendor agrees that this agreement (or its customized version on the listing) governs marketplace bookings through Bash.`;
29
+
30
+ export type VendorBookingAgreementDiffLineKind =
31
+ | "unchanged"
32
+ | "removed"
33
+ | "added"
34
+ | "changed";
35
+
36
+ export type VendorBookingAgreementDiffLine = {
37
+ kind: VendorBookingAgreementDiffLineKind;
38
+ standardLine?: string;
39
+ customLine?: string;
40
+ };
41
+
42
+ export function normalizeVendorBookingAgreementText(text: string): string {
43
+ return text.replace(/\r\n/g, "\n").trim();
44
+ }
45
+
46
+ export function getVendorBookingAgreementDisplayText(
47
+ storedText: string | null | undefined
48
+ ): string {
49
+ const trimmed = storedText?.trim();
50
+ if (trimmed) {
51
+ return trimmed;
52
+ }
53
+ return STANDARD_VENDOR_BOOKING_AGREEMENT;
54
+ }
55
+
56
+ export function isVendorBookingAgreementCustomized(
57
+ storedText: string | null | undefined,
58
+ storedFlag?: boolean | null
59
+ ): boolean {
60
+ if (storedFlag === true) {
61
+ return true;
62
+ }
63
+ if (!storedText?.trim()) {
64
+ return false;
65
+ }
66
+ return (
67
+ normalizeVendorBookingAgreementText(storedText) !==
68
+ normalizeVendorBookingAgreementText(STANDARD_VENDOR_BOOKING_AGREEMENT)
69
+ );
70
+ }
71
+
72
+ export function resolveVendorBookingAgreementForSave(editedText: string): {
73
+ vendorBookingAgreementText: string | null;
74
+ vendorBookingAgreementCustomized: boolean;
75
+ } {
76
+ const normalized = normalizeVendorBookingAgreementText(editedText);
77
+ const standard = normalizeVendorBookingAgreementText(
78
+ STANDARD_VENDOR_BOOKING_AGREEMENT
79
+ );
80
+ if (normalized === standard) {
81
+ return {
82
+ vendorBookingAgreementText: null,
83
+ vendorBookingAgreementCustomized: false,
84
+ };
85
+ }
86
+ return {
87
+ vendorBookingAgreementText: normalized,
88
+ vendorBookingAgreementCustomized: true,
89
+ };
90
+ }
91
+
92
+ /** Line-oriented diff for highlighting vendor edits against the standard agreement. */
93
+ export function diffVendorBookingAgreement(
94
+ standardText: string,
95
+ customText: string
96
+ ): VendorBookingAgreementDiffLine[] {
97
+ const standardLines = normalizeVendorBookingAgreementText(standardText).split(
98
+ "\n"
99
+ );
100
+ const customLines = normalizeVendorBookingAgreementText(customText).split("\n");
101
+ const result: VendorBookingAgreementDiffLine[] = [];
102
+ let i = 0;
103
+ let j = 0;
104
+
105
+ while (i < standardLines.length || j < customLines.length) {
106
+ const standardLine = standardLines[i];
107
+ const customLine = customLines[j];
108
+
109
+ if (i >= standardLines.length) {
110
+ result.push({ kind: "added", customLine });
111
+ j += 1;
112
+ continue;
113
+ }
114
+ if (j >= customLines.length) {
115
+ result.push({ kind: "removed", standardLine });
116
+ i += 1;
117
+ continue;
118
+ }
119
+ if (standardLine === customLine) {
120
+ result.push({ kind: "unchanged", standardLine, customLine });
121
+ i += 1;
122
+ j += 1;
123
+ continue;
124
+ }
125
+
126
+ const standardRemainder = standardLines.slice(i + 1);
127
+ const customRemainder = customLines.slice(j + 1);
128
+ const customAppearsLater = standardRemainder.includes(customLine);
129
+ const standardAppearsLater = customRemainder.includes(standardLine);
130
+
131
+ if (customAppearsLater && !standardAppearsLater) {
132
+ result.push({ kind: "removed", standardLine });
133
+ i += 1;
134
+ continue;
135
+ }
136
+ if (standardAppearsLater && !customAppearsLater) {
137
+ result.push({ kind: "added", customLine });
138
+ j += 1;
139
+ continue;
140
+ }
141
+
142
+ result.push({ kind: "changed", standardLine, customLine });
143
+ i += 1;
144
+ j += 1;
145
+ }
146
+
147
+ return result;
148
+ }
149
+
150
+ export function vendorBookingAgreementDiffHasChanges(
151
+ lines: VendorBookingAgreementDiffLine[]
152
+ ): boolean {
153
+ return lines.some((line) => line.kind !== "unchanged");
154
+ }
155
+
156
+ /** @deprecated Use STANDARD_VENDOR_BOOKING_AGREEMENT */
157
+ export const STANDARD_VENDOR_FORCE_MAJEURE_TERMS =
158
+ STANDARD_VENDOR_BOOKING_AGREEMENT;