@saasquatch/squatch-js 2.8.3-2 → 2.8.3-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/squatch.cjs.js +13 -13
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +191 -180
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +11 -11
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -2
- package/package.json +1 -1
- package/coverage/clover.xml +0 -981
- package/coverage/coverage-final.json +0 -24
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -1804
package/dist/squatch.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (o, t, e) =>
|
|
1
|
+
var Ce = Object.defineProperty;
|
|
2
|
+
var Ae = (o, t, e) => t in o ? Ce(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var l = (o, t, e) => Ae(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
let C = null;
|
|
5
|
-
function
|
|
5
|
+
function Ie(o) {
|
|
6
6
|
const e = o.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
7
7
|
C = new RegExp(`^${e}$`);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function _e() {
|
|
10
10
|
C = null;
|
|
11
11
|
}
|
|
12
12
|
function k(o) {
|
|
@@ -20,7 +20,7 @@ function k(o) {
|
|
|
20
20
|
}), t;
|
|
21
21
|
}
|
|
22
22
|
/*! js-cookie v3.0.5 | MIT */
|
|
23
|
-
function
|
|
23
|
+
function q(o) {
|
|
24
24
|
for (var t = 1; t < arguments.length; t++) {
|
|
25
25
|
var e = arguments[t];
|
|
26
26
|
for (var n in e)
|
|
@@ -28,7 +28,7 @@ function S(o) {
|
|
|
28
28
|
}
|
|
29
29
|
return o;
|
|
30
30
|
}
|
|
31
|
-
var
|
|
31
|
+
var Te = {
|
|
32
32
|
read: function(o) {
|
|
33
33
|
return o[0] === '"' && (o = o.slice(1, -1)), o.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
34
34
|
},
|
|
@@ -39,10 +39,10 @@ var _e = {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
function
|
|
42
|
+
function V(o, t) {
|
|
43
43
|
function e(i, s, r) {
|
|
44
44
|
if (!(typeof document > "u")) {
|
|
45
|
-
r =
|
|
45
|
+
r = q({}, 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);
|
|
46
46
|
var a = "";
|
|
47
47
|
for (var d in r)
|
|
48
48
|
r[d] && (a += "; " + d, r[d] !== !0 && (a += "=" + r[d].split(";")[0]));
|
|
@@ -71,16 +71,16 @@ function G(o, t) {
|
|
|
71
71
|
e(
|
|
72
72
|
i,
|
|
73
73
|
"",
|
|
74
|
-
|
|
74
|
+
q({}, s, {
|
|
75
75
|
expires: -1
|
|
76
76
|
})
|
|
77
77
|
);
|
|
78
78
|
},
|
|
79
79
|
withAttributes: function(i) {
|
|
80
|
-
return
|
|
80
|
+
return V(this.converter, q({}, this.attributes, i));
|
|
81
81
|
},
|
|
82
82
|
withConverter: function(i) {
|
|
83
|
-
return
|
|
83
|
+
return V(q({}, this.converter, i), this.attributes);
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -89,11 +89,11 @@ function G(o, t) {
|
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
|
-
var M =
|
|
93
|
-
const A = "https://app.referralsaasquatch.com",
|
|
94
|
-
function
|
|
92
|
+
var M = V(Te, { path: "/" });
|
|
93
|
+
const A = "https://app.referralsaasquatch.com", X = "https://fast.ssqt.io/npm", S = "squatch", z = "impact";
|
|
94
|
+
function W(o) {
|
|
95
95
|
if (typeof o != "object") throw new Error("config must be an object");
|
|
96
|
-
const t = window.squatchTenant, e =
|
|
96
|
+
const t = window.squatchTenant, e = K(), n = {
|
|
97
97
|
tenantAlias: (o == null ? void 0 : o.tenantAlias) || t,
|
|
98
98
|
domain: (o == null ? void 0 : o.domain) || (e == null ? void 0 : e.domain),
|
|
99
99
|
npmCdn: (o == null ? void 0 : o.npmCdn) || (e == null ? void 0 : e.npmCdn),
|
|
@@ -101,7 +101,7 @@ function q(o) {
|
|
|
101
101
|
};
|
|
102
102
|
if (typeof n.tenantAlias != "string")
|
|
103
103
|
throw new Error("tenantAlias not provided");
|
|
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 ||
|
|
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 || X;
|
|
105
105
|
return {
|
|
106
106
|
tenantAlias: i,
|
|
107
107
|
domain: s,
|
|
@@ -112,27 +112,38 @@ function q(o) {
|
|
|
112
112
|
function I(o) {
|
|
113
113
|
return typeof o == "object" && !Array.isArray(o) && o !== null;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Ue(o) {
|
|
116
116
|
if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
|
|
117
117
|
return o;
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function le(o) {
|
|
120
120
|
if (!I(o)) throw new Error("Widget properties must be an object");
|
|
121
121
|
if (!(o != null && o.user)) throw new Error("Required properties missing.");
|
|
122
122
|
return o;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function he(o) {
|
|
125
125
|
if (!I(o)) throw new Error("Widget properties must be an object");
|
|
126
126
|
return o;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function $() {
|
|
129
129
|
return window.impactToken || window.squatchToken;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function K() {
|
|
132
132
|
return window.impactConfig || window.squatchConfig;
|
|
133
133
|
}
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
function J(o) {
|
|
135
|
+
console.log("[DEBUG] parseErrorResponse - raw responseText:", o);
|
|
136
|
+
try {
|
|
137
|
+
const t = JSON.parse(o);
|
|
138
|
+
if (console.log("[DEBUG] parseErrorResponse - parsed JSON:", t), t && typeof t == "object")
|
|
139
|
+
return console.log("[DEBUG] parseErrorResponse - returning parsed object with apiErrorCode:", t.apiErrorCode), t;
|
|
140
|
+
} catch (t) {
|
|
141
|
+
console.log("[DEBUG] parseErrorResponse - JSON parse failed:", t);
|
|
142
|
+
}
|
|
143
|
+
return { message: o };
|
|
144
|
+
}
|
|
145
|
+
async function We(o, t, e, n) {
|
|
146
|
+
const i = n || $(), s = {
|
|
136
147
|
Accept: "application/json",
|
|
137
148
|
"Content-Type": "application/json",
|
|
138
149
|
...i ? { Authorization: `Bearer ${i}` } : {},
|
|
@@ -144,17 +155,17 @@ async function $e(o, t, e, n) {
|
|
|
144
155
|
body: JSON.stringify({ query: t, variables: e }),
|
|
145
156
|
headers: s
|
|
146
157
|
});
|
|
147
|
-
if (!r.ok) throw
|
|
158
|
+
if (!r.ok) throw J(await r.text());
|
|
148
159
|
return await r.json();
|
|
149
160
|
} catch (r) {
|
|
150
161
|
throw r;
|
|
151
162
|
}
|
|
152
163
|
}
|
|
153
|
-
async function
|
|
164
|
+
async function $e(o, t = "") {
|
|
154
165
|
const e = {
|
|
155
166
|
Accept: "application/json",
|
|
156
167
|
"Content-Type": "application/json"
|
|
157
|
-
}, n = t ||
|
|
168
|
+
}, n = t || $();
|
|
158
169
|
n && (e["X-SaaSquatch-User-Token"] = n);
|
|
159
170
|
try {
|
|
160
171
|
const i = await fetch(o, {
|
|
@@ -162,17 +173,17 @@ async function qe(o, t = "") {
|
|
|
162
173
|
credentials: "include",
|
|
163
174
|
headers: e
|
|
164
175
|
}), s = await i.text();
|
|
165
|
-
if (!i.ok) throw
|
|
176
|
+
if (!i.ok) throw J(s);
|
|
166
177
|
return s && JSON.parse(s);
|
|
167
178
|
} catch (i) {
|
|
168
179
|
throw i;
|
|
169
180
|
}
|
|
170
181
|
}
|
|
171
|
-
async function
|
|
182
|
+
async function Q(o, t, e) {
|
|
172
183
|
const n = {
|
|
173
184
|
Accept: "application/json",
|
|
174
185
|
"Content-Type": "application/json"
|
|
175
|
-
}, i = e ||
|
|
186
|
+
}, i = e || $();
|
|
176
187
|
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
177
188
|
try {
|
|
178
189
|
const s = await fetch(o, {
|
|
@@ -180,18 +191,18 @@ async function X(o, t, e) {
|
|
|
180
191
|
body: t,
|
|
181
192
|
headers: n
|
|
182
193
|
}), r = await s.text();
|
|
183
|
-
if (!s.ok) throw
|
|
194
|
+
if (!s.ok) throw J(r);
|
|
184
195
|
return r && JSON.parse(r);
|
|
185
196
|
} catch (s) {
|
|
186
197
|
throw s;
|
|
187
198
|
}
|
|
188
199
|
}
|
|
189
|
-
async function
|
|
200
|
+
async function qe(o, t, e) {
|
|
190
201
|
const n = {
|
|
191
202
|
Accept: "application/json",
|
|
192
203
|
"Content-Type": "application/json",
|
|
193
204
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
194
|
-
}, i = e ||
|
|
205
|
+
}, i = e || $();
|
|
195
206
|
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
196
207
|
try {
|
|
197
208
|
const s = await fetch(o, {
|
|
@@ -200,7 +211,7 @@ async function We(o, t, e) {
|
|
|
200
211
|
credentials: "include",
|
|
201
212
|
body: t
|
|
202
213
|
}), r = await s.text();
|
|
203
|
-
if (!s.ok) throw
|
|
214
|
+
if (!s.ok) throw J(r);
|
|
204
215
|
return r && JSON.parse(r);
|
|
205
216
|
} catch (s) {
|
|
206
217
|
throw s;
|
|
@@ -221,7 +232,7 @@ const Se = `
|
|
|
221
232
|
}
|
|
222
233
|
}
|
|
223
234
|
`;
|
|
224
|
-
class
|
|
235
|
+
class Z {
|
|
225
236
|
/**
|
|
226
237
|
* Initialize a new {@link WidgetApi} instance.
|
|
227
238
|
*
|
|
@@ -243,7 +254,7 @@ class K {
|
|
|
243
254
|
l(this, "domain");
|
|
244
255
|
l(this, "npmCdn");
|
|
245
256
|
l(this, "referralCookie", this.squatchReferralCookie);
|
|
246
|
-
const n =
|
|
257
|
+
const n = W(t);
|
|
247
258
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain, this.npmCdn = n.npmCdn;
|
|
248
259
|
}
|
|
249
260
|
/**
|
|
@@ -261,7 +272,7 @@ class K {
|
|
|
261
272
|
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
262
273
|
*/
|
|
263
274
|
upsertUser(t) {
|
|
264
|
-
const n =
|
|
275
|
+
const n = le(t), {
|
|
265
276
|
widgetType: i,
|
|
266
277
|
engagementMedium: s = "POPUP",
|
|
267
278
|
jwt: r,
|
|
@@ -272,7 +283,7 @@ class K {
|
|
|
272
283
|
engagementMedium: s,
|
|
273
284
|
locale: a
|
|
274
285
|
}), 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),
|
|
286
|
+
return w && (d.cookies = w), qe(m, JSON.stringify(d), r);
|
|
276
287
|
}
|
|
277
288
|
/**
|
|
278
289
|
* Requests widget template
|
|
@@ -288,11 +299,11 @@ class K {
|
|
|
288
299
|
* @return {Promise} template html if true.
|
|
289
300
|
*/
|
|
290
301
|
render(t) {
|
|
291
|
-
const n =
|
|
302
|
+
const n = he(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 ?? Ue(navigator.language.replace(/\-/g, "_")), p = `/api/v1/${d}/graphql`, g = this.domain + p;
|
|
292
303
|
return new Promise(async (m, w) => {
|
|
293
304
|
var b;
|
|
294
305
|
try {
|
|
295
|
-
const f = await
|
|
306
|
+
const f = await We(
|
|
296
307
|
g,
|
|
297
308
|
Se,
|
|
298
309
|
{
|
|
@@ -315,7 +326,7 @@ class K {
|
|
|
315
326
|
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
316
327
|
*/
|
|
317
328
|
async squatchReferralCookie() {
|
|
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
|
|
329
|
+
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 $e(i);
|
|
319
330
|
return Promise.resolve({
|
|
320
331
|
...s,
|
|
321
332
|
encodedCookie: e
|
|
@@ -334,7 +345,7 @@ function Re({
|
|
|
334
345
|
* domready (c) Dustin Diaz 2014 - License MIT
|
|
335
346
|
*
|
|
336
347
|
*/
|
|
337
|
-
function
|
|
348
|
+
function Y(o, t) {
|
|
338
349
|
let e = [], n, i = o, s = i.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(i.readyState);
|
|
339
350
|
return a || i.addEventListener(
|
|
340
351
|
r,
|
|
@@ -356,7 +367,7 @@ function L({
|
|
|
356
367
|
return `${o}px`;
|
|
357
368
|
}
|
|
358
369
|
}
|
|
359
|
-
class
|
|
370
|
+
class ue {
|
|
360
371
|
/**
|
|
361
372
|
* Initialize a new {@link AnalyticsApi} instance.
|
|
362
373
|
*
|
|
@@ -367,24 +378,24 @@ class he {
|
|
|
367
378
|
constructor(t) {
|
|
368
379
|
l(this, "domain");
|
|
369
380
|
var i;
|
|
370
|
-
const n =
|
|
371
|
-
this.domain = (n == null ? void 0 : n.domain) || ((i =
|
|
381
|
+
const n = Pe(t);
|
|
382
|
+
this.domain = (n == null ? void 0 : n.domain) || ((i = K()) == null ? void 0 : i.domain) || A;
|
|
372
383
|
}
|
|
373
384
|
pushAnalyticsLoadEvent(t) {
|
|
374
385
|
if (!t.externalUserId || !t.externalAccountId) return;
|
|
375
386
|
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
|
|
387
|
+
return Q(d, JSON.stringify({}));
|
|
377
388
|
}
|
|
378
389
|
pushAnalyticsShareClickedEvent(t) {
|
|
379
390
|
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
|
|
391
|
+
return Q(d, JSON.stringify({}));
|
|
381
392
|
}
|
|
382
393
|
}
|
|
383
|
-
function
|
|
394
|
+
function Pe(o) {
|
|
384
395
|
if (!I(o)) throw new Error("'options' should be an object");
|
|
385
396
|
return o;
|
|
386
397
|
}
|
|
387
|
-
const
|
|
398
|
+
const pe = ({
|
|
388
399
|
type: o = "verified-access",
|
|
389
400
|
height: t = "500px"
|
|
390
401
|
}) => {
|
|
@@ -638,11 +649,11 @@ const ue = ({
|
|
|
638
649
|
`}
|
|
639
650
|
</div>
|
|
640
651
|
`;
|
|
641
|
-
},
|
|
652
|
+
}, Me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
642
653
|
__proto__: null,
|
|
643
|
-
getSkeleton:
|
|
654
|
+
getSkeleton: pe
|
|
644
655
|
}, Symbol.toStringTag, { value: "Module" })), y = k("squatch-js:widget");
|
|
645
|
-
class
|
|
656
|
+
class me {
|
|
646
657
|
constructor(t) {
|
|
647
658
|
l(this, "type");
|
|
648
659
|
l(this, "content");
|
|
@@ -653,7 +664,7 @@ class pe {
|
|
|
653
664
|
l(this, "container");
|
|
654
665
|
l(this, "loadEventListener", null);
|
|
655
666
|
var e;
|
|
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
|
|
667
|
+
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 ue({ domain: t.domain }), this.context = t.context, this.container = ((e = t.context) == null ? void 0 : e.container) || t.container;
|
|
657
668
|
}
|
|
658
669
|
_findElement() {
|
|
659
670
|
let t;
|
|
@@ -781,7 +792,7 @@ class pe {
|
|
|
781
792
|
}
|
|
782
793
|
let s = null;
|
|
783
794
|
for (let r = 0; r < 5 && (s = i(), !s); r++)
|
|
784
|
-
await
|
|
795
|
+
await Le(100);
|
|
785
796
|
return s || n.body;
|
|
786
797
|
}
|
|
787
798
|
/**
|
|
@@ -796,7 +807,7 @@ class pe {
|
|
|
796
807
|
*/
|
|
797
808
|
_getSkeletonPreloadHTML(t, e) {
|
|
798
809
|
if (!t) return "";
|
|
799
|
-
const n = this.context.type === "passwordless" ? "instant-access" : "verified-access", i =
|
|
810
|
+
const n = this.context.type === "passwordless" ? "instant-access" : "verified-access", i = pe({
|
|
800
811
|
type: n,
|
|
801
812
|
height: "100%"
|
|
802
813
|
});
|
|
@@ -804,7 +815,7 @@ class pe {
|
|
|
804
815
|
<div id="sq-preload" style="visibility: visible; position: absolute; top: 0; left: 0; width: 100%; z-index: 9999; background: ${e || "white"};">
|
|
805
816
|
${i}
|
|
806
817
|
</div>
|
|
807
|
-
<script>(${
|
|
818
|
+
<script>(${Oe.toString()})()<\/script>
|
|
808
819
|
`;
|
|
809
820
|
}
|
|
810
821
|
/**
|
|
@@ -865,12 +876,12 @@ class pe {
|
|
|
865
876
|
}
|
|
866
877
|
}
|
|
867
878
|
}
|
|
868
|
-
function
|
|
879
|
+
function Le(o) {
|
|
869
880
|
return new Promise((t) => {
|
|
870
881
|
setTimeout(t, o);
|
|
871
882
|
});
|
|
872
883
|
}
|
|
873
|
-
function
|
|
884
|
+
function Oe() {
|
|
874
885
|
var o = setTimeout(t, 1e4);
|
|
875
886
|
function t() {
|
|
876
887
|
var n = document.getElementById("sq-preload");
|
|
@@ -893,8 +904,8 @@ function Le() {
|
|
|
893
904
|
}
|
|
894
905
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : setTimeout(e, 0);
|
|
895
906
|
}
|
|
896
|
-
const
|
|
897
|
-
class O extends
|
|
907
|
+
const x = k("squatch-js:EMBEDwidget");
|
|
908
|
+
class O extends me {
|
|
898
909
|
constructor(e, n) {
|
|
899
910
|
super(e);
|
|
900
911
|
l(this, "show", this.open);
|
|
@@ -902,13 +913,13 @@ class O extends pe {
|
|
|
902
913
|
n && (this.container = n);
|
|
903
914
|
}
|
|
904
915
|
async load() {
|
|
905
|
-
var m, w, b, f, _,
|
|
916
|
+
var m, w, b, f, _, te, ne, ie, oe;
|
|
906
917
|
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
918
|
minWidth: a,
|
|
908
919
|
maxWidth: r,
|
|
909
920
|
initialHeight: i
|
|
910
921
|
}), c = this._findElement();
|
|
911
|
-
(_ = this.context) != null && _.container && (c.style.visibility = "hidden", c.style.height = "0", c.style["overflow-y"] = "hidden"), this.container ? c.shadowRoot ? ((
|
|
922
|
+
(_ = this.context) != null && _.container && (c.style.visibility = "hidden", c.style.height = "0", c.style["overflow-y"] = "hidden"), this.container ? c.shadowRoot ? ((te = c.shadowRoot.lastChild) == null ? void 0 : te.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
923
|
const { contentWindow: h } = d;
|
|
913
924
|
if (!h)
|
|
914
925
|
throw new Error("Frame needs a content window");
|
|
@@ -916,12 +927,12 @@ class O extends pe {
|
|
|
916
927
|
u.open();
|
|
917
928
|
const g = this.widgetApi.domain === "https://staging.referralsaasquatch.com" ? "-staging" : "";
|
|
918
929
|
u.write(`
|
|
919
|
-
${(
|
|
930
|
+
${(ne = e == null ? void 0 : e.main) != null && ne.brandFont ? `
|
|
920
931
|
<link rel="preconnect" href="https://fast${g}.ssqt.io">
|
|
921
932
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
922
933
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
923
934
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
924
|
-
(
|
|
935
|
+
(ie = e == null ? void 0 : e.main) == null ? void 0 : ie.brandFont
|
|
925
936
|
)}" as="style">` : ""}
|
|
926
937
|
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
927
938
|
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
@@ -929,19 +940,19 @@ class O extends pe {
|
|
|
929
940
|
<style data-styles>
|
|
930
941
|
html { visibility: hidden; }
|
|
931
942
|
</style>` : ""}
|
|
932
|
-
${this._getSkeletonPreloadHTML(n, (
|
|
943
|
+
${this._getSkeletonPreloadHTML(n, (oe = e == null ? void 0 : e.color) == null ? void 0 : oe.backgroundColor)}
|
|
933
944
|
${this.content}
|
|
934
945
|
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
935
|
-
`), u.close(),
|
|
936
|
-
const
|
|
946
|
+
`), u.close(), Y(u, async () => {
|
|
947
|
+
const se = h.squatch || h.widgetIdent;
|
|
937
948
|
d.height = i;
|
|
938
|
-
const
|
|
939
|
-
for (const
|
|
940
|
-
const { height: xe } =
|
|
949
|
+
const ve = new h.ResizeObserver((be) => {
|
|
950
|
+
for (const Ee of be) {
|
|
951
|
+
const { height: xe } = Ee.contentRect;
|
|
941
952
|
d.height = xe;
|
|
942
953
|
}
|
|
943
|
-
}),
|
|
944
|
-
|
|
954
|
+
}), ke = await this._findInnerContainer(d);
|
|
955
|
+
ve.observe(ke), this._shouldFireLoadEvent() ? (this._loadEvent(se), x("loaded")) : u && this._attachLoadEventListener(u, se);
|
|
945
956
|
});
|
|
946
957
|
}
|
|
947
958
|
/**
|
|
@@ -949,13 +960,13 @@ class O extends pe {
|
|
|
949
960
|
*/
|
|
950
961
|
open() {
|
|
951
962
|
const e = this._findFrame();
|
|
952
|
-
if (!e) return
|
|
953
|
-
if (!e.contentWindow) return
|
|
963
|
+
if (!e) return x("no target element to open");
|
|
964
|
+
if (!e.contentWindow) return x("Frame needs a content window");
|
|
954
965
|
const n = this._findElement();
|
|
955
966
|
n.style.visibility = "unset", n.style.height = "auto", n.style["overflow-y"] = "auto", e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
956
967
|
const i = e.contentWindow.squatch || e.contentWindow.widgetIdent;
|
|
957
968
|
if (this.context.user)
|
|
958
|
-
this._loadEvent(i),
|
|
969
|
+
this._loadEvent(i), x("loaded");
|
|
959
970
|
else {
|
|
960
971
|
if (!e.contentDocument) return;
|
|
961
972
|
this._attachLoadEventListener(e.contentDocument, i);
|
|
@@ -963,10 +974,10 @@ class O extends pe {
|
|
|
963
974
|
}
|
|
964
975
|
close() {
|
|
965
976
|
const e = this._findFrame();
|
|
966
|
-
if (!e) return
|
|
977
|
+
if (!e) return x("no target element to close");
|
|
967
978
|
e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
968
979
|
const n = this._findElement();
|
|
969
|
-
n.style.visibility = "hidden", n.style.height = "0", n.style["overflow-y"] = "hidden",
|
|
980
|
+
n.style.visibility = "hidden", n.style.height = "0", n.style["overflow-y"] = "hidden", x("Embed widget closed");
|
|
970
981
|
}
|
|
971
982
|
_error(e, n = "embed", i = "") {
|
|
972
983
|
return super._error(e, n, i);
|
|
@@ -977,15 +988,15 @@ class O extends pe {
|
|
|
977
988
|
}
|
|
978
989
|
}
|
|
979
990
|
const T = k("squatch-js:POPUPwidget");
|
|
980
|
-
let
|
|
981
|
-
class
|
|
991
|
+
let R = 0;
|
|
992
|
+
class D extends me {
|
|
982
993
|
constructor(e, n = ".squatchpop") {
|
|
983
994
|
super(e);
|
|
984
995
|
l(this, "trigger");
|
|
985
996
|
l(this, "id");
|
|
986
997
|
l(this, "show", this.open);
|
|
987
998
|
l(this, "hide", this.close);
|
|
988
|
-
this.trigger = n, this.container ? this.id = "squatchModal" : (this.id =
|
|
999
|
+
this.trigger = n, this.container ? this.id = "squatchModal" : (this.id = R === 0 ? "squatchModal" : `squatchModal__${R}`, R = R + 1), document.head.insertAdjacentHTML(
|
|
989
1000
|
"beforeend",
|
|
990
1001
|
`<style>#${this.id}::-webkit-scrollbar { display: none; }</style>`
|
|
991
1002
|
);
|
|
@@ -1050,7 +1061,7 @@ class j extends pe {
|
|
|
1050
1061
|
if (!n)
|
|
1051
1062
|
throw new Error("Frame needs a content window");
|
|
1052
1063
|
const i = n.document;
|
|
1053
|
-
|
|
1064
|
+
Y(i, async () => {
|
|
1054
1065
|
i.body.style.overflowY = "hidden";
|
|
1055
1066
|
let s = !0;
|
|
1056
1067
|
new n.ResizeObserver((a) => {
|
|
@@ -1070,7 +1081,7 @@ class j extends pe {
|
|
|
1070
1081
|
const { contentWindow: r } = s;
|
|
1071
1082
|
if (!r) throw new Error("Squatch.js has an empty iframe");
|
|
1072
1083
|
const a = r.document;
|
|
1073
|
-
|
|
1084
|
+
Y(a, () => {
|
|
1074
1085
|
var c;
|
|
1075
1086
|
const d = r.squatch || r.widgetIdent;
|
|
1076
1087
|
(c = s.contentDocument) == null || c.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(d), T("Popup opened")) : this._attachLoadEventListener(a, d);
|
|
@@ -1090,7 +1101,7 @@ class j extends pe {
|
|
|
1090
1101
|
}
|
|
1091
1102
|
}
|
|
1092
1103
|
const v = k("squatch-js:widgets");
|
|
1093
|
-
class
|
|
1104
|
+
class j {
|
|
1094
1105
|
/**
|
|
1095
1106
|
* Initialize a new {@link Widgets} instance.
|
|
1096
1107
|
*
|
|
@@ -1126,8 +1137,8 @@ class D {
|
|
|
1126
1137
|
* @default "https://fast.ssqt.io/npm"
|
|
1127
1138
|
*/
|
|
1128
1139
|
l(this, "npmCdn");
|
|
1129
|
-
const e =
|
|
1130
|
-
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new
|
|
1140
|
+
const e = W(t);
|
|
1141
|
+
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new Z(e);
|
|
1131
1142
|
}
|
|
1132
1143
|
/**
|
|
1133
1144
|
* This function calls the {@link WidgetApi.upsertUser} method, and it renders
|
|
@@ -1146,7 +1157,7 @@ class D {
|
|
|
1146
1157
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1147
1158
|
*/
|
|
1148
1159
|
async upsertUser(t) {
|
|
1149
|
-
const n =
|
|
1160
|
+
const n = le(t);
|
|
1150
1161
|
try {
|
|
1151
1162
|
const i = await this.api.upsertUser(n);
|
|
1152
1163
|
return {
|
|
@@ -1165,7 +1176,7 @@ class D {
|
|
|
1165
1176
|
user: i.user
|
|
1166
1177
|
};
|
|
1167
1178
|
} catch (i) {
|
|
1168
|
-
throw v(i), i.apiErrorCode && this._renderErrorWidget(i, t.engagementMedium), new Error(i);
|
|
1179
|
+
throw console.log("[DEBUG] Widgets.upsertUser catch - err:", i), console.log("[DEBUG] Widgets.upsertUser catch - typeof err:", typeof i), console.log("[DEBUG] Widgets.upsertUser catch - err.apiErrorCode:", i.apiErrorCode), console.log("[DEBUG] Widgets.upsertUser catch - err keys:", Object.keys(i || {})), v(i), i.apiErrorCode && (console.log("[DEBUG] Widgets.upsertUser - calling _renderErrorWidget"), this._renderErrorWidget(i, t.engagementMedium)), new Error(i);
|
|
1169
1180
|
}
|
|
1170
1181
|
}
|
|
1171
1182
|
/**
|
|
@@ -1184,7 +1195,7 @@ class D {
|
|
|
1184
1195
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1185
1196
|
*/
|
|
1186
1197
|
async render(t) {
|
|
1187
|
-
const n =
|
|
1198
|
+
const n = he(t);
|
|
1188
1199
|
try {
|
|
1189
1200
|
const i = await this.api.render(n);
|
|
1190
1201
|
return {
|
|
@@ -1255,12 +1266,12 @@ class D {
|
|
|
1255
1266
|
};
|
|
1256
1267
|
return r.widgetUrlMappings && r.widgetUrlMappings.forEach((c) => {
|
|
1257
1268
|
var h, u;
|
|
1258
|
-
|
|
1269
|
+
j._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
1270
|
`Don't display ${c.widgetType} when no referral on widget rule match ${c.url}`
|
|
1260
1271
|
));
|
|
1261
1272
|
}), r.fuelTankAutofillUrls && (v("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: c, formSelector: h }) => {
|
|
1262
1273
|
var u, p, g;
|
|
1263
|
-
if (
|
|
1274
|
+
if (j._matchesUrl(c) && (v("Fuel Tank URL matches"), (p = (u = t.user) == null ? void 0 : u.referredBy) != null && p.code)) {
|
|
1264
1275
|
const m = document.querySelector(h);
|
|
1265
1276
|
m ? m.value = ((g = t.user.referredBy.referredReward) == null ? void 0 : g.fuelTankCode) || "" : v(
|
|
1266
1277
|
new Error(
|
|
@@ -1271,7 +1282,7 @@ class D {
|
|
|
1271
1282
|
})), e.engagementMedium === "EMBED" ? i = this._renderEmbedWidget(a) : (i = this._renderPopupWidget(a), s && i.open()), i;
|
|
1272
1283
|
}
|
|
1273
1284
|
_renderPopupWidget(t) {
|
|
1274
|
-
const e = new
|
|
1285
|
+
const e = new D(t, t.context.trigger);
|
|
1275
1286
|
return e.load(), e;
|
|
1276
1287
|
}
|
|
1277
1288
|
_renderEmbedWidget(t) {
|
|
@@ -1297,7 +1308,7 @@ class D {
|
|
|
1297
1308
|
context: { type: "error" }
|
|
1298
1309
|
};
|
|
1299
1310
|
let a;
|
|
1300
|
-
e === "EMBED" ? (a = new O(r), a.load()) : e === "POPUP" && (a = new
|
|
1311
|
+
e === "EMBED" ? (a = new O(r), a.load()) : e === "POPUP" && (a = new D(r), a.load());
|
|
1301
1312
|
}
|
|
1302
1313
|
/**
|
|
1303
1314
|
* @hidden
|
|
@@ -1308,7 +1319,7 @@ class D {
|
|
|
1308
1319
|
return !!window.location.href.match(new RegExp(t));
|
|
1309
1320
|
}
|
|
1310
1321
|
}
|
|
1311
|
-
class
|
|
1322
|
+
class De {
|
|
1312
1323
|
/**
|
|
1313
1324
|
* Initialize a new {@link EventsApi} instance.
|
|
1314
1325
|
*
|
|
@@ -1328,7 +1339,7 @@ class Oe {
|
|
|
1328
1339
|
constructor(t) {
|
|
1329
1340
|
l(this, "tenantAlias");
|
|
1330
1341
|
l(this, "domain");
|
|
1331
|
-
const n =
|
|
1342
|
+
const n = W(t);
|
|
1332
1343
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain;
|
|
1333
1344
|
}
|
|
1334
1345
|
/**
|
|
@@ -1340,8 +1351,8 @@ class Oe {
|
|
|
1340
1351
|
* @return An ID to confirm the event has been accepted for asynchronous processing
|
|
1341
1352
|
*/
|
|
1342
1353
|
track(t, e) {
|
|
1343
|
-
const n = t, i = e, s = je(n), { jwt: r } =
|
|
1344
|
-
return
|
|
1354
|
+
const n = t, i = e, s = je(n), { jwt: r } = Ne(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;
|
|
1355
|
+
return Q(u, JSON.stringify(s), r);
|
|
1345
1356
|
}
|
|
1346
1357
|
}
|
|
1347
1358
|
function je(o) {
|
|
@@ -1354,20 +1365,20 @@ function je(o) {
|
|
|
1354
1365
|
throw new Error("'events' should be an array");
|
|
1355
1366
|
return t;
|
|
1356
1367
|
}
|
|
1357
|
-
function
|
|
1368
|
+
function Ne(o) {
|
|
1358
1369
|
if (!I(o)) throw new Error("'options' should be an object");
|
|
1359
1370
|
return o;
|
|
1360
1371
|
}
|
|
1361
|
-
function
|
|
1372
|
+
function Fe() {
|
|
1362
1373
|
var i;
|
|
1363
|
-
const o = window[z] ? z :
|
|
1374
|
+
const o = window[z] ? z : S, t = ((i = window["_" + o]) == null ? void 0 : i.ready) || [], e = window.impactOnReady || window.squatchOnReady, n = [...t, e].filter((s) => !!s);
|
|
1364
1375
|
setTimeout(() => {
|
|
1365
|
-
window[
|
|
1376
|
+
window[S] && (window[z] = window[S], n.forEach((s) => s()), window[S]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
1366
1377
|
}, 0);
|
|
1367
1378
|
}
|
|
1368
|
-
const
|
|
1369
|
-
const e = (i) =>
|
|
1370
|
-
[i]: e(i) ?
|
|
1379
|
+
const E = k("squatch-js"), re = (o) => typeof o == "object" && !Array.isArray(o), ge = (o, t) => {
|
|
1380
|
+
const e = (i) => re(t[i]) && o.hasOwnProperty(i) && re(o[i]), n = Object.getOwnPropertyNames(t).map((i) => ({
|
|
1381
|
+
[i]: e(i) ? ge(o[i], t[i]) : t[i]
|
|
1371
1382
|
})).reduce((i, s) => ({ ...i, ...s }), {});
|
|
1372
1383
|
return {
|
|
1373
1384
|
...o,
|
|
@@ -1380,41 +1391,41 @@ function N(o) {
|
|
|
1380
1391
|
e[n] = t.charCodeAt(n);
|
|
1381
1392
|
return new TextDecoder("utf8").decode(e);
|
|
1382
1393
|
}
|
|
1383
|
-
function
|
|
1394
|
+
function ae(o) {
|
|
1384
1395
|
const t = new TextEncoder().encode(o), e = Array.from(
|
|
1385
1396
|
t,
|
|
1386
1397
|
(n) => String.fromCodePoint(n)
|
|
1387
1398
|
).join("");
|
|
1388
1399
|
return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1389
1400
|
}
|
|
1390
|
-
function
|
|
1401
|
+
function He() {
|
|
1391
1402
|
var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
|
|
1392
1403
|
for (o = n.length - 1; o >= 0; o--)
|
|
1393
1404
|
if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
|
|
1394
1405
|
return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
|
|
1395
1406
|
}
|
|
1396
|
-
function
|
|
1407
|
+
function Be() {
|
|
1397
1408
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
|
|
1398
1409
|
if (e) {
|
|
1399
1410
|
let n = "", i = "", s = "";
|
|
1400
1411
|
try {
|
|
1401
1412
|
n = JSON.parse(N(e));
|
|
1402
1413
|
} catch (r) {
|
|
1403
|
-
|
|
1414
|
+
E("Unable to decode params", r);
|
|
1404
1415
|
return;
|
|
1405
1416
|
}
|
|
1406
1417
|
try {
|
|
1407
|
-
i = JSON.parse(N(M.get("_saasquatch"))),
|
|
1418
|
+
i = JSON.parse(N(M.get("_saasquatch"))), E("existing cookie", i);
|
|
1408
1419
|
} catch (r) {
|
|
1409
|
-
|
|
1420
|
+
E("Unable to retrieve cookie", r);
|
|
1410
1421
|
}
|
|
1411
1422
|
try {
|
|
1412
|
-
const r =
|
|
1413
|
-
if (
|
|
1414
|
-
const a =
|
|
1415
|
-
s =
|
|
1423
|
+
const r = He();
|
|
1424
|
+
if (E("domain retrieved:", r), i) {
|
|
1425
|
+
const a = ge(i, n);
|
|
1426
|
+
s = ae(JSON.stringify(a)), E("cookie to store:", a);
|
|
1416
1427
|
} else
|
|
1417
|
-
s =
|
|
1428
|
+
s = ae(JSON.stringify(n)), E("cookie to store:", n);
|
|
1418
1429
|
M.set("_saasquatch", s, {
|
|
1419
1430
|
expires: 365,
|
|
1420
1431
|
secure: !1,
|
|
@@ -1423,19 +1434,19 @@ function He() {
|
|
|
1423
1434
|
path: "/"
|
|
1424
1435
|
});
|
|
1425
1436
|
} catch (r) {
|
|
1426
|
-
|
|
1437
|
+
E("Unable to set cookie", r);
|
|
1427
1438
|
}
|
|
1428
1439
|
}
|
|
1429
1440
|
}
|
|
1430
1441
|
const P = k("squatch-js");
|
|
1431
|
-
function
|
|
1442
|
+
function Je() {
|
|
1432
1443
|
var u;
|
|
1433
1444
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
|
|
1434
1445
|
if (!e) {
|
|
1435
1446
|
P("No _saasquatchExtra param");
|
|
1436
1447
|
return;
|
|
1437
1448
|
}
|
|
1438
|
-
const n =
|
|
1449
|
+
const n = W({
|
|
1439
1450
|
tenantAlias: "UNKNOWN"
|
|
1440
1451
|
});
|
|
1441
1452
|
if (!n.domain) {
|
|
@@ -1470,7 +1481,7 @@ function Be() {
|
|
|
1470
1481
|
}
|
|
1471
1482
|
};
|
|
1472
1483
|
}
|
|
1473
|
-
const
|
|
1484
|
+
const Ge = k("squatch-js:decodeUserJwt");
|
|
1474
1485
|
function ze(o) {
|
|
1475
1486
|
var t;
|
|
1476
1487
|
try {
|
|
@@ -1479,11 +1490,11 @@ function ze(o) {
|
|
|
1479
1490
|
const n = N(e);
|
|
1480
1491
|
return (t = JSON.parse(n)) == null ? void 0 : t.user;
|
|
1481
1492
|
} catch (e) {
|
|
1482
|
-
return
|
|
1493
|
+
return Ge(e), null;
|
|
1483
1494
|
}
|
|
1484
1495
|
}
|
|
1485
|
-
const
|
|
1486
|
-
class
|
|
1496
|
+
const de = k("squatch-js:DeclarativeWidget");
|
|
1497
|
+
class fe extends HTMLElement {
|
|
1487
1498
|
constructor() {
|
|
1488
1499
|
super();
|
|
1489
1500
|
/**
|
|
@@ -1550,14 +1561,14 @@ class ge extends HTMLElement {
|
|
|
1550
1561
|
},
|
|
1551
1562
|
type: this.widgetType,
|
|
1552
1563
|
domain: ((s = this.config) == null ? void 0 : s.domain) || A,
|
|
1553
|
-
npmCdn:
|
|
1564
|
+
npmCdn: X,
|
|
1554
1565
|
container: this
|
|
1555
1566
|
};
|
|
1556
1567
|
if (this.type === "EMBED")
|
|
1557
1568
|
return new O(i);
|
|
1558
1569
|
{
|
|
1559
1570
|
const r = this.firstChild ? null : void 0;
|
|
1560
|
-
return new
|
|
1571
|
+
return new D(i, r);
|
|
1561
1572
|
}
|
|
1562
1573
|
});
|
|
1563
1574
|
/**
|
|
@@ -1575,14 +1586,14 @@ class ge extends HTMLElement {
|
|
|
1575
1586
|
},
|
|
1576
1587
|
type: "ERROR_WIDGET",
|
|
1577
1588
|
domain: ((i = this.config) == null ? void 0 : i.domain) || A,
|
|
1578
|
-
npmCdn:
|
|
1589
|
+
npmCdn: X,
|
|
1579
1590
|
container: this
|
|
1580
1591
|
};
|
|
1581
1592
|
if (this.type === "EMBED")
|
|
1582
1593
|
return new O(n);
|
|
1583
1594
|
{
|
|
1584
1595
|
const s = this.firstChild ? null : void 0;
|
|
1585
|
-
return new
|
|
1596
|
+
return new D(n, s);
|
|
1586
1597
|
}
|
|
1587
1598
|
});
|
|
1588
1599
|
l(this, "reload", this.renderWidget);
|
|
@@ -1590,15 +1601,15 @@ class ge extends HTMLElement {
|
|
|
1590
1601
|
l(this, "hide", this.close);
|
|
1591
1602
|
this.attachShadow({
|
|
1592
1603
|
mode: "open"
|
|
1593
|
-
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config =
|
|
1604
|
+
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = K(), this.token = $(), this.tenant = window.squatchTenant, this.container = this;
|
|
1594
1605
|
}
|
|
1595
1606
|
_setupApis(e) {
|
|
1596
1607
|
var n, i;
|
|
1597
1608
|
if (!this.tenant) throw new Error("tenantAlias not provided");
|
|
1598
|
-
this.widgetApi = new
|
|
1609
|
+
this.widgetApi = new Z({
|
|
1599
1610
|
tenantAlias: (e == null ? void 0 : e.tenantAlias) || this.tenant,
|
|
1600
1611
|
domain: (e == null ? void 0 : e.domain) || ((n = this.config) == null ? void 0 : n.domain) || A
|
|
1601
|
-
}), this.analyticsApi = new
|
|
1612
|
+
}), this.analyticsApi = new ue({
|
|
1602
1613
|
domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) || A
|
|
1603
1614
|
});
|
|
1604
1615
|
}
|
|
@@ -1606,7 +1617,7 @@ class ge extends HTMLElement {
|
|
|
1606
1617
|
return e && (e.includes("websiteReferralWidget") || e.includes("friendWidget")) ? "instant-access" : "verified-access";
|
|
1607
1618
|
}
|
|
1608
1619
|
async renderPasswordlessVariant() {
|
|
1609
|
-
return this._setupApis(),
|
|
1620
|
+
return this._setupApis(), de("Rendering as an Instant Access widget"), await this.widgetApi.render({
|
|
1610
1621
|
engagementMedium: this.type,
|
|
1611
1622
|
widgetType: this.widgetType,
|
|
1612
1623
|
locale: this.locale
|
|
@@ -1615,7 +1626,7 @@ class ge extends HTMLElement {
|
|
|
1615
1626
|
async renderUserUpsertVariant() {
|
|
1616
1627
|
this._setupApis();
|
|
1617
1628
|
const e = ze(this.token);
|
|
1618
|
-
return e ? (
|
|
1629
|
+
return e ? (de("Rendering as a Verified widget"), await this.widgetApi.upsertUser({
|
|
1619
1630
|
user: e,
|
|
1620
1631
|
locale: this.locale,
|
|
1621
1632
|
engagementMedium: this.type,
|
|
@@ -1673,7 +1684,7 @@ class ge extends HTMLElement {
|
|
|
1673
1684
|
}
|
|
1674
1685
|
async connectedCallback() {
|
|
1675
1686
|
this.loaded = !0, this.container = this.getAttribute("container"), this.widgetType = this.getAttribute("widget") || void 0;
|
|
1676
|
-
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await Promise.resolve().then(() =>
|
|
1687
|
+
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await Promise.resolve().then(() => Me), i = n({
|
|
1677
1688
|
height: "100%",
|
|
1678
1689
|
type: e
|
|
1679
1690
|
}), s = document.createElement("div");
|
|
@@ -1689,93 +1700,93 @@ class ge extends HTMLElement {
|
|
|
1689
1700
|
a && a.remove(), this.getAttribute("open") !== null && this.open();
|
|
1690
1701
|
}
|
|
1691
1702
|
}
|
|
1692
|
-
class
|
|
1703
|
+
class we extends fe {
|
|
1693
1704
|
constructor() {
|
|
1694
1705
|
super(), this.type = "EMBED", this.loaded = !1;
|
|
1695
1706
|
}
|
|
1696
1707
|
}
|
|
1697
|
-
class
|
|
1708
|
+
class ye extends fe {
|
|
1698
1709
|
constructor() {
|
|
1699
1710
|
super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (t) => {
|
|
1700
1711
|
t.stopPropagation(), this.open();
|
|
1701
1712
|
});
|
|
1702
1713
|
}
|
|
1703
1714
|
}
|
|
1704
|
-
class Ge extends fe {
|
|
1705
|
-
}
|
|
1706
1715
|
class Ve extends we {
|
|
1707
1716
|
}
|
|
1708
|
-
class Xe extends
|
|
1717
|
+
class Xe extends ye {
|
|
1709
1718
|
}
|
|
1710
1719
|
class Qe extends we {
|
|
1711
1720
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
window.customElements.get("squatch-
|
|
1715
|
-
window.customElements.get("impact-
|
|
1716
|
-
|
|
1721
|
+
class Ye extends ye {
|
|
1722
|
+
}
|
|
1723
|
+
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", Ve);
|
|
1724
|
+
window.customElements.get("impact-embed") || window.customElements.define("impact-embed", Qe);
|
|
1725
|
+
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Xe);
|
|
1726
|
+
window.customElements.get("impact-popup") || window.customElements.define("impact-popup", Ye);
|
|
1727
|
+
function et() {
|
|
1717
1728
|
console.log(
|
|
1718
1729
|
"Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
|
|
1719
1730
|
);
|
|
1720
1731
|
}
|
|
1721
|
-
const
|
|
1732
|
+
const U = k("squatch-js");
|
|
1722
1733
|
let F = null, H = null, B = null;
|
|
1723
|
-
function
|
|
1724
|
-
return F ||
|
|
1734
|
+
function tt() {
|
|
1735
|
+
return F || G({}), F;
|
|
1725
1736
|
}
|
|
1726
|
-
function
|
|
1727
|
-
return H ||
|
|
1737
|
+
function ee() {
|
|
1738
|
+
return H || G({}), H;
|
|
1728
1739
|
}
|
|
1729
|
-
function
|
|
1730
|
-
return B ||
|
|
1740
|
+
function nt() {
|
|
1741
|
+
return B || G({}), B;
|
|
1731
1742
|
}
|
|
1732
|
-
function
|
|
1743
|
+
function it(o) {
|
|
1733
1744
|
var t;
|
|
1734
|
-
return (t =
|
|
1745
|
+
return (t = ee()) == null ? void 0 : t.render(o);
|
|
1735
1746
|
}
|
|
1736
|
-
function
|
|
1747
|
+
function ot() {
|
|
1737
1748
|
var t;
|
|
1738
|
-
const o =
|
|
1749
|
+
const o = Je();
|
|
1739
1750
|
if (o) {
|
|
1740
1751
|
const { squatchConfig: e, widgetConfig: n } = o;
|
|
1741
|
-
return
|
|
1752
|
+
return G(e), (t = ee()) == null ? void 0 : t.render(n);
|
|
1742
1753
|
}
|
|
1743
1754
|
}
|
|
1744
|
-
function
|
|
1745
|
-
const e =
|
|
1746
|
-
e.tenantAlias.match("^test") || e.debug ?
|
|
1755
|
+
function G(o) {
|
|
1756
|
+
const e = W(o);
|
|
1757
|
+
e.tenantAlias.match("^test") || e.debug ? Ie("squatch-js*") : _e(), U("initializing ..."), F = new Z(e), H = new j(e), B = new De(e), U("Widget API instance", F), U("Widgets instance", H), U("Events API instance", B);
|
|
1747
1758
|
}
|
|
1748
|
-
function
|
|
1759
|
+
function st(o) {
|
|
1749
1760
|
o();
|
|
1750
1761
|
}
|
|
1751
|
-
function
|
|
1752
|
-
|
|
1762
|
+
function rt(o) {
|
|
1763
|
+
ee().autofill(o);
|
|
1753
1764
|
}
|
|
1754
|
-
function
|
|
1755
|
-
|
|
1765
|
+
function Ke() {
|
|
1766
|
+
Be();
|
|
1756
1767
|
}
|
|
1757
|
-
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop &&
|
|
1758
|
-
var
|
|
1759
|
-
(
|
|
1768
|
+
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Ke();
|
|
1769
|
+
var ce;
|
|
1770
|
+
(ce = window.squatch) != null && ce.init && U(
|
|
1760
1771
|
"Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
|
|
1761
1772
|
);
|
|
1762
|
-
typeof document < "u" &&
|
|
1773
|
+
typeof document < "u" && Fe();
|
|
1763
1774
|
export {
|
|
1764
|
-
|
|
1765
|
-
|
|
1775
|
+
we as DeclarativeEmbedWidget,
|
|
1776
|
+
ye as DeclarativePopupWidget,
|
|
1766
1777
|
O as EmbedWidget,
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1778
|
+
D as PopupWidget,
|
|
1779
|
+
Z as WidgetApi,
|
|
1780
|
+
j as Widgets,
|
|
1781
|
+
ot as _auto,
|
|
1782
|
+
tt as api,
|
|
1783
|
+
rt as autofill,
|
|
1784
|
+
nt as events,
|
|
1785
|
+
et as help,
|
|
1786
|
+
G as init,
|
|
1787
|
+
Ke as pushCookie,
|
|
1788
|
+
st as ready,
|
|
1789
|
+
it as widget,
|
|
1790
|
+
ee as widgets
|
|
1780
1791
|
};
|
|
1781
1792
|
//# sourceMappingURL=squatch.esm.js.map
|