magtool 1.0.1 → 1.0.2

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.
package/dist/cps.js ADDED
@@ -0,0 +1,192 @@
1
+ const y = (e) => {
2
+ const { age: o } = e || {};
3
+ let l, n;
4
+ if (o != null && o.included) {
5
+ const { minAge: t, maxAge: r } = o.included[0] || {};
6
+ t ? l = t : l = "all", r ? n = r : n = "all";
7
+ }
8
+ return n === "all" ? l === "all" ? "All" : `${l}~65+` : `${l}~${n}`;
9
+ }, h = (e, o) => e === "all" ? null : o === 65 ? {
10
+ included: [
11
+ {
12
+ minAge: e
13
+ }
14
+ ]
15
+ } : {
16
+ included: [
17
+ {
18
+ minAge: e,
19
+ maxAge: o
20
+ }
21
+ ]
22
+ }, j = (e) => {
23
+ const { gender: o } = e || {};
24
+ return o != null && o.included ? o.included[0] : null;
25
+ }, $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
+ __proto__: null,
27
+ useAgeFormat: y,
28
+ useAgeValue: h,
29
+ useGenderFormat: j
30
+ }, Symbol.toStringTag, { value: "Module" })), P = (e) => new Promise((o, l) => {
31
+ const n = new Image();
32
+ n.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), n.onload = () => o(n), n.onerror = () => l(new Error("Could not load image"));
33
+ }), C = (e) => new Promise((o, l) => {
34
+ const n = document.createElement("video");
35
+ n.preload = "metadata", window.$getType(e) === "String" ? n.src = e : n.src = URL.createObjectURL(e), n.onloadedmetadata = () => {
36
+ window.URL.revokeObjectURL(e), console.info([n]), o(n);
37
+ };
38
+ }), S = ({ type: e = "csv", data: o, name: l }) => {
39
+ let n = document.createElement("a");
40
+ if (e === "csv") {
41
+ const r = new Blob(["\uFEFF" + o], {
42
+ type: "text/csv,charset=UTF-8"
43
+ });
44
+ n.href = URL.createObjectURL(r);
45
+ }
46
+ let t = new MouseEvent("click");
47
+ n.download = l || "download", n.dispatchEvent(t), (e === "csv" || e === "video") && URL.revokeObjectURL(n.url), n = null, t = null;
48
+ }, M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49
+ __proto__: null,
50
+ download: S,
51
+ loadImage: P,
52
+ loadVideo: C
53
+ }, Symbol.toStringTag, { value: "Module" })), O = ({ table: e, key: o, form: l, value: n, cb: t = () => {
54
+ } }) => {
55
+ const r = e.getSelectionRows();
56
+ r.length > 1 ? (e.clearSelection(), e.toggleRowSelection(r[1], "selected"), l[n] = r[1][o]) : r.length === 1 && (l[n] = r[0][o]), t();
57
+ }, R = (e = {}) => {
58
+ let { sortable: o = !0, empty: l = !1, mmp: n = !1 } = e, t = window.$map.asa.asaMetric.all;
59
+ n && (t = t.concat(window.$map.asa.mmpMetric.all));
60
+ const r = t.map((a, f) => ({
61
+ label: a.label,
62
+ prop: a.value,
63
+ width: a.width,
64
+ sortable: o,
65
+ type: a.type,
66
+ align: a.align,
67
+ visible: a.visible,
68
+ formatter: a.formatter
69
+ }));
70
+ return r.unshift({
71
+ label: "Currency",
72
+ prop: "currency",
73
+ width: 80,
74
+ align: "right"
75
+ }), r;
76
+ }, A = () => ({
77
+ label: "-"
78
+ }), I = ({ columns: e, data: o, currency: l = "", channel: n = "" }) => {
79
+ if (!o.length || !e.length)
80
+ return [];
81
+ const t = {
82
+ spend: {
83
+ prop: "spend",
84
+ prefix: l,
85
+ format: (s) => window.$fa(s, 2)
86
+ },
87
+ taps: {
88
+ prop: "taps",
89
+ format: (s) => window.$fa(s, 0)
90
+ },
91
+ installs: {
92
+ prop: "installs",
93
+ format: (s) => window.$fa(s, 0)
94
+ },
95
+ impressions: {
96
+ prop: "impressions",
97
+ format: (s) => window.$fa(s, 0)
98
+ },
99
+ mmpInstalls: {
100
+ prop: "mmpInstalls",
101
+ format: (s) => window.$fa(s, 0)
102
+ },
103
+ mmpCPI: {
104
+ prop: "mmpCPI",
105
+ format: (s) => window.$fa(s, 2)
106
+ },
107
+ IPM: {
108
+ prop: "IPM",
109
+ format: (s) => window.$fa(s, 2)
110
+ },
111
+ revenue: {
112
+ prop: "revenue",
113
+ format: (s) => window.$fa(s, 2)
114
+ }
115
+ }, r = [], a = {
116
+ avgCPT: {},
117
+ avgCPA: {},
118
+ avgCPM: {},
119
+ cr: {},
120
+ ttr: {},
121
+ IPM: {},
122
+ mmpInstalls: {},
123
+ mmpCPI: {}
124
+ };
125
+ e.forEach((s, i) => {
126
+ a[s.property] && (a[s.property].i = i);
127
+ const p = t[s.property];
128
+ if (p) {
129
+ p.i = i;
130
+ let c = window.$bigNumber(0);
131
+ o.forEach((_) => {
132
+ c = c.plus(_[s.property] || 0);
133
+ }), c = c.toNumber(), p.total = c, r.push(c);
134
+ } else
135
+ r.push("");
136
+ }), Object.keys(t).forEach((s) => {
137
+ const i = t[s];
138
+ i.format && r[i.i] && (r[i.i] = i.format(r[i.i]));
139
+ });
140
+ const m = t.taps.total ? window.$fa(t.spend.total / t.taps.total) : "0.00";
141
+ r[a.avgCPT.i] = m;
142
+ const w = t.installs.total ? window.$fa(t.spend.total / t.installs.total) : "0.00";
143
+ if (r[a.avgCPA.i] = w, a.avgCPM.i !== void 0) {
144
+ const s = t.impressions.total ? window.$fa(t.spend.total / (t.impressions.total / 1e3)) : "0.00";
145
+ r[a.avgCPM.i] = s;
146
+ }
147
+ const g = t.taps.total ? window.$fa(t.installs.total / t.taps.total * 100) : "0.00";
148
+ r[a.cr.i] = g;
149
+ const b = t.impressions.total ? window.$fa(t.taps.total / t.impressions.total * 100) : "0.00";
150
+ r[a.ttr.i] = b;
151
+ const v = t.impressions.total ? window.$fa(t.installs.total * 1e3 / t.impressions.total) : "0.00";
152
+ return r[a.IPM.i] = v, r;
153
+ }, T = (e) => {
154
+ const o = window.$map.asa.allMetric.obj;
155
+ return Object.keys(e).forEach((l) => {
156
+ const n = e[l];
157
+ o[l] && (e[`${l}Format`] = window.$fu({ prop: l, value: n, currency: !1, obj: o }));
158
+ }), e;
159
+ }, E = ({ columns: e, data: o }, l) => e.length && o.length ? e.map((t) => {
160
+ let r = l[t.property] === void 0 ? "" : l[t.property];
161
+ if (r !== "")
162
+ try {
163
+ r = window.$fa(r, window.$map.asa.allMetric.obj[t.property].precision);
164
+ } catch {
165
+ }
166
+ return r;
167
+ }) : [], U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
168
+ __proto__: null,
169
+ useColumn: R,
170
+ useEmptyColumn: A,
171
+ useFormat: T,
172
+ useRemoteSummary: E,
173
+ useSingleSelect: O,
174
+ useSummary: I
175
+ }, Symbol.toStringTag, { value: "Module" })), L = (e, o = 88) => {
176
+ const l = document.querySelector("html"), { scrollTop: n } = l, t = e.getBoundingClientRect();
177
+ l.scrollTo({
178
+ top: n + t.y - o,
179
+ behavior: "smooth"
180
+ });
181
+ }, k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
182
+ __proto__: null,
183
+ pageScrollTo: L
184
+ }, Symbol.toStringTag, { value: "Module" })), d = /* @__PURE__ */ Object.assign({ "./chip/ads.js": $, "./chip/media.js": M, "./chip/table.js": U, "./chip/tool.js": k });
185
+ let u = {};
186
+ Object.keys(d).forEach((e) => {
187
+ u = { ...u, ...d[e] };
188
+ });
189
+ const x = u;
190
+ export {
191
+ x as c
192
+ };
@@ -0,0 +1,23 @@
1
+ const c = (o) => {
2
+ o.directive("focus", {
3
+ mounted(t, i, m) {
4
+ let { value: e = 0, arg: d = "time" } = i;
5
+ if (e === null)
6
+ return;
7
+ let r = 100, l = 0;
8
+ d !== "time" ? l = e : r = Number(e);
9
+ const n = setTimeout(() => {
10
+ let u = t.querySelectorAll("input, textarea");
11
+ u[l].focus(), u[l].select(), clearTimeout(n);
12
+ }, r);
13
+ }
14
+ }), o.directive("pms", {
15
+ mounted(t, i, m) {
16
+ var e;
17
+ (e = i.value) != null && e.readonly && t.remove();
18
+ }
19
+ });
20
+ };
21
+ export {
22
+ c as d
23
+ };