@ancon/wildcat-utils 1.43.4 → 1.44.0-timezone-refactor.1

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 (129) hide show
  1. package/_baseIsEqual-12d01a44.mjs +169 -0
  2. package/_baseIsEqual-bcac9024.js +1 -0
  3. package/_baseIteratee-075c204c.js +1 -0
  4. package/_baseIteratee-4c4d0995.mjs +97 -0
  5. package/_baseSlice-4d543985.mjs +10 -0
  6. package/_baseSlice-e1b41ceb.js +1 -0
  7. package/_getTag-4e44633b.mjs +382 -0
  8. package/_getTag-b8923c48.js +1 -0
  9. package/card/index.d.ts +2 -0
  10. package/card/index.js +1 -1
  11. package/card/index.mjs +5 -3
  12. package/card/isWalletDebitTransaction.d.ts +2 -0
  13. package/card/isWalletDebitTransaction.js +1 -0
  14. package/card/isWalletDebitTransaction.mjs +13 -0
  15. package/checkout/getCheckoutOrderStatusTexts.js +1 -1
  16. package/checkout/getCheckoutOrderStatusTexts.mjs +7 -5
  17. package/checkout/index.js +1 -1
  18. package/checkout/index.mjs +49 -47
  19. package/checkout/isCheckoutItemsAreEqual.js +1 -1
  20. package/checkout/isCheckoutItemsAreEqual.mjs +14 -13
  21. package/date/createLocalTimezoneDate.d.ts +8 -0
  22. package/date/createLocalTimezoneDate.js +1 -0
  23. package/date/createLocalTimezoneDate.mjs +8 -0
  24. package/date/createLocalTimezoneMoment.d.ts +9 -0
  25. package/date/createLocalTimezoneMoment.js +1 -0
  26. package/date/createLocalTimezoneMoment.mjs +8 -0
  27. package/date/getFormattedUTCDateTime.d.ts +10 -0
  28. package/date/getFormattedUTCDateTime.js +1 -0
  29. package/date/getFormattedUTCDateTime.mjs +8 -0
  30. package/date/index.d.ts +4 -0
  31. package/date/index.js +1 -0
  32. package/date/index.mjs +9 -0
  33. package/identity-1bae7cf8.js +1 -0
  34. package/identity-6eafe87b.mjs +64 -0
  35. package/index.d.ts +2 -0
  36. package/index.js +1 -1
  37. package/index.mjs +96 -74
  38. package/logger/index.js +1 -1
  39. package/logger/index.mjs +8 -7
  40. package/logger/pascalCaseFormatter.js +1 -1
  41. package/logger/pascalCaseFormatter.mjs +21 -27
  42. package/order/getCheckOrderItemsMappedByTicketItemStatus.js +1 -1
  43. package/order/getCheckOrderItemsMappedByTicketItemStatus.mjs +15 -13
  44. package/order/getCheckOrderMinimumStatusTicketItem.js +1 -1
  45. package/order/getCheckOrderMinimumStatusTicketItem.mjs +19 -17
  46. package/order/index.js +1 -1
  47. package/order/index.mjs +11 -9
  48. package/outlet/getExpressAvailableOrderFormats.js +1 -1
  49. package/outlet/getExpressAvailableOrderFormats.mjs +27 -26
  50. package/outlet/getExpressNextAvailabilityShiftTime.d.ts +2 -2
  51. package/outlet/getExpressNextAvailabilityShiftTime.js +1 -1
  52. package/outlet/getExpressNextAvailabilityShiftTime.mjs +19 -18
  53. package/outlet/getExpressServiceIntervalEnd.d.ts +2 -2
  54. package/outlet/getExpressServiceIntervalEnd.js +1 -1
  55. package/outlet/getExpressServiceIntervalEnd.mjs +7 -9
  56. package/outlet/getExpressServiceIntervalStart.d.ts +2 -2
  57. package/outlet/getExpressServiceIntervalStart.js +1 -1
  58. package/outlet/getExpressServiceIntervalStart.mjs +7 -9
  59. package/outlet/getListOutletOpeningHoursTable.d.ts +1 -1
  60. package/outlet/getListOutletOpeningHoursTable.js +1 -1
  61. package/outlet/getListOutletOpeningHoursTable.mjs +135 -150
  62. package/outlet/getMomentFromDateAndTimeString.js +1 -1
  63. package/outlet/getMomentFromDateAndTimeString.mjs +1 -1
  64. package/outlet/getOutletActiveOpeningInterval.d.ts +2 -2
  65. package/outlet/getOutletActiveOpeningInterval.js +1 -1
  66. package/outlet/getOutletActiveOpeningInterval.mjs +15 -12
  67. package/outlet/getOutletAvailabilityInfo.js +1 -1
  68. package/outlet/getOutletAvailabilityInfo.mjs +23 -25
  69. package/outlet/getOutletCurrentActiveOperatingHour.js +1 -1
  70. package/outlet/getOutletCurrentActiveOperatingHour.mjs +16 -15
  71. package/outlet/getOutletCurrentAvailabilityInfo.js +1 -1
  72. package/outlet/getOutletCurrentAvailabilityInfo.mjs +27 -26
  73. package/outlet/getOutletCurrentClosingTimeText.js +1 -1
  74. package/outlet/getOutletCurrentClosingTimeText.mjs +14 -10
  75. package/outlet/getOutletDeliveryFee.js +1 -1
  76. package/outlet/getOutletDeliveryFee.mjs +5 -5
  77. package/outlet/getOutletFormattedAddress.d.ts +9 -1
  78. package/outlet/getOutletFormattedAddress.js +1 -1
  79. package/outlet/getOutletFormattedAddress.mjs +9 -4
  80. package/outlet/getOutletNextOpeningTagInformation.js +1 -1
  81. package/outlet/getOutletNextOpeningTagInformation.mjs +8 -7
  82. package/outlet/getOutletNextOpeningTimeText.js +1 -1
  83. package/outlet/getOutletNextOpeningTimeText.mjs +10 -8
  84. package/outlet/getOutletNextReadyToOrderTime.js +1 -1
  85. package/outlet/getOutletNextReadyToOrderTime.mjs +11 -11
  86. package/outlet/getOutletPickerTimesForDay.js +1 -1
  87. package/outlet/getOutletPickerTimesForDay.mjs +33 -34
  88. package/outlet/getOutletPickerTimesForWeek.js +1 -1
  89. package/outlet/getOutletPickerTimesForWeek.mjs +4 -3
  90. package/outlet/getOutletTagInformation.d.ts +1 -1
  91. package/outlet/getOutletTagInformation.js +1 -1
  92. package/outlet/getOutletTagInformation.mjs +69 -70
  93. package/outlet/getOutletTodayOpeningTimes.js +1 -1
  94. package/outlet/getOutletTodayOpeningTimes.mjs +43 -39
  95. package/outlet/getPartitionedOutletsList.js +1 -1
  96. package/outlet/getPartitionedOutletsList.mjs +4 -4
  97. package/outlet/getPickerIntervalsForDay.js +1 -1
  98. package/outlet/getPickerIntervalsForDay.mjs +20 -12
  99. package/outlet/getServiceIntervalEnd.d.ts +1 -1
  100. package/outlet/getServiceIntervalEnd.js +1 -1
  101. package/outlet/getServiceIntervalEnd.mjs +12 -10
  102. package/outlet/getServiceIntervalRange.d.ts +1 -2
  103. package/outlet/getServiceIntervalRange.js +1 -1
  104. package/outlet/getServiceIntervalRange.mjs +8 -12
  105. package/outlet/getServiceIntervalStart.d.ts +1 -1
  106. package/outlet/getServiceIntervalStart.js +1 -1
  107. package/outlet/getServiceIntervalStart.mjs +6 -7
  108. package/outlet/getServiceIntervalsForOrderFormat.d.ts +7 -8
  109. package/outlet/getStructuredOutletAddress.js +1 -1
  110. package/outlet/getStructuredOutletAddress.mjs +7 -7
  111. package/outlet/index.js +1 -1
  112. package/outlet/index.mjs +73 -68
  113. package/outlet/searchNextOpeningMoment.d.ts +1 -1
  114. package/outlet/searchNextOpeningMoment.js +1 -1
  115. package/outlet/searchNextOpeningMoment.mjs +49 -56
  116. package/outlet/serviceDateTimesFromOpeningHours.d.ts +3 -5
  117. package/outlet/serviceDateTimesFromOpeningHours.js +1 -1
  118. package/outlet/serviceDateTimesFromOpeningHours.mjs +342 -27
  119. package/outlet/types.d.ts +0 -2
  120. package/package.json +26 -1
  121. package/time/getEndTimeSpanOfTimePeriod.js +1 -1
  122. package/time/getEndTimeSpanOfTimePeriod.mjs +5 -9
  123. package/{toString-e631a957.mjs → toString-3b91b335.mjs} +12 -11
  124. package/toString-9eae9442.js +1 -0
  125. package/_baseIsEqual-39cef2eb.mjs +0 -530
  126. package/_baseIsEqual-b3df9240.js +0 -1
  127. package/_baseIteratee-13e892b8.mjs +0 -151
  128. package/_baseIteratee-be26bb18.js +0 -1
  129. package/toString-425512fc.js +0 -1
