@ancon/wildcat-utils 1.44.0-r13-2-tz.20 → 1.44.0-r13-2-tz.21

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.
@@ -1 +1 @@
1
- "use strict";const a=require("@ancon/wildcat-types"),l=require("../time/getTimeSpanParts.js"),s=require("./getServiceIntervalTimeSpanMoment.js");require("moment");function v(r,t,c){if(t.exception){const{exception:e}=t;if(e.type===a.IntervalType.Normal){const n=l(e.duration),i=s(r,e.from),o=i.clone().add(n);if(c.isBetween(i,o))return t.exception}}else for(let e=0;e<t.intervals.length;e+=1){const n=t.intervals[e],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=v;
1
+ "use strict";const f=require("@ancon/wildcat-types"),s=require("../time/getTimeSpanParts.js"),l=require("./getServiceIntervalTimeSpanMoment.js");require("moment");function a(c,e,i){if(e.exception){const{exception:t}=e;if(t.type===f.IntervalType.Normal){const n=s(t.duration),o=l(c,t.from,i.utcOffset()),r=o.clone().add(n);if(i.isBetween(o,r))return e.exception}}else for(let t=0;t<e.intervals.length;t+=1){const n=e.intervals[t],o=s(n.duration),r=l(c,n.from,i.utcOffset()),u=r.clone().add(o);if(i.isBetween(r,u))return n}return null}module.exports=a;
@@ -1,25 +1,27 @@
1
- import { IntervalType as f } from "@ancon/wildcat-types";
2
- import c from "../time/getTimeSpanParts.mjs";
3
- import s from "./getServiceIntervalTimeSpanMoment.mjs";
1
+ import { IntervalType as u } from "@ancon/wildcat-types";
2
+ import l from "../time/getTimeSpanParts.mjs";
3
+ import f from "./getServiceIntervalTimeSpanMoment.mjs";
4
4
  import "moment";
5
- function g(r, n, l) {
5
+ function g(c, n, i) {
6
6
  if (n.exception) {
7
7
  const { exception: t } = n;
8
- if (t.type === f.Normal) {
9
- const e = c(t.duration), o = s(
10
- r,
11
- t.from
12
- ), i = o.clone().add(e);
13
- if (l.isBetween(o, i))
8
+ if (t.type === u.Normal) {
9
+ const e = l(t.duration), o = f(
10
+ c,
11
+ t.from,
12
+ i.utcOffset()
13
+ ), r = o.clone().add(e);
14
+ if (i.isBetween(o, r))
14
15
  return n.exception;
15
16
  }
16
17
  } else
17
18
  for (let t = 0; t < n.intervals.length; t += 1) {
18
- const e = n.intervals[t], o = c(e.duration), i = s(
19
- r,
20
- e.from
21
- ), a = i.clone().add(o);
22
- if (l.isBetween(i, a))
19
+ const e = n.intervals[t], o = l(e.duration), r = f(
20
+ c,
21
+ e.from,
22
+ i.utcOffset()
23
+ ), s = r.clone().add(o);
24
+ if (i.isBetween(r, s))
23
25
  return e;
24
26
  }
25
27
  return null;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@ancon/wildcat-types"),v=require("moment"),u=require("../date/createLocalTimezoneMoment.js"),k=require("../time/getTimeSpanParts.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),D=require("./getServiceIntervalTimeSpanMoment.js"),S=require("./searchNextOpeningMoment.js"),O={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function T(n,e){const o=n.isSame(e,"d"),a={[e.format(d.OutletMapKeyFormatter)]:{intervals:[],exception:null,metadata:{dayOfWeek:O[e.isoWeekday()]}}};for(let s=o?1:0;s<d.OutletTimelineDayCount;s+=1){const i=v(n).add(s,"d");a[i.format(d.OutletMapKeyFormatter)]={intervals:[],exception:null,metadata:{dayOfWeek:O[i.isoWeekday()]}}}return a}function W(n,e){const o=u(e.periodFrom),t=u(e.periodTo);if(!o.isSame(t,"d"))Object.keys(n).forEach(s=>{const i=v(s);if(i.isSame(o,"d")||i.isSame(t,"d")||i.isBetween(o,t)){const c=n[s],r=c.exception?c.exception.position:0;e.position>r&&(c.exception=e)}});else{const s=o.format(d.OutletMapKeyFormatter),i=n[s];if(i){const m=i.exception?i.exception.position:0;e.position>m&&(i.exception=e)}}}function I(n,e){Object.keys(n).forEach(o=>{const t=n[o],{dayOfWeek:a}=t.metadata,{dayOfWeek:s}=e;(a&s)===a&&t.intervals.push(e)})}function q(n,e,o){const t=T(e,o);return n.forEach(a=>{a.type===g.IntervalType.Exception?W(t,a):I(t,a)}),t}function x(n,e,o,t){const a=q(n,o,t),s=t.format(d.OutletMapKeyFormatter),i=M(s,a[s],t)!==null,m=e;let c=null,r=null;if(e){const f=o.format(d.OutletMapKeyFormatter),l=M(f,a[f],o);if(l){const{hours:p,minutes:y}=k(l.duration);r=D(f,l.from),c=r.clone().add(p,"hours").add(y,"minutes")}}else r=S(a,o);if(!e&&!r){const f=n.filter(p=>p.state&&u(p.periodTo).isAfter(o)),[l]=f.sort((p,y)=>t.valueOf()-(u(p.periodTo).valueOf()-u(y.periodTo).valueOf()));if(l)return x(n,e,u(l.periodTo),t)}return{closingTime:c,openingTime:r,openDuringSpecifiedTime:m,openNow:i}}exports.DaysOfWeekMap=O;exports.default=x;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@ancon/wildcat-types"),v=require("moment"),u=require("../date/createLocalTimezoneMoment.js"),k=require("../time/getTimeSpanParts.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),D=require("./getServiceIntervalTimeSpanMoment.js"),S=require("./searchNextOpeningMoment.js"),O={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function T(n,e){const t=n.isSame(e,"d"),a={[e.format(d.OutletMapKeyFormatter)]:{intervals:[],exception:null,metadata:{dayOfWeek:O[e.isoWeekday()]}}};for(let i=t?1:0;i<d.OutletTimelineDayCount;i+=1){const s=v(n).add(i,"d");a[s.format(d.OutletMapKeyFormatter)]={intervals:[],exception:null,metadata:{dayOfWeek:O[s.isoWeekday()]}}}return a}function W(n,e){const t=u(e.periodFrom),o=u(e.periodTo);if(!t.isSame(o,"d"))Object.keys(n).forEach(i=>{const s=v(i);if(s.isSame(t,"d")||s.isSame(o,"d")||s.isBetween(t,o)){const c=n[i],r=c.exception?c.exception.position:0;e.position>r&&(c.exception=e)}});else{const i=t.format(d.OutletMapKeyFormatter),s=n[i];if(s){const m=s.exception?s.exception.position:0;e.position>m&&(s.exception=e)}}}function I(n,e){Object.keys(n).forEach(t=>{const o=n[t],{dayOfWeek:a}=o.metadata,{dayOfWeek:i}=e;(a&i)===a&&o.intervals.push(e)})}function q(n,e,t){const o=T(e,t);return n.forEach(a=>{a.type===g.IntervalType.Exception?W(o,a):I(o,a)}),o}function x(n,e,t,o){const a=q(n,t,o),i=o.format(d.OutletMapKeyFormatter),s=M(i,a[i],o)!==null,m=e;let c=null,r=null;if(e){const f=t.format(d.OutletMapKeyFormatter),l=M(f,a[f],t);if(l){const{hours:p,minutes:y}=k(l.duration);r=D(f,l.from,t.utcOffset()),c=r.clone().add(p,"hours").add(y,"minutes")}}else r=S(a,t);if(!e&&!r){const f=n.filter(p=>p.state&&u(p.periodTo).isAfter(t)),[l]=f.sort((p,y)=>o.valueOf()-(u(p.periodTo).valueOf()-u(y.periodTo).valueOf()));if(l)return x(n,e,u(l.periodTo),o)}return{closingTime:c,openingTime:r,openDuringSpecifiedTime:m,openNow:s}}exports.DaysOfWeekMap=O;exports.default=x;
@@ -1,6 +1,6 @@
1
1
  import { IntervalType as g } from "@ancon/wildcat-types";
2
2
  import v from "moment";
3
- import m from "../date/createLocalTimezoneMoment.mjs";
3
+ import f from "../date/createLocalTimezoneMoment.mjs";
4
4
  import M from "../time/getTimeSpanParts.mjs";
5
5
  import { OutletMapKeyFormatter as d, OutletTimelineDayCount as k } from "./constants.mjs";
6
6
  import O from "./getOutletCurrentActiveOperatingHour.mjs";
@@ -19,14 +19,14 @@ const x = {
19
19
  // WEEKENDS: 96,
20
20
  };
21
21
  function I(n, e) {
22
- const o = n.isSame(e, "d"), a = {
22
+ const t = n.isSame(e, "d"), a = {
23
23
  [e.format(d)]: {
24
24
  intervals: [],
25
25
  exception: null,
26
26
  metadata: { dayOfWeek: x[e.isoWeekday()] }
27
27
  }
28
28
  };
29
- for (let s = o ? 1 : 0; s < k; s += 1) {
29
+ for (let s = t ? 1 : 0; s < k; s += 1) {
30
30
  const i = v(n).add(s, "d");
31
31
  a[i.format(d)] = {
32
32
  intervals: [],
@@ -36,79 +36,80 @@ function I(n, e) {
36
36
  }
37
37
  return a;
38
38
  }
39
- function T(n, e) {
40
- const o = m(e.periodFrom), t = m(e.periodTo);
41
- if (!o.isSame(
42
- t,
39
+ function W(n, e) {
40
+ const t = f(e.periodFrom), o = f(e.periodTo);
41
+ if (!t.isSame(
42
+ o,
43
43
  "d"
44
44
  ))
45
45
  Object.keys(n).forEach((s) => {
46
46
  const i = v(s);
47
- if (i.isSame(o, "d") || i.isSame(t, "d") || i.isBetween(o, t)) {
47
+ if (i.isSame(t, "d") || i.isSame(o, "d") || i.isBetween(t, o)) {
48
48
  const p = n[s], r = p.exception ? p.exception.position : 0;
49
49
  e.position > r && (p.exception = e);
50
50
  }
51
51
  });
52
52
  else {
53
- const s = o.format(d), i = n[s];
53
+ const s = t.format(d), i = n[s];
54
54
  if (i) {
55
55
  const u = i.exception ? i.exception.position : 0;
56
56
  e.position > u && (i.exception = e);
57
57
  }
58
58
  }
59
59
  }
60
- function W(n, e) {
61
- Object.keys(n).forEach((o) => {
62
- const t = n[o], { dayOfWeek: a } = t.metadata, { dayOfWeek: s } = e;
63
- (a & s) === a && t.intervals.push(e);
60
+ function E(n, e) {
61
+ Object.keys(n).forEach((t) => {
62
+ const o = n[t], { dayOfWeek: a } = o.metadata, { dayOfWeek: s } = e;
63
+ (a & s) === a && o.intervals.push(e);
64
64
  });
65
65
  }
66
- function E(n, e, o) {
67
- const t = I(e, o);
66
+ function T(n, e, t) {
67
+ const o = I(e, t);
68
68
  return n.forEach((a) => {
69
- a.type === g.Exception ? T(t, a) : W(t, a);
70
- }), t;
69
+ a.type === g.Exception ? W(o, a) : E(o, a);
70
+ }), o;
71
71
  }
72
- function h(n, e, o, t) {
73
- const a = E(
72
+ function h(n, e, t, o) {
73
+ const a = T(
74
74
  n,
75
- o,
76
- t
77
- ), s = t.format(d), i = O(
75
+ t,
76
+ o
77
+ ), s = o.format(d), i = O(
78
78
  s,
79
79
  a[s],
80
- t
80
+ o
81
81
  ) !== null, u = e;
82
82
  let p = null, r = null;
83
83
  if (e) {
84
- const f = o.format(d), c = O(
85
- f,
86
- a[f],
87
- o
84
+ const m = t.format(d), c = O(
85
+ m,
86
+ a[m],
87
+ t
88
88
  );
89
89
  if (c) {
90
90
  const { hours: l, minutes: y } = M(
91
91
  c.duration
92
92
  );
93
93
  r = D(
94
- f,
95
- c.from
94
+ m,
95
+ c.from,
96
+ t.utcOffset()
96
97
  ), p = r.clone().add(l, "hours").add(y, "minutes");
97
98
  }
98
99
  } else
99
- r = S(a, o);
100
+ r = S(a, t);
100
101
  if (!e && !r) {
101
- const f = n.filter(
102
- (l) => l.state && m(l.periodTo).isAfter(o)
103
- ), [c] = f.sort(
104
- (l, y) => t.valueOf() - (m(l.periodTo).valueOf() - m(y.periodTo).valueOf())
102
+ const m = n.filter(
103
+ (l) => l.state && f(l.periodTo).isAfter(t)
104
+ ), [c] = m.sort(
105
+ (l, y) => o.valueOf() - (f(l.periodTo).valueOf() - f(y.periodTo).valueOf())
105
106
  );
106
107
  if (c)
107
108
  return h(
108
109
  n,
109
110
  e,
110
- m(c.periodTo),
111
- t
111
+ f(c.periodTo),
112
+ o
112
113
  );
113
114
  }
114
115
  return { closingTime: p, openingTime: r, openDuringSpecifiedTime: u, openNow: i };
@@ -1 +1 @@
1
- "use strict";const m=require("moment"),y=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),f=require("./constants.js"),u=require("./getServiceIntervalTimeSpanMoment.js");function g(i,n){const e=i.clone().date()-n.date();return e!==0?i.subtract(e,"day"):i}function p(i){let n=null;const{intervals:t,exception:e}=i;if(e){const{state:r}=e;r||(n=e)}else{const r=t.sort((o,s)=>O(o.from).hours-O(s.from).hours),[l]=r;return l}return n}function d(i,n,t){var r,l;const e=[];if(n.exception){if(n.exception.state===y.IntervalState.Opened){const o=u(i,n.exception.from,t.utcOffset());t.isBefore(o)&&e.push({interval:n.exception,moment:o})}}else for(let o=0;o<n.intervals.length;o+=1){const s=n.intervals[o],c=u(i,s.from,t.utcOffset());console.log("relevantMoment",t.format()),console.log("openingMoment",c.format()),t.isBefore(c)&&e.push({interval:s,moment:c})}return e.length<2?((r=e[0])==null?void 0:r.interval)??null:((l=e.sort((o,s)=>o.moment-t-(s.moment-t))[0])==null?void 0:l.interval)??null}function h(i,n){let t=null;const e=m(n).format(f.OutletMapKeyFormatter),r=d(e,i[e],n);if(r&&(t=u(e,r.from)),!t)for(let l=1;l<f.OutletTimelineDayCount;l+=1){const o=m(n).add(l,"d"),s=o.format(f.OutletMapKeyFormatter),c=i[s],a=p(c);if(a){t=u(s,a.from),t=g(t,o);break}}return t}module.exports=h;
1
+ "use strict";const m=require("moment"),y=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),u=require("./constants.js"),c=require("./getServiceIntervalTimeSpanMoment.js");function g(i,e){const n=i.clone().date()-e.date();return n!==0?i.subtract(n,"day"):i}function p(i){let e=null;const{intervals:t,exception:n}=i;if(n){const{state:r}=n;r||(e=n)}else{const r=t.sort((o,s)=>O(o.from).hours-O(s.from).hours),[l]=r;return l}return e}function d(i,e,t){var r,l;const n=[];if(e.exception){if(e.exception.state===y.IntervalState.Opened){const o=c(i,e.exception.from,t.utcOffset());t.isBefore(o)&&n.push({interval:e.exception,moment:o})}}else for(let o=0;o<e.intervals.length;o+=1){const s=e.intervals[o],f=c(i,s.from,t.utcOffset());console.log("relevantMoment",t.format()),console.log("openingMoment",f.format()),t.isBefore(f)&&n.push({interval:s,moment:f})}return n.length<2?((r=n[0])==null?void 0:r.interval)??null:((l=n.sort((o,s)=>o.moment-t-(s.moment-t))[0])==null?void 0:l.interval)??null}function h(i,e){let t=null;const n=m(e).format(u.OutletMapKeyFormatter),r=d(n,i[n],e);if(r&&(t=c(n,r.from,e.utcOffset())),!t)for(let l=1;l<u.OutletTimelineDayCount;l+=1){const o=m(e).add(l,"d"),s=o.format(u.OutletMapKeyFormatter),f=i[s],a=p(f);if(a){t=c(s,a.from,o.utcOffset()),t=g(t,o);break}}return t}module.exports=h;
@@ -1,72 +1,74 @@
1
- import m from "moment";
1
+ import a from "moment";
2
2
  import { IntervalState as p } from "@ancon/wildcat-types";
3
- import u from "../time/getTimeSpanParts.mjs";
3
+ import m from "../time/getTimeSpanParts.mjs";
4
4
  import { OutletMapKeyFormatter as O, OutletTimelineDayCount as g } from "./constants.mjs";
5
- import a from "./getServiceIntervalTimeSpanMoment.mjs";
6
- function y(i, n) {
7
- const e = i.clone().date() - n.date();
8
- return e !== 0 ? i.subtract(e, "day") : i;
5
+ import c from "./getServiceIntervalTimeSpanMoment.mjs";
6
+ function y(i, e) {
7
+ const n = i.clone().date() - e.date();
8
+ return n !== 0 ? i.subtract(n, "day") : i;
9
9
  }
10
10
  function d(i) {
11
- let n = null;
12
- const { intervals: t, exception: e } = i;
13
- if (e) {
14
- const { state: r } = e;
15
- r || (n = e);
11
+ let e = null;
12
+ const { intervals: t, exception: n } = i;
13
+ if (n) {
14
+ const { state: r } = n;
15
+ r || (e = n);
16
16
  } else {
17
17
  const r = t.sort(
18
- (o, f) => u(o.from).hours - u(f.from).hours
18
+ (o, f) => m(o.from).hours - m(f.from).hours
19
19
  ), [s] = r;
20
20
  return s;
21
21
  }
22
- return n;
22
+ return e;
23
23
  }
24
- function h(i, n, t) {
24
+ function h(i, e, t) {
25
25
  var r, s;
26
- const e = [];
27
- if (n.exception) {
28
- if (n.exception.state === p.Opened) {
29
- const o = a(
26
+ const n = [];
27
+ if (e.exception) {
28
+ if (e.exception.state === p.Opened) {
29
+ const o = c(
30
30
  i,
31
- n.exception.from,
31
+ e.exception.from,
32
32
  t.utcOffset()
33
33
  );
34
- t.isBefore(o) && e.push({
35
- interval: n.exception,
34
+ t.isBefore(o) && n.push({
35
+ interval: e.exception,
36
36
  moment: o
37
37
  });
38
38
  }
39
39
  } else
40
- for (let o = 0; o < n.intervals.length; o += 1) {
41
- const f = n.intervals[o], l = a(
40
+ for (let o = 0; o < e.intervals.length; o += 1) {
41
+ const f = e.intervals[o], l = c(
42
42
  i,
43
43
  f.from,
44
44
  t.utcOffset()
45
45
  );
46
- console.log("relevantMoment", t.format()), console.log("openingMoment", l.format()), t.isBefore(l) && e.push({ interval: f, moment: l });
46
+ console.log("relevantMoment", t.format()), console.log("openingMoment", l.format()), t.isBefore(l) && n.push({ interval: f, moment: l });
47
47
  }
48
- return e.length < 2 ? ((r = e[0]) == null ? void 0 : r.interval) ?? null : ((s = e.sort(
48
+ return n.length < 2 ? ((r = n[0]) == null ? void 0 : r.interval) ?? null : ((s = n.sort(
49
49
  // @ts-ignore TODO
50
50
  (o, f) => o.moment - t - (f.moment - t)
51
51
  )[0]) == null ? void 0 : s.interval) ?? null;
52
52
  }
53
- function S(i, n) {
53
+ function S(i, e) {
54
54
  let t = null;
55
- const e = m(n).format(O), r = h(
56
- e,
57
- i[e],
58
- n
55
+ const n = a(e).format(O), r = h(
56
+ n,
57
+ i[n],
58
+ e
59
59
  );
60
- if (r && (t = a(
61
- e,
62
- r.from
60
+ if (r && (t = c(
61
+ n,
62
+ r.from,
63
+ e.utcOffset()
63
64
  )), !t)
64
65
  for (let s = 1; s < g; s += 1) {
65
- const o = m(n).add(s, "d"), f = o.format(O), l = i[f], c = d(l);
66
- if (c) {
67
- t = a(
66
+ const o = a(e).add(s, "d"), f = o.format(O), l = i[f], u = d(l);
67
+ if (u) {
68
+ t = c(
68
69
  f,
69
- c.from
70
+ u.from,
71
+ o.utcOffset()
70
72
  ), t = y(t, o);
71
73
  break;
72
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.44.0-r13-2-tz.20",
3
+ "version": "1.44.0-r13-2-tz.21",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",