@ancon/wildcat-utils 1.44.0-r13-2-tz.30 → 1.44.0-r13-2-tz.32

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