@frak-labs/components 1.1.0-beta.d76e66ff → 1.1.0-beta.ea6cff28
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/cdn/{Banner.D-DIhGBs.js → Banner.DGYexiiS.js} +2 -2
- package/cdn/{ButtonShare.BXBkl-NK.js → ButtonShare.DFg0XCDd.js} +1 -1
- package/cdn/{ButtonWallet.BWpTwDnw.js → ButtonWallet.sGDvcAXt.js} +1 -1
- package/cdn/{GiftIcon.DabDdDcp.js → GiftIcon.C1uAOx7A.js} +1 -1
- package/cdn/{OpenInAppButton.DAGgrKRg.js → OpenInAppButton.CxLPpqFO.js} +1 -1
- package/cdn/PostPurchase.D6Mzbjtu.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/{defaults.DjBUlRT8.js → defaults.BEvoSiy5.js} +2 -2
- package/cdn/loader.js +6 -6
- package/cdn/rewards.B2smvfIs.js +1 -0
- package/cdn/useGlobalComponents.CqTI84Mw.js +1 -0
- package/cdn/useLightDomStyles.CKtA4k-_.js +1 -0
- package/cdn/useReward.CXgeQcsH.js +1 -0
- package/dist/banner.js +6 -6
- package/dist/buttonShare.js +4 -4
- package/dist/buttonWallet.js +1 -1
- package/dist/postPurchase.js +5 -5
- package/dist/rewards-Cxn-bgzC.js +293 -0
- package/dist/{useReward-Cg2wk8XI.js → useReward-BMYSGY-o.js} +2 -2
- package/package.json +3 -3
- package/cdn/PostPurchase.Cp4JWG5x.js +0 -89
- package/cdn/rewards.BaTam2j1.js +0 -1
- package/cdn/useGlobalComponents.4DaqvbCn.js +0 -1
- package/cdn/useLightDomStyles.DNP8gafA.js +0 -1
- package/cdn/useReward.Bi4Hs7kk.js +0 -1
- package/dist/rewards-CDS1CYlm.js +0 -241
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
//#region ../core/dist/getCurrencyAmountKey-hkn17KxN.js
|
|
2
|
+
const e = {
|
|
3
|
+
eur: `fr-FR`,
|
|
4
|
+
usd: `en-US`,
|
|
5
|
+
gbp: `en-GB`
|
|
6
|
+
};
|
|
7
|
+
function t(t) {
|
|
8
|
+
return t && t in e ? t : `eur`;
|
|
9
|
+
}
|
|
10
|
+
function n(t) {
|
|
11
|
+
return t ? e[t] ?? e.eur : e.eur;
|
|
12
|
+
}
|
|
13
|
+
function r(e, r) {
|
|
14
|
+
let i = n(r), a = t(r);
|
|
15
|
+
return e.toLocaleString(i, {
|
|
16
|
+
style: `currency`,
|
|
17
|
+
currency: a,
|
|
18
|
+
minimumFractionDigits: 0,
|
|
19
|
+
maximumFractionDigits: 2
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function i(e) {
|
|
23
|
+
return e.formatToParts(1.1).find((e) => e.type === `decimal`)?.value ?? `.`;
|
|
24
|
+
}
|
|
25
|
+
function a$1(e, r) {
|
|
26
|
+
let a = n(r), o = t(r), s = new Intl.NumberFormat(a, {
|
|
27
|
+
style: `currency`,
|
|
28
|
+
currency: o,
|
|
29
|
+
minimumFractionDigits: 0,
|
|
30
|
+
maximumFractionDigits: 2
|
|
31
|
+
}), c = s.formatToParts(e), l = ``, u = ``, d = ``, f = `suffix`, p = !1;
|
|
32
|
+
for (let e of c) switch (e.type) {
|
|
33
|
+
case `integer`:
|
|
34
|
+
case `group`:
|
|
35
|
+
l += e.value, p = !0;
|
|
36
|
+
break;
|
|
37
|
+
case `decimal`:
|
|
38
|
+
case `fraction`:
|
|
39
|
+
u += e.value;
|
|
40
|
+
break;
|
|
41
|
+
case `currency`:
|
|
42
|
+
d = e.value, f = p ? `suffix` : `prefix`;
|
|
43
|
+
break;
|
|
44
|
+
default: break;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
integer: l,
|
|
48
|
+
decimals: u || `${i(s)}00`,
|
|
49
|
+
unit: d,
|
|
50
|
+
unitPosition: f
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function o$1(e) {
|
|
54
|
+
return {
|
|
55
|
+
integer: String(e),
|
|
56
|
+
unit: `%`,
|
|
57
|
+
unitPosition: `suffix`
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function s$1(e) {
|
|
61
|
+
return e ? `${e}Amount` : `eurAmount`;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region ../core/dist/rewards.js
|
|
65
|
+
function a(e) {
|
|
66
|
+
return Array.isArray(e) ? e : e.conditions;
|
|
67
|
+
}
|
|
68
|
+
function o(e) {
|
|
69
|
+
if (typeof e == `number`) return e;
|
|
70
|
+
if (typeof e == `string` && e.trim() !== ``) {
|
|
71
|
+
let t = Number(e);
|
|
72
|
+
return Number.isFinite(t) ? t : void 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function s(e, t, n) {
|
|
76
|
+
let r = [];
|
|
77
|
+
for (let i of a(e)) {
|
|
78
|
+
if (`logic` in i) {
|
|
79
|
+
r.push(...s(i, t, n));
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (i.field === t && n.has(i.operator)) {
|
|
83
|
+
let e = o(i.value);
|
|
84
|
+
e != null && r.push(e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return r;
|
|
88
|
+
}
|
|
89
|
+
const c = /* @__PURE__ */ new Set([
|
|
90
|
+
`gt`,
|
|
91
|
+
`gte`,
|
|
92
|
+
`between`
|
|
93
|
+
]);
|
|
94
|
+
const l = /* @__PURE__ */ new Set([`gt`, `gte`]);
|
|
95
|
+
function u(e) {
|
|
96
|
+
let t = s(e, `purchase.amount`, c);
|
|
97
|
+
return t.length > 0 ? Math.min(...t) : void 0;
|
|
98
|
+
}
|
|
99
|
+
function d(e) {
|
|
100
|
+
let t = s(e, `time.timestamp`, l);
|
|
101
|
+
if (t.length !== 0) return /* @__PURE__ */ new Date(Math.min(...t) * 1e3);
|
|
102
|
+
}
|
|
103
|
+
function _(e, t) {
|
|
104
|
+
switch (e.payoutType) {
|
|
105
|
+
case `fixed`: return e.amount[t];
|
|
106
|
+
case `percentage`: return e.maxAmount?.[t] ?? 0;
|
|
107
|
+
case `tiered`: return e.tiers.reduce((e, n) => `amount` in n ? Math.max(e, n.amount[t]) : e, 0);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function v(e) {
|
|
111
|
+
return e.payoutType === `percentage` ? e.percent : e.payoutType === `tiered` ? e.tiers.reduce((e, t) => `percent` in t ? Math.max(e, t.percent) : e, 0) : 0;
|
|
112
|
+
}
|
|
113
|
+
function y(e, t) {
|
|
114
|
+
let n = _(e, t);
|
|
115
|
+
return n > 0 ? n : v(e) * 1e-6;
|
|
116
|
+
}
|
|
117
|
+
function x(n, r$1) {
|
|
118
|
+
let a = t(r$1), o = s$1(a);
|
|
119
|
+
switch (n.payoutType) {
|
|
120
|
+
case `fixed`: return r(Math.round(n.amount[o]), a);
|
|
121
|
+
case `percentage`: return `${n.percent} %`;
|
|
122
|
+
case `tiered`: {
|
|
123
|
+
let e = _(n, o);
|
|
124
|
+
if (e > 0) return r(Math.round(e), a);
|
|
125
|
+
let r$2 = v(n);
|
|
126
|
+
return r$2 > 0 ? `${r$2} %` : r(0, a);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function S(t$1, a) {
|
|
131
|
+
let o = t(a), s = s$1(o);
|
|
132
|
+
switch (t$1.payoutType) {
|
|
133
|
+
case `fixed`: return a$1(Math.round(t$1.amount[s]), o);
|
|
134
|
+
case `percentage`: return o$1(t$1.percent);
|
|
135
|
+
case `tiered`: {
|
|
136
|
+
let e = _(t$1, s);
|
|
137
|
+
if (e > 0) return a$1(Math.round(e), o);
|
|
138
|
+
let i = v(t$1);
|
|
139
|
+
return i > 0 ? o$1(i) : a$1(0, o);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function C(t$2, n) {
|
|
144
|
+
if (t$2 && !(y(t$2, s$1(t(n))) <= 0)) return x(t$2, n);
|
|
145
|
+
}
|
|
146
|
+
function w(e, t) {
|
|
147
|
+
return t ? e.replaceAll(`{REWARD}`, t) : e.replaceAll(`{REWARD}`, ``);
|
|
148
|
+
}
|
|
149
|
+
const T = /* @__PURE__ */ new Set([
|
|
150
|
+
`eq`,
|
|
151
|
+
`neq`,
|
|
152
|
+
`gt`,
|
|
153
|
+
`gte`,
|
|
154
|
+
`lt`,
|
|
155
|
+
`lte`,
|
|
156
|
+
`between`
|
|
157
|
+
]);
|
|
158
|
+
const D = /* @__PURE__ */ new Set([
|
|
159
|
+
`contains`,
|
|
160
|
+
`starts_with`,
|
|
161
|
+
`ends_with`
|
|
162
|
+
]);
|
|
163
|
+
function A(e) {
|
|
164
|
+
return `logic` in e && `conditions` in e;
|
|
165
|
+
}
|
|
166
|
+
function j(e, t) {
|
|
167
|
+
return e[t];
|
|
168
|
+
}
|
|
169
|
+
function M(e) {
|
|
170
|
+
if (typeof e == `number`) return Number.isFinite(e) ? e : void 0;
|
|
171
|
+
if (typeof e == `string` && e.trim() !== ``) {
|
|
172
|
+
let t = Number(e);
|
|
173
|
+
return Number.isFinite(t) ? t : void 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function N(e, t) {
|
|
177
|
+
let n = M(e), r = M(t);
|
|
178
|
+
return n !== void 0 && r !== void 0 ? n - r : String(e).localeCompare(String(t));
|
|
179
|
+
}
|
|
180
|
+
function P(e, t, n) {
|
|
181
|
+
if (!Array.isArray(n)) return e === `not_in`;
|
|
182
|
+
if (t === void 0) return;
|
|
183
|
+
let r = n.includes(t);
|
|
184
|
+
return e === `in` ? r : !r;
|
|
185
|
+
}
|
|
186
|
+
function F(e, t, n, r) {
|
|
187
|
+
switch (e) {
|
|
188
|
+
case `eq`: return t === n;
|
|
189
|
+
case `neq`: return t !== n;
|
|
190
|
+
case `gt`: return N(t, n) > 0;
|
|
191
|
+
case `gte`: return N(t, n) >= 0;
|
|
192
|
+
case `lt`: return N(t, n) < 0;
|
|
193
|
+
case `lte`: return N(t, n) <= 0;
|
|
194
|
+
case `between`: return r == null || Array.isArray(r) ? void 0 : N(t, n) >= 0 && N(t, r) <= 0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function I(e, t, n) {
|
|
198
|
+
if (typeof t == `string` && typeof n == `string`) return e === `contains` ? t.includes(n) : e === `starts_with` ? t.startsWith(n) : t.endsWith(n);
|
|
199
|
+
}
|
|
200
|
+
function L(e, t) {
|
|
201
|
+
let n = j(t, e.field), { operator: r, value: i, valueTo: a } = e;
|
|
202
|
+
if (r === `exists`) return n !== void 0;
|
|
203
|
+
if (r === `not_exists`) return n === void 0;
|
|
204
|
+
if (r === `in` || r === `not_in`) return P(r, n, i);
|
|
205
|
+
if (!(Array.isArray(i) || n === void 0 || i === null)) {
|
|
206
|
+
if (T.has(r)) return F(r, n, i, a);
|
|
207
|
+
if (D.has(r)) return I(r, n, i);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function R(e, t) {
|
|
211
|
+
if (A(e)) {
|
|
212
|
+
let n = e.conditions.map((e) => R(e, t));
|
|
213
|
+
return e.logic === `all` ? n.every(Boolean) : e.logic === `any` ? n.some(Boolean) : e.logic !== `none` || !n.some(Boolean);
|
|
214
|
+
}
|
|
215
|
+
return L(e, t) ?? !0;
|
|
216
|
+
}
|
|
217
|
+
function z(e, t) {
|
|
218
|
+
return e ? Array.isArray(e) ? e.every((e) => R(e, t)) : R(e, t) : !0;
|
|
219
|
+
}
|
|
220
|
+
function B(e, t) {
|
|
221
|
+
return e.expiresAt != null && new Date(e.expiresAt).getTime() <= t;
|
|
222
|
+
}
|
|
223
|
+
function V(e, t) {
|
|
224
|
+
let n = d(e.conditions);
|
|
225
|
+
return n == null || n.getTime() <= t;
|
|
226
|
+
}
|
|
227
|
+
function H(e, t) {
|
|
228
|
+
return t === `referee` ? e.referee : e.referrer;
|
|
229
|
+
}
|
|
230
|
+
function U(e, t, n) {
|
|
231
|
+
let r = H(e, n);
|
|
232
|
+
return r ? y(r, t) : 0;
|
|
233
|
+
}
|
|
234
|
+
function W(e, t) {
|
|
235
|
+
if (!t || t.length === 0 || !e.productScope) return;
|
|
236
|
+
let n = t.filter((t) => z(e.productScope, t));
|
|
237
|
+
return n.length > 0 ? n : void 0;
|
|
238
|
+
}
|
|
239
|
+
function G(e, t) {
|
|
240
|
+
return !t || t.length === 0 || !e.productScope || t.some((t) => z(e.productScope, t));
|
|
241
|
+
}
|
|
242
|
+
function K(t$3, n = {}) {
|
|
243
|
+
let r = (n.now ?? /* @__PURE__ */ new Date()).getTime(), a = n.audience ?? `referrer`, o = s$1(t(n.currency)), s = (n.targetInteraction ? t$3.filter((e) => e.interactionTypeKey === n.targetInteraction) : t$3).filter((e) => !B(e, r)), c = s.filter((e) => V(e, r));
|
|
244
|
+
if (c.length > 0) {
|
|
245
|
+
let e = c.reduce((e, t) => {
|
|
246
|
+
let r = G(e, n.products), i = G(t, n.products);
|
|
247
|
+
return r === i ? U(t, o, a) > U(e, o, a) ? t : e : i ? t : e;
|
|
248
|
+
});
|
|
249
|
+
return {
|
|
250
|
+
campaign: e,
|
|
251
|
+
status: `live`,
|
|
252
|
+
matchedProducts: W(e, n.products)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
let l = s.map((e) => ({
|
|
256
|
+
campaign: e,
|
|
257
|
+
startsAt: d(e.conditions)
|
|
258
|
+
})).filter((e) => e.startsAt != null);
|
|
259
|
+
if (l.length === 0) return;
|
|
260
|
+
let u = l.reduce((e, t) => {
|
|
261
|
+
let r = G(e.campaign, n.products), i = G(t.campaign, n.products);
|
|
262
|
+
return r === i ? t.startsAt.getTime() < e.startsAt.getTime() ? t : e : i ? t : e;
|
|
263
|
+
});
|
|
264
|
+
return {
|
|
265
|
+
campaign: u.campaign,
|
|
266
|
+
status: `upcoming`,
|
|
267
|
+
startsAt: u.startsAt,
|
|
268
|
+
matchedProducts: W(u.campaign, n.products)
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function q(e, n = {}) {
|
|
272
|
+
let r$3 = K(e, n);
|
|
273
|
+
if (!r$3) return;
|
|
274
|
+
let i = H(r$3.campaign, n.audience ?? `referrer`);
|
|
275
|
+
if (!i) return;
|
|
276
|
+
let a = C(i, n.currency);
|
|
277
|
+
if (!a) return;
|
|
278
|
+
let o = u(r$3.campaign.conditions), s = o == null ? void 0 : r(o, n.currency), c = r$3.campaign.defaultLockupSeconds, l = c && c > 0 ? Math.round(c / 86400) : void 0;
|
|
279
|
+
return {
|
|
280
|
+
formatted: a,
|
|
281
|
+
parts: S(i, n.currency),
|
|
282
|
+
payoutType: i.payoutType,
|
|
283
|
+
minPurchaseAmount: s,
|
|
284
|
+
lockupDurationDays: l,
|
|
285
|
+
referrerReward: r$3.campaign.referrer,
|
|
286
|
+
refereeReward: r$3.campaign.referee,
|
|
287
|
+
minPurchaseValue: o ?? void 0,
|
|
288
|
+
isProductScoped: r$3.campaign.productScope != null,
|
|
289
|
+
matchedProducts: r$3.matchedProducts
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
export { w as i, K as n, q as r, C as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as q } from "./rewards-Cxn-bgzC.js";
|
|
2
2
|
import { getMerchantInformation } from "@frak-labs/core-sdk/actions";
|
|
3
3
|
import { useEffect, useState } from "preact/hooks";
|
|
4
4
|
//#region src/hooks/useReward.ts
|
|
@@ -24,7 +24,7 @@ function useReward(shouldUseReward, targetInteraction, audience, products) {
|
|
|
24
24
|
const client = window.FrakSetup?.client;
|
|
25
25
|
if (!client) return;
|
|
26
26
|
getMerchantInformation(client).then((merchantInfo) => {
|
|
27
|
-
const best =
|
|
27
|
+
const best = q(merchantInfo.rewards, {
|
|
28
28
|
currency: client.config.metadata?.currency,
|
|
29
29
|
targetInteraction,
|
|
30
30
|
audience,
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1.0-beta.
|
|
14
|
+
"version": "1.1.0-beta.ea6cff28",
|
|
15
15
|
"description": "Frak Wallet components, helping any person to interact with the Frak wallet.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -103,9 +103,9 @@
|
|
|
103
103
|
"publish": "echo 'Publishing components...'"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@frak-labs/core-sdk": "1.3.0-beta.
|
|
106
|
+
"@frak-labs/core-sdk": "1.3.0-beta.ea6cff28",
|
|
107
107
|
"@frak-labs/design-system": "0.0.0",
|
|
108
|
-
"@frak-labs/frame-connector": "1.3.0-beta.
|
|
108
|
+
"@frak-labs/frame-connector": "1.3.0-beta.ea6cff28",
|
|
109
109
|
"preact": "^10.29.7",
|
|
110
110
|
"preact-custom-element": "^4.6.0"
|
|
111
111
|
},
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import{C as e,D as t,S as n,d as r,i,l as a,o,r as s,w as c}from"./loader.js";import{a as ee,d as l,f as u,h as d,l as te,m as f,n as p,p as m,s as h,t as g,u as _}from"./defaults.DjBUlRT8.js";import{r as ne,t as re}from"./GiftIcon.DabDdDcp.js";import{t as ie}from"./useGlobalComponents.4DaqvbCn.js";import{t as ae}from"./useLightDomStyles.DNP8gafA.js";import{i as v,r as oe,t as y}from"./rewards.BaTam2j1.js";var se=`PostPurchase_card__5fv5lh0`,b=`PostPurchase_cardLayout__5fv5lh1`,ce=`PostPurchase_cardLeft__5fv5lh2`,le=`PostPurchase_cardRight__5fv5lh3`,ue=`PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0`,x=`PostPurchase_customImage__5fv5lha`,de=`PostPurchase_frakLogo__5fv5lhb`,fe=`PostPurchase_giftIcon__5fv5lh8`,pe=`PostPurchase_icon__5fv5lh7`,me=`PostPurchase_imageWrapper__5fv5lh9`,he=`PostPurchase_message__5fv5lh5`;function ge(e,t,n,r){let i=e?.isReferred?`referee`:`referrer`,a=y(t.rewards,{targetInteraction:`purchase`,currency:n,audience:i,products:r});if(!a)return null;let{campaign:o}=a,s=e?.isReferred&&o.referee?`referee`:`referrer`;return{variant:s,reward:s===`referee`?o.referee:o.referrer,merchantDomain:t.onChainMetadata.domain}}function S({customerId:d,orderId:y,token:S,sharingUrl:_e,merchantId:C,placement:w,classname:T=``,variant:E,badgeText:D,referrerText:O,refereeText:k,ctaText:A,preview:j,previewVariant:M,products:N,imageUrl:P}){let F=!!j,{shouldRender:I,isHidden:L,isClientReady:R}=h(),z=p(w),B=ee(),V=_(()=>r(N),[N]);ae(`frak-post-purchase`,w,z?.components?.postPurchase?.css,`.PostPurchase_card__5fv5lh0 {
|
|
2
|
-
padding: 16px;
|
|
3
|
-
border-radius: 12px;
|
|
4
|
-
background-color: var(--surface-background__pbq4akc);
|
|
5
|
-
border: 1px solid var(--border-default__pbq4akv);
|
|
6
|
-
}
|
|
7
|
-
.PostPurchase_cardLayout__5fv5lh1 {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: row;
|
|
10
|
-
align-items: center;
|
|
11
|
-
gap: 32px;
|
|
12
|
-
}
|
|
13
|
-
.PostPurchase_cardLeft__5fv5lh2 {
|
|
14
|
-
flex-grow: 1;
|
|
15
|
-
min-width: 0;
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
gap: 8px;
|
|
19
|
-
}
|
|
20
|
-
.PostPurchase_cardRight__5fv5lh3 {
|
|
21
|
-
flex-shrink: 0;
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
align-items: flex-end;
|
|
25
|
-
gap: 8px;
|
|
26
|
-
text-align: right;
|
|
27
|
-
}
|
|
28
|
-
.PostPurchase_badge__5fv5lh4 {
|
|
29
|
-
align-self: flex-start;
|
|
30
|
-
background-color: #FFF534;
|
|
31
|
-
border-radius: 4px;
|
|
32
|
-
padding: 4px 8px;
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
font-weight: 600;
|
|
35
|
-
line-height: 12px;
|
|
36
|
-
color: var(--text-primary__pbq4ak0);
|
|
37
|
-
}
|
|
38
|
-
.PostPurchase_message__5fv5lh5 {
|
|
39
|
-
margin: 0;
|
|
40
|
-
font-size: 16px;
|
|
41
|
-
line-height: 22px;
|
|
42
|
-
color: var(--text-primary__pbq4ak0);
|
|
43
|
-
font-weight: 600;
|
|
44
|
-
}
|
|
45
|
-
.PostPurchase_cta__5fv5lh6 {
|
|
46
|
-
display: inline-flex;
|
|
47
|
-
align-items: center;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
gap: 4px;
|
|
50
|
-
padding: 12px 16px;
|
|
51
|
-
border-radius: 9999px;
|
|
52
|
-
background-color: var(--text-primary__pbq4ak0);
|
|
53
|
-
color: var(--text-onAction__pbq4ak6);
|
|
54
|
-
font-size: 12px;
|
|
55
|
-
font-weight: bold;
|
|
56
|
-
text-transform: uppercase;
|
|
57
|
-
}
|
|
58
|
-
.PostPurchase_cta__5fv5lh6:disabled {
|
|
59
|
-
opacity: 0.7;
|
|
60
|
-
cursor: default;
|
|
61
|
-
}
|
|
62
|
-
.PostPurchase_icon__5fv5lh7 {
|
|
63
|
-
margin: -2px 0;
|
|
64
|
-
}
|
|
65
|
-
.PostPurchase_giftIcon__5fv5lh8 {
|
|
66
|
-
display: block;
|
|
67
|
-
flex-shrink: 0;
|
|
68
|
-
}
|
|
69
|
-
.PostPurchase_imageWrapper__5fv5lh9 {
|
|
70
|
-
flex-shrink: 0;
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
justify-content: center;
|
|
74
|
-
width: 80px;
|
|
75
|
-
height: 80px;
|
|
76
|
-
overflow: hidden;
|
|
77
|
-
}
|
|
78
|
-
.PostPurchase_customImage__5fv5lha {
|
|
79
|
-
max-width: 100%;
|
|
80
|
-
max-height: 100%;
|
|
81
|
-
width: auto;
|
|
82
|
-
height: auto;
|
|
83
|
-
object-fit: contain;
|
|
84
|
-
display: block;
|
|
85
|
-
}
|
|
86
|
-
.PostPurchase_frakLogo__5fv5lhb {
|
|
87
|
-
display: block;
|
|
88
|
-
margin-left: auto;
|
|
89
|
-
}`,t);let[H,ve]=l(null),[U,W]=l(!1);u(()=>{F||!R||!d||!y||!S||i({customerId:d,orderId:y,token:S,merchantId:C}).catch(()=>{})},[F,R,d,y,S,C]),u(()=>{if(F||!R||U)return;let t=window.FrakSetup?.client;t&&Promise.all([o(t),a(t)]).then(([e,t])=>{W(!0),ve({referralStatus:e,merchantInfo:t})}).catch(t=>{if(t instanceof c&&t.code===e.configError){W(!0);return}console.warn(`[Frak] Post-purchase context error`,t)})},[F,R,U]);let G=_(()=>H?ge(H.referralStatus,H.merchantInfo,window.FrakSetup?.client?.config?.metadata?.currency,V):null,[H,V]),K=te(null),q=E??G?.variant??(F?M??`referrer`:void 0),J=_e??G?.merchantDomain,Y=_(()=>{if(!G?.reward)return;let e=window.FrakSetup?.client?.config?.metadata?.currency;return oe(G.reward,e)},[G?.reward]),ye=ie(),X=z?.components?.postPurchase??ye?.postPurchase,Z=D??X?.badgeText,Q=P??X?.imageUrl,$=_(()=>{let e=g[B].postPurchase;return{message:q===`referee`?Y?v(k??X?.refereeText??e.refereeText,Y):k??X?.refereeNoRewardText??e.refereeNoRewardText:Y?v(O??X?.referrerText??e.referrerText,Y):O??X?.referrerNoRewardText??e.referrerNoRewardText,cta:Y?v(A??X?.ctaText??e.ctaText,Y):A??X?.ctaNoRewardText??e.ctaNoRewardText}},[B,q,Y,X,O,k,A]);u(()=>{q&&K.current!==q&&R&&(!F&&(!I||L)||(n(window.FrakSetup?.client,`post_purchase_impression`,{placement:w,variant:q,has_reward:!!G?.reward}),K.current=q))},[q,I,L,R,F,w,G?.reward]);let be=m(()=>{q&&(n(window.FrakSetup?.client,`post_purchase_clicked`,{placement:w,variant:q}),s(void 0,w,{link:J,products:V}))},[q,w,J,V]);return!q||!F&&(!I||L||!G)?null:f(`div`,{className:[se,T].filter(Boolean).join(` `),children:f(`div`,{class:b,children:[f(`div`,{class:ce,children:[Z&&f(`span`,{class:`PostPurchase_badge__5fv5lh4`,children:Z}),f(`p`,{class:he,children:$.message}),f(`button`,{type:`button`,className:`${ue} button`,disabled:!F&&!R,onClick:F?void 0:be,children:[$.cta,f(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`${pe} button`,children:f(`path`,{d:`M13.9 11.14C13.99 11.05 14.15 11.11 14.15 11.24V11.64C14.15 13.05 12.63 14.19 10.75 14.19C8.87 14.19 7.34 13.05 7.34 11.64V11.24C7.34 11.11 7.51 11.05 7.59 11.14C8.35 11.93 9.48 12.43 10.75 12.43C12.01 12.43 13.15 11.93 13.9 11.14ZM1.85 9.65C1.85 9.51 2.01 9.44 2.1 9.54C2.85 10.32 3.99 10.82 5.25 10.82C5.52 10.82 5.79 10.8 6.04 10.76C6.26 10.72 6.47 10.88 6.47 11.1V12.17C6.47 12.32 6.37 12.45 6.22 12.48C5.92 12.55 5.59 12.59 5.25 12.59C3.37 12.59 1.85 11.45 1.85 10.04V9.65ZM10.75 6.21C12.63 6.21 14.15 7.35 14.15 8.75C14.15 10.16 12.63 11.3 10.75 11.3C8.87 11.3 7.34 10.16 7.34 8.75C7.34 7.35 8.87 6.21 10.75 6.21ZM1.85 6.85C1.85 6.71 2.01 6.65 2.1 6.74C2.85 7.53 3.99 8.03 5.25 8.03C5.52 8.03 5.79 8 6.04 7.96C6.26 7.92 6.47 8.09 6.47 8.3V9.37C6.47 9.52 6.37 9.65 6.22 9.69C5.92 9.75 5.59 9.79 5.25 9.79C3.37 9.79 1.85 8.65 1.85 7.24V6.85ZM5.25 1.81C7.13 1.81 8.66 2.95 8.66 4.36C8.66 5.76 7.13 6.9 5.25 6.9C3.37 6.9 1.85 5.76 1.85 4.36C1.85 2.95 3.37 1.81 5.25 1.81Z`,fill:`currentColor`})})]})]}),f(`div`,{class:le,children:[Q?f(`span`,{class:me,children:f(`img`,{src:Q,alt:``,class:x})}):f(re,{className:fe,width:80,height:80}),f(ne,{className:de,width:42,height:24})]})]})})}d(S,`frak-post-purchase`,[`customerId`,`orderId`,`token`,`sharingUrl`,`merchantId`,`placement`,`classname`,`variant`,`badgeText`,`referrerText`,`refereeText`,`ctaText`,`products`,`preview`,`previewVariant`,`imageUrl`],{shadow:!1});export{S as PostPurchase};
|
package/cdn/rewards.BaTam2j1.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e,v as t,y as n}from"./loader.js";function r(e){return Array.isArray(e)?e:e.conditions}function i(e){if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function a(e,t,n){let o=[];for(let s of r(e)){if(`logic`in s){o.push(...a(s,t,n));continue}if(s.field===t&&n.has(s.operator)){let e=i(s.value);e!=null&&o.push(e)}}return o}const o=new Set([`gt`,`gte`,`between`]),s=new Set([`gt`,`gte`]);function c(e){let t=a(e,`purchase.amount`,o);return t.length>0?Math.min(...t):void 0}function l(e){let t=a(e,`time.timestamp`,s);if(t.length!==0)return new Date(Math.min(...t)*1e3)}function u(e,t){switch(e.payoutType){case`fixed`:return e.amount[t];case`percentage`:return e.maxAmount?.[t]??0;case`tiered`:return e.tiers.reduce((e,n)=>`amount`in n?Math.max(e,n.amount[t]):e,0)}}function d(e){return e.payoutType===`percentage`?e.percent:e.payoutType===`tiered`?e.tiers.reduce((e,t)=>`percent`in t?Math.max(e,t.percent):e,0):0}function f(e,t){let n=u(e,t);return n>0?n:d(e)*1e-6}function p(r,i){let a=e(i),o=t(a);switch(r.payoutType){case`fixed`:return n(Math.round(r.amount[o]),a);case`percentage`:return`${r.percent} %`;case`tiered`:{let e=u(r,o);if(e>0)return n(Math.round(e),a);let t=d(r);return t>0?`${t} %`:n(0,a)}}}function m(n,r){if(n&&!(f(n,t(e(r)))<=0))return p(n,r)}function h(e,t){return t?e.replaceAll(`{REWARD}`,t):e.replaceAll(`{REWARD}`,``)}const g=new Set([`eq`,`neq`,`gt`,`gte`,`lt`,`lte`,`between`]),_=new Set([`contains`,`starts_with`,`ends_with`]);function v(e){return`logic`in e&&`conditions`in e}function y(e,t){return e[t]}function b(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function x(e,t){let n=b(e),r=b(t);return n!==void 0&&r!==void 0?n-r:String(e).localeCompare(String(t))}function S(e,t,n){if(!Array.isArray(n))return e===`not_in`;if(t===void 0)return;let r=n.includes(t);return e===`in`?r:!r}function C(e,t,n,r){switch(e){case`eq`:return t===n;case`neq`:return t!==n;case`gt`:return x(t,n)>0;case`gte`:return x(t,n)>=0;case`lt`:return x(t,n)<0;case`lte`:return x(t,n)<=0;case`between`:return r==null||Array.isArray(r)?void 0:x(t,n)>=0&&x(t,r)<=0}}function w(e,t,n){if(typeof t==`string`&&typeof n==`string`)return e===`contains`?t.includes(n):e===`starts_with`?t.startsWith(n):t.endsWith(n)}function T(e,t){let n=y(t,e.field),{operator:r,value:i,valueTo:a}=e;if(r===`exists`)return n!==void 0;if(r===`not_exists`)return n===void 0;if(r===`in`||r===`not_in`)return S(r,n,i);if(!(Array.isArray(i)||n===void 0||i===null)){if(g.has(r))return C(r,n,i,a);if(_.has(r))return w(r,n,i)}}function E(e,t){if(v(e)){let n=e.conditions.map(e=>E(e,t));return e.logic===`all`?n.every(Boolean):e.logic===`any`?n.some(Boolean):e.logic!==`none`||!n.some(Boolean)}return T(e,t)??!0}function D(e,t){return e?Array.isArray(e)?e.every(e=>E(e,t)):E(e,t):!0}function O(e,t){return e.expiresAt!=null&&new Date(e.expiresAt).getTime()<=t}function k(e,t){let n=l(e.conditions);return n==null||n.getTime()<=t}function A(e,t){return t===`referee`?e.referee:e.referrer}function j(e,t,n){let r=A(e,n);return r?f(r,t):0}function M(e,t){if(!t||t.length===0||!e.productScope)return;let n=t.filter(t=>D(e.productScope,t));return n.length>0?n:void 0}function N(e,t){return!t||t.length===0||!e.productScope||t.some(t=>D(e.productScope,t))}function P(n,r={}){let i=(r.now??new Date).getTime(),a=r.audience??`referrer`,o=t(e(r.currency)),s=(r.targetInteraction?n.filter(e=>e.interactionTypeKey===r.targetInteraction):n).filter(e=>!O(e,i)),c=s.filter(e=>k(e,i));if(c.length>0){let e=c.reduce((e,t)=>{let n=N(e,r.products),i=N(t,r.products);return n===i?j(t,o,a)>j(e,o,a)?t:e:i?t:e});return{campaign:e,status:`live`,matchedProducts:M(e,r.products)}}let u=s.map(e=>({campaign:e,startsAt:l(e.conditions)})).filter(e=>e.startsAt!=null);if(u.length===0)return;let d=u.reduce((e,t)=>{let n=N(e.campaign,r.products),i=N(t.campaign,r.products);return n===i?t.startsAt.getTime()<e.startsAt.getTime()?t:e:i?t:e});return{campaign:d.campaign,status:`upcoming`,startsAt:d.startsAt,matchedProducts:M(d.campaign,r.products)}}function F(e,t={}){let r=P(e,t);if(!r)return;let i=A(r.campaign,t.audience??`referrer`);if(!i)return;let a=m(i,t.currency);if(!a)return;let o=c(r.campaign.conditions),s=o==null?void 0:n(o,t.currency),l=r.campaign.defaultLockupSeconds,u=l&&l>0?Math.round(l/86400):void 0;return{formatted:a,payoutType:i.payoutType,minPurchaseAmount:s,lockupDurationDays:u,referrerReward:r.campaign.referrer,refereeReward:r.campaign.referee,minPurchaseValue:o??void 0,isProductScoped:r.campaign.productScope!=null,matchedProducts:r.matchedProducts}}export{h as i,F as n,m as r,P as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{x as e}from"./loader.js";import{c as t,o as n}from"./defaults.DjBUlRT8.js";function r(){return t(n,()=>e.getConfig().components)}export{r as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as e}from"./loader.js";import{f as t,i as n}from"./defaults.DjBUlRT8.js";function r(r,i,a,o,s){t(()=>{s&&e.injectBase(`shared`,s),e.injectBase(r,o??n)},[r]),t(()=>{!i||!a||e.injectPlacement(r,i,a)},[r,i,a])}export{r as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as e}from"./loader.js";import{d as t,f as n}from"./defaults.DjBUlRT8.js";import{n as r}from"./rewards.BaTam2j1.js";function i(i,a,o,s){let[c,l]=t(void 0);return n(()=>{if(!i)return;let t=window.FrakSetup?.client;t&&e(t).then(e=>{let n=r(e.rewards,{currency:t.config.metadata?.currency,targetInteraction:a,audience:o,products:s});n&&n.payoutType!==`percentage`&&l(n.formatted)}).catch(()=>{})},[i,a,o,s]),{reward:c}}export{i as t};
|
package/dist/rewards-CDS1CYlm.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
//#region ../core/dist/getCurrencyAmountKey-C-1W-BRg.js
|
|
2
|
-
const e = {
|
|
3
|
-
eur: `fr-FR`,
|
|
4
|
-
usd: `en-US`,
|
|
5
|
-
gbp: `en-GB`
|
|
6
|
-
};
|
|
7
|
-
function t(t) {
|
|
8
|
-
return t && t in e ? t : `eur`;
|
|
9
|
-
}
|
|
10
|
-
function n(t) {
|
|
11
|
-
return t ? e[t] ?? e.eur : e.eur;
|
|
12
|
-
}
|
|
13
|
-
function r$1(e, r) {
|
|
14
|
-
let i = n(r), a = t(r);
|
|
15
|
-
return e.toLocaleString(i, {
|
|
16
|
-
style: `currency`,
|
|
17
|
-
currency: a,
|
|
18
|
-
minimumFractionDigits: 0,
|
|
19
|
-
maximumFractionDigits: 2
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function i$1(e) {
|
|
23
|
-
return e ? `${e}Amount` : `eurAmount`;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region ../core/dist/rewards.js
|
|
27
|
-
function r(e) {
|
|
28
|
-
return Array.isArray(e) ? e : e.conditions;
|
|
29
|
-
}
|
|
30
|
-
function i(e) {
|
|
31
|
-
if (typeof e == `number`) return e;
|
|
32
|
-
if (typeof e == `string` && e.trim() !== ``) {
|
|
33
|
-
let t = Number(e);
|
|
34
|
-
return Number.isFinite(t) ? t : void 0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function a(e, t, n) {
|
|
38
|
-
let o = [];
|
|
39
|
-
for (let s of r(e)) {
|
|
40
|
-
if (`logic` in s) {
|
|
41
|
-
o.push(...a(s, t, n));
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (s.field === t && n.has(s.operator)) {
|
|
45
|
-
let e = i(s.value);
|
|
46
|
-
e != null && o.push(e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return o;
|
|
50
|
-
}
|
|
51
|
-
const o = /* @__PURE__ */ new Set([
|
|
52
|
-
`gt`,
|
|
53
|
-
`gte`,
|
|
54
|
-
`between`
|
|
55
|
-
]);
|
|
56
|
-
const s = /* @__PURE__ */ new Set([`gt`, `gte`]);
|
|
57
|
-
function c(e) {
|
|
58
|
-
let t = a(e, `purchase.amount`, o);
|
|
59
|
-
return t.length > 0 ? Math.min(...t) : void 0;
|
|
60
|
-
}
|
|
61
|
-
function l(e) {
|
|
62
|
-
let t = a(e, `time.timestamp`, s);
|
|
63
|
-
if (t.length !== 0) return /* @__PURE__ */ new Date(Math.min(...t) * 1e3);
|
|
64
|
-
}
|
|
65
|
-
function h(e, t) {
|
|
66
|
-
switch (e.payoutType) {
|
|
67
|
-
case `fixed`: return e.amount[t];
|
|
68
|
-
case `percentage`: return e.maxAmount?.[t] ?? 0;
|
|
69
|
-
case `tiered`: return e.tiers.reduce((e, n) => `amount` in n ? Math.max(e, n.amount[t]) : e, 0);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function g(e) {
|
|
73
|
-
return e.payoutType === `percentage` ? e.percent : e.payoutType === `tiered` ? e.tiers.reduce((e, t) => `percent` in t ? Math.max(e, t.percent) : e, 0) : 0;
|
|
74
|
-
}
|
|
75
|
-
function _(e, t) {
|
|
76
|
-
let n = h(e, t);
|
|
77
|
-
return n > 0 ? n : g(e) * 1e-6;
|
|
78
|
-
}
|
|
79
|
-
function y(r, i) {
|
|
80
|
-
let a = t(i), o = i$1(a);
|
|
81
|
-
switch (r.payoutType) {
|
|
82
|
-
case `fixed`: return r$1(Math.round(r.amount[o]), a);
|
|
83
|
-
case `percentage`: return `${r.percent} %`;
|
|
84
|
-
case `tiered`: {
|
|
85
|
-
let t = h(r, o);
|
|
86
|
-
if (t > 0) return r$1(Math.round(t), a);
|
|
87
|
-
let n = g(r);
|
|
88
|
-
return n > 0 ? `${n} %` : r$1(0, a);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function b(e, r) {
|
|
93
|
-
if (e && !(_(e, i$1(t(r))) <= 0)) return y(e, r);
|
|
94
|
-
}
|
|
95
|
-
function x(e, t) {
|
|
96
|
-
return t ? e.replaceAll(`{REWARD}`, t) : e.replaceAll(`{REWARD}`, ``);
|
|
97
|
-
}
|
|
98
|
-
const S = /* @__PURE__ */ new Set([
|
|
99
|
-
`eq`,
|
|
100
|
-
`neq`,
|
|
101
|
-
`gt`,
|
|
102
|
-
`gte`,
|
|
103
|
-
`lt`,
|
|
104
|
-
`lte`,
|
|
105
|
-
`between`
|
|
106
|
-
]);
|
|
107
|
-
const w = /* @__PURE__ */ new Set([
|
|
108
|
-
`contains`,
|
|
109
|
-
`starts_with`,
|
|
110
|
-
`ends_with`
|
|
111
|
-
]);
|
|
112
|
-
function D(e) {
|
|
113
|
-
return `logic` in e && `conditions` in e;
|
|
114
|
-
}
|
|
115
|
-
function O(e, t) {
|
|
116
|
-
return e[t];
|
|
117
|
-
}
|
|
118
|
-
function k(e) {
|
|
119
|
-
if (typeof e == `number`) return Number.isFinite(e) ? e : void 0;
|
|
120
|
-
if (typeof e == `string` && e.trim() !== ``) {
|
|
121
|
-
let t = Number(e);
|
|
122
|
-
return Number.isFinite(t) ? t : void 0;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function A(e, t) {
|
|
126
|
-
let n = k(e), r = k(t);
|
|
127
|
-
return n !== void 0 && r !== void 0 ? n - r : String(e).localeCompare(String(t));
|
|
128
|
-
}
|
|
129
|
-
function j(e, t, n) {
|
|
130
|
-
if (!Array.isArray(n)) return e === `not_in`;
|
|
131
|
-
if (t === void 0) return;
|
|
132
|
-
let r = n.includes(t);
|
|
133
|
-
return e === `in` ? r : !r;
|
|
134
|
-
}
|
|
135
|
-
function M(e, t, n, r) {
|
|
136
|
-
switch (e) {
|
|
137
|
-
case `eq`: return t === n;
|
|
138
|
-
case `neq`: return t !== n;
|
|
139
|
-
case `gt`: return A(t, n) > 0;
|
|
140
|
-
case `gte`: return A(t, n) >= 0;
|
|
141
|
-
case `lt`: return A(t, n) < 0;
|
|
142
|
-
case `lte`: return A(t, n) <= 0;
|
|
143
|
-
case `between`: return r == null || Array.isArray(r) ? void 0 : A(t, n) >= 0 && A(t, r) <= 0;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function N(e, t, n) {
|
|
147
|
-
if (typeof t == `string` && typeof n == `string`) return e === `contains` ? t.includes(n) : e === `starts_with` ? t.startsWith(n) : t.endsWith(n);
|
|
148
|
-
}
|
|
149
|
-
function P(e, t) {
|
|
150
|
-
let n = O(t, e.field), { operator: r, value: i, valueTo: a } = e;
|
|
151
|
-
if (r === `exists`) return n !== void 0;
|
|
152
|
-
if (r === `not_exists`) return n === void 0;
|
|
153
|
-
if (r === `in` || r === `not_in`) return j(r, n, i);
|
|
154
|
-
if (!(Array.isArray(i) || n === void 0 || i === null)) {
|
|
155
|
-
if (S.has(r)) return M(r, n, i, a);
|
|
156
|
-
if (w.has(r)) return N(r, n, i);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function F(e, t) {
|
|
160
|
-
if (D(e)) {
|
|
161
|
-
let n = e.conditions.map((e) => F(e, t));
|
|
162
|
-
return e.logic === `all` ? n.every(Boolean) : e.logic === `any` ? n.some(Boolean) : e.logic !== `none` || !n.some(Boolean);
|
|
163
|
-
}
|
|
164
|
-
return P(e, t) ?? !0;
|
|
165
|
-
}
|
|
166
|
-
function I(e, t) {
|
|
167
|
-
return e ? Array.isArray(e) ? e.every((e) => F(e, t)) : F(e, t) : !0;
|
|
168
|
-
}
|
|
169
|
-
function L(e, t) {
|
|
170
|
-
return e.expiresAt != null && new Date(e.expiresAt).getTime() <= t;
|
|
171
|
-
}
|
|
172
|
-
function R(e, t) {
|
|
173
|
-
let n = l(e.conditions);
|
|
174
|
-
return n == null || n.getTime() <= t;
|
|
175
|
-
}
|
|
176
|
-
function z(e, t) {
|
|
177
|
-
return t === `referee` ? e.referee : e.referrer;
|
|
178
|
-
}
|
|
179
|
-
function B(e, t, n) {
|
|
180
|
-
let r = z(e, n);
|
|
181
|
-
return r ? _(r, t) : 0;
|
|
182
|
-
}
|
|
183
|
-
function V(e, t) {
|
|
184
|
-
if (!t || t.length === 0 || !e.productScope) return;
|
|
185
|
-
let n = t.filter((t) => I(e.productScope, t));
|
|
186
|
-
return n.length > 0 ? n : void 0;
|
|
187
|
-
}
|
|
188
|
-
function H(e, t) {
|
|
189
|
-
return !t || t.length === 0 || !e.productScope || t.some((t) => I(e.productScope, t));
|
|
190
|
-
}
|
|
191
|
-
function U(e, r = {}) {
|
|
192
|
-
let i = (r.now ?? /* @__PURE__ */ new Date()).getTime(), a = r.audience ?? `referrer`, o = i$1(t(r.currency)), s = (r.targetInteraction ? e.filter((e) => e.interactionTypeKey === r.targetInteraction) : e).filter((e) => !L(e, i)), c = s.filter((e) => R(e, i));
|
|
193
|
-
if (c.length > 0) {
|
|
194
|
-
let e = c.reduce((e, t) => {
|
|
195
|
-
let n = H(e, r.products), i = H(t, r.products);
|
|
196
|
-
return n === i ? B(t, o, a) > B(e, o, a) ? t : e : i ? t : e;
|
|
197
|
-
});
|
|
198
|
-
return {
|
|
199
|
-
campaign: e,
|
|
200
|
-
status: `live`,
|
|
201
|
-
matchedProducts: V(e, r.products)
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
let u = s.map((e) => ({
|
|
205
|
-
campaign: e,
|
|
206
|
-
startsAt: l(e.conditions)
|
|
207
|
-
})).filter((e) => e.startsAt != null);
|
|
208
|
-
if (u.length === 0) return;
|
|
209
|
-
let d = u.reduce((e, t) => {
|
|
210
|
-
let n = H(e.campaign, r.products), i = H(t.campaign, r.products);
|
|
211
|
-
return n === i ? t.startsAt.getTime() < e.startsAt.getTime() ? t : e : i ? t : e;
|
|
212
|
-
});
|
|
213
|
-
return {
|
|
214
|
-
campaign: d.campaign,
|
|
215
|
-
status: `upcoming`,
|
|
216
|
-
startsAt: d.startsAt,
|
|
217
|
-
matchedProducts: V(d.campaign, r.products)
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function W(t, n = {}) {
|
|
221
|
-
let r = U(t, n);
|
|
222
|
-
if (!r) return;
|
|
223
|
-
let i = z(r.campaign, n.audience ?? `referrer`);
|
|
224
|
-
if (!i) return;
|
|
225
|
-
let a = b(i, n.currency);
|
|
226
|
-
if (!a) return;
|
|
227
|
-
let o = c(r.campaign.conditions), s = o == null ? void 0 : r$1(o, n.currency), l = r.campaign.defaultLockupSeconds, u = l && l > 0 ? Math.round(l / 86400) : void 0;
|
|
228
|
-
return {
|
|
229
|
-
formatted: a,
|
|
230
|
-
payoutType: i.payoutType,
|
|
231
|
-
minPurchaseAmount: s,
|
|
232
|
-
lockupDurationDays: u,
|
|
233
|
-
referrerReward: r.campaign.referrer,
|
|
234
|
-
refereeReward: r.campaign.referee,
|
|
235
|
-
minPurchaseValue: o ?? void 0,
|
|
236
|
-
isProductScoped: r.campaign.productScope != null,
|
|
237
|
-
matchedProducts: r.matchedProducts
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
//#endregion
|
|
241
|
-
export { x as i, W as n, b as r, U as t };
|