@@ -1,203 +1,188 @@
1
- import S from "moment";
2
- import { OrderFormat as y, DayOfWeek as l, IntervalType as c, IntervalState as g } from "@ancon/wildcat-types";
3
- import h from "../shared/isWithinFlag.mjs";
4
- import F from "../shared/generateId.mjs";
1
+ import W from "moment";
2
+ import { OrderFormat as p, DayOfWeek as f, IntervalType as l, IntervalState as F } from "@ancon/wildcat-types";
3
+ import H from "../shared/isWithinFlag.mjs";
4
+ import I from "../shared/generateId.mjs";
5
5
  import "react";
6
+ import T from "../time/getTimeSpanParts.mjs";
7
+ import M from "../date/createLocalTimezoneMoment.mjs";
6
8
  const k = [
7
- { id: y.EatIn, name: "eatIn" },
8
- { id: y.TakeAway, name: "takeaway" },
9
- { id: y.TableOrder, name: "tableOrder" },
10
- { id: y.Delivery, name: "delivery" },
11
- { id: y.BoxPickup, name: "boxPickup" }
9
+ { id: p.EatIn, name: "eatIn" },
10
+ { id: p.TakeAway, name: "takeaway" },
11
+ { id: p.TableOrder, name: "tableOrder" },
12
+ { id: p.Delivery, name: "delivery" },
13
+ { id: p.BoxPickup, name: "boxPickup" }
12
14
  ];
