magtool 1.5.10 → 1.5.12

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,42 +1,52 @@
1
- const $ = (n) => new Promise((p, l) => {
2
- const i = new Image();
3
- i.src = window.$getType(n) === "String" ? n : URL.createObjectURL(n), i.onload = () => p(i), i.onerror = () => l(new Error("Could not load image"));
4
- }), C = ({ columns: n, data: p, currency: l = "", channel: i = "" }) => {
5
- if (!p.length || !n.length)
1
+ const g = (n) => new Promise((l, p) => {
2
+ const s = new Image();
3
+ s.src = window.$getType(n) === "String" ? n : URL.createObjectURL(n), s.onload = () => l(s), s.onerror = () => p(new Error("Could not load image"));
4
+ }), $ = ({ type: n = "csv", data: l, name: p }) => {
5
+ let s = document.createElement("a");
6
+ if (n === "csv") {
7
+ const a = new Blob(["\uFEFF" + l], {
8
+ type: "text/csv,charset=UTF-8"
9
+ });
10
+ s.href = URL.createObjectURL(a);
11
+ }
12
+ let t = new MouseEvent("click");
13
+ s.download = p || "download", s.dispatchEvent(t), (n === "csv" || n === "video") && URL.revokeObjectURL(s.url), s = null, t = null;
14
+ }, C = ({ columns: n, data: l, currency: p = "", channel: s = "" }) => {
15
+ if (!l.length || !n.length)
6
16
  return [];
7
- const o = {
17
+ const t = {
8
18
  spend: {
9
19
  prop: "spend",
10
- prefix: l,
11
- format: (t) => window.$fa(t, 2)
20
+ prefix: p,
21
+ format: (o) => window.$fa(o, 2)
12
22
  },
13
23
  taps: {
14
24
  prop: "taps",
15
- format: (t) => window.$fa(t, 0)
25
+ format: (o) => window.$fa(o, 0)
16
26
  },
17
27
  installs: {
18
28
  prop: "installs",
19
- format: (t) => window.$fa(t, 0)
29
+ format: (o) => window.$fa(o, 0)
20
30
  },
21
31
  impressions: {
22
32
  prop: "impressions",
23
- format: (t) => window.$fa(t, 0)
33
+ format: (o) => window.$fa(o, 0)
24
34
  },
25
35
  mmpInstalls: {
26
36
  prop: "mmpInstalls",
27
- format: (t) => window.$fa(t, 0)
37
+ format: (o) => window.$fa(o, 0)
28
38
  },
29
39
  mmpCPI: {
30
40
  prop: "mmpCPI",
31
- format: (t) => window.$fa(t, 2)
41
+ format: (o) => window.$fa(o, 2)
32
42
  },
33
43
  IPM: {
34
44
  prop: "IPM",
35
- format: (t) => window.$fa(t, 2)
45
+ format: (o) => window.$fa(o, 2)
36
46
  },
37
47
  revenue: {
38
48
  prop: "revenue",
39
- format: (t) => window.$fa(t, 2)
49
+ format: (o) => window.$fa(o, 2)
40
50
  }
41
51
  }, a = [], r = {
42
52
  avgCPT: {},
@@ -48,36 +58,37 @@ const $ = (n) => new Promise((p, l) => {
48
58
  mmpInstalls: {},
49
59
  mmpCPI: {}
50
60
  };
51
- n.forEach((t, s) => {
52
- r[t.property] && (r[t.property].i = s);
53
- const m = o[t.property];
54
- if (m) {
55
- m.i = s;
56
- let e = window.$bigNumber(0);
57
- p.forEach((g) => {
58
- e = e.plus(g[t.property] || 0);
59
- }), e = e.toNumber(), m.total = e, a.push(e);
61
+ n.forEach((o, e) => {
62
+ r[o.property] && (r[o.property].i = e);
63
+ const c = t[o.property];
64
+ if (c) {
65
+ c.i = e;
66
+ let i = window.$bn(0);
67
+ l.forEach((v) => {
68
+ i = i.plus(v[o.property] || 0);
69
+ }), i = i.toNumber(), c.total = i, a.push(i);
60
70
  } else
61
71
  a.push("");
62
- }), Object.keys(o).forEach((t) => {
63
- const s = o[t];
64
- s.format && a[s.i] && (a[s.i] = s.format(a[s.i]));
72
+ }), Object.keys(t).forEach((o) => {
73
+ const e = t[o];
74
+ e.format && a[e.i] && (a[e.i] = e.format(a[e.i]));
65
75
  });
66
- const w = o.taps.total ? window.$fa(o.spend.total / o.taps.total) : "0.00";
67
- a[r.avgCPT.i] = w;
68
- const f = o.installs.total ? window.$fa(o.spend.total / o.installs.total) : "0.00";
76
+ const m = t.taps.total ? window.$fa(t.spend.total / t.taps.total) : "0.00";
77
+ a[r.avgCPT.i] = m;
78
+ const f = t.installs.total ? window.$fa(t.spend.total / t.installs.total) : "0.00";
69
79
  if (a[r.avgCPA.i] = f, r.avgCPM.i !== void 0) {
70
- const t = o.impressions.total ? window.$fa(o.spend.total / (o.impressions.total / 1e3)) : "0.00";
71
- a[r.avgCPM.i] = t;
80
+ const o = t.impressions.total ? window.$fa(t.spend.total / (t.impressions.total / 1e3)) : "0.00";
81
+ a[r.avgCPM.i] = o;
72
82
  }
73
- const c = o.taps.total ? window.$fa(o.installs.total / o.taps.total * 100) : "0.00";
74
- a[r.cr.i] = c;
75
- const d = o.impressions.total ? window.$fa(o.taps.total / o.impressions.total * 100) : "0.00";
83
+ const w = t.taps.total ? window.$fa(t.installs.total / t.taps.total * 100) : "0.00";
84
+ a[r.cr.i] = w;
85
+ const d = t.impressions.total ? window.$fa(t.taps.total / t.impressions.total * 100) : "0.00";
76
86
  a[r.ttr.i] = d;
77
- const u = o.impressions.total ? window.$fa(o.installs.total * 1e3 / o.impressions.total) : "0.00";
87
+ const u = t.impressions.total ? window.$fa(t.installs.total * 1e3 / t.impressions.total) : "0.00";
78
88
  return a[r.IPM.i] = u, a;
79
89
  };
80
90
  export {
81
- $ as l,
91
+ $ as d,
92
+ g as l,
82
93
  C as u
83
94
  };