atriusmaps-node-sdk 3.3.1166 → 3.3.1168

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "3.3.1166";
5
+ var version = "3.3.1168";
6
6
  var pkg = {
7
7
  version: version};
8
8
 
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var luxon = require('luxon');
3
4
  var operationHours = require('../../../src/utils/operationHours.js');
4
5
  var constants = require('../../../utils/constants.js');
5
6
 
6
- const SOON_THRESHOLD_MINUTES = 60;
7
7
  function computeIsOpenNow(poi, venueTimezone, now = /* @__PURE__ */ new Date()) {
8
8
  if (poi.state === "permanently-closed") {
9
9
  return false;
@@ -26,7 +26,7 @@ function computeIsOpenNow(poi, venueTimezone, now = /* @__PURE__ */ new Date())
26
26
  if (!weekdayPeriods || weekdayPeriods.length === 0) {
27
27
  return void 0;
28
28
  }
29
- return operationHours.isOpen(weekdayPeriods, localizedNow);
29
+ return operationHours.isOpen(weekdayPeriods, luxon.DateTime.fromJSDate(now, { zone: venueTimezone }));
30
30
  }
31
31
  function computePoiOpenStatus(poi, venueTimezone, T, now = /* @__PURE__ */ new Date()) {
32
32
  const openNow = computeIsOpenNow(poi, venueTimezone, now);
@@ -57,14 +57,17 @@ function resolveStatus(poi, venueTimezone, openNow, now) {
57
57
  if (!weekdayPeriods || weekdayPeriods.length === 0) {
58
58
  return plainStatus;
59
59
  }
60
- const { minutesToOpen, minutesToClose } = operationHours.getBoundaryMinutes(weekdayPeriods, localizedNow);
60
+ const { minutesToOpen, minutesToClose } = operationHours.getBoundaryMinutes(
61
+ weekdayPeriods,
62
+ luxon.DateTime.fromJSDate(now, { zone: venueTimezone })
63
+ );
61
64
  if (openNow) {
62
65
  return isWithinThreshold(minutesToClose) ? constants.PoiOpenStatus.CLOSING_SOON : constants.PoiOpenStatus.OPEN;
63
66
  }
64
67
  return isWithinThreshold(minutesToOpen) ? constants.PoiOpenStatus.OPENING_SOON : constants.PoiOpenStatus.CLOSED;
65
68
  }
66
69
  function isWithinThreshold(minutes) {
67
- return minutes !== void 0 && minutes > 0 && minutes <= SOON_THRESHOLD_MINUTES;
70
+ return minutes !== void 0 && minutes > 0 && minutes <= operationHours.SOON_THRESHOLD_MINUTES;
68
71
  }
69
72
 
70
73
  exports.computeIsOpenNow = computeIsOpenNow;
@@ -13,6 +13,7 @@ const parmToPlugin = {
13
13
  contentStage: "venueDataLoader",
14
14
  accountId: "venueDataLoader",
15
15
  search: "online/headerOnline",
16
+ searchView: ["online/homeView", "analytics2"],
16
17
  ho: ["online/getDirectionsFromTo", "analytics2"],
17
18
  home: "online/homeView",
18
19
  zoom: "mapRenderer",
@@ -1,297 +1,131 @@
1
1
  'use strict';
2
2
 
3
3
  var luxon = require('luxon');
4
- var R = require('ramda');
5
4
 
6
- function _interopNamespaceDefault(e) {
7
- var n = Object.create(null);
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- if (k !== 'default') {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
5
+ const SOON_THRESHOLD_MINUTES = 60;
6
+ const WEEKDAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
7
+ const SHORT_WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
8
+ const HOURS_PATTERN = /^(Su|Mo|Tu|We|Th|Fr|Sa)(?:-(Su|Mo|Tu|We|Th|Fr|Sa))?\s+(\d{1,2}:\d{2})-(\d{1,2}:\d{2})$/;
9
+ function canParseOperationHours(hours) {
10
+ return typeof hours === "string" && hours.trim() !== "" && hours.split(";").every((part) => HOURS_PATTERN.test(part.trim()));
11
+ }
12
+ function parseAndOrderWeekdays(hours, today) {
13
+ const periods = /* @__PURE__ */ new Map();
14
+ for (const segment of hours.split(";")) {
15
+ const match = HOURS_PATTERN.exec(segment.trim());
16
+ if (!match) {
17
+ return [];
18
+ }
19
+ const [, firstDay, lastDay, opening, closing] = match;
20
+ const from = parseTime(opening);
21
+ const to = parseTime(closing);
22
+ const timePeriod = { from, to, formatted: `${formatTime(from)} - ${formatTime(to)}` };
23
+ const start = SHORT_WEEKDAYS.indexOf(firstDay);
24
+ const end = SHORT_WEEKDAYS.indexOf(lastDay ?? firstDay);
25
+ let day = start;
26
+ do {
27
+ periods.set(day, timePeriod);
28
+ if (day === end) {
29
+ break;
16
30
  }
17
- });
31
+ day = (day + 1) % WEEKDAYS.length;
32
+ } while (day !== start);
18
33
  }
19
- n.default = e;
20
- return Object.freeze(n);
34
+ return [...periods.entries()].sort(([a], [b]) => a - b).map(([day, timePeriod]) => ({ weekday: WEEKDAYS[day], isToday: day === today.getDay(), timePeriod }));
21
35
  }
22
-
23
- var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
24
-
25
- function canParseOperationHours(operationHours) {
26
- if (!operationHours || typeof operationHours !== "string") {
27
- return false;
28
- }
29
- const trimmed = operationHours.trim();
30
- if (trimmed === "") {
31
- return false;
32
- }
33
- const validDayPattern = /^(Su|Mo|Tu|We|Th|Fr|Sa)(-(?:Su|Mo|Tu|We|Th|Fr|Sa))?\s+\d{1,2}:\d{2}-\d{1,2}:\d{2}$/;
34
- const segments = trimmed.split(";").map((s) => s.trim());
35
- return segments.every((segment) => validDayPattern.test(segment));
36
+ function isOpen(periods, today) {
37
+ return Boolean(resolveSchedule(periods, asDateTime(today)).active);
36
38
  }
37
- function isOpen(weekdayPeriods, today) {
38
- const currentWeekday = findWeekday(weekdayPeriods, today);
39
- if (!currentWeekday) {
40
- return false;
41
- }
42
- const hours = today.getHours();
43
- const minutes = today.getMinutes();
44
- const { from, to } = currentWeekday.timePeriod;
45
- return isInTimePeriod(hours, minutes, from.hours, from.minutes, to.hours, to.minutes);
46
- }
47
- function getBoundaryMinutes(weekdayPeriods, localizedNow) {
48
- const currentWeekday = findWeekday(weekdayPeriods, localizedNow);
49
- if (!currentWeekday) {
50
- return { minutesToOpen: void 0, minutesToClose: void 0 };
51
- }
39
+ function getBoundaryMinutes(periods, today) {
40
+ const now = asDateTime(today);
41
+ const { active, next, alwaysOpen } = resolveSchedule(periods, now);
52
42
  return {
53
- minutesToOpen: minutesBetweenDateTimeAndWeekdayTime(localizedNow, currentWeekday.timePeriod.from),
54
- minutesToClose: minutesBetweenDateTimeAndWeekdayTime(localizedNow, currentWeekday.timePeriod.to)
43
+ minutesToOpen: !active && next ? next.start.diff(now, "minutes").minutes : void 0,
44
+ minutesToClose: active && !alwaysOpen ? active.end.diff(now, "minutes").minutes : void 0
55
45
  };
56
46
  }
57
- function isInTimePeriod(nowHours, nowMinutes, fromHours, fromMinutes, toHours, toMinutes) {
58
- const isOvernightPeriod = isFirstTimeAfterSecond(fromHours, fromMinutes, toHours, toMinutes);
59
- if (isOvernightPeriod) {
60
- return isInTimePeriod(nowHours, nowMinutes, fromHours, fromMinutes, 24, 0) || isInTimePeriod(nowHours, nowMinutes, 0, 0, toHours, toMinutes);
61
- } else {
62
- const isAfterFrom = isFirstTimeAfterSecond(nowHours, nowMinutes, fromHours, fromMinutes);
63
- const isBeforeTo = isFirstTimeAfterSecond(toHours, toMinutes, nowHours, nowMinutes);
64
- return isAfterFrom && isBeforeTo;
65
- }
66
- }
67
- function isFirstTimeAfterSecond(firstHours, firstMinutes, secondHours, secondMinutes) {
68
- return firstHours > secondHours || firstHours === secondHours && firstMinutes >= secondMinutes;
69
- }
70
- function findWeekday(weekdayPeriods, today) {
71
- return findWeekdayByDayIndex(weekdayPeriods, today.getDay());
72
- }
73
- function findWeekdayByDayIndex(weekdayPeriods, index) {
74
- const currentWeekdayName = WEEKDAY_ARRAY[index];
75
- return weekdayPeriods.find(({ weekday }) => weekday === currentWeekdayName);
76
- }
77
- function parseAndOrderWeekdays(rawWeekdayPeriods, today) {
78
- const weekdays = parseWeekdayPeriods(rawWeekdayPeriods);
79
- const orderedWeekdays = orderFromSunday(weekdays);
80
- return markCurrentWeekday(orderedWeekdays, today);
81
- }
82
- const SHORT_WEEKDAY_TO_NUMERAL = {
83
- Su: 0,
84
- Mo: 1,
85
- Tu: 2,
86
- We: 3,
87
- Th: 4,
88
- Fr: 5,
89
- Sa: 6
90
- };
91
- const WEEKDAY_ARRAY = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
92
- const WEEKDAY_TO_NUMERAL = WEEKDAY_ARRAY.reduce(
93
- (obj, weekday, index) => Object.assign(obj, { [weekday]: index }),
94
- {}
95
- );
96
- const WEEKDAYS_DELIMITER = ";";
97
- const WEEKDAY_AND_TIME_DELIMITER = /\s+/;
98
- const WEEKDAY_DELIMITER = "-";
99
- const TIME_PERIOD_DELIMITER = "-";
100
- const TIME_DELIMITER = ":";
101
- const AM = " AM";
102
- const PM = " PM";
103
- function parseWeekdayPeriods(rawWeekdayPeriods) {
104
- return rawWeekdayPeriods.split(WEEKDAYS_DELIMITER).map((weekdayAndTimePeriod) => weekdayAndTimePeriod.trim()).map((weekdayAndTimePeriod) => weekdayAndTimePeriod.split(WEEKDAY_AND_TIME_DELIMITER)).flatMap(([weekdayPeriod, timePeriod]) => {
105
- const weekdays = parseWeekdayPeriod(weekdayPeriod);
106
- const formattedTimePeriod = prepareTimePeriodData(timePeriod);
107
- return createWeekdayAndTimePeriodPairs(weekdays, formattedTimePeriod);
108
- });
109
- }
110
- function parseWeekdayPeriod(weekdayPeriod) {
111
- const [start, end] = weekdayPeriod.split(WEEKDAY_DELIMITER);
112
- const startIndex = SHORT_WEEKDAY_TO_NUMERAL[start];
113
- let weekdayIndices;
114
- if (end) {
115
- const endIndex = SHORT_WEEKDAY_TO_NUMERAL[end];
116
- weekdayIndices = weekdayIndicesRange(startIndex, endIndex);
117
- } else {
118
- weekdayIndices = [startIndex];
47
+ function getOpenTimeLabel(hours, nowDate, T, timezone) {
48
+ if (!hours || !canParseOperationHours(hours)) {
49
+ return "";
119
50
  }
120
- return weekdayIndices.map((index) => WEEKDAY_ARRAY[index]);
121
- }
122
- function weekdayIndicesRange(startIndex, endIndex) {
123
- const weekdayIndices = [startIndex];
124
- let currentDayIndex = startIndex;
125
- do {
126
- currentDayIndex = (currentDayIndex + 1) % WEEKDAY_ARRAY.length;
127
- weekdayIndices.push(currentDayIndex);
128
- } while (currentDayIndex !== endIndex);
129
- return weekdayIndices;
130
- }
131
- function prepareTimePeriodData(timePeriod) {
132
- const [from, to] = timePeriod.split(TIME_PERIOD_DELIMITER);
133
- const [fromTime, fromTimeFormatted] = getHoursMinutesAndFormatted(from);
134
- const [toTime, toTimeFormatted] = getHoursMinutesAndFormatted(to);
135
- const timePeriodFormatted = fromTimeFormatted + ` ${TIME_PERIOD_DELIMITER} ` + toTimeFormatted;
136
- return {
137
- from: fromTime,
138
- to: toTime,
139
- formatted: timePeriodFormatted
140
- };
141
- }
142
- function getHoursMinutesAndFormatted(time) {
143
- const [hours, minutes] = time.split(TIME_DELIMITER);
144
- const timeFormatted = formatTimeAmPm(hours, minutes);
145
- return [{ hours: +hours, minutes: +minutes }, timeFormatted];
146
- }
147
- function formatTimeAmPm(hours, minutes) {
148
- const hoursNum = +hours;
149
- const minutesNum = +minutes;
150
- const ampm = hoursNum < 12 || hoursNum === 24 ? AM : PM;
151
- const displayHours = hoursNum % 12 || 12;
152
- const minutesStr = minutesNum > 9 ? String(minutesNum) : "0" + minutesNum;
153
- return displayHours + TIME_DELIMITER + minutesStr + ampm;
154
- }
155
- function createWeekdayAndTimePeriodPairs(weekdays, timePeriod) {
156
- return weekdays.map((weekday) => ({ weekday, timePeriod }));
157
- }
158
- function orderFromSunday(weekdayPeriods) {
159
- const startWeekdayIndex = 0;
160
- const orderedWeekdays = [];
161
- weekdayPeriods.forEach((weekday) => {
162
- const weekdayIndex = WEEKDAY_TO_NUMERAL[weekday.weekday];
163
- let order = weekdayIndex - startWeekdayIndex;
164
- if (order < 0) {
165
- order += WEEKDAY_ARRAY.length;
166
- }
167
- orderedWeekdays[order] = weekday;
168
- });
169
- return filterEmptyDays(orderedWeekdays);
170
- }
171
- function filterEmptyDays(weekdays) {
172
- return weekdays.filter((x) => Boolean(x));
173
- }
174
- function markCurrentWeekday(weekdays, today) {
175
- const todayDayName = WEEKDAY_ARRAY[today.getDay()];
176
- const addIsToday = R__namespace.converge(R__namespace.assoc("isToday"), [R__namespace.propEq(todayDayName, "weekday"), R__namespace.identity]);
177
- return weekdays.map((weekday) => addIsToday(weekday));
178
- }
179
- function getOpenTimeLabel(operationHours, nowDate, T, timezone) {
180
- if (operationHours === "Mo-Su 00:00-24:00") {
51
+ const now = luxon.DateTime.fromJSDate(nowDate, { zone: timezone ?? void 0 }).startOf("minute");
52
+ const periods = parseAndOrderWeekdays(hours, toLocalDate(nowDate, timezone));
53
+ const { active, next, alwaysOpen } = resolveSchedule(periods, now);
54
+ if (alwaysOpen) {
181
55
  return T("ui:Always open");
182
56
  }
183
- if (!operationHours) {
184
- return "";
57
+ if (active) {
58
+ const minutes2 = active.end.diff(now, "minutes").minutes;
59
+ return minutes2 <= SOON_THRESHOLD_MINUTES ? T("ui:Closing in _minutes_", { count: minutes2 }) : T("ui:Open until _time_", { time: formatDateTime(active.end) });
185
60
  }
186
- if (!canParseOperationHours(operationHours)) {
61
+ if (!next) {
187
62
  return "";
188
63
  }
189
- const localizedDate = toLocalDate(nowDate, timezone);
190
- const weekdayPeriods = parseAndOrderWeekdays(operationHours, localizedDate);
191
- if (!weekdayPeriods) {
192
- return "";
193
- }
194
- const currentWeekday = findWeekday(weekdayPeriods, localizedDate);
195
- if (!currentWeekday || compareDateTimeAndWeekdayTime(localizedDate, currentWeekday.timePeriod.to) === -1) {
196
- return prepareTimeToNextWorkingDay(localizedDate, weekdayPeriods, T);
197
- }
198
- if (isDateInWeekdayOpenHours(localizedDate, currentWeekday)) {
199
- return prepareTimeToTodayClose(localizedDate, currentWeekday, T);
64
+ const minutes = next.start.diff(now, "minutes").minutes;
65
+ if (minutes <= SOON_THRESHOLD_MINUTES) {
66
+ return T("ui:Opening in _minutes_", { count: minutes });
200
67
  }
201
- return prepareTimeToTodayOpen(localizedDate, currentWeekday, T);
68
+ const time = formatDateTime(next.start);
69
+ const weekday = WEEKDAYS[next.start.weekday % 7];
70
+ return T("ui:Closed until _time_", { time: next.start.hasSame(now, "day") ? time : `${weekday} ${time}` });
202
71
  }
203
72
  function toLocalDate(date, timezone) {
204
- const { year, month, day, hour, minute } = luxon.DateTime.fromJSDate(date, {
205
- zone: timezone ?? void 0
206
- });
73
+ const { year, month, day, hour, minute } = luxon.DateTime.fromJSDate(date, { zone: timezone ?? void 0 });
207
74
  return new Date(year, month - 1, day, hour, minute);
208
75
  }
209
- function prepareTimeToNextWorkingDay(nowDate, weekdayPeriods, T) {
210
- const tomorrowDate = getNextDayDate(nowDate);
211
- const nextWeekday = findWeekday(weekdayPeriods, tomorrowDate);
212
- if (nextWeekday) {
213
- const minutesToTomorrowOpen = minutesBetweenDateTimeAndNextWeekdayTime(nowDate, nextWeekday.timePeriod.from);
214
- if (minutesToTomorrowOpen >= 60) {
215
- return formatClosedUntilWeekday(nextWeekday, T);
216
- } else {
217
- return formatOpeningInMinutes(minutesToTomorrowOpen, T);
76
+ function resolveSchedule(periods, now) {
77
+ const windows = [];
78
+ for (let offset = -1; offset <= 14; offset++) {
79
+ const day = now.startOf("day").plus({ days: offset });
80
+ const period = periods.find((period2) => period2.weekday === WEEKDAYS[day.weekday % 7]);
81
+ if (period) {
82
+ windows.push(createWindow(day, period.timePeriod));
218
83
  }
219
- } else {
220
- const nextWorkingWeekday = findNextWorkingWeekday(weekdayPeriods, nowDate);
221
- return nextWorkingWeekday ? formatClosedUntilWeekday(nextWorkingWeekday, T) : "";
222
84
  }
223
- }
224
- function prepareTimeToTodayClose(nowDate, currentWeekday, T) {
225
- const minutesToClose = minutesBetweenDateTimeAndWeekdayTime(nowDate, currentWeekday.timePeriod.to);
226
- if (minutesToClose >= 60) {
227
- return formatOpenUntilHours(currentWeekday, T);
228
- } else {
229
- return formatClosingInMinutes(minutesToClose, T);
85
+ const merged = [];
86
+ for (const window of windows.sort((a, b) => a.start.toMillis() - b.start.toMillis())) {
87
+ const previous = merged[merged.length - 1];
88
+ if (previous && window.start <= previous.end) {
89
+ if (window.end > previous.end) {
90
+ previous.end = window.end;
91
+ }
92
+ } else {
93
+ merged.push(window);
94
+ }
230
95
  }
96
+ const active = merged.find((window) => window.start <= now && now < window.end);
97
+ return {
98
+ active,
99
+ next: merged.find((window) => window.start > now),
100
+ alwaysOpen: Boolean(active && active.end >= now.plus({ weeks: 1 }))
101
+ };
231
102
  }
232
- function prepareTimeToTodayOpen(nowDate, currentWeekday, T) {
233
- const minutesToOpen = minutesBetweenDateTimeAndWeekdayTime(nowDate, currentWeekday.timePeriod.from);
234
- if (minutesToOpen >= 60) {
235
- return formatClosedUntilHours(currentWeekday, T);
236
- } else {
237
- return formatOpeningInMinutes(minutesToOpen, T);
103
+ function createWindow(day, { from, to }) {
104
+ if (from.hours === to.hours && from.minutes === to.minutes) {
105
+ return { start: day, end: day.plus({ days: 1 }) };
238
106
  }
107
+ const overnight = from.hours > to.hours || from.hours === to.hours && from.minutes > to.minutes;
108
+ return { start: atTime(day, from), end: atTime(overnight ? day.plus({ days: 1 }) : day, to) };
239
109
  }
240
- function isDateInWeekdayOpenHours(date, weekday) {
241
- const { from, to } = weekday.timePeriod;
242
- return isInTimePeriod(date.getHours(), date.getMinutes(), from.hours, from.minutes, to.hours, to.minutes);
110
+ function atTime(day, time) {
111
+ return time.hours === 24 ? day.plus({ days: 1 }).startOf("day") : day.set({ hour: time.hours, minute: time.minutes });
243
112
  }
244
- function getNextDayDate(date) {
245
- const nextDate = new Date(date);
246
- nextDate.setDate(nextDate.getDate() + 1);
247
- return nextDate;
113
+ function asDateTime(date) {
114
+ return (date instanceof Date ? luxon.DateTime.fromJSDate(date) : date).startOf("minute");
248
115
  }
249
- function compareDateTimeAndWeekdayTime(date, weekdayHours) {
250
- const minutesBetween = minutesBetweenDateTimeAndWeekdayTime(date, weekdayHours);
251
- if (minutesBetween === 0) {
252
- return 0;
253
- }
254
- if (minutesBetween > 0) {
255
- return 1;
256
- }
257
- return -1;
116
+ function parseTime(time) {
117
+ const [hours, minutes] = time.split(":").map(Number);
118
+ return { hours, minutes };
258
119
  }
259
- function minutesBetweenDateTimeAndWeekdayTime(dateTime, weekdayTime) {
260
- const dateTimeMinutes = dateTime.getHours() * 60 + dateTime.getMinutes();
261
- const weekdayTimeMinutes = weekdayTime.hours * 60 + weekdayTime.minutes;
262
- return weekdayTimeMinutes - dateTimeMinutes;
120
+ function formatDateTime(date) {
121
+ return formatTime({ hours: date.hour, minutes: date.minute });
263
122
  }
264
- function minutesBetweenDateTimeAndNextWeekdayTime(dateTime, weekdayTime) {
265
- const dateTimeMinutes = dateTime.getHours() * 60 + dateTime.getMinutes();
266
- const weekdayTimeMinutes = weekdayTime.hours * 60 + weekdayTime.minutes;
267
- const midnightMinutes = 24 * 60;
268
- return weekdayTimeMinutes + (midnightMinutes - dateTimeMinutes);
123
+ function formatTime({ hours, minutes }) {
124
+ const suffix = hours < 12 || hours === 24 ? "AM" : "PM";
125
+ return `${hours % 12 || 12}:${String(minutes).padStart(2, "0")} ${suffix}`;
269
126
  }
270
- const formatOpeningInMinutes = (minutesToOpen, T) => T("ui:Opening in _minutes_", { count: minutesToOpen });
271
- const formatClosingInMinutes = (minutesToClose, T) => T("ui:Closing in _minutes_", { count: minutesToClose });
272
- const formatClosedUntilHours = (weekday, T) => {
273
- const { hours, minutes } = weekday.timePeriod.from;
274
- const formattedTime = formatTimeAmPm(hours, minutes);
275
- return T("ui:Closed until _time_", { time: formattedTime });
276
- };
277
- const formatOpenUntilHours = (weekday, T) => {
278
- const { hours, minutes } = weekday.timePeriod.to;
279
- const formattedTime = formatTimeAmPm(hours, minutes);
280
- return T("ui:Open until _time_", { time: formattedTime });
281
- };
282
- const formatClosedUntilWeekday = (weekday, T) => {
283
- const { hours, minutes } = weekday.timePeriod.from;
284
- const formattedTime = `${weekday.weekday} ${formatTimeAmPm(hours, minutes)}`;
285
- return T("ui:Closed until _time_", { time: formattedTime });
286
- };
287
- const findNextWorkingWeekday = (weekdayPeriods, nowDate) => {
288
- let startIndex = (nowDate.getDay() + 1) % 7;
289
- while (!findWeekdayByDayIndex(weekdayPeriods, startIndex)) {
290
- startIndex = (startIndex + 1) % 7;
291
- }
292
- return findWeekdayByDayIndex(weekdayPeriods, startIndex);
293
- };
294
127
 
128
+ exports.SOON_THRESHOLD_MINUTES = SOON_THRESHOLD_MINUTES;
295
129
  exports.canParseOperationHours = canParseOperationHours;
296
130
  exports.getBoundaryMinutes = getBoundaryMinutes;
297
131
  exports.getOpenTimeLabel = getOpenTimeLabel;
@@ -1 +1 @@
1
- var a="3.3.1166",e={version:a};export{e as default,a as version};
1
+ var a="3.3.1168",e={version:a};export{e as default,a as version};
@@ -1 +1 @@
1
- import{getOpenTimeLabel as t,canParseOperationHours as n,toLocalDate as e,parseAndOrderWeekdays as o,isOpen as r,getBoundaryMinutes as i}from"../../../src/utils/operationHours.js";import{PoiOpenStatus as s}from"../../../utils/constants.js";function u(t,i,s=new Date){if("permanently-closed"===t.state)return!1;const u=t.dynamicData?.["open-closed-status"];if(u){const t=u.expiresAt;if(void 0===t||t>s.getTime())return u.isOpen}if(!i)return;if(!n(t.operationHours))return;const a=e(s,i),c=o(t.operationHours,a);return c&&0!==c.length?r(c,a):void 0}function a(r,a,f,m=new Date){const O=u(r,a,m);if(void 0===O)return;const d=function(t,r,u,a){const f=u?s.OPEN:s.CLOSED;if(c(t,a)||!r||!n(t.operationHours))return f;const m=e(a,r),O=o(t.operationHours,m);if(!O||0===O.length)return f;const{minutesToOpen:d,minutesToClose:l}=i(O,m);if(u)return p(l)?s.CLOSING_SOON:s.OPEN;return p(d)?s.OPENING_SOON:s.CLOSED}(r,a,O,m);return{isOpen:O,status:d,timeLabel:a&&!c(r,m)&&t(r.operationHours,m,f,a)||void 0}}function c(t,n){if("permanently-closed"===t.state)return!0;const e=t.dynamicData?.["open-closed-status"];return!!e&&(void 0===e.expiresAt||e.expiresAt>n.getTime())}function p(t){return void 0!==t&&t>0&&t<=60}export{u as computeIsOpenNow,a as computePoiOpenStatus};
1
+ import{DateTime as t}from"luxon";import{getOpenTimeLabel as e,canParseOperationHours as n,toLocalDate as o,parseAndOrderWeekdays as r,isOpen as i,getBoundaryMinutes as s,SOON_THRESHOLD_MINUTES as u}from"../../../src/utils/operationHours.js";import{PoiOpenStatus as a}from"../../../utils/constants.js";function c(e,s,u=new Date){if("permanently-closed"===e.state)return!1;const a=e.dynamicData?.["open-closed-status"];if(a){const t=a.expiresAt;if(void 0===t||t>u.getTime())return a.isOpen}if(!s)return;if(!n(e.operationHours))return;const c=o(u,s),f=r(e.operationHours,c);return f&&0!==f.length?i(f,t.fromJSDate(u,{zone:s})):void 0}function f(i,u,f,l=new Date){const O=c(i,u,l);if(void 0===O)return;const d=function(e,i,u,c){const f=u?a.OPEN:a.CLOSED;if(p(e,c)||!i||!n(e.operationHours))return f;const l=o(c,i),O=r(e.operationHours,l);if(!O||0===O.length)return f;const{minutesToOpen:d,minutesToClose:D}=s(O,t.fromJSDate(c,{zone:i}));if(u)return m(D)?a.CLOSING_SOON:a.OPEN;return m(d)?a.OPENING_SOON:a.CLOSED}(i,u,O,l);return{isOpen:O,status:d,timeLabel:u&&!p(i,l)&&e(i.operationHours,l,f,u)||void 0}}function p(t,e){if("permanently-closed"===t.state)return!0;const n=t.dynamicData?.["open-closed-status"];return!!n&&(void 0===n.expiresAt||n.expiresAt>e.getTime())}function m(t){return void 0!==t&&t>0&&t<=u}export{c as computeIsOpenNow,f as computePoiOpenStatus};
@@ -1 +1 @@
1
- const e={navFrom:"online/getDirectionsFromTo",navTo:"online/getDirectionsFromTo",waypoints:"online/getDirectionsFromTo",accessible:"online/getDirectionsFromTo",showNav:"online/getDirectionsFromTo",poiId:["online/getDirectionsFromTo","online/poiView"],vid:"venueDataLoader",lang:"venueDataLoader",stage:"venueDataLoader",contentStage:"venueDataLoader",accountId:"venueDataLoader",search:"online/headerOnline",ho:["online/getDirectionsFromTo","analytics2"],home:"online/homeView",zoom:"mapRenderer",pitch:"mapRenderer",bearing:"mapRenderer",lat:"mapRenderer",lng:"mapRenderer",radius:"mapRenderer",buildingId:"mapRenderer",floorId:"mapRenderer",visualTest:"mapRenderer",refInstallId:"analytics2",disableZoomToExplorePopup:"levelIndicator"};function n(n,o,r=!1){if(o.has("lldebug"))try{const e=JSON.parse(o.get("lldebug")??"null");n.debug=null===e?{}:e}catch{n.debug=!0}Object.keys(e).forEach(a=>{if(!o.has(a))return;const i=e[a];(Array.isArray(i)?i:[i]).forEach(e=>{let i=n.plugins[e];!i&&r&&(i=n.plugins[e]={}),i&&(i.deepLinkProps={...i.deepLinkProps,[a]:o.get(a)})})});const a=n.plugins["online/poiView"];return o.has("poiId")&&o.has("showNav")&&a&&delete a.deepLinkProps?.poiId,n}export{n as setDeepLinksForParms};
1
+ const e={navFrom:"online/getDirectionsFromTo",navTo:"online/getDirectionsFromTo",waypoints:"online/getDirectionsFromTo",accessible:"online/getDirectionsFromTo",showNav:"online/getDirectionsFromTo",poiId:["online/getDirectionsFromTo","online/poiView"],vid:"venueDataLoader",lang:"venueDataLoader",stage:"venueDataLoader",contentStage:"venueDataLoader",accountId:"venueDataLoader",search:"online/headerOnline",searchView:["online/homeView","analytics2"],ho:["online/getDirectionsFromTo","analytics2"],home:"online/homeView",zoom:"mapRenderer",pitch:"mapRenderer",bearing:"mapRenderer",lat:"mapRenderer",lng:"mapRenderer",radius:"mapRenderer",buildingId:"mapRenderer",floorId:"mapRenderer",visualTest:"mapRenderer",refInstallId:"analytics2",disableZoomToExplorePopup:"levelIndicator"};function n(n,o,r=!1){if(o.has("lldebug"))try{const e=JSON.parse(o.get("lldebug")??"null");n.debug=null===e?{}:e}catch{n.debug=!0}Object.keys(e).forEach(i=>{if(!o.has(i))return;const a=e[i];(Array.isArray(a)?a:[a]).forEach(e=>{let a=n.plugins[e];!a&&r&&(a=n.plugins[e]={}),a&&(a.deepLinkProps={...a.deepLinkProps,[i]:o.get(i)})})});const i=n.plugins["online/poiView"];return o.has("poiId")&&o.has("showNav")&&i&&delete i.deepLinkProps?.poiId,n}export{n as setDeepLinksForParms};
@@ -1 +1 @@
1
- import{DateTime as t}from"luxon";import*as n from"ramda";function e(t){if(!t||"string"!=typeof t)return!1;const n=t.trim();if(""===n)return!1;const e=/^(Su|Mo|Tu|We|Th|Fr|Sa)(-(?:Su|Mo|Tu|We|Th|Fr|Sa))?\s+\d{1,2}:\d{2}-\d{1,2}:\d{2}$/;return n.split(";").map(t=>t.trim()).every(t=>e.test(t))}function r(t,n){const e=s(t,n);if(!e)return!1;const r=n.getHours(),o=n.getMinutes(),{from:i,to:c}=e.timePeriod;return u(r,o,i.hours,i.minutes,c.hours,c.minutes)}function o(t,n){const e=s(t,n);return e?{minutesToOpen:D(n,e.timePeriod.from),minutesToClose:D(n,e.timePeriod.to)}:{minutesToOpen:void 0,minutesToClose:void 0}}function u(t,n,e,r,o,s){if(i(e,r,o,s))return u(t,n,e,r,24,0)||u(t,n,0,0,o,s);{const u=i(t,n,e,r),c=i(o,s,t,n);return u&&c}}function i(t,n,e,r){return t>e||t===e&&n>=r}function s(t,n){return c(t,n.getDay())}function c(t,n){const e=a[n];return t.find(({weekday:t})=>t===e)}function m(t,e){const r=function(t){return t.split(l).map(t=>t.trim()).map(t=>t.split(p)).flatMap(([t,n])=>{const e=function(t){const[n,e]=t.split(y),r=f[n];let o;if(e){o=function(t,n){const e=[t];let r=t;do{r=(r+1)%a.length,e.push(r)}while(r!==n);return e}(r,f[e])}else o=[r];return o.map(t=>a[t])}(t),r=function(t){const[n,e]=t.split(h),[r,o]=M(n),[u,i]=M(e);return{from:r,to:u,formatted:o+` ${h} `+i}}(n);return function(t,n){return t.map(t=>({weekday:t,timePeriod:n}))}(e,r)})}(t),o=function(t){const n=0,e=[];return t.forEach(t=>{let r=d[t.weekday]-n;r<0&&(r+=a.length),e[r]=t}),function(t){return t.filter(t=>Boolean(t))}(e)}(r);return function(t,e){const r=a[e.getDay()],o=n.converge(n.assoc("isToday"),[n.propEq(r,"weekday"),n.identity]);return t.map(t=>o(t))}(o,e)}const f={Su:0,Mo:1,Tu:2,We:3,Th:4,Fr:5,Sa:6},a=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d=a.reduce((t,n,e)=>Object.assign(t,{[n]:e}),{}),l=";",p=/\s+/,y="-",h="-",g=":",P=" AM",T=" PM";function M(t){const[n,e]=t.split(g);return[{hours:+n,minutes:+e},S(n,e)]}function S(t,n){const e=+t,r=+n,o=e<12||24===e?P:T,u=e%12||12,i=r>9?String(r):"0"+r;return u+g+i+o}function _(t,n,r,o){if("Mo-Su 00:00-24:00"===t)return r("ui:Always open");if(!t)return"";if(!e(t))return"";const i=w(n,o),c=m(t,i);if(!c)return"";const f=s(c,i);return f&&-1!==function(t,n){const e=D(t,n);if(0===e)return 0;if(e>0)return 1;return-1}(i,f.timePeriod.to)?function(t,n){const{from:e,to:r}=n.timePeriod;return u(t.getHours(),t.getMinutes(),e.hours,e.minutes,r.hours,r.minutes)}(i,f)?function(t,n,e){const r=D(t,n.timePeriod.to);return r>=60?O(n,e):v(r,e)}(i,f,r):function(t,n,e){const r=D(t,n.timePeriod.from);return r>=60?C(n,e):k(r,e)}(i,f,r):function(t,n,e){const r=function(t){const n=new Date(t);return n.setDate(n.getDate()+1),n}(t),o=s(n,r);if(o){const n=function(t,n){const e=60*t.getHours()+t.getMinutes(),r=60*n.hours+n.minutes;return r+(1440-e)}(t,o.timePeriod.from);return n>=60?F(o,e):k(n,e)}{const r=H(n,t);return r?F(r,e):""}}(i,c,r)}function w(n,e){const{year:r,month:o,day:u,hour:i,minute:s}=t.fromJSDate(n,{zone:e??void 0});return new Date(r,o-1,u,i,s)}function D(t,n){const e=60*t.getHours()+t.getMinutes();return 60*n.hours+n.minutes-e}const k=(t,n)=>n("ui:Opening in _minutes_",{count:t}),v=(t,n)=>n("ui:Closing in _minutes_",{count:t}),C=(t,n)=>{const{hours:e,minutes:r}=t.timePeriod.from;return n("ui:Closed until _time_",{time:S(e,r)})},O=(t,n)=>{const{hours:e,minutes:r}=t.timePeriod.to;return n("ui:Open until _time_",{time:S(e,r)})},F=(t,n)=>{const{hours:e,minutes:r}=t.timePeriod.from;return n("ui:Closed until _time_",{time:`${t.weekday} ${S(e,r)}`})},H=(t,n)=>{let e=(n.getDay()+1)%7;for(;!c(t,e);)e=(e+1)%7;return c(t,e)};export{e as canParseOperationHours,o as getBoundaryMinutes,_ as getOpenTimeLabel,r as isOpen,m as parseAndOrderWeekdays,w as toLocalDate};
1
+ import{DateTime as t}from"luxon";const n=60,e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=["Su","Mo","Tu","We","Th","Fr","Sa"],r=/^(Su|Mo|Tu|We|Th|Fr|Sa)(?:-(Su|Mo|Tu|We|Th|Fr|Sa))?\s+(\d{1,2}:\d{2})-(\d{1,2}:\d{2})$/;function i(t){return"string"==typeof t&&""!==t.trim()&&t.split(";").every(t=>r.test(t.trim()))}function u(t,n){const i=new Map;for(const n of t.split(";")){const t=r.exec(n.trim());if(!t)return[];const[,u,o,a,d]=t,f=h(a),m=h(d),c={from:f,to:m,formatted:`${S(f)} - ${S(m)}`},l=s.indexOf(u),y=s.indexOf(o??u);let p=l;do{if(i.set(p,c),p===y)break;p=(p+1)%e.length}while(p!==l)}return[...i.entries()].sort(([t],[n])=>t-n).map(([t,s])=>({weekday:e[t],isToday:t===n.getDay(),timePeriod:s}))}function o(t,n){return Boolean(m(t,y(n)).active)}function a(t,n){const e=y(n),{active:s,next:r,alwaysOpen:i}=m(t,e);return{minutesToOpen:!s&&r?r.start.diff(e,"minutes").minutes:void 0,minutesToClose:s&&!i?s.end.diff(e,"minutes").minutes:void 0}}function d(n,s,r,o){if(!n||!i(n))return"";const a=t.fromJSDate(s,{zone:o??void 0}).startOf("minute"),d=u(n,f(s,o)),{active:c,next:l,alwaysOpen:y}=m(d,a);if(y)return r("ui:Always open");if(c){const t=c.end.diff(a,"minutes").minutes;return t<=60?r("ui:Closing in _minutes_",{count:t}):r("ui:Open until _time_",{time:p(c.end)})}if(!l)return"";const h=l.start.diff(a,"minutes").minutes;if(h<=60)return r("ui:Opening in _minutes_",{count:h});const S=p(l.start),w=e[l.start.weekday%7];return r("ui:Closed until _time_",{time:l.start.hasSame(a,"day")?S:`${w} ${S}`})}function f(n,e){const{year:s,month:r,day:i,hour:u,minute:o}=t.fromJSDate(n,{zone:e??void 0});return new Date(s,r-1,i,u,o)}function m(t,n){const s=[];for(let r=-1;r<=14;r++){const i=n.startOf("day").plus({days:r}),u=t.find(t=>t.weekday===e[i.weekday%7]);u&&s.push(c(i,u.timePeriod))}const r=[];for(const t of s.sort((t,n)=>t.start.toMillis()-n.start.toMillis())){const n=r[r.length-1];n&&t.start<=n.end?t.end>n.end&&(n.end=t.end):r.push(t)}const i=r.find(t=>t.start<=n&&n<t.end);return{active:i,next:r.find(t=>t.start>n),alwaysOpen:Boolean(i&&i.end>=n.plus({weeks:1}))}}function c(t,{from:n,to:e}){if(n.hours===e.hours&&n.minutes===e.minutes)return{start:t,end:t.plus({days:1})};const s=n.hours>e.hours||n.hours===e.hours&&n.minutes>e.minutes;return{start:l(t,n),end:l(s?t.plus({days:1}):t,e)}}function l(t,n){return 24===n.hours?t.plus({days:1}).startOf("day"):t.set({hour:n.hours,minute:n.minutes})}function y(n){return(n instanceof Date?t.fromJSDate(n):n).startOf("minute")}function h(t){const[n,e]=t.split(":").map(Number);return{hours:n,minutes:e}}function p(t){return S({hours:t.hour,minutes:t.minute})}function S({hours:t,minutes:n}){const e=t<12||24===t?"AM":"PM";return`${t%12||12}:${String(n).padStart(2,"0")} ${e}`}export{n as SOON_THRESHOLD_MINUTES,i as canParseOperationHours,a as getBoundaryMinutes,d as getOpenTimeLabel,o as isOpen,u as parseAndOrderWeekdays,f as toLocalDate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atriusmaps-node-sdk",
3
- "version": "3.3.1166",
3
+ "version": "3.3.1168",
4
4
  "description": "This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information",
5
5
  "keywords": [
6
6
  "acuitybrands",