@ancon/wildcat-utils 1.44.0-r13-2-tz.8 → 1.44.0-r13-2-tz.10

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 q=require("@ancon/wildcat-types"),r=require("moment"),u=require("./getSettingsForOrderFormat.js"),T=require("./isOutletAcceptingPreOrders.js"),v=require("./getOutletTagInformation.js"),x=require("./getNextTenthMinute.js"),_=require("./getServiceIntervalsForOrderFormat.js"),I=require("./getOutletNextServiceTimeOffset.js");require("../date/createLocalTimezoneMoment.js");require("../time/getTimeSpanParts.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getServiceIntervalTimeSpanMoment.js");require("./searchNextOpeningMoment.js");function S(e,i){const s=(e==null?void 0:e.state)===q.OutletState.Opened,t=u(i,e==null?void 0:e.orderFormatSettings),m=(t==null?void 0:t.preparationTime)??"00:00:00",O=T((e==null?void 0:e.orderFormatSettings)||[]),f=_(i,(e==null?void 0:e.serviceDateTimes)||[]),c=v.default(f,s,r(),r()),p=!s&&O&&c.openingTime?c.openingTime:void 0,o=r(),a=r(p),n=(o>a?o:a).second(0).millisecond(0),d=I(i,m,e==null?void 0:e.deliveryIntegrationEnabled);d>0&&n.add(d,"minute");const g=x(n)-n.minutes();return g&&n.add(g,"minutes"),n}module.exports=S;
1
+ "use strict";const q=require("@ancon/wildcat-types"),r=require("moment"),u=require("./getSettingsForOrderFormat.js"),T=require("./isOutletAcceptingPreOrders.js"),v=require("./getOutletTagInformation.js"),x=require("./getNextTenthMinute.js"),_=require("./getServiceIntervalsForOrderFormat.js"),I=require("./getOutletNextServiceTimeOffset.js");require("../date/createLocalTimezoneMoment.js");require("../time/getTimeSpanParts.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getServiceIntervalTimeSpanMoment.js");require("./searchNextOpeningMoment.js");function S(e,i){const s=(e==null?void 0:e.state)===q.OutletState.Opened,t=u(i,e==null?void 0:e.orderFormatSettings),d=(t==null?void 0:t.preparationTime)??"00:00:00",f=T((e==null?void 0:e.orderFormatSettings)||[]),O=_(i,(e==null?void 0:e.serviceDateTimes)||[]),o=v.default(O,s,r(),r()),p=!s&&f&&o.openingTime?o.openingTime:void 0,c=r(),a=r(p),n=(c>a?c:a).second(0).millisecond(0),g=I(i,d,e==null?void 0:e.deliveryIntegrationEnabled);g>0&&n.add(g,"minute"),console.log("=> before",n.format());const m=x(n)-n.minutes();return console.log("=> after",n.format()),m&&n.add(m,"minutes"),n}module.exports=S;
@@ -12,28 +12,28 @@ import "./constants.mjs";
12
12
  import "./getOutletCurrentActiveOperatingHour.mjs";
13
13
  import "./getServiceIntervalTimeSpanMoment.mjs";
14
14
  import "./searchNextOpeningMoment.mjs";
