@saasquatch/squatch-js 2.8.3-0 → 2.8.3-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/CHANGELOG.md +29 -8
- package/coverage/clover.xml +630 -593
- package/coverage/coverage-final.json +22 -20
- package/coverage/lcov.info +1087 -997
- package/dist/squatch.cjs.js +275 -18
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +752 -438
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +70 -61
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -2
- package/dist/types.d.ts +134 -1
- package/dist/utils/logger.d.ts +4 -1
- package/dist/widgets/PopupWidget.d.ts +3 -2
- package/dist/widgets/SkeletonTemplate.d.ts +1 -3
- package/dist/widgets/Widget.d.ts +12 -1
- package/package.json +1 -2
- package/dist/SkeletonTemplate-CIRGs_GB.js +0 -258
- package/dist/SkeletonTemplate-CIRGs_GB.js.map +0 -1
- package/dist/SkeletonTemplate-hwDwv3Ys.cjs +0 -250
- package/dist/SkeletonTemplate-hwDwv3Ys.cjs.map +0 -1
package/dist/squatch.esm.js
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (o, t, e) =>
|
|
4
|
-
let
|
|
5
|
-
function
|
|
1
|
+
var Ee = Object.defineProperty;
|
|
2
|
+
var Ce = (o, t, e) => t in o ? Ee(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var l = (o, t, e) => Ce(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
let C = null;
|
|
5
|
+
function Ae(o) {
|
|
6
6
|
const e = o.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
7
|
-
|
|
7
|
+
C = new RegExp(`^${e}$`);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
9
|
+
function Ie() {
|
|
10
|
+
C = null;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
function k(o) {
|
|
13
|
+
const t = (...e) => {
|
|
14
|
+
C && C.test(o) && console.log(`[${o}]`, ...e);
|
|
15
15
|
};
|
|
16
|
+
return Object.defineProperty(t, "enabled", {
|
|
17
|
+
get() {
|
|
18
|
+
return !!(C && C.test(o));
|
|
19
|
+
}
|
|
20
|
+
}), t;
|
|
16
21
|
}
|
|
17
22
|
/*! js-cookie v3.0.5 | MIT */
|
|
18
|
-
function
|
|
23
|
+
function S(o) {
|
|
19
24
|
for (var t = 1; t < arguments.length; t++) {
|
|
20
25
|
var e = arguments[t];
|
|
21
|
-
for (var
|
|
22
|
-
o[
|
|
26
|
+
for (var n in e)
|
|
27
|
+
o[n] = e[n];
|
|
23
28
|
}
|
|
24
29
|
return o;
|
|
25
30
|
}
|
|
26
|
-
var
|
|
31
|
+
var _e = {
|
|
27
32
|
read: function(o) {
|
|
28
33
|
return o[0] === '"' && (o = o.slice(1, -1)), o.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
29
34
|
},
|
|
@@ -35,47 +40,47 @@ var be = {
|
|
|
35
40
|
}
|
|
36
41
|
};
|
|
37
42
|
function G(o, t) {
|
|
38
|
-
function e(
|
|
43
|
+
function e(i, s, r) {
|
|
39
44
|
if (!(typeof document > "u")) {
|
|
40
|
-
r =
|
|
45
|
+
r = S({}, t, r), typeof r.expires == "number" && (r.expires = new Date(Date.now() + r.expires * 864e5)), r.expires && (r.expires = r.expires.toUTCString()), i = encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
41
46
|
var a = "";
|
|
42
|
-
for (var
|
|
43
|
-
r[
|
|
44
|
-
return document.cookie =
|
|
47
|
+
for (var d in r)
|
|
48
|
+
r[d] && (a += "; " + d, r[d] !== !0 && (a += "=" + r[d].split(";")[0]));
|
|
49
|
+
return document.cookie = i + "=" + o.write(s, i) + a;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
|
-
function i
|
|
48
|
-
if (!(typeof document > "u" || arguments.length && !
|
|
52
|
+
function n(i) {
|
|
53
|
+
if (!(typeof document > "u" || arguments.length && !i)) {
|
|
49
54
|
for (var s = document.cookie ? document.cookie.split("; ") : [], r = {}, a = 0; a < s.length; a++) {
|
|
50
|
-
var
|
|
55
|
+
var d = s[a].split("="), c = d.slice(1).join("=");
|
|
51
56
|
try {
|
|
52
|
-
var h = decodeURIComponent(
|
|
53
|
-
if (r[h] = o.read(
|
|
57
|
+
var h = decodeURIComponent(d[0]);
|
|
58
|
+
if (r[h] = o.read(c, h), i === h)
|
|
54
59
|
break;
|
|
55
60
|
} catch {
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
|
-
return
|
|
63
|
+
return i ? r[i] : r;
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
return Object.create(
|
|
62
67
|
{
|
|
63
68
|
set: e,
|
|
64
|
-
get:
|
|
65
|
-
remove: function(
|
|
69
|
+
get: n,
|
|
70
|
+
remove: function(i, s) {
|
|
66
71
|
e(
|
|
67
|
-
|
|
72
|
+
i,
|
|
68
73
|
"",
|
|
69
|
-
|
|
74
|
+
S({}, s, {
|
|
70
75
|
expires: -1
|
|
71
76
|
})
|
|
72
77
|
);
|
|
73
78
|
},
|
|
74
|
-
withAttributes: function(
|
|
75
|
-
return G(this.converter,
|
|
79
|
+
withAttributes: function(i) {
|
|
80
|
+
return G(this.converter, S({}, this.attributes, i));
|
|
76
81
|
},
|
|
77
|
-
withConverter: function(
|
|
78
|
-
return G(
|
|
82
|
+
withConverter: function(i) {
|
|
83
|
+
return G(S({}, this.converter, i), this.attributes);
|
|
79
84
|
}
|
|
80
85
|
},
|
|
81
86
|
{
|
|
@@ -84,21 +89,21 @@ function G(o, t) {
|
|
|
84
89
|
}
|
|
85
90
|
);
|
|
86
91
|
}
|
|
87
|
-
var
|
|
88
|
-
const A = "https://app.referralsaasquatch.com",
|
|
89
|
-
function
|
|
92
|
+
var M = G(_e, { path: "/" });
|
|
93
|
+
const A = "https://app.referralsaasquatch.com", V = "https://fast.ssqt.io/npm", R = "squatch", z = "impact";
|
|
94
|
+
function q(o) {
|
|
90
95
|
if (typeof o != "object") throw new Error("config must be an object");
|
|
91
|
-
const t = window.squatchTenant, e =
|
|
96
|
+
const t = window.squatchTenant, e = Y(), n = {
|
|
92
97
|
tenantAlias: (o == null ? void 0 : o.tenantAlias) || t,
|
|
93
98
|
domain: (o == null ? void 0 : o.domain) || (e == null ? void 0 : e.domain),
|
|
94
99
|
npmCdn: (o == null ? void 0 : o.npmCdn) || (e == null ? void 0 : e.npmCdn),
|
|
95
100
|
debug: (o == null ? void 0 : o.debug) || (e == null ? void 0 : e.debug)
|
|
96
101
|
};
|
|
97
|
-
if (typeof
|
|
102
|
+
if (typeof n.tenantAlias != "string")
|
|
98
103
|
throw new Error("tenantAlias not provided");
|
|
99
|
-
const
|
|
104
|
+
const i = n.tenantAlias, s = typeof n.domain == "string" && n.domain || A, r = typeof n.debug == "boolean" && n.debug || !1, a = typeof n.npmCdn == "string" && n.npmCdn || V;
|
|
100
105
|
return {
|
|
101
|
-
tenantAlias:
|
|
106
|
+
tenantAlias: i,
|
|
102
107
|
domain: s,
|
|
103
108
|
debug: r,
|
|
104
109
|
npmCdn: a
|
|
@@ -107,30 +112,30 @@ function W(o) {
|
|
|
107
112
|
function I(o) {
|
|
108
113
|
return typeof o == "object" && !Array.isArray(o) && o !== null;
|
|
109
114
|
}
|
|
110
|
-
function
|
|
115
|
+
function Te(o) {
|
|
111
116
|
if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
|
|
112
117
|
return o;
|
|
113
118
|
}
|
|
114
|
-
function
|
|
119
|
+
function ce(o) {
|
|
115
120
|
if (!I(o)) throw new Error("Widget properties must be an object");
|
|
116
121
|
if (!(o != null && o.user)) throw new Error("Required properties missing.");
|
|
117
122
|
return o;
|
|
118
123
|
}
|
|
119
|
-
function
|
|
124
|
+
function le(o) {
|
|
120
125
|
if (!I(o)) throw new Error("Widget properties must be an object");
|
|
121
126
|
return o;
|
|
122
127
|
}
|
|
123
|
-
function
|
|
128
|
+
function W() {
|
|
124
129
|
return window.impactToken || window.squatchToken;
|
|
125
130
|
}
|
|
126
|
-
function
|
|
131
|
+
function Y() {
|
|
127
132
|
return window.impactConfig || window.squatchConfig;
|
|
128
133
|
}
|
|
129
|
-
async function
|
|
130
|
-
const
|
|
134
|
+
async function $e(o, t, e, n) {
|
|
135
|
+
const i = n || W(), s = {
|
|
131
136
|
Accept: "application/json",
|
|
132
137
|
"Content-Type": "application/json",
|
|
133
|
-
...
|
|
138
|
+
...i ? { Authorization: `Bearer ${i}` } : {},
|
|
134
139
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
135
140
|
};
|
|
136
141
|
try {
|
|
@@ -145,35 +150,35 @@ async function Ie(o, t, e, i) {
|
|
|
145
150
|
throw r;
|
|
146
151
|
}
|
|
147
152
|
}
|
|
148
|
-
async function
|
|
153
|
+
async function qe(o, t = "") {
|
|
149
154
|
const e = {
|
|
150
155
|
Accept: "application/json",
|
|
151
156
|
"Content-Type": "application/json"
|
|
152
|
-
},
|
|
153
|
-
|
|
157
|
+
}, n = t || W();
|
|
158
|
+
n && (e["X-SaaSquatch-User-Token"] = n);
|
|
154
159
|
try {
|
|
155
|
-
const
|
|
160
|
+
const i = await fetch(o, {
|
|
156
161
|
method: "GET",
|
|
157
162
|
credentials: "include",
|
|
158
163
|
headers: e
|
|
159
|
-
}), s = await
|
|
160
|
-
if (!
|
|
164
|
+
}), s = await i.text();
|
|
165
|
+
if (!i.ok) throw new Error(s);
|
|
161
166
|
return s && JSON.parse(s);
|
|
162
|
-
} catch (
|
|
163
|
-
throw
|
|
167
|
+
} catch (i) {
|
|
168
|
+
throw i;
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
|
-
async function
|
|
167
|
-
const
|
|
171
|
+
async function X(o, t, e) {
|
|
172
|
+
const n = {
|
|
168
173
|
Accept: "application/json",
|
|
169
174
|
"Content-Type": "application/json"
|
|
170
|
-
},
|
|
171
|
-
|
|
175
|
+
}, i = e || W();
|
|
176
|
+
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
172
177
|
try {
|
|
173
178
|
const s = await fetch(o, {
|
|
174
179
|
method: "POST",
|
|
175
180
|
body: t,
|
|
176
|
-
headers:
|
|
181
|
+
headers: n
|
|
177
182
|
}), r = await s.text();
|
|
178
183
|
if (!s.ok) throw new Error(r);
|
|
179
184
|
return r && JSON.parse(r);
|
|
@@ -181,16 +186,16 @@ async function V(o, t, e) {
|
|
|
181
186
|
throw s;
|
|
182
187
|
}
|
|
183
188
|
}
|
|
184
|
-
async function
|
|
185
|
-
const
|
|
189
|
+
async function We(o, t, e) {
|
|
190
|
+
const n = {
|
|
186
191
|
Accept: "application/json",
|
|
187
192
|
"Content-Type": "application/json",
|
|
188
193
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
189
|
-
},
|
|
190
|
-
|
|
194
|
+
}, i = e || W();
|
|
195
|
+
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
191
196
|
try {
|
|
192
197
|
const s = await fetch(o, {
|
|
193
|
-
headers:
|
|
198
|
+
headers: n,
|
|
194
199
|
method: "PUT",
|
|
195
200
|
credentials: "include",
|
|
196
201
|
body: t
|
|
@@ -201,7 +206,7 @@ async function ke(o, t, e) {
|
|
|
201
206
|
throw s;
|
|
202
207
|
}
|
|
203
208
|
}
|
|
204
|
-
const
|
|
209
|
+
const Se = `
|
|
205
210
|
query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
|
|
206
211
|
renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
|
|
207
212
|
template
|
|
@@ -216,7 +221,7 @@ const xe = `
|
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
`;
|
|
219
|
-
class
|
|
224
|
+
class K {
|
|
220
225
|
/**
|
|
221
226
|
* Initialize a new {@link WidgetApi} instance.
|
|
222
227
|
*
|
|
@@ -238,8 +243,8 @@ class Y {
|
|
|
238
243
|
l(this, "domain");
|
|
239
244
|
l(this, "npmCdn");
|
|
240
245
|
l(this, "referralCookie", this.squatchReferralCookie);
|
|
241
|
-
const
|
|
242
|
-
this.tenantAlias =
|
|
246
|
+
const n = q(t);
|
|
247
|
+
this.tenantAlias = n.tenantAlias, this.domain = n.domain, this.npmCdn = n.npmCdn;
|
|
243
248
|
}
|
|
244
249
|
/**
|
|
245
250
|
* Creates/upserts user, requests widget template.
|
|
@@ -256,18 +261,18 @@ class Y {
|
|
|
256
261
|
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
257
262
|
*/
|
|
258
263
|
upsertUser(t) {
|
|
259
|
-
const
|
|
260
|
-
widgetType:
|
|
264
|
+
const n = ce(t), {
|
|
265
|
+
widgetType: i,
|
|
261
266
|
engagementMedium: s = "POPUP",
|
|
262
267
|
jwt: r,
|
|
263
268
|
locale: a,
|
|
264
|
-
user:
|
|
265
|
-
} =
|
|
266
|
-
widgetType:
|
|
269
|
+
user: d
|
|
270
|
+
} = n, c = encodeURIComponent(this.tenantAlias), h = d.accountId ? encodeURIComponent(d.accountId) : null, u = d.id ? encodeURIComponent(d.id) : null, p = Re({
|
|
271
|
+
widgetType: i,
|
|
267
272
|
engagementMedium: s,
|
|
268
273
|
locale: a
|
|
269
|
-
}),
|
|
270
|
-
return
|
|
274
|
+
}), g = `/api/v1/${c}/widget/account/${h}/user/${u}/upsert${p}`, m = this.domain + g, w = (M || window.Cookies).get("_saasquatch");
|
|
275
|
+
return w && (d.cookies = w), We(m, JSON.stringify(d), r);
|
|
271
276
|
}
|
|
272
277
|
/**
|
|
273
278
|
* Requests widget template
|
|
@@ -283,24 +288,24 @@ class Y {
|
|
|
283
288
|
* @return {Promise} template html if true.
|
|
284
289
|
*/
|
|
285
290
|
render(t) {
|
|
286
|
-
const
|
|
287
|
-
return new Promise(async (
|
|
288
|
-
var
|
|
291
|
+
const n = le(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, d = encodeURIComponent(this.tenantAlias), c = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? Te(navigator.language.replace(/\-/g, "_")), p = `/api/v1/${d}/graphql`, g = this.domain + p;
|
|
292
|
+
return new Promise(async (m, w) => {
|
|
293
|
+
var b;
|
|
289
294
|
try {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
295
|
+
const f = await $e(
|
|
296
|
+
g,
|
|
297
|
+
Se,
|
|
293
298
|
{
|
|
294
|
-
user: h &&
|
|
299
|
+
user: h && c ? { id: h, accountId: c } : null,
|
|
295
300
|
engagementMedium: s,
|
|
296
|
-
widgetType:
|
|
301
|
+
widgetType: i,
|
|
297
302
|
locale: u
|
|
298
303
|
},
|
|
299
304
|
r
|
|
300
305
|
);
|
|
301
|
-
|
|
302
|
-
} catch (
|
|
303
|
-
f
|
|
306
|
+
m((b = f == null ? void 0 : f.data) == null ? void 0 : b.renderWidget);
|
|
307
|
+
} catch (f) {
|
|
308
|
+
w(f);
|
|
304
309
|
}
|
|
305
310
|
});
|
|
306
311
|
}
|
|
@@ -310,35 +315,35 @@ class Y {
|
|
|
310
315
|
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
311
316
|
*/
|
|
312
317
|
async squatchReferralCookie() {
|
|
313
|
-
const t = encodeURIComponent(this.tenantAlias), e = (
|
|
318
|
+
const t = encodeURIComponent(this.tenantAlias), e = (M || window.Cookies).get("_saasquatch") || "", n = e ? `?cookies=${encodeURIComponent(e)}` : "", i = `${this.domain}/a/${t}/widgets/squatchcookiejson${n}`, s = await qe(i);
|
|
314
319
|
return Promise.resolve({
|
|
315
320
|
...s,
|
|
316
321
|
encodedCookie: e
|
|
317
322
|
});
|
|
318
323
|
}
|
|
319
324
|
}
|
|
320
|
-
function
|
|
325
|
+
function Re({
|
|
321
326
|
widgetType: o,
|
|
322
327
|
engagementMedium: t,
|
|
323
328
|
locale: e
|
|
324
329
|
}) {
|
|
325
|
-
const
|
|
326
|
-
return
|
|
330
|
+
const n = new URLSearchParams();
|
|
331
|
+
return n.append("engagementMedium", t), o && n.append("widgetType", o), e && n.append("locale", e), `?${n.toString()}`;
|
|
327
332
|
}
|
|
328
333
|
/*!
|
|
329
334
|
* domready (c) Dustin Diaz 2014 - License MIT
|
|
330
335
|
*
|
|
331
336
|
*/
|
|
332
|
-
function
|
|
333
|
-
let e = [],
|
|
334
|
-
return a ||
|
|
337
|
+
function Q(o, t) {
|
|
338
|
+
let e = [], n, i = o, s = i.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(i.readyState);
|
|
339
|
+
return a || i.addEventListener(
|
|
335
340
|
r,
|
|
336
|
-
|
|
337
|
-
for (
|
|
341
|
+
n = () => {
|
|
342
|
+
for (i.removeEventListener(r, n), a = !0; n = e.shift(); ) n();
|
|
338
343
|
}
|
|
339
344
|
), a ? setTimeout(t, 0) : e.push(t);
|
|
340
345
|
}
|
|
341
|
-
function
|
|
346
|
+
function L({
|
|
342
347
|
value: o,
|
|
343
348
|
unit: t
|
|
344
349
|
}) {
|
|
@@ -351,7 +356,7 @@ function M({
|
|
|
351
356
|
return `${o}px`;
|
|
352
357
|
}
|
|
353
358
|
}
|
|
354
|
-
class
|
|
359
|
+
class he {
|
|
355
360
|
/**
|
|
356
361
|
* Initialize a new {@link AnalyticsApi} instance.
|
|
357
362
|
*
|
|
@@ -361,26 +366,283 @@ class ae {
|
|
|
361
366
|
*/
|
|
362
367
|
constructor(t) {
|
|
363
368
|
l(this, "domain");
|
|
364
|
-
var
|
|
365
|
-
const
|
|
366
|
-
this.domain = (
|
|
369
|
+
var i;
|
|
370
|
+
const n = Ue(t);
|
|
371
|
+
this.domain = (n == null ? void 0 : n.domain) || ((i = Y()) == null ? void 0 : i.domain) || A;
|
|
367
372
|
}
|
|
368
373
|
pushAnalyticsLoadEvent(t) {
|
|
369
374
|
if (!t.externalUserId || !t.externalAccountId) return;
|
|
370
|
-
const e = encodeURIComponent(t.tenantAlias),
|
|
371
|
-
return
|
|
375
|
+
const e = encodeURIComponent(t.tenantAlias), n = encodeURIComponent(t.externalAccountId), i = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = t.programId ? `&programId=${encodeURIComponent(t.programId)}` : "", a = `/a/${e}/widgets/analytics/loaded?externalAccountId=${n}&externalUserId=${i}&engagementMedium=${s}${r}`, d = this.domain + a;
|
|
376
|
+
return X(d, JSON.stringify({}));
|
|
372
377
|
}
|
|
373
378
|
pushAnalyticsShareClickedEvent(t) {
|
|
374
|
-
const e = encodeURIComponent(t.tenantAlias),
|
|
375
|
-
return
|
|
379
|
+
const e = encodeURIComponent(t.tenantAlias), n = encodeURIComponent(t.externalAccountId), i = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = encodeURIComponent(t.shareMedium), a = `/a/${e}/widgets/analytics/shared?externalAccountId=${n}&externalUserId=${i}&engagementMedium=${s}&shareMedium=${r}`, d = this.domain + a;
|
|
380
|
+
return X(d, JSON.stringify({}));
|
|
376
381
|
}
|
|
377
382
|
}
|
|
378
|
-
function
|
|
383
|
+
function Ue(o) {
|
|
379
384
|
if (!I(o)) throw new Error("'options' should be an object");
|
|
380
385
|
return o;
|
|
381
386
|
}
|
|
382
|
-
const
|
|
383
|
-
|
|
387
|
+
const ue = ({
|
|
388
|
+
type: o = "verified-access",
|
|
389
|
+
height: t = "500px"
|
|
390
|
+
}) => {
|
|
391
|
+
const e = "#e0e0e0";
|
|
392
|
+
return `
|
|
393
|
+
<style>
|
|
394
|
+
* {
|
|
395
|
+
box-sizing: border-box;
|
|
396
|
+
padding: 0;
|
|
397
|
+
margin: 0;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.widget-container {
|
|
401
|
+
background: white;
|
|
402
|
+
width: 100%;
|
|
403
|
+
padding: 40px;
|
|
404
|
+
box-sizing: border-box;
|
|
405
|
+
overflow: hidden;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
@keyframes shimmer {
|
|
409
|
+
0% { background-position: -100% 0; }
|
|
410
|
+
100% { background-position: 100% 0; }
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.skeleton {
|
|
414
|
+
background: ${e};
|
|
415
|
+
background: linear-gradient(
|
|
416
|
+
90deg,
|
|
417
|
+
${e} 25%,
|
|
418
|
+
#f5f5f5 50%,
|
|
419
|
+
${e} 75%
|
|
420
|
+
);
|
|
421
|
+
background-size: 200% 100%;
|
|
422
|
+
animation: shimmer 1.5s infinite linear;
|
|
423
|
+
border-radius: 6px;
|
|
424
|
+
margin-bottom: 12px;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/* Typography Skeletons */
|
|
428
|
+
.sk-title-lg { height: 36px; width: 80%; margin-bottom: 16px; }
|
|
429
|
+
.sk-title-md { height: 28px; width: 30%; margin-bottom: 20px; margin-top: 40px; }
|
|
430
|
+
.sk-text { height: 16px; width: 90%; margin-bottom: 8px; }
|
|
431
|
+
.sk-text-short { width: 40%; }
|
|
432
|
+
.sk-label { height: 14px; width: 25%; margin-bottom: 10px; }
|
|
433
|
+
|
|
434
|
+
/* Layouts */
|
|
435
|
+
.hero-section {
|
|
436
|
+
display: flex;
|
|
437
|
+
gap: 40px;
|
|
438
|
+
margin-bottom: 40px;
|
|
439
|
+
padding-bottom: 40px;
|
|
440
|
+
flex-direction: row;
|
|
441
|
+
height: 100%;
|
|
442
|
+
/* Removed border-bottom */
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.hero-content {
|
|
446
|
+
flex: 1;
|
|
447
|
+
display: flex;
|
|
448
|
+
flex-direction: column;
|
|
449
|
+
justify-content: center;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.hero-image {
|
|
453
|
+
flex: 1;
|
|
454
|
+
height: 300px;
|
|
455
|
+
border-radius: 12px;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/* -- Specific Instant Access Overrides -- */
|
|
459
|
+
.instant-access-layout {
|
|
460
|
+
margin-bottom: 0;
|
|
461
|
+
padding-bottom: 0;
|
|
462
|
+
align-items: center;
|
|
463
|
+
}
|
|
464
|
+
.ia-image {
|
|
465
|
+
height: 400px;
|
|
466
|
+
}
|
|
467
|
+
.ia-center {
|
|
468
|
+
margin-left: auto;
|
|
469
|
+
margin-right: auto;
|
|
470
|
+
}
|
|
471
|
+
.ia-content {
|
|
472
|
+
align-items: center;
|
|
473
|
+
text-align: center;
|
|
474
|
+
}
|
|
475
|
+
.sk-btn-action {
|
|
476
|
+
height: 45px;
|
|
477
|
+
width: 140px;
|
|
478
|
+
border-radius: 6px;
|
|
479
|
+
margin: 24px auto;
|
|
480
|
+
}
|
|
481
|
+
.input-group {
|
|
482
|
+
display: flex;
|
|
483
|
+
gap: 10px;
|
|
484
|
+
width: 100%;
|
|
485
|
+
max-width: 400px;
|
|
486
|
+
}
|
|
487
|
+
.sk-btn-copy {
|
|
488
|
+
height: 50px;
|
|
489
|
+
width: 120px;
|
|
490
|
+
border-radius: 8px;
|
|
491
|
+
}
|
|
492
|
+
/* ------------------------------------- */
|
|
493
|
+
|
|
494
|
+
.share-section { margin-bottom: 40px; }
|
|
495
|
+
.sk-input { height: 50px; width: 100%; border-radius: 8px; margin-bottom: 16px; }
|
|
496
|
+
|
|
497
|
+
.social-buttons { display: flex; gap: 12px; }
|
|
498
|
+
.sk-btn-social { flex: 1; height: 50px; border-radius: 8px; }
|
|
499
|
+
|
|
500
|
+
.stats-section {
|
|
501
|
+
display: flex;
|
|
502
|
+
gap: 24px;
|
|
503
|
+
margin-bottom: 40px;
|
|
504
|
+
padding: 30px 0;
|
|
505
|
+
/* Removed border-top and border-bottom */
|
|
506
|
+
}
|
|
507
|
+
.stat-card { flex: 1; display: flex; flex-direction: column; align-items: center; }
|
|
508
|
+
.stat-divider { padding-left: 24px; }
|
|
509
|
+
.sk-stat-num { height: 48px; width: 120px; margin-bottom: 8px; }
|
|
510
|
+
.sk-stat-label { height: 18px; width: 80px; }
|
|
511
|
+
|
|
512
|
+
/* Table Styles */
|
|
513
|
+
.table-header { display: flex; gap: 16px; margin-bottom: 16px; }
|
|
514
|
+
.sk-th { height: 16px; }
|
|
515
|
+
.table-row {
|
|
516
|
+
display: flex;
|
|
517
|
+
align-items: center;
|
|
518
|
+
gap: 16px;
|
|
519
|
+
padding: 16px 0;
|
|
520
|
+
/* Removed border-bottom */
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.col-user { flex: 2; }
|
|
524
|
+
.col-status { flex: 1; }
|
|
525
|
+
.col-reward { flex: 2; }
|
|
526
|
+
.col-date { flex: 1; }
|
|
527
|
+
|
|
528
|
+
.sk-badge { height: 28px; width: 90px; border-radius: 14px; }
|
|
529
|
+
.sk-reward-block { height: 36px; width: 100%; border-radius: 6px; }
|
|
530
|
+
|
|
531
|
+
.pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
|
|
532
|
+
.sk-btn-page { height: 36px; width: 64px; border-radius: 6px; margin-bottom: 0; }
|
|
533
|
+
|
|
534
|
+
@media (max-width: 768px) {
|
|
535
|
+
body { padding: 20px; }
|
|
536
|
+
.widget-container { padding: 24px; }
|
|
537
|
+
|
|
538
|
+
.hero-section { flex-direction: column-reverse; gap: 24px; }
|
|
539
|
+
.instant-access-layout { flex-direction: column; }
|
|
540
|
+
|
|
541
|
+
.hero-image { height: 220px; width: 100%; }
|
|
542
|
+
.sk-title-lg { width: 100%; }
|
|
543
|
+
|
|
544
|
+
.col-date { display: none; }
|
|
545
|
+
}
|
|
546
|
+
</style>
|
|
547
|
+
|
|
548
|
+
<div class="widget-container">
|
|
549
|
+
${o === "verified-access" ? `
|
|
550
|
+
<div class="hero-section">
|
|
551
|
+
<div class="hero-content">
|
|
552
|
+
<div class="skeleton sk-title-lg"></div>
|
|
553
|
+
<div class="skeleton sk-text"></div>
|
|
554
|
+
<div class="skeleton sk-text sk-text-short"></div>
|
|
555
|
+
</div>
|
|
556
|
+
<div class="skeleton hero-image"></div>
|
|
557
|
+
</div>
|
|
558
|
+
|
|
559
|
+
<div class="share-section">
|
|
560
|
+
<div class="skeleton sk-label"></div>
|
|
561
|
+
<div class="skeleton sk-input"></div>
|
|
562
|
+
<div class="social-buttons">
|
|
563
|
+
<div class="skeleton sk-btn-social"></div>
|
|
564
|
+
<div class="skeleton sk-btn-social"></div>
|
|
565
|
+
<div class="skeleton sk-btn-social"></div>
|
|
566
|
+
<div class="skeleton sk-btn-social"></div>
|
|
567
|
+
</div>
|
|
568
|
+
</div>
|
|
569
|
+
|
|
570
|
+
<div class="skeleton sk-title-md" style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"></div>
|
|
571
|
+
<div class="skeleton sk-text" style="width: 60%; margin-left: auto; margin-right: auto"></div>
|
|
572
|
+
|
|
573
|
+
<div class="stats-section">
|
|
574
|
+
<div class="stat-card">
|
|
575
|
+
<div class="skeleton sk-stat-num"></div>
|
|
576
|
+
<div class="skeleton sk-stat-label"></div>
|
|
577
|
+
</div>
|
|
578
|
+
<div class="stat-card stat-divider">
|
|
579
|
+
<div class="skeleton sk-stat-num"></div>
|
|
580
|
+
<div class="skeleton sk-stat-label"></div>
|
|
581
|
+
</div>
|
|
582
|
+
</div>
|
|
583
|
+
|
|
584
|
+
<div class="skeleton sk-title-md"></div>
|
|
585
|
+
|
|
586
|
+
<div class="table-header">
|
|
587
|
+
<div class="skeleton sk-th col-user"></div>
|
|
588
|
+
<div class="skeleton sk-th col-status"></div>
|
|
589
|
+
<div class="skeleton sk-th col-reward"></div>
|
|
590
|
+
<div class="skeleton sk-th col-date"></div>
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
<div class="table-row">
|
|
594
|
+
<div class="col-user"><div class="skeleton sk-text" style="width: 70%; margin: 0"></div></div>
|
|
595
|
+
<div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
|
|
596
|
+
<div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
|
|
597
|
+
<div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
|
|
598
|
+
</div>
|
|
599
|
+
|
|
600
|
+
<div class="table-row">
|
|
601
|
+
<div class="col-user"><div class="skeleton sk-text" style="width: 60%; margin: 0"></div></div>
|
|
602
|
+
<div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
|
|
603
|
+
<div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
|
|
604
|
+
<div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
|
|
605
|
+
</div>
|
|
606
|
+
|
|
607
|
+
<div class="table-row">
|
|
608
|
+
<div class="col-user"><div class="skeleton sk-text" style="width: 75%; margin: 0"></div></div>
|
|
609
|
+
<div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
|
|
610
|
+
<div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
|
|
611
|
+
<div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
|
|
612
|
+
</div>
|
|
613
|
+
|
|
614
|
+
<div class="pagination">
|
|
615
|
+
<div class="skeleton sk-btn-page"></div>
|
|
616
|
+
<div class="skeleton sk-btn-page"></div>
|
|
617
|
+
</div>
|
|
618
|
+
` : `
|
|
619
|
+
<div class="hero-section instant-access-layout">
|
|
620
|
+
<div class="skeleton hero-image ia-image"></div>
|
|
621
|
+
|
|
622
|
+
<div class="hero-content ia-content">
|
|
623
|
+
<div class="skeleton sk-title-lg ia-center"></div>
|
|
624
|
+
<div class="skeleton sk-text ia-center"></div>
|
|
625
|
+
|
|
626
|
+
<div class="skeleton sk-btn-action"></div>
|
|
627
|
+
|
|
628
|
+
<div class="skeleton sk-label"></div>
|
|
629
|
+
<div class="input-group">
|
|
630
|
+
<div class="skeleton sk-input"></div>
|
|
631
|
+
<div class="skeleton sk-btn-copy"></div>
|
|
632
|
+
</div>
|
|
633
|
+
|
|
634
|
+
<div class="skeleton sk-text-short ia-center" style="margin-top: 20px; width: 30%"></div>
|
|
635
|
+
<div class="skeleton sk-text-short ia-center" style="width: 20%"></div>
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
`}
|
|
639
|
+
</div>
|
|
640
|
+
`;
|
|
641
|
+
}, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
642
|
+
__proto__: null,
|
|
643
|
+
getSkeleton: ue
|
|
644
|
+
}, Symbol.toStringTag, { value: "Module" })), y = k("squatch-js:widget");
|
|
645
|
+
class pe {
|
|
384
646
|
constructor(t) {
|
|
385
647
|
l(this, "type");
|
|
386
648
|
l(this, "content");
|
|
@@ -391,11 +653,11 @@ class ce {
|
|
|
391
653
|
l(this, "container");
|
|
392
654
|
l(this, "loadEventListener", null);
|
|
393
655
|
var e;
|
|
394
|
-
|
|
656
|
+
y("widget initializing ..."), this.content = t.content === "error" ? this._error(t.rsCode) : t.content, this.type = t.type, this.widgetApi = t.api, this.npmCdn = t.npmCdn, this.analyticsApi = new he({ domain: t.domain }), this.context = t.context, this.container = ((e = t.context) == null ? void 0 : e.container) || t.container;
|
|
395
657
|
}
|
|
396
658
|
_findElement() {
|
|
397
659
|
let t;
|
|
398
|
-
if (typeof this.container == "string" ? (t = document.querySelector(this.container),
|
|
660
|
+
if (typeof this.container == "string" ? (t = document.querySelector(this.container), y("loading widget with selector", t)) : this.container instanceof HTMLElement ? (t = this.container, y("loading widget with container", t)) : this.container ? (t = null, y("container must be an HTMLElement or string", this.container)) : (t = document.querySelector("#squatchembed") || document.querySelector(".squatchembed") || document.querySelector("#impactembed") || document.querySelector(".impactembed"), y("loading widget with default selector", t)), !(t instanceof HTMLElement))
|
|
399
661
|
throw new Error(
|
|
400
662
|
`element with selector '${this.container || "#squatchembed, .squatchembed, #impactembed, or .impactembed"}' not found.'`
|
|
401
663
|
);
|
|
@@ -405,8 +667,8 @@ class ce {
|
|
|
405
667
|
const e = document.createElement("iframe");
|
|
406
668
|
return e.squatchJsApi = this, e.id = "squatchFrame", e.width = "100%", e.src = "about:blank", e.scrolling = "no", e.setAttribute(
|
|
407
669
|
"style",
|
|
408
|
-
"border: 0; background-color: none; width: 1px; min-width: 100%;"
|
|
409
|
-
), t != null && t.minWidth && (e.style.minWidth = t.minWidth), t != null && t.maxWidth && (e.style.maxWidth = t.maxWidth), (t != null && t.maxWidth || t != null && t.minWidth) && (e.style.width = "100%"), t != null && t.initialHeight && (e.height = t.initialHeight), e;
|
|
670
|
+
"border: 0; background-color: none; width: 1px; min-width: 100%; display: block;"
|
|
671
|
+
), t != null && t.minWidth && (e.style.minWidth = t.minWidth), t != null && t.maxWidth && (e.style.maxWidth = t.maxWidth), (t != null && t.maxWidth || t != null && t.minWidth) && (e.style.width = "100%"), t != null && t.initialHeight && (e.height = String(t.initialHeight)), e;
|
|
410
672
|
}
|
|
411
673
|
_findFrame() {
|
|
412
674
|
const t = this.container ? this._findElement() : document.body;
|
|
@@ -421,16 +683,16 @@ class ce {
|
|
|
421
683
|
), this.loadEventListener = null);
|
|
422
684
|
}
|
|
423
685
|
_attachLoadEventListener(t, e) {
|
|
424
|
-
this.loadEventListener === null && (this.loadEventListener = (
|
|
686
|
+
this.loadEventListener === null && (this.loadEventListener = (n) => {
|
|
425
687
|
this._loadEvent({
|
|
426
688
|
...e,
|
|
427
|
-
userId:
|
|
428
|
-
accountId:
|
|
689
|
+
userId: n.detail.userId,
|
|
690
|
+
accountId: n.detail.accountId
|
|
429
691
|
});
|
|
430
692
|
}, t.addEventListener("sq:user-registration", this.loadEventListener));
|
|
431
693
|
}
|
|
432
694
|
_loadEvent(t) {
|
|
433
|
-
var
|
|
695
|
+
var n;
|
|
434
696
|
if (!t) return;
|
|
435
697
|
if (!I(t))
|
|
436
698
|
throw new Error("Widget Load event identity property is not an object");
|
|
@@ -446,18 +708,18 @@ class ce {
|
|
|
446
708
|
programId: t.programId
|
|
447
709
|
};
|
|
448
710
|
} else {
|
|
449
|
-
const { analytics:
|
|
711
|
+
const { analytics: i, mode: s } = t;
|
|
450
712
|
e = {
|
|
451
|
-
tenantAlias:
|
|
452
|
-
externalAccountId:
|
|
453
|
-
externalUserId:
|
|
713
|
+
tenantAlias: i.attributes.tenant,
|
|
714
|
+
externalAccountId: i.attributes.accountId,
|
|
715
|
+
externalUserId: i.attributes.userId,
|
|
454
716
|
engagementMedium: s.widgetMode
|
|
455
717
|
};
|
|
456
718
|
}
|
|
457
|
-
(
|
|
458
|
-
|
|
459
|
-
}).catch((
|
|
460
|
-
|
|
719
|
+
(n = this.analyticsApi.pushAnalyticsLoadEvent(e)) == null || n.then((i) => {
|
|
720
|
+
y(`${e.engagementMedium} loaded event recorded.`);
|
|
721
|
+
}).catch((i) => {
|
|
722
|
+
y(`ERROR: pushAnalyticsLoadEvent() ${i}`);
|
|
461
723
|
});
|
|
462
724
|
}
|
|
463
725
|
_shareEvent(t, e) {
|
|
@@ -467,15 +729,15 @@ class ce {
|
|
|
467
729
|
externalUserId: t.analytics.attributes.userId,
|
|
468
730
|
engagementMedium: t.mode.widgetMode,
|
|
469
731
|
shareMedium: e
|
|
470
|
-
}).then((
|
|
471
|
-
|
|
472
|
-
`${t.mode.widgetMode} share ${e} event recorded. ${
|
|
732
|
+
}).then((n) => {
|
|
733
|
+
y(
|
|
734
|
+
`${t.mode.widgetMode} share ${e} event recorded. ${n}`
|
|
473
735
|
);
|
|
474
|
-
}).catch((
|
|
475
|
-
|
|
736
|
+
}).catch((n) => {
|
|
737
|
+
y(`ERROR: pushAnalyticsShareClickedEvent() ${n}`);
|
|
476
738
|
});
|
|
477
739
|
}
|
|
478
|
-
_error(t, e = "modal",
|
|
740
|
+
_error(t, e = "modal", n = "") {
|
|
479
741
|
return `<!DOCTYPE html>
|
|
480
742
|
<!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
|
|
481
743
|
<!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
|
|
@@ -483,7 +745,7 @@ class ce {
|
|
|
483
745
|
<head>
|
|
484
746
|
<link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
|
|
485
747
|
<style>
|
|
486
|
-
${
|
|
748
|
+
${n}
|
|
487
749
|
</style>
|
|
488
750
|
</head>
|
|
489
751
|
<body>
|
|
@@ -512,15 +774,38 @@ class ce {
|
|
|
512
774
|
const { contentWindow: e } = t;
|
|
513
775
|
if (!e)
|
|
514
776
|
throw new Error("Squatch.js frame inner frame is empty");
|
|
515
|
-
const
|
|
516
|
-
function
|
|
517
|
-
const r =
|
|
777
|
+
const n = e.document;
|
|
778
|
+
function i() {
|
|
779
|
+
const r = n.getElementsByTagName("sqh-global-container"), a = n.getElementsByClassName("squatch-container");
|
|
518
780
|
return r.length > 0 ? r[0] : a.length > 0 ? a[0] : null;
|
|
519
781
|
}
|
|
520
782
|
let s = null;
|
|
521
|
-
for (let r = 0; r < 5 && (s =
|
|
522
|
-
await
|
|
523
|
-
return s ||
|
|
783
|
+
for (let r = 0; r < 5 && (s = i(), !s); r++)
|
|
784
|
+
await Me(100);
|
|
785
|
+
return s || n.body;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Returns HTML for an in-iframe skeleton preload overlay that is removed
|
|
789
|
+
* once all Stencil component chunks have loaded and been hydrated.
|
|
790
|
+
*
|
|
791
|
+
* Uses a MutationObserver to detect when components receive the `hydrated`
|
|
792
|
+
* class, debouncing removal so the skeleton stays visible until all chunks
|
|
793
|
+
* have finished loading. Includes a timeout fallback.
|
|
794
|
+
*
|
|
795
|
+
* Only generates content for mint-components widgets; returns empty string otherwise.
|
|
796
|
+
*/
|
|
797
|
+
_getSkeletonPreloadHTML(t, e) {
|
|
798
|
+
if (!t) return "";
|
|
799
|
+
const n = this.context.type === "passwordless" ? "instant-access" : "verified-access", i = ue({
|
|
800
|
+
type: n,
|
|
801
|
+
height: "100%"
|
|
802
|
+
});
|
|
803
|
+
return `
|
|
804
|
+
<div id="sq-preload" style="visibility: visible; position: absolute; top: 0; left: 0; width: 100%; z-index: 9999; background: ${e || "white"};">
|
|
805
|
+
${i}
|
|
806
|
+
</div>
|
|
807
|
+
<script>(${Le.toString()})()<\/script>
|
|
808
|
+
`;
|
|
524
809
|
}
|
|
525
810
|
/**
|
|
526
811
|
* Reloads the current widget, makes updated request to API and renders result.
|
|
@@ -528,30 +813,30 @@ class ce {
|
|
|
528
813
|
* @param param0 Form field values
|
|
529
814
|
* @param jwt JWT for API authentication
|
|
530
815
|
*/
|
|
531
|
-
reload({ email: t, firstName: e, lastName:
|
|
816
|
+
reload({ email: t, firstName: e, lastName: n }, i) {
|
|
532
817
|
const s = this._findFrame();
|
|
533
818
|
if (!s) throw new Error("Could not find widget iframe");
|
|
534
819
|
const r = s.contentWindow, a = this.context.engagementMedium || "POPUP";
|
|
535
820
|
if (!r)
|
|
536
821
|
throw new Error("Frame needs a content window");
|
|
537
|
-
let
|
|
822
|
+
let d;
|
|
538
823
|
if (this.context.type === "upsert") {
|
|
539
824
|
if (!this.context.user) throw new Error("Can't reload without user ids");
|
|
540
|
-
let
|
|
825
|
+
let c = {
|
|
541
826
|
email: t || null,
|
|
542
827
|
firstName: e || null,
|
|
543
|
-
lastName:
|
|
828
|
+
lastName: n || null,
|
|
544
829
|
id: this.context.user.id,
|
|
545
830
|
accountId: this.context.user.accountId
|
|
546
831
|
};
|
|
547
|
-
|
|
548
|
-
user:
|
|
832
|
+
d = this.widgetApi.upsertUser({
|
|
833
|
+
user: c,
|
|
549
834
|
engagementMedium: a,
|
|
550
835
|
widgetType: this.type,
|
|
551
|
-
jwt:
|
|
836
|
+
jwt: i
|
|
552
837
|
});
|
|
553
838
|
} else if (this.context.type === "passwordless")
|
|
554
|
-
|
|
839
|
+
d = this.widgetApi.render({
|
|
555
840
|
user: void 0,
|
|
556
841
|
engagementMedium: a,
|
|
557
842
|
widgetType: this.type,
|
|
@@ -559,79 +844,104 @@ class ce {
|
|
|
559
844
|
});
|
|
560
845
|
else
|
|
561
846
|
throw new Error("can't reload an error widget");
|
|
562
|
-
|
|
563
|
-
|
|
847
|
+
d.then(({ template: c }) => {
|
|
848
|
+
c && (this.content = c, this.__deprecated__register(
|
|
564
849
|
s,
|
|
565
850
|
{ email: t, engagementMedium: a },
|
|
566
851
|
() => {
|
|
567
852
|
this.load(), a === "POPUP" && this.open();
|
|
568
853
|
}
|
|
569
854
|
));
|
|
570
|
-
}).catch(({ message:
|
|
571
|
-
|
|
855
|
+
}).catch(({ message: c }) => {
|
|
856
|
+
y(`${c}`);
|
|
572
857
|
});
|
|
573
858
|
}
|
|
574
|
-
__deprecated__register(t, e,
|
|
859
|
+
__deprecated__register(t, e, n) {
|
|
575
860
|
const s = t.contentWindow.document, r = s.createElement("button"), a = s.getElementsByClassName("squatch-register")[0];
|
|
576
861
|
if (a) {
|
|
577
862
|
r.className = "btn btn-primary", r.id = "show-stats-btn", r.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
|
|
578
|
-
const
|
|
579
|
-
r.setAttribute("style",
|
|
863
|
+
const d = e.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
|
|
864
|
+
r.setAttribute("style", d), r.onclick = n, a.style.paddingTop = "30px", a.innerHTML = `<p><strong>${e.email}</strong><br>Has been successfully registered</p>`, a.appendChild(r);
|
|
580
865
|
}
|
|
581
866
|
}
|
|
582
867
|
}
|
|
583
|
-
function
|
|
868
|
+
function Me(o) {
|
|
584
869
|
return new Promise((t) => {
|
|
585
870
|
setTimeout(t, o);
|
|
586
871
|
});
|
|
587
872
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
873
|
+
function Le() {
|
|
874
|
+
var o = setTimeout(t, 1e4);
|
|
875
|
+
function t() {
|
|
876
|
+
var n = document.getElementById("sq-preload");
|
|
877
|
+
n && n.remove(), clearTimeout(o);
|
|
878
|
+
}
|
|
879
|
+
function e() {
|
|
880
|
+
var n = /* @__PURE__ */ new Set();
|
|
881
|
+
if (document.querySelectorAll("*").forEach(function(i) {
|
|
882
|
+
i.tagName.includes("-") && n.add(i.tagName.toLowerCase());
|
|
883
|
+
}), !n.size) return t();
|
|
884
|
+
Promise.all(
|
|
885
|
+
Array.from(n).map(function(i) {
|
|
886
|
+
return customElements.whenDefined(i);
|
|
887
|
+
})
|
|
888
|
+
).then(function() {
|
|
889
|
+
requestAnimationFrame(function() {
|
|
890
|
+
requestAnimationFrame(t);
|
|
891
|
+
});
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : setTimeout(e, 0);
|
|
895
|
+
}
|
|
896
|
+
const E = k("squatch-js:EMBEDwidget");
|
|
897
|
+
class O extends pe {
|
|
898
|
+
constructor(e, n) {
|
|
591
899
|
super(e);
|
|
592
900
|
l(this, "show", this.open);
|
|
593
901
|
l(this, "hide", this.close);
|
|
594
|
-
|
|
902
|
+
n && (this.container = n);
|
|
595
903
|
}
|
|
596
904
|
async load() {
|
|
597
|
-
var m,
|
|
598
|
-
const e = (
|
|
599
|
-
minWidth:
|
|
600
|
-
maxWidth:
|
|
905
|
+
var m, w, b, f, _, ee, te, ne, ie;
|
|
906
|
+
const e = (w = (m = this.context.widgetConfig) == null ? void 0 : m.values) == null ? void 0 : w.brandingConfig, n = (b = this.content) == null ? void 0 : b.includes("mint-components"), i = (e == null ? void 0 : e.loadingHeight) || 500, s = (f = e == null ? void 0 : e.widgetSize) == null ? void 0 : f.embeddedWidgets, r = s != null && s.maxWidth ? L(s.maxWidth) : "", a = s != null && s.minWidth ? L(s.minWidth) : "", d = this._createFrame({
|
|
907
|
+
minWidth: a,
|
|
908
|
+
maxWidth: r,
|
|
601
909
|
initialHeight: i
|
|
602
910
|
}), c = this._findElement();
|
|
603
|
-
(
|
|
604
|
-
const { contentWindow:
|
|
605
|
-
if (!
|
|
911
|
+
(_ = this.context) != null && _.container && (c.style.visibility = "hidden", c.style.height = "0", c.style["overflow-y"] = "hidden"), this.container ? c.shadowRoot ? ((ee = c.shadowRoot.lastChild) == null ? void 0 : ee.nodeName) === "IFRAME" ? c.shadowRoot.replaceChild(d, c.shadowRoot.lastChild) : c.shadowRoot.appendChild(d) : c.firstChild ? c.replaceChild(d, c.firstChild) : c.appendChild(d) : (!c.firstChild || c.firstChild.nodeName === "#text") && c.appendChild(d);
|
|
912
|
+
const { contentWindow: h } = d;
|
|
913
|
+
if (!h)
|
|
606
914
|
throw new Error("Frame needs a content window");
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
${(
|
|
612
|
-
<link rel="preconnect" href="https://fast${
|
|
915
|
+
const u = h.document;
|
|
916
|
+
u.open();
|
|
917
|
+
const g = this.widgetApi.domain === "https://staging.referralsaasquatch.com" ? "-staging" : "";
|
|
918
|
+
u.write(`
|
|
919
|
+
${(te = e == null ? void 0 : e.main) != null && te.brandFont ? `
|
|
920
|
+
<link rel="preconnect" href="https://fast${g}.ssqt.io">
|
|
613
921
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
614
922
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
615
923
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
616
|
-
(
|
|
924
|
+
(ne = e == null ? void 0 : e.main) == null ? void 0 : ne.brandFont
|
|
617
925
|
)}" as="style">` : ""}
|
|
618
926
|
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
619
927
|
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
928
|
+
${n ? `
|
|
620
929
|
<style data-styles>
|
|
621
|
-
html { visibility:hidden;}
|
|
622
|
-
</style
|
|
930
|
+
html { visibility: hidden; }
|
|
931
|
+
</style>` : ""}
|
|
932
|
+
${this._getSkeletonPreloadHTML(n, (ie = e == null ? void 0 : e.color) == null ? void 0 : ie.backgroundColor)}
|
|
623
933
|
${this.content}
|
|
624
|
-
|
|
625
|
-
`),
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
const
|
|
629
|
-
for (const
|
|
630
|
-
const { height:
|
|
631
|
-
|
|
934
|
+
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
935
|
+
`), u.close(), Q(u, async () => {
|
|
936
|
+
const oe = h.squatch || h.widgetIdent;
|
|
937
|
+
d.height = i;
|
|
938
|
+
const ye = new h.ResizeObserver((ke) => {
|
|
939
|
+
for (const be of ke) {
|
|
940
|
+
const { height: xe } = be.contentRect;
|
|
941
|
+
d.height = xe;
|
|
632
942
|
}
|
|
633
|
-
}),
|
|
634
|
-
|
|
943
|
+
}), ve = await this._findInnerContainer(d);
|
|
944
|
+
ye.observe(ve), this._shouldFireLoadEvent() ? (this._loadEvent(oe), E("loaded")) : u && this._attachLoadEventListener(u, oe);
|
|
635
945
|
});
|
|
636
946
|
}
|
|
637
947
|
/**
|
|
@@ -639,43 +949,43 @@ class L extends ce {
|
|
|
639
949
|
*/
|
|
640
950
|
open() {
|
|
641
951
|
const e = this._findFrame();
|
|
642
|
-
if (!e) return
|
|
643
|
-
if (!e.contentWindow) return
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
const
|
|
952
|
+
if (!e) return E("no target element to open");
|
|
953
|
+
if (!e.contentWindow) return E("Frame needs a content window");
|
|
954
|
+
const n = this._findElement();
|
|
955
|
+
n.style.visibility = "unset", n.style.height = "auto", n.style["overflow-y"] = "auto", e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
956
|
+
const i = e.contentWindow.squatch || e.contentWindow.widgetIdent;
|
|
647
957
|
if (this.context.user)
|
|
648
|
-
this._loadEvent(
|
|
958
|
+
this._loadEvent(i), E("loaded");
|
|
649
959
|
else {
|
|
650
960
|
if (!e.contentDocument) return;
|
|
651
|
-
this._attachLoadEventListener(e.contentDocument,
|
|
961
|
+
this._attachLoadEventListener(e.contentDocument, i);
|
|
652
962
|
}
|
|
653
963
|
}
|
|
654
964
|
close() {
|
|
655
965
|
const e = this._findFrame();
|
|
656
|
-
if (!e) return
|
|
966
|
+
if (!e) return E("no target element to close");
|
|
657
967
|
e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
658
|
-
const
|
|
659
|
-
|
|
968
|
+
const n = this._findElement();
|
|
969
|
+
n.style.visibility = "hidden", n.style.height = "0", n.style["overflow-y"] = "hidden", E("Embed widget closed");
|
|
660
970
|
}
|
|
661
|
-
_error(e,
|
|
662
|
-
return super._error(e,
|
|
971
|
+
_error(e, n = "embed", i = "") {
|
|
972
|
+
return super._error(e, n, i);
|
|
663
973
|
}
|
|
664
974
|
_shouldFireLoadEvent() {
|
|
665
|
-
const e = !this.container,
|
|
666
|
-
return !!this.context.user && (e ||
|
|
975
|
+
const e = !this.container, n = this.container instanceof HTMLElement && (this.container.tagName.startsWith("SQUATCH-") || this.container.tagName.startsWith("IMPACT-"));
|
|
976
|
+
return !!this.context.user && (e || n);
|
|
667
977
|
}
|
|
668
978
|
}
|
|
669
|
-
const
|
|
670
|
-
let
|
|
671
|
-
class
|
|
672
|
-
constructor(e,
|
|
979
|
+
const T = k("squatch-js:POPUPwidget");
|
|
980
|
+
let U = 0;
|
|
981
|
+
class j extends pe {
|
|
982
|
+
constructor(e, n = ".squatchpop") {
|
|
673
983
|
super(e);
|
|
674
984
|
l(this, "trigger");
|
|
675
985
|
l(this, "id");
|
|
676
986
|
l(this, "show", this.open);
|
|
677
987
|
l(this, "hide", this.close);
|
|
678
|
-
this.trigger =
|
|
988
|
+
this.trigger = n, this.container ? this.id = "squatchModal" : (this.id = U === 0 ? "squatchModal" : `squatchModal__${U}`, U = U + 1), document.head.insertAdjacentHTML(
|
|
679
989
|
"beforeend",
|
|
680
990
|
`<style>#${this.id}::-webkit-scrollbar { display: none; }</style>`
|
|
681
991
|
);
|
|
@@ -684,41 +994,41 @@ class O extends ce {
|
|
|
684
994
|
if (!this.trigger) return;
|
|
685
995
|
let e;
|
|
686
996
|
try {
|
|
687
|
-
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e &&
|
|
997
|
+
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && T("No element found with trigger selector", this.trigger);
|
|
688
998
|
} catch {
|
|
689
|
-
|
|
999
|
+
T("Not a valid selector", this.trigger);
|
|
690
1000
|
}
|
|
691
1001
|
e && (e.onclick = () => {
|
|
692
1002
|
this.open();
|
|
693
1003
|
});
|
|
694
1004
|
}
|
|
695
1005
|
_createPopupDialog(e) {
|
|
696
|
-
var
|
|
697
|
-
const
|
|
698
|
-
|
|
1006
|
+
var d;
|
|
1007
|
+
const n = document.createElement("dialog"), i = (d = e == null ? void 0 : e.widgetSize) == null ? void 0 : d.popupWidgets, s = i != null && i.minWidth ? L(i.minWidth) : "auto", r = i != null && i.maxWidth ? L(i.maxWidth) : "500px";
|
|
1008
|
+
n.id = this.id, n.setAttribute(
|
|
699
1009
|
"style",
|
|
700
1010
|
`width: 100%; min-width: ${s}; max-width: ${r}; border: none; padding: 0;`
|
|
701
1011
|
);
|
|
702
|
-
const a = (
|
|
703
|
-
|
|
1012
|
+
const a = (c) => {
|
|
1013
|
+
c.stopPropagation(), c.target === n && n.close();
|
|
704
1014
|
};
|
|
705
|
-
return
|
|
1015
|
+
return n.addEventListener("click", a), n;
|
|
706
1016
|
}
|
|
707
1017
|
async load() {
|
|
708
|
-
var
|
|
709
|
-
const e = (
|
|
710
|
-
this._initialiseCTA();
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
const { contentWindow: c } =
|
|
1018
|
+
var p, g, m, w, b, f, _;
|
|
1019
|
+
const e = (g = (p = this.context.widgetConfig) == null ? void 0 : p.values) == null ? void 0 : g.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (m = this.content) == null ? void 0 : m.includes("mint-components"), s = this._createFrame();
|
|
1020
|
+
s.style.height = n + "px", this._initialiseCTA();
|
|
1021
|
+
const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r, d = this._createPopupDialog(e);
|
|
1022
|
+
d.appendChild(s), ((w = a.lastChild) == null ? void 0 : w.nodeName) === "DIALOG" ? a.replaceChild(d, a.lastChild) : a.appendChild(d);
|
|
1023
|
+
const { contentWindow: c } = s;
|
|
714
1024
|
if (!c)
|
|
715
1025
|
throw new Error("Frame needs a content window");
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
${(
|
|
721
|
-
<link rel="preconnect" href="https://fast${
|
|
1026
|
+
const h = c.document;
|
|
1027
|
+
h.open();
|
|
1028
|
+
const u = this.widgetApi.domain;
|
|
1029
|
+
h.write(`
|
|
1030
|
+
${(b = e == null ? void 0 : e.main) != null && b.brandFont ? `
|
|
1031
|
+
<link rel="preconnect" href="https://fast${u === "https://staging.referralsaasquatch.com" ? "-staging" : ""}.ssqt.io">
|
|
722
1032
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
723
1033
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
724
1034
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
@@ -726,57 +1036,61 @@ class O extends ce {
|
|
|
726
1036
|
)}" as="style">` : ""}
|
|
727
1037
|
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
728
1038
|
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
1039
|
+
${i ? `
|
|
729
1040
|
<style data-styles>
|
|
730
|
-
html { visibility:hidden;}
|
|
731
|
-
</style
|
|
1041
|
+
html { visibility: hidden; }
|
|
1042
|
+
</style>` : ""}
|
|
1043
|
+
${this._getSkeletonPreloadHTML(i, (_ = e == null ? void 0 : e.color) == null ? void 0 : _.backgroundColor)}
|
|
732
1044
|
${this.content}
|
|
733
|
-
|
|
734
|
-
`),
|
|
1045
|
+
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1046
|
+
`), h.close(), T("Popup template loaded into iframe"), await this._setupResizeHandler(s);
|
|
735
1047
|
}
|
|
736
|
-
async _setupResizeHandler(e
|
|
1048
|
+
async _setupResizeHandler(e) {
|
|
737
1049
|
const { contentWindow: n } = e;
|
|
738
1050
|
if (!n)
|
|
739
1051
|
throw new Error("Frame needs a content window");
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1052
|
+
const i = n.document;
|
|
1053
|
+
Q(i, async () => {
|
|
1054
|
+
i.body.style.overflowY = "hidden";
|
|
1055
|
+
let s = !0;
|
|
1056
|
+
new n.ResizeObserver((a) => {
|
|
1057
|
+
for (const d of a) {
|
|
1058
|
+
const { top: c, bottom: h } = d.contentRect, u = h + c;
|
|
1059
|
+
u <= 0 || (s ? (s = !1, e.style.height = "0", e.height = i.body.scrollHeight + "", e.style.height = "") : e.height = u + "", d.target.style = "");
|
|
746
1060
|
}
|
|
747
1061
|
}).observe(await this._findInnerContainer(e));
|
|
748
1062
|
});
|
|
749
1063
|
}
|
|
750
1064
|
open() {
|
|
751
|
-
const e = this.container ? this._findElement() : document.body,
|
|
752
|
-
if (!
|
|
753
|
-
|
|
1065
|
+
const e = this.container ? this._findElement() : document.body, i = (e.shadowRoot || e).querySelector(`#${this.id}`);
|
|
1066
|
+
if (!i) throw new Error("Could not determine container div");
|
|
1067
|
+
i.showModal();
|
|
754
1068
|
const s = this._findFrame();
|
|
755
1069
|
if (!s) throw new Error("Could not find iframe");
|
|
756
1070
|
const { contentWindow: r } = s;
|
|
757
1071
|
if (!r) throw new Error("Squatch.js has an empty iframe");
|
|
758
1072
|
const a = r.document;
|
|
759
|
-
|
|
760
|
-
var
|
|
761
|
-
const
|
|
762
|
-
(
|
|
1073
|
+
Q(a, () => {
|
|
1074
|
+
var c;
|
|
1075
|
+
const d = r.squatch || r.widgetIdent;
|
|
1076
|
+
(c = s.contentDocument) == null || c.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(d), T("Popup opened")) : this._attachLoadEventListener(a, d);
|
|
763
1077
|
});
|
|
764
1078
|
}
|
|
765
1079
|
close() {
|
|
766
1080
|
const e = this._findFrame();
|
|
767
1081
|
e != null && e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
768
|
-
const
|
|
1082
|
+
const n = this.container ? this._findElement() : document.body, s = (n.shadowRoot || n).querySelector(`#${this.id}`);
|
|
769
1083
|
if (!s) throw new Error("Could not determine container div");
|
|
770
|
-
s.close(),
|
|
1084
|
+
s.close(), T("Popup closed");
|
|
771
1085
|
}
|
|
772
1086
|
_clickedOutside({ target: e }) {
|
|
773
1087
|
}
|
|
774
|
-
_error(e,
|
|
775
|
-
return super._error(e,
|
|
1088
|
+
_error(e, n = "modal", i = "") {
|
|
1089
|
+
return super._error(e, n, i || "body { margin: 0; } .modal { box-shadow: none; border: 0; }");
|
|
776
1090
|
}
|
|
777
1091
|
}
|
|
778
|
-
const
|
|
779
|
-
class
|
|
1092
|
+
const v = k("squatch-js:widgets");
|
|
1093
|
+
class D {
|
|
780
1094
|
/**
|
|
781
1095
|
* Initialize a new {@link Widgets} instance.
|
|
782
1096
|
*
|
|
@@ -812,8 +1126,8 @@ class j {
|
|
|
812
1126
|
* @default "https://fast.ssqt.io/npm"
|
|
813
1127
|
*/
|
|
814
1128
|
l(this, "npmCdn");
|
|
815
|
-
const e =
|
|
816
|
-
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new
|
|
1129
|
+
const e = q(t);
|
|
1130
|
+
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new K(e);
|
|
817
1131
|
}
|
|
818
1132
|
/**
|
|
819
1133
|
* This function calls the {@link WidgetApi.upsertUser} method, and it renders
|
|
@@ -832,26 +1146,26 @@ class j {
|
|
|
832
1146
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
833
1147
|
*/
|
|
834
1148
|
async upsertUser(t) {
|
|
835
|
-
const
|
|
1149
|
+
const n = ce(t);
|
|
836
1150
|
try {
|
|
837
|
-
const
|
|
1151
|
+
const i = await this.api.upsertUser(n);
|
|
838
1152
|
return {
|
|
839
|
-
widget: this._renderWidget(
|
|
1153
|
+
widget: this._renderWidget(i, n, {
|
|
840
1154
|
type: "upsert",
|
|
841
|
-
user:
|
|
1155
|
+
user: n.user,
|
|
842
1156
|
engagementMedium: t.engagementMedium,
|
|
843
1157
|
container: t.container,
|
|
844
1158
|
trigger: t.trigger,
|
|
845
1159
|
widgetConfig: {
|
|
846
1160
|
values: {
|
|
847
|
-
brandingConfig:
|
|
1161
|
+
brandingConfig: i == null ? void 0 : i.brandingConfig
|
|
848
1162
|
}
|
|
849
1163
|
}
|
|
850
1164
|
}),
|
|
851
|
-
user:
|
|
1165
|
+
user: i.user
|
|
852
1166
|
};
|
|
853
|
-
} catch (
|
|
854
|
-
throw
|
|
1167
|
+
} catch (i) {
|
|
1168
|
+
throw v(i), i.apiErrorCode && this._renderErrorWidget(i, t.engagementMedium), new Error(i);
|
|
855
1169
|
}
|
|
856
1170
|
}
|
|
857
1171
|
/**
|
|
@@ -870,21 +1184,21 @@ class j {
|
|
|
870
1184
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
871
1185
|
*/
|
|
872
1186
|
async render(t) {
|
|
873
|
-
const
|
|
1187
|
+
const n = le(t);
|
|
874
1188
|
try {
|
|
875
|
-
const
|
|
1189
|
+
const i = await this.api.render(n);
|
|
876
1190
|
return {
|
|
877
|
-
widget: this._renderWidget(
|
|
1191
|
+
widget: this._renderWidget(i, n, {
|
|
878
1192
|
type: "passwordless",
|
|
879
|
-
engagementMedium:
|
|
880
|
-
container:
|
|
881
|
-
trigger:
|
|
882
|
-
widgetConfig:
|
|
1193
|
+
engagementMedium: n.engagementMedium,
|
|
1194
|
+
container: n.container,
|
|
1195
|
+
trigger: n.trigger,
|
|
1196
|
+
widgetConfig: i == null ? void 0 : i.widgetConfig
|
|
883
1197
|
}),
|
|
884
|
-
user:
|
|
1198
|
+
user: i.user
|
|
885
1199
|
};
|
|
886
|
-
} catch (
|
|
887
|
-
throw
|
|
1200
|
+
} catch (i) {
|
|
1201
|
+
throw i.apiErrorCode && this._renderErrorWidget(i, n.engagementMedium), new Error(i);
|
|
888
1202
|
}
|
|
889
1203
|
}
|
|
890
1204
|
/**
|
|
@@ -901,20 +1215,20 @@ class j {
|
|
|
901
1215
|
const s = await this.api.squatchReferralCookie();
|
|
902
1216
|
e(s);
|
|
903
1217
|
} catch (s) {
|
|
904
|
-
throw
|
|
1218
|
+
throw v("Autofill error", s), new Error(s);
|
|
905
1219
|
}
|
|
906
1220
|
return;
|
|
907
1221
|
}
|
|
908
1222
|
if (typeof e != "string")
|
|
909
1223
|
throw new Error("Autofill accepts a string or function");
|
|
910
|
-
let
|
|
911
|
-
if (
|
|
912
|
-
|
|
1224
|
+
let n = document.querySelectorAll(e), i;
|
|
1225
|
+
if (n.length > 0)
|
|
1226
|
+
i = n[0];
|
|
913
1227
|
else
|
|
914
|
-
throw
|
|
1228
|
+
throw v("Element id/class or function missing"), new Error("Element id/class or function missing");
|
|
915
1229
|
try {
|
|
916
1230
|
const s = await this.api.squatchReferralCookie();
|
|
917
|
-
|
|
1231
|
+
i.value = s.codes[0];
|
|
918
1232
|
} catch (s) {
|
|
919
1233
|
throw new Error(s);
|
|
920
1234
|
}
|
|
@@ -927,41 +1241,41 @@ class j {
|
|
|
927
1241
|
* @param {string} config.engagementMedium (POPUP, EMBED)
|
|
928
1242
|
* @returns {Widget} widget (PopupWidget or EmbedWidget)
|
|
929
1243
|
*/
|
|
930
|
-
_renderWidget(t, e,
|
|
931
|
-
var
|
|
932
|
-
if (
|
|
933
|
-
let
|
|
1244
|
+
_renderWidget(t, e, n) {
|
|
1245
|
+
var d;
|
|
1246
|
+
if (v("Rendering Widget..."), !t) throw new Error("Unable to get a response");
|
|
1247
|
+
let i, s = !!e.displayOnLoad;
|
|
934
1248
|
const r = t.jsOptions || {}, a = {
|
|
935
1249
|
content: t.template,
|
|
936
|
-
type: e.widgetType || ((
|
|
1250
|
+
type: e.widgetType || ((d = r.widget) == null ? void 0 : d.defaultWidgetType),
|
|
937
1251
|
api: this.api,
|
|
938
1252
|
domain: this.domain,
|
|
939
1253
|
npmCdn: this.npmCdn,
|
|
940
|
-
context:
|
|
1254
|
+
context: n
|
|
941
1255
|
};
|
|
942
|
-
return r.widgetUrlMappings && r.widgetUrlMappings.forEach((
|
|
1256
|
+
return r.widgetUrlMappings && r.widgetUrlMappings.forEach((c) => {
|
|
943
1257
|
var h, u;
|
|
944
|
-
|
|
945
|
-
`Don't display ${
|
|
1258
|
+
D._matchesUrl(c.url) && (c.widgetType !== "CONVERSION_WIDGET" || (u = (h = t.user) == null ? void 0 : h.referredBy) != null && u.code ? (s = c.displayOnLoad, v(`Display ${c.widgetType} on ${c.url}`)) : v(
|
|
1259
|
+
`Don't display ${c.widgetType} when no referral on widget rule match ${c.url}`
|
|
946
1260
|
));
|
|
947
|
-
}), r.fuelTankAutofillUrls && (
|
|
948
|
-
var u,
|
|
949
|
-
if (
|
|
950
|
-
const
|
|
951
|
-
|
|
1261
|
+
}), r.fuelTankAutofillUrls && (v("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: c, formSelector: h }) => {
|
|
1262
|
+
var u, p, g;
|
|
1263
|
+
if (D._matchesUrl(c) && (v("Fuel Tank URL matches"), (p = (u = t.user) == null ? void 0 : u.referredBy) != null && p.code)) {
|
|
1264
|
+
const m = document.querySelector(h);
|
|
1265
|
+
m ? m.value = ((g = t.user.referredBy.referredReward) == null ? void 0 : g.fuelTankCode) || "" : v(
|
|
952
1266
|
new Error(
|
|
953
1267
|
`Element with id/class ${h} was not found.`
|
|
954
1268
|
)
|
|
955
1269
|
);
|
|
956
1270
|
}
|
|
957
|
-
})), e.engagementMedium === "EMBED" ?
|
|
1271
|
+
})), e.engagementMedium === "EMBED" ? i = this._renderEmbedWidget(a) : (i = this._renderPopupWidget(a), s && i.open()), i;
|
|
958
1272
|
}
|
|
959
1273
|
_renderPopupWidget(t) {
|
|
960
|
-
const e = new
|
|
1274
|
+
const e = new j(t, t.context.trigger);
|
|
961
1275
|
return e.load(), e;
|
|
962
1276
|
}
|
|
963
1277
|
_renderEmbedWidget(t) {
|
|
964
|
-
const e = new
|
|
1278
|
+
const e = new O(t, t.context.container);
|
|
965
1279
|
return e.load(), e;
|
|
966
1280
|
}
|
|
967
1281
|
/**
|
|
@@ -971,11 +1285,11 @@ class j {
|
|
|
971
1285
|
* @returns {void}
|
|
972
1286
|
*/
|
|
973
1287
|
_renderErrorWidget(t, e = "POPUP") {
|
|
974
|
-
const { apiErrorCode:
|
|
975
|
-
|
|
1288
|
+
const { apiErrorCode: n, rsCode: i, message: s } = t;
|
|
1289
|
+
v(new Error(`${n} (${i}) ${s}`));
|
|
976
1290
|
const r = {
|
|
977
1291
|
content: "error",
|
|
978
|
-
rsCode:
|
|
1292
|
+
rsCode: i,
|
|
979
1293
|
api: this.api,
|
|
980
1294
|
domain: this.domain,
|
|
981
1295
|
npmCdn: this.npmCdn,
|
|
@@ -983,7 +1297,7 @@ class j {
|
|
|
983
1297
|
context: { type: "error" }
|
|
984
1298
|
};
|
|
985
1299
|
let a;
|
|
986
|
-
e === "EMBED" ? (a = new
|
|
1300
|
+
e === "EMBED" ? (a = new O(r), a.load()) : e === "POPUP" && (a = new j(r), a.load());
|
|
987
1301
|
}
|
|
988
1302
|
/**
|
|
989
1303
|
* @hidden
|
|
@@ -994,7 +1308,7 @@ class j {
|
|
|
994
1308
|
return !!window.location.href.match(new RegExp(t));
|
|
995
1309
|
}
|
|
996
1310
|
}
|
|
997
|
-
class
|
|
1311
|
+
class Oe {
|
|
998
1312
|
/**
|
|
999
1313
|
* Initialize a new {@link EventsApi} instance.
|
|
1000
1314
|
*
|
|
@@ -1014,8 +1328,8 @@ class Ue {
|
|
|
1014
1328
|
constructor(t) {
|
|
1015
1329
|
l(this, "tenantAlias");
|
|
1016
1330
|
l(this, "domain");
|
|
1017
|
-
const
|
|
1018
|
-
this.tenantAlias =
|
|
1331
|
+
const n = q(t);
|
|
1332
|
+
this.tenantAlias = n.tenantAlias, this.domain = n.domain;
|
|
1019
1333
|
}
|
|
1020
1334
|
/**
|
|
1021
1335
|
* Track an event for a user
|
|
@@ -1026,11 +1340,11 @@ class Ue {
|
|
|
1026
1340
|
* @return An ID to confirm the event has been accepted for asynchronous processing
|
|
1027
1341
|
*/
|
|
1028
1342
|
track(t, e) {
|
|
1029
|
-
const
|
|
1030
|
-
return
|
|
1343
|
+
const n = t, i = e, s = je(n), { jwt: r } = De(i), a = encodeURIComponent(this.tenantAlias), d = encodeURIComponent(s.userId), c = encodeURIComponent(s.accountId), h = `/api/v1/${a}/open/account/${c}/user/${d}/events`, u = this.domain + h;
|
|
1344
|
+
return X(u, JSON.stringify(s), r);
|
|
1031
1345
|
}
|
|
1032
1346
|
}
|
|
1033
|
-
function
|
|
1347
|
+
function je(o) {
|
|
1034
1348
|
if (!I(o)) throw new Error("tracking parameter must be an object");
|
|
1035
1349
|
if (!(o != null && o.accountId)) throw new Error("accountId field is required");
|
|
1036
1350
|
if (!(o != null && o.events)) throw new Error("events field is required");
|
|
@@ -1040,68 +1354,68 @@ function Re(o) {
|
|
|
1040
1354
|
throw new Error("'events' should be an array");
|
|
1041
1355
|
return t;
|
|
1042
1356
|
}
|
|
1043
|
-
function
|
|
1357
|
+
function De(o) {
|
|
1044
1358
|
if (!I(o)) throw new Error("'options' should be an object");
|
|
1045
1359
|
return o;
|
|
1046
1360
|
}
|
|
1047
|
-
function
|
|
1048
|
-
var
|
|
1049
|
-
const o = window[
|
|
1361
|
+
function Ne() {
|
|
1362
|
+
var i;
|
|
1363
|
+
const o = window[z] ? z : R, t = ((i = window["_" + o]) == null ? void 0 : i.ready) || [], e = window.impactOnReady || window.squatchOnReady, n = [...t, e].filter((s) => !!s);
|
|
1050
1364
|
setTimeout(() => {
|
|
1051
|
-
window[
|
|
1365
|
+
window[R] && (window[z] = window[R], n.forEach((s) => s()), window[R]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
1052
1366
|
}, 0);
|
|
1053
1367
|
}
|
|
1054
|
-
const
|
|
1055
|
-
const e = (
|
|
1056
|
-
[
|
|
1057
|
-
})).reduce((
|
|
1368
|
+
const x = k("squatch-js"), se = (o) => typeof o == "object" && !Array.isArray(o), me = (o, t) => {
|
|
1369
|
+
const e = (i) => se(t[i]) && o.hasOwnProperty(i) && se(o[i]), n = Object.getOwnPropertyNames(t).map((i) => ({
|
|
1370
|
+
[i]: e(i) ? me(o[i], t[i]) : t[i]
|
|
1371
|
+
})).reduce((i, s) => ({ ...i, ...s }), {});
|
|
1058
1372
|
return {
|
|
1059
1373
|
...o,
|
|
1060
|
-
...
|
|
1374
|
+
...n
|
|
1061
1375
|
};
|
|
1062
1376
|
};
|
|
1063
|
-
function
|
|
1377
|
+
function N(o) {
|
|
1064
1378
|
const t = atob(o.replace(/_/g, "/").replace(/-/g, "+")), e = new Uint8Array(t.length);
|
|
1065
|
-
for (let
|
|
1066
|
-
e[
|
|
1379
|
+
for (let n = 0; n < t.length; n++)
|
|
1380
|
+
e[n] = t.charCodeAt(n);
|
|
1067
1381
|
return new TextDecoder("utf8").decode(e);
|
|
1068
1382
|
}
|
|
1069
|
-
function
|
|
1383
|
+
function re(o) {
|
|
1070
1384
|
const t = new TextEncoder().encode(o), e = Array.from(
|
|
1071
1385
|
t,
|
|
1072
|
-
(
|
|
1386
|
+
(n) => String.fromCodePoint(n)
|
|
1073
1387
|
).join("");
|
|
1074
1388
|
return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1075
1389
|
}
|
|
1076
|
-
function
|
|
1077
|
-
var o, t, e = "weird_get_top_level_domain=cookie",
|
|
1078
|
-
for (o =
|
|
1079
|
-
if (t =
|
|
1390
|
+
function Fe() {
|
|
1391
|
+
var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
|
|
1392
|
+
for (o = n.length - 1; o >= 0; o--)
|
|
1393
|
+
if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
|
|
1080
1394
|
return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
|
|
1081
1395
|
}
|
|
1082
|
-
function
|
|
1396
|
+
function He() {
|
|
1083
1397
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
|
|
1084
1398
|
if (e) {
|
|
1085
|
-
let
|
|
1399
|
+
let n = "", i = "", s = "";
|
|
1086
1400
|
try {
|
|
1087
|
-
|
|
1401
|
+
n = JSON.parse(N(e));
|
|
1088
1402
|
} catch (r) {
|
|
1089
|
-
|
|
1403
|
+
x("Unable to decode params", r);
|
|
1090
1404
|
return;
|
|
1091
1405
|
}
|
|
1092
1406
|
try {
|
|
1093
|
-
|
|
1407
|
+
i = JSON.parse(N(M.get("_saasquatch"))), x("existing cookie", i);
|
|
1094
1408
|
} catch (r) {
|
|
1095
|
-
|
|
1409
|
+
x("Unable to retrieve cookie", r);
|
|
1096
1410
|
}
|
|
1097
1411
|
try {
|
|
1098
|
-
const r =
|
|
1099
|
-
if (
|
|
1100
|
-
const a =
|
|
1101
|
-
s =
|
|
1412
|
+
const r = Fe();
|
|
1413
|
+
if (x("domain retrieved:", r), i) {
|
|
1414
|
+
const a = me(i, n);
|
|
1415
|
+
s = re(JSON.stringify(a)), x("cookie to store:", a);
|
|
1102
1416
|
} else
|
|
1103
|
-
s =
|
|
1104
|
-
|
|
1417
|
+
s = re(JSON.stringify(n)), x("cookie to store:", n);
|
|
1418
|
+
M.set("_saasquatch", s, {
|
|
1105
1419
|
expires: 365,
|
|
1106
1420
|
secure: !1,
|
|
1107
1421
|
sameSite: "Lax",
|
|
@@ -1109,67 +1423,67 @@ function Me() {
|
|
|
1109
1423
|
path: "/"
|
|
1110
1424
|
});
|
|
1111
1425
|
} catch (r) {
|
|
1112
|
-
|
|
1426
|
+
x("Unable to set cookie", r);
|
|
1113
1427
|
}
|
|
1114
1428
|
}
|
|
1115
1429
|
}
|
|
1116
|
-
const
|
|
1117
|
-
function
|
|
1430
|
+
const P = k("squatch-js");
|
|
1431
|
+
function Be() {
|
|
1118
1432
|
var u;
|
|
1119
1433
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
|
|
1120
1434
|
if (!e) {
|
|
1121
|
-
|
|
1435
|
+
P("No _saasquatchExtra param");
|
|
1122
1436
|
return;
|
|
1123
1437
|
}
|
|
1124
|
-
const
|
|
1438
|
+
const n = q({
|
|
1125
1439
|
tenantAlias: "UNKNOWN"
|
|
1126
1440
|
});
|
|
1127
|
-
if (!
|
|
1128
|
-
|
|
1441
|
+
if (!n.domain) {
|
|
1442
|
+
P("domain must be provided in config to use _saasquatchExtra");
|
|
1129
1443
|
return;
|
|
1130
1444
|
}
|
|
1131
|
-
let
|
|
1445
|
+
let i;
|
|
1132
1446
|
try {
|
|
1133
|
-
|
|
1447
|
+
i = JSON.parse(N(e));
|
|
1134
1448
|
} catch {
|
|
1135
|
-
|
|
1449
|
+
P("Unable to decode _saasquatchExtra config");
|
|
1136
1450
|
return;
|
|
1137
1451
|
}
|
|
1138
|
-
function s(
|
|
1139
|
-
return
|
|
1452
|
+
function s(p) {
|
|
1453
|
+
return p.replace(/^https?:\/\//, "");
|
|
1140
1454
|
}
|
|
1141
|
-
const r = s(
|
|
1142
|
-
if (!
|
|
1143
|
-
|
|
1455
|
+
const r = s(n.domain), a = Object.keys((i == null ? void 0 : i[r]) || {})[0], d = (u = i == null ? void 0 : i[r]) == null ? void 0 : u[a];
|
|
1456
|
+
if (!d) {
|
|
1457
|
+
P("_saasquatchExtra did not have an expected structure");
|
|
1144
1458
|
return;
|
|
1145
1459
|
}
|
|
1146
|
-
const { autoPopupWidgetType:
|
|
1460
|
+
const { autoPopupWidgetType: c, ...h } = d;
|
|
1147
1461
|
return {
|
|
1148
1462
|
widgetConfig: {
|
|
1149
|
-
widgetType:
|
|
1463
|
+
widgetType: c,
|
|
1150
1464
|
displayOnLoad: !0,
|
|
1151
1465
|
...h
|
|
1152
1466
|
},
|
|
1153
1467
|
squatchConfig: {
|
|
1154
|
-
...
|
|
1468
|
+
...n,
|
|
1155
1469
|
tenantAlias: a
|
|
1156
1470
|
}
|
|
1157
1471
|
};
|
|
1158
1472
|
}
|
|
1159
|
-
const
|
|
1160
|
-
function
|
|
1473
|
+
const Je = k("squatch-js:decodeUserJwt");
|
|
1474
|
+
function ze(o) {
|
|
1161
1475
|
var t;
|
|
1162
1476
|
try {
|
|
1163
1477
|
const e = o.split(".")[1];
|
|
1164
1478
|
if (e === void 0) return null;
|
|
1165
|
-
const
|
|
1166
|
-
return (t = JSON.parse(
|
|
1479
|
+
const n = N(e);
|
|
1480
|
+
return (t = JSON.parse(n)) == null ? void 0 : t.user;
|
|
1167
1481
|
} catch (e) {
|
|
1168
|
-
return
|
|
1482
|
+
return Je(e), null;
|
|
1169
1483
|
}
|
|
1170
1484
|
}
|
|
1171
|
-
const
|
|
1172
|
-
class
|
|
1485
|
+
const ae = k("squatch-js:DeclarativeWidget");
|
|
1486
|
+
class ge extends HTMLElement {
|
|
1173
1487
|
constructor() {
|
|
1174
1488
|
super();
|
|
1175
1489
|
/**
|
|
@@ -1222,28 +1536,28 @@ class le extends HTMLElement {
|
|
|
1222
1536
|
* @hidden
|
|
1223
1537
|
*/
|
|
1224
1538
|
l(this, "loaded");
|
|
1225
|
-
l(this, "_setWidget", (e,
|
|
1539
|
+
l(this, "_setWidget", (e, n) => {
|
|
1226
1540
|
var s;
|
|
1227
|
-
const
|
|
1541
|
+
const i = {
|
|
1228
1542
|
api: this.widgetApi,
|
|
1229
1543
|
content: e.template,
|
|
1230
1544
|
context: {
|
|
1231
|
-
type:
|
|
1232
|
-
user:
|
|
1545
|
+
type: n.type,
|
|
1546
|
+
user: n.user,
|
|
1233
1547
|
container: this.container || void 0,
|
|
1234
1548
|
engagementMedium: this.type,
|
|
1235
1549
|
widgetConfig: e.widgetConfig
|
|
1236
1550
|
},
|
|
1237
1551
|
type: this.widgetType,
|
|
1238
1552
|
domain: ((s = this.config) == null ? void 0 : s.domain) || A,
|
|
1239
|
-
npmCdn:
|
|
1553
|
+
npmCdn: V,
|
|
1240
1554
|
container: this
|
|
1241
1555
|
};
|
|
1242
1556
|
if (this.type === "EMBED")
|
|
1243
|
-
return new
|
|
1557
|
+
return new O(i);
|
|
1244
1558
|
{
|
|
1245
1559
|
const r = this.firstChild ? null : void 0;
|
|
1246
|
-
return new
|
|
1560
|
+
return new j(i, r);
|
|
1247
1561
|
}
|
|
1248
1562
|
});
|
|
1249
1563
|
/**
|
|
@@ -1251,8 +1565,8 @@ class le extends HTMLElement {
|
|
|
1251
1565
|
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
1252
1566
|
*/
|
|
1253
1567
|
l(this, "setErrorWidget", (e) => {
|
|
1254
|
-
var
|
|
1255
|
-
const
|
|
1568
|
+
var i;
|
|
1569
|
+
const n = {
|
|
1256
1570
|
api: this.widgetApi,
|
|
1257
1571
|
content: "error",
|
|
1258
1572
|
context: {
|
|
@@ -1260,15 +1574,15 @@ class le extends HTMLElement {
|
|
|
1260
1574
|
container: this.container || void 0
|
|
1261
1575
|
},
|
|
1262
1576
|
type: "ERROR_WIDGET",
|
|
1263
|
-
domain: ((
|
|
1264
|
-
npmCdn:
|
|
1577
|
+
domain: ((i = this.config) == null ? void 0 : i.domain) || A,
|
|
1578
|
+
npmCdn: V,
|
|
1265
1579
|
container: this
|
|
1266
1580
|
};
|
|
1267
1581
|
if (this.type === "EMBED")
|
|
1268
|
-
return new
|
|
1582
|
+
return new O(n);
|
|
1269
1583
|
{
|
|
1270
1584
|
const s = this.firstChild ? null : void 0;
|
|
1271
|
-
return new
|
|
1585
|
+
return new j(n, s);
|
|
1272
1586
|
}
|
|
1273
1587
|
});
|
|
1274
1588
|
l(this, "reload", this.renderWidget);
|
|
@@ -1276,23 +1590,23 @@ class le extends HTMLElement {
|
|
|
1276
1590
|
l(this, "hide", this.close);
|
|
1277
1591
|
this.attachShadow({
|
|
1278
1592
|
mode: "open"
|
|
1279
|
-
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config =
|
|
1593
|
+
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = Y(), this.token = W(), this.tenant = window.squatchTenant, this.container = this;
|
|
1280
1594
|
}
|
|
1281
1595
|
_setupApis(e) {
|
|
1282
|
-
var
|
|
1596
|
+
var n, i;
|
|
1283
1597
|
if (!this.tenant) throw new Error("tenantAlias not provided");
|
|
1284
|
-
this.widgetApi = new
|
|
1598
|
+
this.widgetApi = new K({
|
|
1285
1599
|
tenantAlias: (e == null ? void 0 : e.tenantAlias) || this.tenant,
|
|
1286
|
-
domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) || A
|
|
1287
|
-
}), this.analyticsApi = new ae({
|
|
1288
1600
|
domain: (e == null ? void 0 : e.domain) || ((n = this.config) == null ? void 0 : n.domain) || A
|
|
1601
|
+
}), this.analyticsApi = new he({
|
|
1602
|
+
domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) || A
|
|
1289
1603
|
});
|
|
1290
1604
|
}
|
|
1291
1605
|
getWidgetType(e) {
|
|
1292
1606
|
return e && (e.includes("websiteReferralWidget") || e.includes("friendWidget")) ? "instant-access" : "verified-access";
|
|
1293
1607
|
}
|
|
1294
1608
|
async renderPasswordlessVariant() {
|
|
1295
|
-
return this._setupApis(),
|
|
1609
|
+
return this._setupApis(), ae("Rendering as an Instant Access widget"), await this.widgetApi.render({
|
|
1296
1610
|
engagementMedium: this.type,
|
|
1297
1611
|
widgetType: this.widgetType,
|
|
1298
1612
|
locale: this.locale
|
|
@@ -1300,8 +1614,8 @@ class le extends HTMLElement {
|
|
|
1300
1614
|
}
|
|
1301
1615
|
async renderUserUpsertVariant() {
|
|
1302
1616
|
this._setupApis();
|
|
1303
|
-
const e =
|
|
1304
|
-
return e ? (
|
|
1617
|
+
const e = ze(this.token);
|
|
1618
|
+
return e ? (ae("Rendering as a Verified widget"), await this.widgetApi.upsertUser({
|
|
1305
1619
|
user: e,
|
|
1306
1620
|
locale: this.locale,
|
|
1307
1621
|
engagementMedium: this.type,
|
|
@@ -1311,7 +1625,7 @@ class le extends HTMLElement {
|
|
|
1311
1625
|
locale: this.locale,
|
|
1312
1626
|
engagementMedium: this.type,
|
|
1313
1627
|
widgetType: this.widgetType
|
|
1314
|
-
}).then((
|
|
1628
|
+
}).then((i) => this._setWidget(i, { type: "upsert", user: e })).catch(this.setErrorWidget)) : this.setErrorWidget(Error("No user object in token."));
|
|
1315
1629
|
}
|
|
1316
1630
|
/**
|
|
1317
1631
|
* Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
|
|
@@ -1348,8 +1662,8 @@ class le extends HTMLElement {
|
|
|
1348
1662
|
static get observedAttributes() {
|
|
1349
1663
|
return ["widget", "locale"];
|
|
1350
1664
|
}
|
|
1351
|
-
attributeChangedCallback(e,
|
|
1352
|
-
if (!(
|
|
1665
|
+
attributeChangedCallback(e, n, i) {
|
|
1666
|
+
if (!(n === i || !this.loaded))
|
|
1353
1667
|
switch (e) {
|
|
1354
1668
|
case "locale":
|
|
1355
1669
|
case "widget":
|
|
@@ -1359,15 +1673,15 @@ class le extends HTMLElement {
|
|
|
1359
1673
|
}
|
|
1360
1674
|
async connectedCallback() {
|
|
1361
1675
|
this.loaded = !0, this.container = this.getAttribute("container"), this.widgetType = this.getAttribute("widget") || void 0;
|
|
1362
|
-
const e = this.getWidgetType(this.widgetType), { getSkeleton:
|
|
1676
|
+
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await Promise.resolve().then(() => Pe), i = n({
|
|
1363
1677
|
height: "100%",
|
|
1364
1678
|
type: e
|
|
1365
1679
|
}), s = document.createElement("div");
|
|
1366
|
-
s.id = "loading-skeleton", s.innerHTML =
|
|
1680
|
+
s.id = "loading-skeleton", s.innerHTML = i;
|
|
1367
1681
|
const r = this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
1368
1682
|
if (this.type === "POPUP") {
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1683
|
+
const d = r.getElementById("#squatchModal");
|
|
1684
|
+
d && (d.innerHTML = "", d.appendChild(s));
|
|
1371
1685
|
} else
|
|
1372
1686
|
r.innerHTML = "", r.appendChild(s);
|
|
1373
1687
|
await this.renderWidget();
|
|
@@ -1375,93 +1689,93 @@ class le extends HTMLElement {
|
|
|
1375
1689
|
a && a.remove(), this.getAttribute("open") !== null && this.open();
|
|
1376
1690
|
}
|
|
1377
1691
|
}
|
|
1378
|
-
class
|
|
1692
|
+
class fe extends ge {
|
|
1379
1693
|
constructor() {
|
|
1380
1694
|
super(), this.type = "EMBED", this.loaded = !1;
|
|
1381
1695
|
}
|
|
1382
1696
|
}
|
|
1383
|
-
class
|
|
1697
|
+
class we extends ge {
|
|
1384
1698
|
constructor() {
|
|
1385
1699
|
super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (t) => {
|
|
1386
1700
|
t.stopPropagation(), this.open();
|
|
1387
1701
|
});
|
|
1388
1702
|
}
|
|
1389
1703
|
}
|
|
1390
|
-
class
|
|
1704
|
+
class Ge extends fe {
|
|
1391
1705
|
}
|
|
1392
|
-
class
|
|
1706
|
+
class Ve extends we {
|
|
1393
1707
|
}
|
|
1394
|
-
class
|
|
1708
|
+
class Xe extends fe {
|
|
1395
1709
|
}
|
|
1396
|
-
class
|
|
1710
|
+
class Qe extends we {
|
|
1397
1711
|
}
|
|
1398
|
-
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed",
|
|
1399
|
-
window.customElements.get("impact-embed") || window.customElements.define("impact-embed",
|
|
1400
|
-
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup",
|
|
1401
|
-
window.customElements.get("impact-popup") || window.customElements.define("impact-popup",
|
|
1402
|
-
function
|
|
1712
|
+
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", Ge);
|
|
1713
|
+
window.customElements.get("impact-embed") || window.customElements.define("impact-embed", Xe);
|
|
1714
|
+
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Ve);
|
|
1715
|
+
window.customElements.get("impact-popup") || window.customElements.define("impact-popup", Qe);
|
|
1716
|
+
function Ze() {
|
|
1403
1717
|
console.log(
|
|
1404
1718
|
"Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
|
|
1405
1719
|
);
|
|
1406
1720
|
}
|
|
1407
|
-
const
|
|
1408
|
-
let
|
|
1409
|
-
function
|
|
1410
|
-
return
|
|
1721
|
+
const $ = k("squatch-js");
|
|
1722
|
+
let F = null, H = null, B = null;
|
|
1723
|
+
function et() {
|
|
1724
|
+
return F || J({}), F;
|
|
1411
1725
|
}
|
|
1412
|
-
function
|
|
1413
|
-
return
|
|
1726
|
+
function Z() {
|
|
1727
|
+
return H || J({}), H;
|
|
1414
1728
|
}
|
|
1415
|
-
function
|
|
1416
|
-
return
|
|
1729
|
+
function tt() {
|
|
1730
|
+
return B || J({}), B;
|
|
1417
1731
|
}
|
|
1418
|
-
function
|
|
1732
|
+
function nt(o) {
|
|
1419
1733
|
var t;
|
|
1420
|
-
return (t =
|
|
1734
|
+
return (t = Z()) == null ? void 0 : t.render(o);
|
|
1421
1735
|
}
|
|
1422
|
-
function
|
|
1736
|
+
function it() {
|
|
1423
1737
|
var t;
|
|
1424
|
-
const o =
|
|
1738
|
+
const o = Be();
|
|
1425
1739
|
if (o) {
|
|
1426
|
-
const { squatchConfig: e, widgetConfig:
|
|
1427
|
-
return
|
|
1740
|
+
const { squatchConfig: e, widgetConfig: n } = o;
|
|
1741
|
+
return J(e), (t = Z()) == null ? void 0 : t.render(n);
|
|
1428
1742
|
}
|
|
1429
1743
|
}
|
|
1430
|
-
function
|
|
1431
|
-
const e =
|
|
1432
|
-
e.tenantAlias.match("^test") || e.debug ?
|
|
1744
|
+
function J(o) {
|
|
1745
|
+
const e = q(o);
|
|
1746
|
+
e.tenantAlias.match("^test") || e.debug ? Ae("squatch-js*") : Ie(), $("initializing ..."), F = new K(e), H = new D(e), B = new Oe(e), $("Widget API instance", F), $("Widgets instance", H), $("Events API instance", B);
|
|
1433
1747
|
}
|
|
1434
|
-
function
|
|
1748
|
+
function ot(o) {
|
|
1435
1749
|
o();
|
|
1436
1750
|
}
|
|
1437
|
-
function
|
|
1438
|
-
|
|
1751
|
+
function st(o) {
|
|
1752
|
+
Z().autofill(o);
|
|
1439
1753
|
}
|
|
1440
|
-
function
|
|
1441
|
-
|
|
1754
|
+
function Ye() {
|
|
1755
|
+
He();
|
|
1442
1756
|
}
|
|
1443
|
-
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop &&
|
|
1444
|
-
var
|
|
1445
|
-
(
|
|
1757
|
+
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Ye();
|
|
1758
|
+
var de;
|
|
1759
|
+
(de = window.squatch) != null && de.init && $(
|
|
1446
1760
|
"Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
|
|
1447
1761
|
);
|
|
1448
|
-
typeof document < "u" &&
|
|
1762
|
+
typeof document < "u" && Ne();
|
|
1449
1763
|
export {
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1764
|
+
fe as DeclarativeEmbedWidget,
|
|
1765
|
+
we as DeclarativePopupWidget,
|
|
1766
|
+
O as EmbedWidget,
|
|
1767
|
+
j as PopupWidget,
|
|
1768
|
+
K as WidgetApi,
|
|
1769
|
+
D as Widgets,
|
|
1770
|
+
it as _auto,
|
|
1771
|
+
et as api,
|
|
1772
|
+
st as autofill,
|
|
1773
|
+
tt as events,
|
|
1774
|
+
Ze as help,
|
|
1775
|
+
J as init,
|
|
1776
|
+
Ye as pushCookie,
|
|
1777
|
+
ot as ready,
|
|
1778
|
+
nt as widget,
|
|
1779
|
+
Z as widgets
|
|
1466
1780
|
};
|
|
1467
1781
|
//# sourceMappingURL=squatch.esm.js.map
|