13
- function v(e) {
14
- const o = S.utc(e).subtract(1, "day").startOf("day"), t = [];
15
- for (let n = 0, s = o; n < 7; n += 1)
16
- s = s.clone().add(1, "day").startOf("day"), t.push(s.clone());
17
- return t;
15
+ function h(r) {
16
+ const s = W(r).subtract(1, "day").startOf("day"), e = [];
17
+ for (let n = 0, t = s; n < 7; n += 1)
18
+ t = t.clone().add(1, "day").startOf("day"), e.push(t.clone());
19
+ return e;
18
20
  }
19
- function T(e) {
20
- return [...e].sort((o, t) => o.isoWeekday() - t.isoWeekday());
21
+ function Y(r) {
22
+ return [...r].sort((s, e) => s.isoWeekday() - e.isoWeekday());
21
23
  }
22
- function W(e) {
23
- return e.split(":").map(Number);
24
- }
25
- function x(e, o, t) {
26
- const [n, s] = W(e.start), [m, u] = W(
27
- e.duration
28
- ), [r, p] = W(t || "00:00:00");
29
- if (e.type === c.Interval) {
30
- let a = o.clone().add(n, "hour").add(s, "minute");
31
- const d = a.clone().add(r, "hour").add(p, "minute").date() - o.date();
32
- d !== 0 && (a = a.subtract(d, "day"));
33
- const f = a.clone().add(m, "hour").add(u, "minute");
24
+ function x(r, s) {
25
+ const e = T(r.from), n = T(r.duration);
26
+ if (r.type === l.Normal) {
27
+ let t = s.clone().add(e.hours, "hour").add(e.minutes, "minute");
28
+ const i = t.date() - s.date();
29
+ i !== 0 && (t = t.subtract(i, "day"));
30
+ const o = t.clone().add(n);
34
31
  return {
35
- id: e.id,
36
- start: a.toISOString(),
37
- end: f.toISOString()
32
+ id: r.id,
33
+ start: t.format("YYYY-MM-DDTHH:mm:ss"),
34
+ end: o.format("YYYY-MM-DDTHH:mm:ss")
38
35
  };
39
36
  }
40
- if (e.type === c.Exception) {
41
- const a = S(e.fromDate), i = S(e.toDate);
42
- if (o.isBetween(a, i, void 0, "[]")) {
43
- const d = o.clone().add(n, "hour").add(s, "minute"), f = d.clone().add(m, "hour").add(u, "minute");
37
+ if (r.type === l.Exception) {
38
+ const t = M(r.periodFrom), i = M(r.periodTo);
39
+ if (s.isBetween(t, i, void 0, "[]")) {
40
+ const o = s.clone().add(e.hours, "hour").add(e.minutes, "minute"), a = o.clone().add(n);
44
41
  return {
45
- id: e.id,
46
- start: d.toISOString(),
47
- end: f.toISOString(),
48
- reason: e.reason
42
+ id: r.id,
43
+ start: o.format("YYYY-MM-DDTHH:mm:ss"),
44
+ end: a.format("YYYY-MM-DDTHH:mm:ss"),
45
+ reason: r.reason
49
46
  };
50
47
  }
51
48
  return null;
52
49
  }
53
50
  throw new Error("Invalid interval type");
54
51
  }
55
- function M(e, o, t, n) {
56
- const s = {
57
- [l.Monday]: 1,
58
- [l.Tuesday]: 2,
59
- [l.Wednesday]: 3,
60
- [l.Thursday]: 4,
61
- [l.Friday]: 5,
62
- [l.Saturday]: 6,
63
- [l.Sunday]: 7,
64
- [l.Everyday]: null
52
+ function D(r, s, e) {
53
+ const n = {
54
+ [f.Monday]: 1,
55
+ [f.Tuesday]: 2,
56
+ [f.Wednesday]: 3,
57
+ [f.Thursday]: 4,
58
+ [f.Friday]: 5,
59
+ [f.Saturday]: 6,
60
+ [f.Sunday]: 7,
61
+ [f.Everyday]: null
65
62
  };
66
- for (let m = 0; m < o.length; m += 1) {
67
- const u = o[m], r = u.isoWeekday(), p = e.dayOfWeek, i = (s[p] ?? null) === r || p === l.Everyday;
68
- if (t[r] || (t[r] = {
69
- isoWeekday: r,
63
+ for (let t = 0; t < s.length; t += 1) {
64
+ const i = s[t], o = i.isoWeekday(), a = r.dayOfWeek, m = (n[a] ?? null) === o || a === f.Everyday;
65
+ if (e[o] || (e[o] = {
66
+ isoWeekday: o,
70
67
  key: "",
71
68
  open: [],
72
69
  adjusted: [],
73
70
  closed: []
74
- }), i) {
75
- const d = x(
76
- e,
77
- u,
78
- n
79
- );
80
- d && (t[r].key += d.id, e.type === c.Interval && e.state === g.Open ? t[r].open.push(d) : e.type === c.Interval && e.state === g.Closed ? t[r].closed.push(d) : e.type === c.Exception && e.state === g.Open ? t[r].adjusted.push(d) : e.type === c.Exception && e.state === g.Closed && t[r].closed.push(d));
71
+ }), m) {
72
+ const d = x(r, i);
73
+ d && (e[o].key += d.id, r.type === l.Normal && r.state === F.Opened ? e[o].open.push(d) : r.type === l.Normal && r.state === F.Closed ? e[o].closed.push(d) : r.type === l.Exception && r.state === F.Opened ? e[o].adjusted.push(d) : r.type === l.Exception && r.state === F.Closed && e[o].closed.push(d));
81
74
  }
82
75
  }
83
76
  }
84
- function H(e) {
85
- switch (e.type) {
86
- case c.Exception:
87
- return F("interval-exception");
88
- case c.Interval:
89
- return F("interval-normal");
77
+ function v(r) {
78
+ switch (r.type) {
79
+ case l.Exception:
80
+ return I("interval-exception");
81
+ case l.Normal:
82
+ return I("interval-normal");
90
83
  default:
91
- return F("interval-unknown");
84
+ return I("interval-unknown");
92
85
  }
93
86
  }
94
- function E(e) {
95
- const o = e.reduce(
96
- (t, n) => (k.forEach((s) => {
97
- h(s.id, n.orderFormats) && (t[s.id] || (t[s.id] = {
98
- orderFormat: s,
99
- intervals: []
100
- }), t[s.id].intervals.push(
101
- ...n.intervals.sort(
102
- (m, u) => m.dayOfWeek - u.dayOfWeek
103
- )
104
- ));
105
- }), t),
106
- {}
107
- );
108
- return Object.values(o);
87
+ function E(r) {
88
+ const s = r.reduce((e, n) => (k.forEach((t) => {
89
+ H(t.id, n.orderFormats) && (e[t.id] || (e[t.id] = {
90
+ orderFormat: t,
91
+ intervals: []
92
+ }), e[t.id].intervals.push(
93
+ ...n.intervals.sort(
94
+ (i, o) => i.dayOfWeek - o.dayOfWeek
95
+ )
96
+ ));
97
+ }), e), {});
98
+ return Object.values(s);
109
99
  }
110
- function b(e, o) {
111
- const t = o.reduce((n, s) => s <= e ? n + 1 : n, 0);
112
- return e - t;
100
+ function S(r, s) {
101
+ const e = s.reduce((n, t) => t <= r ? n + 1 : n, 0);
102
+ return r - e;
113
103
  }
114
- function D(e) {
115
- const { mergedTables: o } = e.reduce(
116
- (t, n, s) => {
117
- const m = t.mergedTables.findIndex(
118
- (u) => u !== n && !u.orderFormats.some(
119
- (r) => n.orderFormats.some(
120
- (p) => p.id === r.id
104
+ function j(r) {
105
+ const { mergedTables: s } = r.reduce(
106
+ (e, n, t) => {
107
+ const i = e.mergedTables.findIndex(
108
+ (o) => o !== n && !o.orderFormats.some(
109
+ (a) => n.orderFormats.some(
110
+ (u) => u.id === a.id
121
111
  )
122
- ) && u.openingHours.every(
123
- (r) => n.openingHours.some((p) => p.key === r.key)
112
+ ) && o.openingHours.every(
113
+ (a) => n.openingHours.some((u) => u.key === a.key)
124
114
  ) && n.openingHours.every(
125
- (r) => u.openingHours.some((p) => p.key === r.key)
115
+ (a) => o.openingHours.some((u) => u.key === a.key)
126
116
  )
127
117
  );
128
- if (m >= 0) {
129
- if (t.skipOrderFormats.some(
130
- (i) => n.orderFormats.every((d) => d.id === i.id)
118
+ if (i >= 0) {
119
+ if (e.skipOrderFormats.some(
120
+ (d) => n.orderFormats.every((y) => y.id === d.id)
131
121
  ))
132
- return t;
133
- const r = t.mergedTables[m];
134
- t.mergedTables.splice(m, 1, {
135
- ...r,
136
- orderFormats: [...n.orderFormats, ...r.orderFormats]
122
+ return e;
123
+ const a = e.mergedTables[i];
124
+ e.mergedTables.splice(i, 1, {
125
+ ...a,
126
+ orderFormats: [...n.orderFormats, ...a.orderFormats]
137
127
  });
138
- const p = r.orderFormats.filter(
139
- (i) => !t.skipOrderFormats.some((d) => d.id === i.id)
128
+ const u = a.orderFormats.filter(
129
+ (d) => !e.skipOrderFormats.some((y) => y.id === d.id)
140
130
  );
141
- p.length > 0 && t.skipOrderFormats.push(...p);
142
- const a = b(s, [...t.removedIndexes]);
143
- return t.mergedTables.splice(a, 1), t.removedIndexes.push(s), t;
131
+ u.length > 0 && e.skipOrderFormats.push(...u);
132
+ const m = S(t, [...e.removedIndexes]);
133
+ return e.mergedTables.splice(m, 1), e.removedIndexes.push(t), e;
144
134
  }
145
- return t;
135
+ return e;
146
136
  },
147
- { mergedTables: [...e], removedIndexes: [], skipOrderFormats: [] }
137
+ { mergedTables: [...r], removedIndexes: [], skipOrderFormats: [] }
148
138
  );
149
- return o;
139
+ return s;
150
140
  }
151
- function j(e) {
152
- return e.map((o) => ({
153
- ...o,
154
- intervals: o.intervals.map((t) => ({
155
- ...t,
156
- id: H(t)
141
+ function w(r) {
142
+ return r.map((s) => ({
143
+ ...s,
144
+ intervals: s.intervals.map((e) => ({
145
+ ...e,
146
+ id: v(e)
157
147
  }))
158
148
  }));
159
149
  }
160
- function R(e, o) {
161
- const t = E(
162
- j(e.serviceDateTimes)
163
- ), n = v(o), s = T(n), m = t.reduce(
164
- (a, i) => (a[i.orderFormat.id] || (a[i.orderFormat.id] = {}), i.intervals.reduce((d, f) => (M(
165
- f,
166
- s,
167
- d,
168
- e.timeZoneOffset
169
- ), d), a[i.orderFormat.id]), a),
150
+ function L(r, s) {
151
+ const e = E(
152
+ w(r.serviceDateTimes)
153
+ ), n = h(s), t = Y(n), i = e.reduce(
154
+ (m, d) => (m[d.orderFormat.id] || (m[d.orderFormat.id] = {}), d.intervals.reduce((y, c) => (D(c, t, y), y), m[d.orderFormat.id]), m),
170
155
  {}
171
- ), u = {
172
- [y.EatIn]: k[0],
173
- [y.TakeAway]: k[1],
174
- [y.TableOrder]: k[2],
175
- [y.Delivery]: k[3],
176
- [y.BoxPickup]: k[4]
177
- }, r = Object.entries(
178
- m
179
- ).map(([a, i]) => ({
180
- orderFormats: [u[Number(a)]],
181
- openingHours: Object.entries(i).map(
182
- ([d, f]) => ({
183
- isoWeekday: Number(d),
184
- key: f.key,
185
- open: f.open.sort(
186
- (O, I) => O.start.localeCompare(I.start)
156
+ ), o = {
157
+ [p.EatIn]: k[0],
158
+ [p.TakeAway]: k[1],
159
+ [p.TableOrder]: k[2],
160
+ [p.Delivery]: k[3],
161
+ [p.BoxPickup]: k[4]
162
+ }, a = Object.entries(
163
+ i
164
+ ).map(([m, d]) => ({
165
+ orderFormats: [o[Number(m)]],
166
+ openingHours: Object.entries(d).map(
167
+ ([y, c]) => ({
168
+ isoWeekday: Number(y),
169
+ key: c.key,
170
+ open: c.open.sort(
171
+ (g, O) => g.start.localeCompare(O.start)
187
172
  ),
188
- adjusted: f.adjusted.sort(
189
- (O, I) => O.start.localeCompare(I.start)
173
+ adjusted: c.adjusted.sort(
174
+ (g, O) => g.start.localeCompare(O.start)
190
175
  ),
191
- closed: f.closed.sort(
192
- (O, I) => O.start.localeCompare(I.start)
176
+ closed: c.closed.sort(
177
+ (g, O) => g.start.localeCompare(O.start)
193
178
  )
194
179
  })
195
180
  )
196
181
  }));
197
- return D(r).sort(
198
- (a, i) => a.orderFormats[0].id - i.orderFormats[0].id
182
+ return j(a).sort(
183
+ (m, d) => m.orderFormats[0].id - d.orderFormats[0].id
199
184
  );
200
185
  }
201
186
  export {
202
- R as default
187
+ L as default
203
188
  };
@@ -1 +1 @@
1
- "use strict";const u=require("moment");function m(t){const[e,r,n]=t.split(":");return u().utc(!1).startOf("day").set({hour:Number(e),minute:Number(r),second:Number(n),millisecond:0})}function s(t,e){const[r,n,o]=t.split("-");return m(e).year(Number(r)).month(Number(n)-1).date(Number(o))}module.exports=s;
1
+ "use strict";const m=require("moment");function u(t){const[e,r,n]=t.split(":");return m().startOf("day").set({hour:Number(e),minute:Number(r),second:Number(n),millisecond:0})}function i(t,e){const[r,n,o]=t.split("-");return u(e).year(Number(r)).month(Number(n)-1).date(Number(o))}module.exports=i;
@@ -1,7 +1,7 @@
1
1
  import o from "moment";
2
2
  function u(t) {
3
3
  const [e, r, n] = t.split(":");
4
- return o().utc(!1).startOf("day").set({
4
+ return o().startOf("day").set({
5
5
  hour: Number(e),
6
6
  minute: Number(r),
7
7
  second: Number(n),
@@ -1,4 +1,4 @@
1
- import { OpeningHours, OrderFormat } from '@ancon/wildcat-types';
1
+ import { OpeningHoursInterval, OrderFormat } from '@ancon/wildcat-types';
2
2
  import { Moment } from 'moment';
3
3
  /**
4
4
  * Get the active opening interval for the given outlet opening hours, date and order format
@@ -8,4 +8,4 @@ import { Moment } from 'moment';
8
8
  * @param orderFormat - The order format to check
9
9
  * @returns The active opening interval or undefined if no interval is active for the given date and order format
10
10
  */
11
- export default function getOutletActiveOpeningInterval(date: Moment, openingHours: OpeningHours[], orderFormat: OrderFormat): OpeningHours | undefined;
11
+ export default function getOutletActiveOpeningInterval(date: Moment, openingHours: OpeningHoursInterval[], orderFormat: OrderFormat): OpeningHoursInterval | undefined;
@@ -1 +1 @@
1
- "use strict";const n=require("@ancon/wildcat-types"),p=require("moment"),l=require("../shared/constants.js");function y(r,c,i){const a=c.reduce((t,e)=>{if((e.orderFormat&i)===i)switch(e.type){case n.IntervalType.Exception:{const s=p(e.periodFrom),f=p(e.periodTo);r.isBetween(s,f,"day","[]")&&(e.state===n.IntervalState.Closed?t.closedExceptions.push(e):t.openExceptions.push(e))}break;case n.IntervalType.Interval:default:(e.dayOfWeek===n.DayOfWeek.Everyday||e.dayOfWeek===l.DaysOfWeekMap[r.isoWeekday()])&&t.openIntervals.push(e);break}return t},{closedExceptions:[],openExceptions:[],openIntervals:[]}),{closedExceptions:d,openExceptions:o,openIntervals:u}=a;if(!d.length){if(o.length){if(o.length>1){const[t]=o.sort((e,s)=>e.position-s.position);return t}return o[0]}return u[0]}}module.exports=y;
1
+ "use strict";const n=require("@ancon/wildcat-types"),f=require("../shared/constants.js"),p=require("../date/createLocalTimezoneMoment.js");require("moment");function y(r,c,i){const a=c.reduce((t,e)=>{if((e.orderFormat&i)===i)switch(e.type){case n.IntervalType.Exception:{const s=p(e.periodFrom),l=p(e.periodTo);r.isBetween(s,l,"day","[]")&&(e.state===n.IntervalState.Closed?t.closedExceptions.push(e):t.openExceptions.push(e))}break;case n.IntervalType.Normal:default:(e.dayOfWeek===n.DayOfWeek.Everyday||e.dayOfWeek===f.DaysOfWeekMap[r.isoWeekday()])&&t.openIntervals.push(e);break}return t},{closedExceptions:[],openExceptions:[],openIntervals:[]}),{closedExceptions:d,openExceptions:o,openIntervals:u}=a;if(!d.length){if(o.length){if(o.length>1){const[t]=o.sort((e,s)=>e.position-s.position);return t}return o[0]}return u[0]}}module.exports=y;
@@ -1,21 +1,24 @@
1
- import { DayOfWeek as l, IntervalType as r, IntervalState as m } from "@ancon/wildcat-types";
2
- import i from "moment";
1
+ import { DayOfWeek as u, IntervalType as r, IntervalState as m } from "@ancon/wildcat-types";
3
2
  import { DaysOfWeekMap as y } from "../shared/constants.mjs";
4
- function k(s, f, p) {
5
- const c = f.reduce(
3
+ import i from "../date/createLocalTimezoneMoment.mjs";
4
+ import "moment";
5
+ function O(s, c, p) {
6
+ const f = c.reduce(
6
7
  (o, e) => {
7
8
  if ((e.orderFormat & p) === p)
8
9
  switch (e.type) {
9
10
  case r.Exception:
10
11
  {
11
- const n = i(e.periodFrom), u = i(e.periodTo);
12
- s.isBetween(n, u, "day", "[]") && (e.state === m.Closed ? o.closedExceptions.push(e) : o.openExceptions.push(e));
12
+ const n = i(
13
+ e.periodFrom
14
+ ), l = i(e.periodTo);
15
+ s.isBetween(n, l, "day", "[]") && (e.state === m.Closed ? o.closedExceptions.push(e) : o.openExceptions.push(e));
13
16
  }
14
17
  break;
15
- case r.Interval:
18
+ case r.Normal:
16
19
  default:
17
20
  // Every day in the week
18
- (e.dayOfWeek === l.Everyday || // Specific day in the week
21
+ (e.dayOfWeek === u.Everyday || // Specific day in the week
19
22
  e.dayOfWeek === y[s.isoWeekday()]) && o.openIntervals.push(e);
20
23
  break;
21
24
  }
@@ -26,8 +29,8 @@ function k(s, f, p) {
26
29
  openExceptions: [],
27
30
  openIntervals: []
28
31
  }
29
- ), { closedExceptions: d, openExceptions: t, openIntervals: a } = c;
30
- if (!d.length) {
32
+ ), { closedExceptions: a, openExceptions: t, openIntervals: d } = f;
33
+ if (!a.length) {
31
34
  if (t.length) {
32
35
  if (t.length > 1) {
33
36
  const [o] = t.sort(
@@ -37,9 +40,9 @@ function k(s, f, p) {
37
40
  }
38
41
  return t[0];
39
42
  }
40
- return a[0];
43
+ return d[0];
41
44
  }
42
45
  }
43
46
  export {
44
- k as default
47
+ O as default
45
48
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("moment"),l=require("@ancon/wildcat-types"),r=60;var c=(e=>(e[e.Today=0]="Today",e[e.Tomorrow=1]="Tomorrow",e))(c||{});function o(e,t,d=!1){let s=null;if(e.openNow&&e.closingTime!==null)(e.closingTime.diff(t,"minutes")<r||d)&&(s={time:e.closingTime.utcOffset(t.utcOffset()).format("LT"),state:l.OutletState.Closed});else if(!e.openNow&&e.openingTime)if(e.openingTime.isSame(t,"d"))s={time:f(e.openingTime).utcOffset(t.utcOffset()).calendar(),state:l.OutletState.Open};else{const u=f().add(1,"day").utcOffset(t.utcOffset()),i=f(e.openingTime).utcOffset(t.utcOffset());i.isSame(u,"d")?s={time:i.format("LT"),state:l.OutletState.Open,day:1}:i.isAfter(t.clone().add(1,"week"))?s={time:i.format("D MMMM LT"),state:l.OutletState.Open}:i&&(s={time:i.format("ddd LT"),state:l.OutletState.Open})}return s}exports.OutletAvailabilityDay=c;exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("moment"),s=require("@ancon/wildcat-types"),m=60;var u=(e=>(e[e.Today=0]="Today",e[e.Tomorrow=1]="Tomorrow",e))(u||{});function n(e,l,r=!1){let t=null;if(e.openNow&&e.closingTime!==null)(e.closingTime.diff(l,"minutes")<m||r)&&(t={time:e.closingTime.format("LT"),state:s.OutletState.Closed});else if(!e.openNow&&e.openingTime)if(e.openingTime.isSame(l,"d"))t={time:o(e.openingTime).calendar(),state:s.OutletState.Opened};else{const d=o().add(1,"day"),i=o(e.openingTime);i.isSame(d,"d")?t={time:i.format("LT"),state:s.OutletState.Opened,day:1}:i.isAfter(l.clone().add(1,"week"))?t={time:i.format("D MMMM LT"),state:s.OutletState.Opened}:i&&(t={time:i.format("ddd LT"),state:s.OutletState.Opened})}return t}exports.OutletAvailabilityDay=u;exports.default=n;
@@ -1,40 +1,38 @@
1
- import d from "moment";
2
- import { OutletState as i } from "@ancon/wildcat-types";
3
- const l = 60;
4
- var o = /* @__PURE__ */ ((e) => (e[e.Today = 0] = "Today", e[e.Tomorrow = 1] = "Tomorrow", e))(o || {});
5
- function T(e, t, m = !1) {
1
+ import m from "moment";
2
+ import { OutletState as t } from "@ancon/wildcat-types";
3
+ const r = 60;
4
+ var T = /* @__PURE__ */ ((e) => (e[e.Today = 0] = "Today", e[e.Tomorrow = 1] = "Tomorrow", e))(T || {});
5
+ function p(e, o, l = !1) {
6
6
  let s = null;
7
7
  if (e.openNow && e.closingTime !== null)
8
- (e.closingTime.diff(t, "minutes") < l || m) && (s = {
9
- time: e.closingTime.utcOffset(t.utcOffset()).format("LT"),
10
- state: i.Closed
8
+ (e.closingTime.diff(o, "minutes") < r || l) && (s = {
9
+ time: e.closingTime.format("LT"),
10
+ state: t.Closed
11
11
  });
12
12
  else if (!e.openNow && e.openingTime)
13
- if (e.openingTime.isSame(t, "d"))
13
+ if (e.openingTime.isSame(o, "d"))
14
14
  s = {
15
- time: d(e.openingTime).utcOffset(t.utcOffset()).calendar(),
16
- state: i.Open
15
+ time: m(e.openingTime).calendar(),
16
+ state: t.Opened
17
17
  };
18
18
  else {
19
- const c = d().add(1, "day").utcOffset(t.utcOffset()), f = d(e.openingTime).utcOffset(
20
- t.utcOffset()
21
- );
22
- f.isSame(c, "d") ? s = {
23
- time: f.format("LT"),
24
- state: i.Open,
19
+ const d = m().add(1, "day"), i = m(e.openingTime);
20
+ i.isSame(d, "d") ? s = {
21
+ time: i.format("LT"),
22
+ state: t.Opened,
25
23
  day: 1
26
24
  /* Tomorrow */
27
- } : f.isAfter(t.clone().add(1, "week")) ? s = {
28
- time: f.format("D MMMM LT"),
29
- state: i.Open
30
- } : f && (s = {
31
- time: f.format("ddd LT"),
32
- state: i.Open
25
+ } : i.isAfter(o.clone().add(1, "week")) ? s = {
26
+ time: i.format("D MMMM LT"),
27
+ state: t.Opened
28
+ } : i && (s = {
29
+ time: i.format("ddd LT"),
30
+ state: t.Opened
33
31
  });
34
32
  }
35
33
  return s;
36
34
  }
37
35
  export {
38
- o as OutletAvailabilityDay,
39
- T as default
36
+ T as OutletAvailabilityDay,
37
+ p as default
40
38
  };
@@ -1 +1 @@
1
- "use strict";const a=require("@ancon/wildcat-types"),u=require("./getMomentFromDateAndTimeString.js");require("moment");function m(s,e,l){if(e.exception){const{exception:t}=e;if(t.type===a.IntervalType.Interval){const[n,o]=t.duration.split(":").map(Number),i=u(s,t.start),r=i.clone().add(n,"hours").add(o,"minutes");if(l.isBetween(i,r))return e.exception}}else for(let t=0;t<e.intervals.length;t+=1){const n=e.intervals[t],[o,i]=n.duration.split(":").map(Number),r=u(s,n.start),c=r.clone().add(o,"hours").add(i,"minutes");if(l.isBetween(r,c))return n}return null}module.exports=m;
1
+ "use strict";const a=require("@ancon/wildcat-types"),l=require("../time/getTimeSpanParts.js"),s=require("./getMomentFromDateAndTimeString.js");require("moment");function f(r,e,c){if(e.exception){const{exception:t}=e;if(t.type===a.IntervalType.Normal){const n=l(t.duration),i=s(r,t.from),o=i.clone().add(n);if(c.isBetween(i,o))return e.exception}}else for(let t=0;t<e.intervals.length;t+=1){const n=e.intervals[t],i=l(n.duration),o=s(r,n.from),u=o.clone().add(i);if(c.isBetween(o,u))return n}return null}module.exports=f;
@@ -1,28 +1,29 @@
1
- import { IntervalType as m } from "@ancon/wildcat-types";
2
- import u from "./getMomentFromDateAndTimeString.mjs";
1
+ import { IntervalType as f } from "@ancon/wildcat-types";
2
+ import c from "../time/getTimeSpanParts.mjs";
3
+ import m from "./getMomentFromDateAndTimeString.mjs";
3
4
  import "moment";
4
- function d(s, n, l) {
5
+ function g(r, n, l) {
5
6
  if (n.exception) {
6
7
  const { exception: t } = n;
7
- if (t.type === m.Interval) {
8
- const [e, r] = t.duration.split(":").map(Number), i = u(
9
- s,
10
- t.start
11
- ), o = i.clone().add(e, "hours").add(r, "minutes");
12
- if (l.isBetween(i, o))
8
+ if (t.type === f.Normal) {
9
+ const e = c(t.duration), o = m(
10
+ r,
11
+ t.from
12
+ ), i = o.clone().add(e);
13
+ if (l.isBetween(o, i))
13
14
  return n.exception;
14
15
  }
15
16
  } else
16
17
  for (let t = 0; t < n.intervals.length; t += 1) {
17
- const e = n.intervals[t], [r, i] = e.duration.split(":").map(Number), o = u(
18
- s,
19
- e.start
20
- ), c = o.clone().add(r, "hours").add(i, "minutes");
21
- if (l.isBetween(o, c))
18
+ const e = n.intervals[t], o = c(e.duration), i = m(
19
+ r,
20
+ e.from
21
+ ), s = i.clone().add(o);
22
+ if (l.isBetween(i, s))
22
23
  return e;
23
24
  }
24
25
  return null;
25
26
  }
26
27
  export {
27
- d as default
28
+ g as default
28
29
  };
@@ -1 +1 @@
1
- "use strict";const T=require("@ancon/wildcat-types"),p=require("moment"),u=require("./getOutletTagInformation.js"),a=require("./getOutletAvailabilityInfo.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getMomentFromDateAndTimeString.js");require("./searchNextOpeningMoment.js");function d(o,e){let{openingTime:i}=o,{closingTime:n}=o;return!!e.openingTime&&!!e.closingTime?(o.openingTime?o.openingTime.isBetween(e.openingTime,e.closingTime)&&(i=e.openingTime):i=e.openingTime,o.closingTime?o.closingTime.isBetween(e.openingTime,e.closingTime)&&(n=e.closingTime):n=e.closingTime):((!i&&e.openingTime||e.openingTime&&i&&e.openingTime.isBefore(i))&&(i=e.openingTime),!n&&e.closingTime?n=e.closingTime:e.closingTime&&n&&(e.closingTime.isBefore(n)||(n=e.closingTime))),{openingTime:i,closingTime:n}}function c(o){const{serviceDateTimes:e,state:i,timeZoneOffset:n}=o,l=p(),t=i===T.OutletState.Open,m=e.reduce((s,g)=>{const f=(g==null?void 0:g.intervals)||[],r=u.default(f,t,l,l,n);return s?s.openNow&&!r.openNow?s:{...d(s,r),openNow:s.openNow||r.openNow,openDuringSpecifiedTime:s.openDuringSpecifiedTime||r.openDuringSpecifiedTime}:r},void 0);return m?a.default(m,l,!1):null}module.exports=c;
1
+ "use strict";const f=require("@ancon/wildcat-types"),T=require("moment"),u=require("./getOutletTagInformation.js"),p=require("./getOutletAvailabilityInfo.js");require("../date/createLocalTimezoneMoment.js");require("../time/getTimeSpanParts.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getMomentFromDateAndTimeString.js");require("./searchNextOpeningMoment.js");function a(o,e){let{openingTime:n}=o,{closingTime:i}=o;return!!e.openingTime&&!!e.closingTime?(o.openingTime?o.openingTime.isBetween(e.openingTime,e.closingTime)&&(n=e.openingTime):n=e.openingTime,o.closingTime?o.closingTime.isBetween(e.openingTime,e.closingTime)&&(i=e.closingTime):i=e.closingTime):((!n&&e.openingTime||e.openingTime&&n&&e.openingTime.isBefore(n))&&(n=e.openingTime),!i&&e.closingTime?i=e.closingTime:e.closingTime&&i&&(e.closingTime.isBefore(i)||(i=e.closingTime))),{openingTime:n,closingTime:i}}function d(o){const{serviceDateTimes:e,state:n}=o,i=T(),g=n===f.OutletState.Opened,r=e.reduce((s,l)=>{const m=(l==null?void 0:l.intervals)||[],t=u.default(m,g,i,i);return s?s.openNow&&!t.openNow?s:{...a(s,t),openNow:s.openNow||t.openNow,openDuringSpecifiedTime:s.openDuringSpecifiedTime||t.openDuringSpecifiedTime}:t},void 0);return r?p.default(r,i,!1):null}module.exports=d;