15
- function z(n, r) {
16
- const m = (n == null ? void 0 : n.state) === T.Opened, t = v(
15
+ function z(e, r) {
16
+ const o = (e == null ? void 0 : e.state) === T.Opened, t = v(
17
17
  r,
18
- n == null ? void 0 : n.orderFormatSettings
19
- ), f = (t == null ? void 0 : t.preparationTime) ?? "00:00:00", d = x(
20
- (n == null ? void 0 : n.orderFormatSettings) || []
21
- ), g = y(
18
+ e == null ? void 0 : e.orderFormatSettings
19
+ ), c = (t == null ? void 0 : t.preparationTime) ?? "00:00:00", g = x(
20
+ (e == null ? void 0 : e.orderFormatSettings) || []
21
+ ), d = y(
22
22
  r,
23
- (n == null ? void 0 : n.serviceDateTimes) || []
24
- ), s = I(
25
- g,
26
- m,
23
+ (e == null ? void 0 : e.serviceDateTimes) || []
24
+ ), m = I(
25
+ d,
26
+ o,
27
27
  i(),
28
28
  i()
29
- ), O = !m && d && s.openingTime ? s.openingTime : void 0, o = i(), p = i(O), e = (o > p ? o : p).second(0).millisecond(0), a = F(
29
+ ), O = !o && g && m.openingTime ? m.openingTime : void 0, s = i(), p = i(O), n = (s > p ? s : p).second(0).millisecond(0), f = F(
30
30
  r,
31
- f,
32
- n == null ? void 0 : n.deliveryIntegrationEnabled
31
+ c,
32
+ e == null ? void 0 : e.deliveryIntegrationEnabled
33
33
  );
34
- a > 0 && e.add(a, "minute");
35
- const c = S(e) - e.minutes();
36
- return c && e.add(c, "minutes"), e;
34
+ f > 0 && n.add(f, "minute"), console.log("=> before", n.format());
35
+ const a = S(n) - n.minutes();
36
+ return console.log("=> after", n.format()), a && n.add(a, "minutes"), n;
37
37
  }
38
38
  export {
39
39
  z as default
@@ -1 +1 @@
1
- "use strict";const m=require("moment"),y=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),c=require("./constants.js"),a=require("./getServiceIntervalTimeSpanMoment.js");function p(i,e){const t=i.clone().date()-e.date();return t!==0?i.subtract(t,"day"):i}function d(i){let e=null;const{intervals:n,exception:t}=i;if(t){const{state:r}=t;r||(e=t)}else{const r=n.sort((o,s)=>O(o.from).hours-O(s.from).hours),[l]=r;return l}return e}function g(i,e,n){var r,l;const t=[];if(e.exception){if(e.exception.state===y.IntervalState.Opened){const o=a(i,e.exception.from);n.isBefore(o)&&t.push({interval:e.exception,moment:o})}}else for(let o=0;o<e.intervals.length;o+=1){const s=e.intervals[o],u=a(i,s.from);n.isBefore(u)&&t.push({interval:s,moment:u})}return t.length<2?((r=t[0])==null?void 0:r.interval)??null:((l=t.sort((o,s)=>o.moment-n-(s.moment-n))[0])==null?void 0:l.interval)??null}function h(i,e){let n=null;const t=m(e).format(c.OutletMapKeyFormatter),r=g(t,i[t],e);if(r&&(n=a(t,r.from)),!n)for(let l=1;l<c.OutletTimelineDayCount;l+=1){const o=m(e).add(l,"d"),s=o.format(c.OutletMapKeyFormatter),u=i[s],f=d(u);if(f){n=a(s,f.from),n=p(n,o);break}}return n}module.exports=h;
1
+ "use strict";const m=require("moment"),y=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),a=require("./constants.js"),u=require("./getServiceIntervalTimeSpanMoment.js");function g(r,e){const t=r.clone().date()-e.date();return t!==0?r.subtract(t,"day"):r}function p(r){let e=null;const{intervals:n,exception:t}=r;if(t){const{state:i}=t;i||(e=t)}else{const i=n.sort((o,s)=>O(o.from).hours-O(s.from).hours),[l]=i;return l}return e}function d(r,e,n){var i,l;const t=[];if(e.exception){if(e.exception.state===y.IntervalState.Opened){const o=u(r,e.exception.from);console.log("relevantMoment",n.format()),console.log("openingMoment",o.format()),n.clone().utc(!0).isBefore(o.clone().utc(!0))&&t.push({interval:e.exception,moment:o})}}else for(let o=0;o<e.intervals.length;o+=1){const s=e.intervals[o],c=u(r,s.from);n.isBefore(c)&&t.push({interval:s,moment:c})}return t.length<2?((i=t[0])==null?void 0:i.interval)??null:((l=t.sort((o,s)=>o.moment-n-(s.moment-n))[0])==null?void 0:l.interval)??null}function h(r,e){let n=null;const t=m(e).format(a.OutletMapKeyFormatter),i=d(t,r[t],e);if(i&&(n=u(t,i.from)),!n)for(let l=1;l<a.OutletTimelineDayCount;l+=1){const o=m(e).add(l,"d"),s=o.format(a.OutletMapKeyFormatter),c=r[s],f=p(c);if(f){n=u(s,f.from),n=g(n,o);break}}return n}module.exports=h;
@@ -1,36 +1,36 @@
1
- import u from "moment";
1
+ import m from "moment";
2
2
  import { IntervalState as p } from "@ancon/wildcat-types";
3
- import c from "../time/getTimeSpanParts.mjs";
4
- import { OutletMapKeyFormatter as O, OutletTimelineDayCount as y } from "./constants.mjs";
3
+ import u from "../time/getTimeSpanParts.mjs";
4
+ import { OutletMapKeyFormatter as O, OutletTimelineDayCount as g } from "./constants.mjs";
5
5
  import a from "./getServiceIntervalTimeSpanMoment.mjs";
6
- function d(i, e) {
7
- const t = i.clone().date() - e.date();
8
- return t !== 0 ? i.subtract(t, "day") : i;
6
+ function y(r, e) {
7
+ const t = r.clone().date() - e.date();
8
+ return t !== 0 ? r.subtract(t, "day") : r;
9
9
  }
10
- function g(i) {
10
+ function d(r) {
11
11
  let e = null;
12
- const { intervals: n, exception: t } = i;
12
+ const { intervals: n, exception: t } = r;
13
13
  if (t) {
14
- const { state: r } = t;
15
- r || (e = t);
14
+ const { state: i } = t;
15
+ i || (e = t);
16
16
  } else {
17
- const r = n.sort(
18
- (o, l) => c(o.from).hours - c(l.from).hours
19
- ), [s] = r;
17
+ const i = n.sort(
18
+ (o, l) => u(o.from).hours - u(l.from).hours
19
+ ), [s] = i;
20
20
  return s;
21
21
  }
22
22
  return e;
23
23
  }
24
- function h(i, e, n) {
25
- var r, s;
24
+ function h(r, e, n) {
25
+ var i, s;
26
26
  const t = [];
27
27
  if (e.exception) {
28
28
  if (e.exception.state === p.Opened) {
29
29
  const o = a(
30
- i,
30
+ r,
31
31
  e.exception.from
32
32
  );
33
- n.isBefore(o) && t.push({
33
+ console.log("relevantMoment", n.format()), console.log("openingMoment", o.format()), n.clone().utc(!0).isBefore(o.clone().utc(!0)) && t.push({
34
34
  interval: e.exception,
35
35
  moment: o
36
36
  });
@@ -38,34 +38,34 @@ function h(i, e, n) {
38
38
  } else
39
39
  for (let o = 0; o < e.intervals.length; o += 1) {
40
40
  const l = e.intervals[o], f = a(
41
- i,
41
+ r,
42
42
  l.from
43
43
  );
44
44
  n.isBefore(f) && t.push({ interval: l, moment: f });
45
45
  }
46
- return t.length < 2 ? ((r = t[0]) == null ? void 0 : r.interval) ?? null : ((s = t.sort(
46
+ return t.length < 2 ? ((i = t[0]) == null ? void 0 : i.interval) ?? null : ((s = t.sort(
47
47
  // @ts-ignore TODO
48
48
  (o, l) => o.moment - n - (l.moment - n)
49
49
  )[0]) == null ? void 0 : s.interval) ?? null;
50
50
  }
51
- function S(i, e) {
51
+ function S(r, e) {
52
52
  let n = null;
53
- const t = u(e).format(O), r = h(
53
+ const t = m(e).format(O), i = h(
54
54
  t,
55
- i[t],
55
+ r[t],
56
56
  e
57
57
  );
58
- if (r && (n = a(
58
+ if (i && (n = a(
59
59
  t,
60
- r.from
60
+ i.from
61
61
  )), !n)
62
- for (let s = 1; s < y; s += 1) {
63
- const o = u(e).add(s, "d"), l = o.format(O), f = i[l], m = g(f);
64
- if (m) {
62
+ for (let s = 1; s < g; s += 1) {
63
+ const o = m(e).add(s, "d"), l = o.format(O), f = r[l], c = d(f);
64
+ if (c) {
65
65
  n = a(
66
66
  l,
67
- m.from
68
- ), n = d(n, o);
67
+ c.from
68
+ ), n = y(n, o);
69
69
  break;
70
70
  }
71
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.44.0-r13-2-tz.8",
3
+ "version": "1.44.0-r13-2-tz.10",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",