@saasquatch/squatch-js 2.8.2-9 → 2.8.3-0
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/coverage/clover.xml +944 -0
- package/coverage/coverage-final.json +22 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +1714 -0
- package/dist/SkeletonTemplate-CIRGs_GB.js +258 -0
- package/dist/SkeletonTemplate-CIRGs_GB.js.map +1 -0
- package/dist/SkeletonTemplate-hwDwv3Ys.cjs +250 -0
- package/dist/SkeletonTemplate-hwDwv3Ys.cjs.map +1 -0
- package/dist/squatch.cjs.js +25 -2593
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +812 -1988
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +251 -2575
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +4 -5
- package/dist/utils/logger.d.ts +20 -0
- package/dist/widgets/PopupWidget.d.ts +2 -2
- package/dist/widgets/SkeletonTemplate.d.ts +3 -2
- package/dist/widgets/declarative/DeclarativeWidget.d.ts +4 -0
- package/dist/widgets/declarative/DeclarativeWidgets.d.ts +0 -6
- package/package.json +1 -2
- package/vite.config.ts +1 -1
package/dist/squatch.esm.js
CHANGED
|
@@ -1,608 +1,207 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
1
|
+
var ye = Object.defineProperty;
|
|
2
|
+
var Ee = (o, t, e) => t in o ? ye(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var l = (o, t, e) => Ee(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
let P = null;
|
|
5
|
+
function Ce(o) {
|
|
6
|
+
const e = o.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
7
|
+
P = new RegExp(`^${e}$`);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var hasRequiredMs;
|
|
11
|
-
function requireMs() {
|
|
12
|
-
if (hasRequiredMs) return ms;
|
|
13
|
-
hasRequiredMs = 1;
|
|
14
|
-
var s = 1e3;
|
|
15
|
-
var m = s * 60;
|
|
16
|
-
var h = m * 60;
|
|
17
|
-
var d = h * 24;
|
|
18
|
-
var w = d * 7;
|
|
19
|
-
var y = d * 365.25;
|
|
20
|
-
ms = function(val, options) {
|
|
21
|
-
options = options || {};
|
|
22
|
-
var type = typeof val;
|
|
23
|
-
if (type === "string" && val.length > 0) {
|
|
24
|
-
return parse(val);
|
|
25
|
-
} else if (type === "number" && isFinite(val)) {
|
|
26
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
27
|
-
}
|
|
28
|
-
throw new Error(
|
|
29
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
function parse(str) {
|
|
33
|
-
str = String(str);
|
|
34
|
-
if (str.length > 100) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
38
|
-
str
|
|
39
|
-
);
|
|
40
|
-
if (!match) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var n = parseFloat(match[1]);
|
|
44
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
45
|
-
switch (type) {
|
|
46
|
-
case "years":
|
|
47
|
-
case "year":
|
|
48
|
-
case "yrs":
|
|
49
|
-
case "yr":
|
|
50
|
-
case "y":
|
|
51
|
-
return n * y;
|
|
52
|
-
case "weeks":
|
|
53
|
-
case "week":
|
|
54
|
-
case "w":
|
|
55
|
-
return n * w;
|
|
56
|
-
case "days":
|
|
57
|
-
case "day":
|
|
58
|
-
case "d":
|
|
59
|
-
return n * d;
|
|
60
|
-
case "hours":
|
|
61
|
-
case "hour":
|
|
62
|
-
case "hrs":
|
|
63
|
-
case "hr":
|
|
64
|
-
case "h":
|
|
65
|
-
return n * h;
|
|
66
|
-
case "minutes":
|
|
67
|
-
case "minute":
|
|
68
|
-
case "mins":
|
|
69
|
-
case "min":
|
|
70
|
-
case "m":
|
|
71
|
-
return n * m;
|
|
72
|
-
case "seconds":
|
|
73
|
-
case "second":
|
|
74
|
-
case "secs":
|
|
75
|
-
case "sec":
|
|
76
|
-
case "s":
|
|
77
|
-
return n * s;
|
|
78
|
-
case "milliseconds":
|
|
79
|
-
case "millisecond":
|
|
80
|
-
case "msecs":
|
|
81
|
-
case "msec":
|
|
82
|
-
case "ms":
|
|
83
|
-
return n;
|
|
84
|
-
default:
|
|
85
|
-
return void 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function fmtShort(ms2) {
|
|
89
|
-
var msAbs = Math.abs(ms2);
|
|
90
|
-
if (msAbs >= d) {
|
|
91
|
-
return Math.round(ms2 / d) + "d";
|
|
92
|
-
}
|
|
93
|
-
if (msAbs >= h) {
|
|
94
|
-
return Math.round(ms2 / h) + "h";
|
|
95
|
-
}
|
|
96
|
-
if (msAbs >= m) {
|
|
97
|
-
return Math.round(ms2 / m) + "m";
|
|
98
|
-
}
|
|
99
|
-
if (msAbs >= s) {
|
|
100
|
-
return Math.round(ms2 / s) + "s";
|
|
101
|
-
}
|
|
102
|
-
return ms2 + "ms";
|
|
103
|
-
}
|
|
104
|
-
function fmtLong(ms2) {
|
|
105
|
-
var msAbs = Math.abs(ms2);
|
|
106
|
-
if (msAbs >= d) {
|
|
107
|
-
return plural(ms2, msAbs, d, "day");
|
|
108
|
-
}
|
|
109
|
-
if (msAbs >= h) {
|
|
110
|
-
return plural(ms2, msAbs, h, "hour");
|
|
111
|
-
}
|
|
112
|
-
if (msAbs >= m) {
|
|
113
|
-
return plural(ms2, msAbs, m, "minute");
|
|
114
|
-
}
|
|
115
|
-
if (msAbs >= s) {
|
|
116
|
-
return plural(ms2, msAbs, s, "second");
|
|
117
|
-
}
|
|
118
|
-
return ms2 + " ms";
|
|
119
|
-
}
|
|
120
|
-
function plural(ms2, msAbs, n, name) {
|
|
121
|
-
var isPlural = msAbs >= n * 1.5;
|
|
122
|
-
return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
|
|
123
|
-
}
|
|
124
|
-
return ms;
|
|
9
|
+
function ve() {
|
|
10
|
+
P = null;
|
|
125
11
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
hasRequiredCommon = 1;
|
|
131
|
-
function setup(env) {
|
|
132
|
-
createDebug.debug = createDebug;
|
|
133
|
-
createDebug.default = createDebug;
|
|
134
|
-
createDebug.coerce = coerce;
|
|
135
|
-
createDebug.disable = disable;
|
|
136
|
-
createDebug.enable = enable;
|
|
137
|
-
createDebug.enabled = enabled;
|
|
138
|
-
createDebug.humanize = requireMs();
|
|
139
|
-
Object.keys(env).forEach(function(key) {
|
|
140
|
-
createDebug[key] = env[key];
|
|
141
|
-
});
|
|
142
|
-
createDebug.instances = [];
|
|
143
|
-
createDebug.names = [];
|
|
144
|
-
createDebug.skips = [];
|
|
145
|
-
createDebug.formatters = {};
|
|
146
|
-
function selectColor(namespace) {
|
|
147
|
-
var hash = 0;
|
|
148
|
-
for (var i = 0; i < namespace.length; i++) {
|
|
149
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
150
|
-
hash |= 0;
|
|
151
|
-
}
|
|
152
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
153
|
-
}
|
|
154
|
-
createDebug.selectColor = selectColor;
|
|
155
|
-
function createDebug(namespace) {
|
|
156
|
-
var prevTime;
|
|
157
|
-
function debug2() {
|
|
158
|
-
if (!debug2.enabled) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
162
|
-
args[_key] = arguments[_key];
|
|
163
|
-
}
|
|
164
|
-
var self = debug2;
|
|
165
|
-
var curr = Number(/* @__PURE__ */ new Date());
|
|
166
|
-
var ms2 = curr - (prevTime || curr);
|
|
167
|
-
self.diff = ms2;
|
|
168
|
-
self.prev = prevTime;
|
|
169
|
-
self.curr = curr;
|
|
170
|
-
prevTime = curr;
|
|
171
|
-
args[0] = createDebug.coerce(args[0]);
|
|
172
|
-
if (typeof args[0] !== "string") {
|
|
173
|
-
args.unshift("%O");
|
|
174
|
-
}
|
|
175
|
-
var index = 0;
|
|
176
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
|
177
|
-
if (match === "%%") {
|
|
178
|
-
return match;
|
|
179
|
-
}
|
|
180
|
-
index++;
|
|
181
|
-
var formatter = createDebug.formatters[format];
|
|
182
|
-
if (typeof formatter === "function") {
|
|
183
|
-
var val = args[index];
|
|
184
|
-
match = formatter.call(self, val);
|
|
185
|
-
args.splice(index, 1);
|
|
186
|
-
index--;
|
|
187
|
-
}
|
|
188
|
-
return match;
|
|
189
|
-
});
|
|
190
|
-
createDebug.formatArgs.call(self, args);
|
|
191
|
-
var logFn = self.log || createDebug.log;
|
|
192
|
-
logFn.apply(self, args);
|
|
193
|
-
}
|
|
194
|
-
debug2.namespace = namespace;
|
|
195
|
-
debug2.enabled = createDebug.enabled(namespace);
|
|
196
|
-
debug2.useColors = createDebug.useColors();
|
|
197
|
-
debug2.color = selectColor(namespace);
|
|
198
|
-
debug2.destroy = destroy;
|
|
199
|
-
debug2.extend = extend;
|
|
200
|
-
if (typeof createDebug.init === "function") {
|
|
201
|
-
createDebug.init(debug2);
|
|
202
|
-
}
|
|
203
|
-
createDebug.instances.push(debug2);
|
|
204
|
-
return debug2;
|
|
205
|
-
}
|
|
206
|
-
function destroy() {
|
|
207
|
-
var index = createDebug.instances.indexOf(this);
|
|
208
|
-
if (index !== -1) {
|
|
209
|
-
createDebug.instances.splice(index, 1);
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
function extend(namespace, delimiter) {
|
|
215
|
-
return createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
216
|
-
}
|
|
217
|
-
function enable(namespaces) {
|
|
218
|
-
createDebug.save(namespaces);
|
|
219
|
-
createDebug.names = [];
|
|
220
|
-
createDebug.skips = [];
|
|
221
|
-
var i;
|
|
222
|
-
var split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
223
|
-
var len = split.length;
|
|
224
|
-
for (i = 0; i < len; i++) {
|
|
225
|
-
if (!split[i]) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
namespaces = split[i].replace(/\*/g, ".*?");
|
|
229
|
-
if (namespaces[0] === "-") {
|
|
230
|
-
createDebug.skips.push(new RegExp("^" + namespaces.substr(1) + "$"));
|
|
231
|
-
} else {
|
|
232
|
-
createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
for (i = 0; i < createDebug.instances.length; i++) {
|
|
236
|
-
var instance = createDebug.instances[i];
|
|
237
|
-
instance.enabled = createDebug.enabled(instance.namespace);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
function disable() {
|
|
241
|
-
createDebug.enable("");
|
|
242
|
-
}
|
|
243
|
-
function enabled(name) {
|
|
244
|
-
if (name[name.length - 1] === "*") {
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
var i;
|
|
248
|
-
var len;
|
|
249
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
250
|
-
if (createDebug.skips[i].test(name)) {
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
255
|
-
if (createDebug.names[i].test(name)) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
function coerce(val) {
|
|
262
|
-
if (val instanceof Error) {
|
|
263
|
-
return val.stack || val.message;
|
|
264
|
-
}
|
|
265
|
-
return val;
|
|
266
|
-
}
|
|
267
|
-
createDebug.enable(createDebug.load());
|
|
268
|
-
return createDebug;
|
|
269
|
-
}
|
|
270
|
-
common = setup;
|
|
271
|
-
return common;
|
|
272
|
-
}
|
|
273
|
-
var hasRequiredBrowser;
|
|
274
|
-
function requireBrowser() {
|
|
275
|
-
if (hasRequiredBrowser) return browser.exports;
|
|
276
|
-
hasRequiredBrowser = 1;
|
|
277
|
-
(function(module, exports) {
|
|
278
|
-
function _typeof(obj) {
|
|
279
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
280
|
-
_typeof = function _typeof2(obj2) {
|
|
281
|
-
return typeof obj2;
|
|
282
|
-
};
|
|
283
|
-
} else {
|
|
284
|
-
_typeof = function _typeof2(obj2) {
|
|
285
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
return _typeof(obj);
|
|
289
|
-
}
|
|
290
|
-
exports.log = log;
|
|
291
|
-
exports.formatArgs = formatArgs;
|
|
292
|
-
exports.save = save;
|
|
293
|
-
exports.load = load;
|
|
294
|
-
exports.useColors = useColors;
|
|
295
|
-
exports.storage = localstorage();
|
|
296
|
-
exports.colors = ["#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33"];
|
|
297
|
-
function useColors() {
|
|
298
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
299
|
-
return true;
|
|
300
|
-
}
|
|
301
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
305
|
-
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
306
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
307
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
308
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
309
|
-
}
|
|
310
|
-
function formatArgs(args) {
|
|
311
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
312
|
-
if (!this.useColors) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
var c = "color: " + this.color;
|
|
316
|
-
args.splice(1, 0, c, "color: inherit");
|
|
317
|
-
var index = 0;
|
|
318
|
-
var lastC = 0;
|
|
319
|
-
args[0].replace(/%[a-zA-Z%]/g, function(match) {
|
|
320
|
-
if (match === "%%") {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
index++;
|
|
324
|
-
if (match === "%c") {
|
|
325
|
-
lastC = index;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
args.splice(lastC, 0, c);
|
|
329
|
-
}
|
|
330
|
-
function log() {
|
|
331
|
-
var _console;
|
|
332
|
-
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === "object" && console.log && (_console = console).log.apply(_console, arguments);
|
|
333
|
-
}
|
|
334
|
-
function save(namespaces) {
|
|
335
|
-
try {
|
|
336
|
-
if (namespaces) {
|
|
337
|
-
exports.storage.setItem("debug", namespaces);
|
|
338
|
-
} else {
|
|
339
|
-
exports.storage.removeItem("debug");
|
|
340
|
-
}
|
|
341
|
-
} catch (error) {
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
function load() {
|
|
345
|
-
var r;
|
|
346
|
-
try {
|
|
347
|
-
r = exports.storage.getItem("debug");
|
|
348
|
-
} catch (error) {
|
|
349
|
-
}
|
|
350
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
351
|
-
r = process.env.DEBUG;
|
|
352
|
-
}
|
|
353
|
-
return r;
|
|
354
|
-
}
|
|
355
|
-
function localstorage() {
|
|
356
|
-
try {
|
|
357
|
-
return localStorage;
|
|
358
|
-
} catch (error) {
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
module.exports = requireCommon()(exports);
|
|
362
|
-
var formatters = module.exports.formatters;
|
|
363
|
-
formatters.j = function(v) {
|
|
364
|
-
try {
|
|
365
|
-
return JSON.stringify(v);
|
|
366
|
-
} catch (error) {
|
|
367
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
})(browser, browser.exports);
|
|
371
|
-
return browser.exports;
|
|
12
|
+
function E(o) {
|
|
13
|
+
return (...t) => {
|
|
14
|
+
P && P.test(o) && console.log(`[${o}]`, ...t);
|
|
15
|
+
};
|
|
372
16
|
}
|
|
373
|
-
var browserExports = requireBrowser();
|
|
374
|
-
const debug = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
|
|
375
17
|
/*! js-cookie v3.0.5 | MIT */
|
|
376
|
-
function
|
|
377
|
-
for (var
|
|
378
|
-
var
|
|
379
|
-
for (var
|
|
380
|
-
|
|
381
|
-
}
|
|
18
|
+
function T(o) {
|
|
19
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
20
|
+
var e = arguments[t];
|
|
21
|
+
for (var i in e)
|
|
22
|
+
o[i] = e[i];
|
|
382
23
|
}
|
|
383
|
-
return
|
|
24
|
+
return o;
|
|
384
25
|
}
|
|
385
|
-
var
|
|
386
|
-
read: function(
|
|
387
|
-
|
|
388
|
-
value = value.slice(1, -1);
|
|
389
|
-
}
|
|
390
|
-
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
26
|
+
var be = {
|
|
27
|
+
read: function(o) {
|
|
28
|
+
return o[0] === '"' && (o = o.slice(1, -1)), o.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
391
29
|
},
|
|
392
|
-
write: function(
|
|
393
|
-
return encodeURIComponent(
|
|
30
|
+
write: function(o) {
|
|
31
|
+
return encodeURIComponent(o).replace(
|
|
394
32
|
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
395
33
|
decodeURIComponent
|
|
396
34
|
);
|
|
397
35
|
}
|
|
398
36
|
};
|
|
399
|
-
function
|
|
400
|
-
function
|
|
401
|
-
if (typeof document
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (attributes[attributeName] === true) {
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
|
|
422
|
-
}
|
|
423
|
-
return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
|
|
424
|
-
}
|
|
425
|
-
function get(name) {
|
|
426
|
-
if (typeof document === "undefined" || arguments.length && !name) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
var cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
430
|
-
var jar = {};
|
|
431
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
432
|
-
var parts = cookies[i].split("=");
|
|
433
|
-
var value = parts.slice(1).join("=");
|
|
434
|
-
try {
|
|
435
|
-
var found = decodeURIComponent(parts[0]);
|
|
436
|
-
jar[found] = converter.read(value, found);
|
|
437
|
-
if (name === found) {
|
|
438
|
-
break;
|
|
37
|
+
function G(o, t) {
|
|
38
|
+
function e(n, s, r) {
|
|
39
|
+
if (!(typeof document > "u")) {
|
|
40
|
+
r = T({}, t, r), typeof r.expires == "number" && (r.expires = new Date(Date.now() + r.expires * 864e5)), r.expires && (r.expires = r.expires.toUTCString()), n = encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
41
|
+
var a = "";
|
|
42
|
+
for (var c in r)
|
|
43
|
+
r[c] && (a += "; " + c, r[c] !== !0 && (a += "=" + r[c].split(";")[0]));
|
|
44
|
+
return document.cookie = n + "=" + o.write(s, n) + a;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function i(n) {
|
|
48
|
+
if (!(typeof document > "u" || arguments.length && !n)) {
|
|
49
|
+
for (var s = document.cookie ? document.cookie.split("; ") : [], r = {}, a = 0; a < s.length; a++) {
|
|
50
|
+
var c = s[a].split("="), d = c.slice(1).join("=");
|
|
51
|
+
try {
|
|
52
|
+
var h = decodeURIComponent(c[0]);
|
|
53
|
+
if (r[h] = o.read(d, h), n === h)
|
|
54
|
+
break;
|
|
55
|
+
} catch {
|
|
439
56
|
}
|
|
440
|
-
} catch (e) {
|
|
441
57
|
}
|
|
58
|
+
return n ? r[n] : r;
|
|
442
59
|
}
|
|
443
|
-
return name ? jar[name] : jar;
|
|
444
60
|
}
|
|
445
61
|
return Object.create(
|
|
446
62
|
{
|
|
447
|
-
set,
|
|
448
|
-
get,
|
|
449
|
-
remove: function(
|
|
450
|
-
|
|
451
|
-
|
|
63
|
+
set: e,
|
|
64
|
+
get: i,
|
|
65
|
+
remove: function(n, s) {
|
|
66
|
+
e(
|
|
67
|
+
n,
|
|
452
68
|
"",
|
|
453
|
-
|
|
69
|
+
T({}, s, {
|
|
454
70
|
expires: -1
|
|
455
71
|
})
|
|
456
72
|
);
|
|
457
73
|
},
|
|
458
|
-
withAttributes: function(
|
|
459
|
-
return
|
|
74
|
+
withAttributes: function(n) {
|
|
75
|
+
return G(this.converter, T({}, this.attributes, n));
|
|
460
76
|
},
|
|
461
|
-
withConverter: function(
|
|
462
|
-
return
|
|
77
|
+
withConverter: function(n) {
|
|
78
|
+
return G(T({}, this.converter, n), this.attributes);
|
|
463
79
|
}
|
|
464
80
|
},
|
|
465
81
|
{
|
|
466
|
-
attributes: { value: Object.freeze(
|
|
467
|
-
converter: { value: Object.freeze(
|
|
82
|
+
attributes: { value: Object.freeze(t) },
|
|
83
|
+
converter: { value: Object.freeze(o) }
|
|
468
84
|
}
|
|
469
85
|
);
|
|
470
86
|
}
|
|
471
|
-
var
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
const raw = {
|
|
481
|
-
tenantAlias: (_raw == null ? void 0 : _raw["tenantAlias"]) || tenant,
|
|
482
|
-
domain: (_raw == null ? void 0 : _raw["domain"]) || (config == null ? void 0 : config.domain),
|
|
483
|
-
npmCdn: (_raw == null ? void 0 : _raw["npmCdn"]) || (config == null ? void 0 : config.npmCdn),
|
|
484
|
-
debug: (_raw == null ? void 0 : _raw["debug"]) || (config == null ? void 0 : config.debug)
|
|
87
|
+
var S = G(be, { path: "/" });
|
|
88
|
+
const A = "https://app.referralsaasquatch.com", z = "https://fast.ssqt.io/npm", U = "squatch", J = "impact";
|
|
89
|
+
function W(o) {
|
|
90
|
+
if (typeof o != "object") throw new Error("config must be an object");
|
|
91
|
+
const t = window.squatchTenant, e = Q(), i = {
|
|
92
|
+
tenantAlias: (o == null ? void 0 : o.tenantAlias) || t,
|
|
93
|
+
domain: (o == null ? void 0 : o.domain) || (e == null ? void 0 : e.domain),
|
|
94
|
+
npmCdn: (o == null ? void 0 : o.npmCdn) || (e == null ? void 0 : e.npmCdn),
|
|
95
|
+
debug: (o == null ? void 0 : o.debug) || (e == null ? void 0 : e.debug)
|
|
485
96
|
};
|
|
486
|
-
if (typeof
|
|
97
|
+
if (typeof i.tenantAlias != "string")
|
|
487
98
|
throw new Error("tenantAlias not provided");
|
|
488
|
-
const tenantAlias =
|
|
489
|
-
const domain = typeof raw.domain === "string" && raw.domain || DEFAULT_DOMAIN;
|
|
490
|
-
const debug2 = typeof raw.debug === "boolean" && raw.debug || false;
|
|
491
|
-
const npmCdn = typeof raw.npmCdn === "string" && raw.npmCdn || DEFAULT_NPM_CDN;
|
|
99
|
+
const n = i.tenantAlias, s = typeof i.domain == "string" && i.domain || A, r = typeof i.debug == "boolean" && i.debug || !1, a = typeof i.npmCdn == "string" && i.npmCdn || z;
|
|
492
100
|
return {
|
|
493
|
-
tenantAlias,
|
|
494
|
-
domain,
|
|
495
|
-
debug:
|
|
496
|
-
npmCdn
|
|
101
|
+
tenantAlias: n,
|
|
102
|
+
domain: s,
|
|
103
|
+
debug: r,
|
|
104
|
+
npmCdn: a
|
|
497
105
|
};
|
|
498
106
|
}
|
|
499
|
-
function
|
|
500
|
-
return typeof
|
|
107
|
+
function I(o) {
|
|
108
|
+
return typeof o == "object" && !Array.isArray(o) && o !== null;
|
|
501
109
|
}
|
|
502
|
-
function
|
|
503
|
-
if (
|
|
504
|
-
return
|
|
505
|
-
}
|
|
110
|
+
function Ae(o) {
|
|
111
|
+
if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
|
|
112
|
+
return o;
|
|
506
113
|
}
|
|
507
|
-
function
|
|
508
|
-
if (!
|
|
509
|
-
if (!(
|
|
510
|
-
return
|
|
114
|
+
function se(o) {
|
|
115
|
+
if (!I(o)) throw new Error("Widget properties must be an object");
|
|
116
|
+
if (!(o != null && o.user)) throw new Error("Required properties missing.");
|
|
117
|
+
return o;
|
|
511
118
|
}
|
|
512
|
-
function
|
|
513
|
-
if (!
|
|
514
|
-
return
|
|
119
|
+
function re(o) {
|
|
120
|
+
if (!I(o)) throw new Error("Widget properties must be an object");
|
|
121
|
+
return o;
|
|
515
122
|
}
|
|
516
|
-
function
|
|
123
|
+
function q() {
|
|
517
124
|
return window.impactToken || window.squatchToken;
|
|
518
125
|
}
|
|
519
|
-
function
|
|
126
|
+
function Q() {
|
|
520
127
|
return window.impactConfig || window.squatchConfig;
|
|
521
128
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const token = jwt || getToken();
|
|
525
|
-
const headers = {
|
|
129
|
+
async function Ie(o, t, e, i) {
|
|
130
|
+
const n = i || q(), s = {
|
|
526
131
|
Accept: "application/json",
|
|
527
132
|
"Content-Type": "application/json",
|
|
528
|
-
...
|
|
133
|
+
...n ? { Authorization: `Bearer ${n}` } : {},
|
|
529
134
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
530
135
|
};
|
|
531
136
|
try {
|
|
532
|
-
const
|
|
137
|
+
const r = await fetch(o, {
|
|
533
138
|
method: "POST",
|
|
534
|
-
body: JSON.stringify({ query, variables }),
|
|
535
|
-
headers
|
|
139
|
+
body: JSON.stringify({ query: t, variables: e }),
|
|
140
|
+
headers: s
|
|
536
141
|
});
|
|
537
|
-
if (!
|
|
538
|
-
return await
|
|
539
|
-
} catch (
|
|
540
|
-
throw
|
|
142
|
+
if (!r.ok) throw new Error(await r.text());
|
|
143
|
+
return await r.json();
|
|
144
|
+
} catch (r) {
|
|
145
|
+
throw r;
|
|
541
146
|
}
|
|
542
147
|
}
|
|
543
|
-
async function
|
|
544
|
-
const
|
|
148
|
+
async function _e(o, t = "") {
|
|
149
|
+
const e = {
|
|
545
150
|
Accept: "application/json",
|
|
546
151
|
"Content-Type": "application/json"
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
if (token) headers["X-SaaSquatch-User-Token"] = token;
|
|
152
|
+
}, i = t || q();
|
|
153
|
+
i && (e["X-SaaSquatch-User-Token"] = i);
|
|
550
154
|
try {
|
|
551
|
-
const
|
|
155
|
+
const n = await fetch(o, {
|
|
552
156
|
method: "GET",
|
|
553
157
|
credentials: "include",
|
|
554
|
-
headers
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
throw e;
|
|
158
|
+
headers: e
|
|
159
|
+
}), s = await n.text();
|
|
160
|
+
if (!n.ok) throw new Error(s);
|
|
161
|
+
return s && JSON.parse(s);
|
|
162
|
+
} catch (n) {
|
|
163
|
+
throw n;
|
|
561
164
|
}
|
|
562
165
|
}
|
|
563
|
-
async function
|
|
564
|
-
const
|
|
166
|
+
async function V(o, t, e) {
|
|
167
|
+
const i = {
|
|
565
168
|
Accept: "application/json",
|
|
566
169
|
"Content-Type": "application/json"
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
if (token) headers["X-SaaSquatch-User-Token"] = token;
|
|
170
|
+
}, n = e || q();
|
|
171
|
+
n && (i["X-SaaSquatch-User-Token"] = n);
|
|
570
172
|
try {
|
|
571
|
-
const
|
|
173
|
+
const s = await fetch(o, {
|
|
572
174
|
method: "POST",
|
|
573
|
-
body:
|
|
574
|
-
headers
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
throw e;
|
|
175
|
+
body: t,
|
|
176
|
+
headers: i
|
|
177
|
+
}), r = await s.text();
|
|
178
|
+
if (!s.ok) throw new Error(r);
|
|
179
|
+
return r && JSON.parse(r);
|
|
180
|
+
} catch (s) {
|
|
181
|
+
throw s;
|
|
581
182
|
}
|
|
582
183
|
}
|
|
583
|
-
async function
|
|
584
|
-
const
|
|
184
|
+
async function ke(o, t, e) {
|
|
185
|
+
const i = {
|
|
585
186
|
Accept: "application/json",
|
|
586
187
|
"Content-Type": "application/json",
|
|
587
188
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
if (token) headers["X-SaaSquatch-User-Token"] = token;
|
|
189
|
+
}, n = e || q();
|
|
190
|
+
n && (i["X-SaaSquatch-User-Token"] = n);
|
|
591
191
|
try {
|
|
592
|
-
const
|
|
593
|
-
headers,
|
|
192
|
+
const s = await fetch(o, {
|
|
193
|
+
headers: i,
|
|
594
194
|
method: "PUT",
|
|
595
195
|
credentials: "include",
|
|
596
|
-
body:
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
throw e;
|
|
196
|
+
body: t
|
|
197
|
+
}), r = await s.text();
|
|
198
|
+
if (!s.ok) throw new Error(r);
|
|
199
|
+
return r && JSON.parse(r);
|
|
200
|
+
} catch (s) {
|
|
201
|
+
throw s;
|
|
603
202
|
}
|
|
604
203
|
}
|
|
605
|
-
const
|
|
204
|
+
const xe = `
|
|
606
205
|
query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
|
|
607
206
|
renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
|
|
608
207
|
template
|
|
@@ -617,7 +216,7 @@ const RENDER_WIDGET_QUERY = `
|
|
|
617
216
|
}
|
|
618
217
|
}
|
|
619
218
|
`;
|
|
620
|
-
class
|
|
219
|
+
class Y {
|
|
621
220
|
/**
|
|
622
221
|
* Initialize a new {@link WidgetApi} instance.
|
|
623
222
|
*
|
|
@@ -634,16 +233,13 @@ class WidgetApi {
|
|
|
634
233
|
* import {WidgetApi} from '@saasquatch/squatch-js';
|
|
635
234
|
* let squatchApi = new WidgetApi({tenantAlias:'test_12b5bo1b25125'});
|
|
636
235
|
*/
|
|
637
|
-
constructor(
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
this.tenantAlias = clean.tenantAlias;
|
|
645
|
-
this.domain = clean.domain;
|
|
646
|
-
this.npmCdn = clean.npmCdn;
|
|
236
|
+
constructor(t) {
|
|
237
|
+
l(this, "tenantAlias");
|
|
238
|
+
l(this, "domain");
|
|
239
|
+
l(this, "npmCdn");
|
|
240
|
+
l(this, "referralCookie", this.squatchReferralCookie);
|
|
241
|
+
const i = W(t);
|
|
242
|
+
this.tenantAlias = i.tenantAlias, this.domain = i.domain, this.npmCdn = i.npmCdn;
|
|
647
243
|
}
|
|
648
244
|
/**
|
|
649
245
|
* Creates/upserts user, requests widget template.
|
|
@@ -659,29 +255,19 @@ class WidgetApi {
|
|
|
659
255
|
*
|
|
660
256
|
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
661
257
|
*/
|
|
662
|
-
upsertUser(
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const optionalParams = _buildParams({
|
|
676
|
-
widgetType,
|
|
677
|
-
engagementMedium,
|
|
678
|
-
locale
|
|
679
|
-
});
|
|
680
|
-
const path = `/api/v1/${tenantAlias}/widget/account/${accountId}/user/${userId}/upsert${optionalParams}`;
|
|
681
|
-
const url = this.domain + path;
|
|
682
|
-
const cookies = (api$1 || window.Cookies).get("_saasquatch");
|
|
683
|
-
if (cookies) user["cookies"] = cookies;
|
|
684
|
-
return doPut(url, JSON.stringify(user), jwt);
|
|
258
|
+
upsertUser(t) {
|
|
259
|
+
const i = se(t), {
|
|
260
|
+
widgetType: n,
|
|
261
|
+
engagementMedium: s = "POPUP",
|
|
262
|
+
jwt: r,
|
|
263
|
+
locale: a,
|
|
264
|
+
user: c
|
|
265
|
+
} = i, d = encodeURIComponent(this.tenantAlias), h = c.accountId ? encodeURIComponent(c.accountId) : null, u = c.id ? encodeURIComponent(c.id) : null, m = We({
|
|
266
|
+
widgetType: n,
|
|
267
|
+
engagementMedium: s,
|
|
268
|
+
locale: a
|
|
269
|
+
}), p = `/api/v1/${d}/widget/account/${h}/user/${u}/upsert${m}`, g = this.domain + p, f = (S || window.Cookies).get("_saasquatch");
|
|
270
|
+
return f && (c.cookies = f), ke(g, JSON.stringify(c), r);
|
|
685
271
|
}
|
|
686
272
|
/**
|
|
687
273
|
* Requests widget template
|
|
@@ -696,34 +282,25 @@ class WidgetApi {
|
|
|
696
282
|
* to validate the data (can be disabled)
|
|
697
283
|
* @return {Promise} template html if true.
|
|
698
284
|
*/
|
|
699
|
-
render(
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
console.log({ params });
|
|
704
|
-
const tenantAlias = encodeURIComponent(this.tenantAlias);
|
|
705
|
-
const accountId = (user == null ? void 0 : user.accountId) ? encodeURIComponent(user.accountId) : null;
|
|
706
|
-
const userId = (user == null ? void 0 : user.id) ? encodeURIComponent(user.id) : null;
|
|
707
|
-
const locale = clean.locale ?? validateLocale(navigator.language.replace(/\-/g, "_"));
|
|
708
|
-
const path = `/api/v1/${tenantAlias}/graphql`;
|
|
709
|
-
const url = this.domain + path;
|
|
710
|
-
return new Promise(async (resolve, reject) => {
|
|
711
|
-
var _a2;
|
|
285
|
+
render(t) {
|
|
286
|
+
const i = re(t), { widgetType: n, engagementMedium: s = "POPUP", jwt: r, user: a } = i, c = encodeURIComponent(this.tenantAlias), d = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = i.locale ?? Ae(navigator.language.replace(/\-/g, "_")), m = `/api/v1/${c}/graphql`, p = this.domain + m;
|
|
287
|
+
return new Promise(async (g, f) => {
|
|
288
|
+
var _;
|
|
712
289
|
try {
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
290
|
+
const C = await Ie(
|
|
291
|
+
p,
|
|
292
|
+
xe,
|
|
716
293
|
{
|
|
717
|
-
user:
|
|
718
|
-
engagementMedium,
|
|
719
|
-
widgetType,
|
|
720
|
-
locale
|
|
294
|
+
user: h && d ? { id: h, accountId: d } : null,
|
|
295
|
+
engagementMedium: s,
|
|
296
|
+
widgetType: n,
|
|
297
|
+
locale: u
|
|
721
298
|
},
|
|
722
|
-
|
|
299
|
+
r
|
|
723
300
|
);
|
|
724
|
-
|
|
725
|
-
} catch (
|
|
726
|
-
|
|
301
|
+
g((_ = C == null ? void 0 : C.data) == null ? void 0 : _.renderWidget);
|
|
302
|
+
} catch (C) {
|
|
303
|
+
f(C);
|
|
727
304
|
}
|
|
728
305
|
});
|
|
729
306
|
}
|
|
@@ -733,64 +310,48 @@ class WidgetApi {
|
|
|
733
310
|
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
734
311
|
*/
|
|
735
312
|
async squatchReferralCookie() {
|
|
736
|
-
const
|
|
737
|
-
const _saasquatch = (api$1 || window.Cookies).get("_saasquatch") || "";
|
|
738
|
-
const cookie = _saasquatch ? `?cookies=${encodeURIComponent(_saasquatch)}` : ``;
|
|
739
|
-
const url = `${this.domain}/a/${tenantAlias}/widgets/squatchcookiejson${cookie}`;
|
|
740
|
-
const response = await doGet(url);
|
|
313
|
+
const t = encodeURIComponent(this.tenantAlias), e = (S || window.Cookies).get("_saasquatch") || "", i = e ? `?cookies=${encodeURIComponent(e)}` : "", n = `${this.domain}/a/${t}/widgets/squatchcookiejson${i}`, s = await _e(n);
|
|
741
314
|
return Promise.resolve({
|
|
742
|
-
...
|
|
743
|
-
encodedCookie:
|
|
315
|
+
...s,
|
|
316
|
+
encodedCookie: e
|
|
744
317
|
});
|
|
745
318
|
}
|
|
746
319
|
}
|
|
747
|
-
function
|
|
748
|
-
widgetType,
|
|
749
|
-
engagementMedium,
|
|
750
|
-
locale
|
|
320
|
+
function We({
|
|
321
|
+
widgetType: o,
|
|
322
|
+
engagementMedium: t,
|
|
323
|
+
locale: e
|
|
751
324
|
}) {
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
if (widgetType) queryParams.append("widgetType", widgetType);
|
|
755
|
-
if (locale) queryParams.append("locale", locale);
|
|
756
|
-
return `?${queryParams.toString()}`;
|
|
325
|
+
const i = new URLSearchParams();
|
|
326
|
+
return i.append("engagementMedium", t), o && i.append("widgetType", o), e && i.append("locale", e), `?${i.toString()}`;
|
|
757
327
|
}
|
|
758
328
|
/*!
|
|
759
329
|
* domready (c) Dustin Diaz 2014 - License MIT
|
|
760
330
|
*
|
|
761
331
|
*/
|
|
762
|
-
function
|
|
763
|
-
let
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
doc.addEventListener(
|
|
771
|
-
domContentLoaded,
|
|
772
|
-
listener = () => {
|
|
773
|
-
doc.removeEventListener(domContentLoaded, listener);
|
|
774
|
-
loaded = true;
|
|
775
|
-
while (listener = fns.shift()) listener();
|
|
776
|
-
}
|
|
777
|
-
);
|
|
778
|
-
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
332
|
+
function X(o, t) {
|
|
333
|
+
let e = [], i, n = o, s = n.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(n.readyState);
|
|
334
|
+
return a || n.addEventListener(
|
|
335
|
+
r,
|
|
336
|
+
i = () => {
|
|
337
|
+
for (n.removeEventListener(r, i), a = !0; i = e.shift(); ) i();
|
|
338
|
+
}
|
|
339
|
+
), a ? setTimeout(t, 0) : e.push(t);
|
|
779
340
|
}
|
|
780
|
-
function
|
|
781
|
-
value,
|
|
782
|
-
unit
|
|
341
|
+
function M({
|
|
342
|
+
value: o,
|
|
343
|
+
unit: t
|
|
783
344
|
}) {
|
|
784
|
-
switch (
|
|
345
|
+
switch (t) {
|
|
785
346
|
case "px":
|
|
786
|
-
return `${
|
|
347
|
+
return `${o}px`;
|
|
787
348
|
case "%":
|
|
788
|
-
return `${
|
|
349
|
+
return `${o}%`;
|
|
789
350
|
default:
|
|
790
|
-
return `${
|
|
351
|
+
return `${o}px`;
|
|
791
352
|
}
|
|
792
353
|
}
|
|
793
|
-
class
|
|
354
|
+
class ae {
|
|
794
355
|
/**
|
|
795
356
|
* Initialize a new {@link AnalyticsApi} instance.
|
|
796
357
|
*
|
|
@@ -798,193 +359,136 @@ class AnalyticsApi {
|
|
|
798
359
|
* @param {string} [config.domain='https://app.referralsaasquatch.com'] The server domain.
|
|
799
360
|
*
|
|
800
361
|
*/
|
|
801
|
-
constructor(
|
|
802
|
-
|
|
803
|
-
var
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const engagementMedium = encodeURIComponent(
|
|
814
|
-
|
|
815
|
-
const path = `/a/${tenantAlias}/widgets/analytics/loaded?externalAccountId=${accountId}&externalUserId=${userId}&engagementMedium=${engagementMedium}${programId}`;
|
|
816
|
-
const url = this.domain + path;
|
|
817
|
-
return doPost(url, JSON.stringify({}));
|
|
818
|
-
}
|
|
819
|
-
pushAnalyticsShareClickedEvent(params) {
|
|
820
|
-
const tenantAlias = encodeURIComponent(params.tenantAlias);
|
|
821
|
-
const accountId = encodeURIComponent(params.externalAccountId);
|
|
822
|
-
const userId = encodeURIComponent(params.externalUserId);
|
|
823
|
-
const engagementMedium = encodeURIComponent(params.engagementMedium);
|
|
824
|
-
const shareMedium = encodeURIComponent(params.shareMedium);
|
|
825
|
-
const path = `/a/${tenantAlias}/widgets/analytics/shared?externalAccountId=${accountId}&externalUserId=${userId}&engagementMedium=${engagementMedium}&shareMedium=${shareMedium}`;
|
|
826
|
-
const url = this.domain + path;
|
|
827
|
-
return doPost(url, JSON.stringify({}));
|
|
362
|
+
constructor(t) {
|
|
363
|
+
l(this, "domain");
|
|
364
|
+
var n;
|
|
365
|
+
const i = qe(t);
|
|
366
|
+
this.domain = (i == null ? void 0 : i.domain) || ((n = Q()) == null ? void 0 : n.domain) || A;
|
|
367
|
+
}
|
|
368
|
+
pushAnalyticsLoadEvent(t) {
|
|
369
|
+
if (!t.externalUserId || !t.externalAccountId) return;
|
|
370
|
+
const e = encodeURIComponent(t.tenantAlias), i = encodeURIComponent(t.externalAccountId), n = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = t.programId ? `&programId=${encodeURIComponent(t.programId)}` : "", a = `/a/${e}/widgets/analytics/loaded?externalAccountId=${i}&externalUserId=${n}&engagementMedium=${s}${r}`, c = this.domain + a;
|
|
371
|
+
return V(c, JSON.stringify({}));
|
|
372
|
+
}
|
|
373
|
+
pushAnalyticsShareClickedEvent(t) {
|
|
374
|
+
const e = encodeURIComponent(t.tenantAlias), i = encodeURIComponent(t.externalAccountId), n = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = encodeURIComponent(t.shareMedium), a = `/a/${e}/widgets/analytics/shared?externalAccountId=${i}&externalUserId=${n}&engagementMedium=${s}&shareMedium=${r}`, c = this.domain + a;
|
|
375
|
+
return V(c, JSON.stringify({}));
|
|
828
376
|
}
|
|
829
377
|
}
|
|
830
|
-
function
|
|
831
|
-
if (!
|
|
832
|
-
return
|
|
378
|
+
function qe(o) {
|
|
379
|
+
if (!I(o)) throw new Error("'options' should be an object");
|
|
380
|
+
return o;
|
|
833
381
|
}
|
|
834
|
-
const
|
|
835
|
-
class
|
|
836
|
-
constructor(
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
var
|
|
846
|
-
|
|
847
|
-
this.content = params.content === "error" ? this._error(params.rsCode) : params.content;
|
|
848
|
-
this.type = params.type;
|
|
849
|
-
this.widgetApi = params.api;
|
|
850
|
-
this.npmCdn = params.npmCdn;
|
|
851
|
-
this.analyticsApi = new AnalyticsApi({ domain: params.domain });
|
|
852
|
-
this.context = params.context;
|
|
853
|
-
this.container = ((_a2 = params.context) == null ? void 0 : _a2.container) || params.container;
|
|
382
|
+
const w = E("squatch-js:widget");
|
|
383
|
+
class ce {
|
|
384
|
+
constructor(t) {
|
|
385
|
+
l(this, "type");
|
|
386
|
+
l(this, "content");
|
|
387
|
+
l(this, "analyticsApi");
|
|
388
|
+
l(this, "widgetApi");
|
|
389
|
+
l(this, "context");
|
|
390
|
+
l(this, "npmCdn");
|
|
391
|
+
l(this, "container");
|
|
392
|
+
l(this, "loadEventListener", null);
|
|
393
|
+
var e;
|
|
394
|
+
w("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 ae({ domain: t.domain }), this.context = t.context, this.container = ((e = t.context) == null ? void 0 : e.container) || t.container;
|
|
854
395
|
}
|
|
855
396
|
_findElement() {
|
|
856
|
-
let
|
|
857
|
-
if (typeof this.container
|
|
858
|
-
element = document.querySelector(this.container);
|
|
859
|
-
_log$8("loading widget with selector", element);
|
|
860
|
-
} else if (this.container instanceof HTMLElement) {
|
|
861
|
-
element = this.container;
|
|
862
|
-
_log$8("loading widget with container", element);
|
|
863
|
-
} else if (this.container) {
|
|
864
|
-
element = null;
|
|
865
|
-
_log$8("container must be an HTMLElement or string", this.container);
|
|
866
|
-
} else {
|
|
867
|
-
element = document.querySelector("#squatchembed") || document.querySelector(".squatchembed") || document.querySelector("#impactembed") || document.querySelector(".impactembed");
|
|
868
|
-
_log$8("loading widget with default selector", element);
|
|
869
|
-
}
|
|
870
|
-
if (!(element instanceof HTMLElement))
|
|
397
|
+
let t;
|
|
398
|
+
if (typeof this.container == "string" ? (t = document.querySelector(this.container), w("loading widget with selector", t)) : this.container instanceof HTMLElement ? (t = this.container, w("loading widget with container", t)) : this.container ? (t = null, w("container must be an HTMLElement or string", this.container)) : (t = document.querySelector("#squatchembed") || document.querySelector(".squatchembed") || document.querySelector("#impactembed") || document.querySelector(".impactembed"), w("loading widget with default selector", t)), !(t instanceof HTMLElement))
|
|
871
399
|
throw new Error(
|
|
872
400
|
`element with selector '${this.container || "#squatchembed, .squatchembed, #impactembed, or .impactembed"}' not found.'`
|
|
873
401
|
);
|
|
874
|
-
return
|
|
875
|
-
}
|
|
876
|
-
_createFrame(
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
frame.id = "squatchFrame";
|
|
880
|
-
frame.width = "100%";
|
|
881
|
-
frame.src = "about:blank";
|
|
882
|
-
frame.scrolling = "no";
|
|
883
|
-
frame.setAttribute(
|
|
402
|
+
return t;
|
|
403
|
+
}
|
|
404
|
+
_createFrame(t) {
|
|
405
|
+
const e = document.createElement("iframe");
|
|
406
|
+
return e.squatchJsApi = this, e.id = "squatchFrame", e.width = "100%", e.src = "about:blank", e.scrolling = "no", e.setAttribute(
|
|
884
407
|
"style",
|
|
885
408
|
"border: 0; background-color: none; width: 1px; min-width: 100%;"
|
|
886
|
-
);
|
|
887
|
-
if (options == null ? void 0 : options.minWidth) frame.style.minWidth = options.minWidth;
|
|
888
|
-
if (options == null ? void 0 : options.maxWidth) frame.style.maxWidth = options.maxWidth;
|
|
889
|
-
if ((options == null ? void 0 : options.maxWidth) || (options == null ? void 0 : options.minWidth)) {
|
|
890
|
-
frame.style.width = "100%";
|
|
891
|
-
}
|
|
892
|
-
if (options == null ? void 0 : options.initialHeight) {
|
|
893
|
-
frame.height = options.initialHeight;
|
|
894
|
-
}
|
|
895
|
-
return frame;
|
|
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;
|
|
896
410
|
}
|
|
897
411
|
_findFrame() {
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
return parent.querySelector(
|
|
412
|
+
const t = this.container ? this._findElement() : document.body;
|
|
413
|
+
return (t.shadowRoot || t).querySelector(
|
|
901
414
|
"iframe#squatchFrame"
|
|
902
415
|
);
|
|
903
416
|
}
|
|
904
|
-
_detachLoadEventListener(
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
userId: e.detail.userId,
|
|
919
|
-
accountId: e.detail.accountId
|
|
920
|
-
});
|
|
921
|
-
};
|
|
922
|
-
frameDoc.addEventListener("sq:user-registration", this.loadEventListener);
|
|
923
|
-
}
|
|
417
|
+
_detachLoadEventListener(t) {
|
|
418
|
+
this.loadEventListener && (t.removeEventListener(
|
|
419
|
+
"sq:user-registration",
|
|
420
|
+
this.loadEventListener
|
|
421
|
+
), this.loadEventListener = null);
|
|
422
|
+
}
|
|
423
|
+
_attachLoadEventListener(t, e) {
|
|
424
|
+
this.loadEventListener === null && (this.loadEventListener = (i) => {
|
|
425
|
+
this._loadEvent({
|
|
426
|
+
...e,
|
|
427
|
+
userId: i.detail.userId,
|
|
428
|
+
accountId: i.detail.accountId
|
|
429
|
+
});
|
|
430
|
+
}, t.addEventListener("sq:user-registration", this.loadEventListener));
|
|
924
431
|
}
|
|
925
|
-
_loadEvent(
|
|
926
|
-
var
|
|
927
|
-
if (!
|
|
928
|
-
if (!
|
|
432
|
+
_loadEvent(t) {
|
|
433
|
+
var i;
|
|
434
|
+
if (!t) return;
|
|
435
|
+
if (!I(t))
|
|
929
436
|
throw new Error("Widget Load event identity property is not an object");
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
if (!sqh.tenantAlias || !sqh.accountId || !sqh.userId || !sqh.engagementMedium)
|
|
437
|
+
let e;
|
|
438
|
+
if ("programId" in t) {
|
|
439
|
+
if (!t.tenantAlias || !t.accountId || !t.userId || !t.engagementMedium)
|
|
934
440
|
throw new Error("Widget Load event missing required properties");
|
|
935
|
-
|
|
936
|
-
tenantAlias:
|
|
937
|
-
externalAccountId:
|
|
938
|
-
externalUserId:
|
|
939
|
-
engagementMedium:
|
|
940
|
-
programId:
|
|
441
|
+
e = {
|
|
442
|
+
tenantAlias: t.tenantAlias,
|
|
443
|
+
externalAccountId: t.accountId,
|
|
444
|
+
externalUserId: t.userId,
|
|
445
|
+
engagementMedium: t.engagementMedium,
|
|
446
|
+
programId: t.programId
|
|
941
447
|
};
|
|
942
448
|
} else {
|
|
943
|
-
const { analytics, mode } =
|
|
944
|
-
|
|
945
|
-
tenantAlias:
|
|
946
|
-
externalAccountId:
|
|
947
|
-
externalUserId:
|
|
948
|
-
engagementMedium:
|
|
449
|
+
const { analytics: n, mode: s } = t;
|
|
450
|
+
e = {
|
|
451
|
+
tenantAlias: n.attributes.tenant,
|
|
452
|
+
externalAccountId: n.attributes.accountId,
|
|
453
|
+
externalUserId: n.attributes.userId,
|
|
454
|
+
engagementMedium: s.widgetMode
|
|
949
455
|
};
|
|
950
456
|
}
|
|
951
|
-
(
|
|
952
|
-
|
|
953
|
-
}).catch((
|
|
954
|
-
|
|
457
|
+
(i = this.analyticsApi.pushAnalyticsLoadEvent(e)) == null || i.then((n) => {
|
|
458
|
+
w(`${e.engagementMedium} loaded event recorded.`);
|
|
459
|
+
}).catch((n) => {
|
|
460
|
+
w(`ERROR: pushAnalyticsLoadEvent() ${n}`);
|
|
955
461
|
});
|
|
956
462
|
}
|
|
957
|
-
_shareEvent(
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
});
|
|
972
|
-
}
|
|
463
|
+
_shareEvent(t, e) {
|
|
464
|
+
t && this.analyticsApi.pushAnalyticsShareClickedEvent({
|
|
465
|
+
tenantAlias: t.analytics.attributes.tenant,
|
|
466
|
+
externalAccountId: t.analytics.attributes.accountId,
|
|
467
|
+
externalUserId: t.analytics.attributes.userId,
|
|
468
|
+
engagementMedium: t.mode.widgetMode,
|
|
469
|
+
shareMedium: e
|
|
470
|
+
}).then((i) => {
|
|
471
|
+
w(
|
|
472
|
+
`${t.mode.widgetMode} share ${e} event recorded. ${i}`
|
|
473
|
+
);
|
|
474
|
+
}).catch((i) => {
|
|
475
|
+
w(`ERROR: pushAnalyticsShareClickedEvent() ${i}`);
|
|
476
|
+
});
|
|
973
477
|
}
|
|
974
|
-
_error(
|
|
975
|
-
|
|
478
|
+
_error(t, e = "modal", i = "") {
|
|
479
|
+
return `<!DOCTYPE html>
|
|
976
480
|
<!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
|
|
977
481
|
<!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
|
|
978
482
|
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
|
|
979
483
|
<head>
|
|
980
484
|
<link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
|
|
981
485
|
<style>
|
|
982
|
-
${
|
|
486
|
+
${i}
|
|
983
487
|
</style>
|
|
984
488
|
</head>
|
|
985
489
|
<body>
|
|
986
490
|
|
|
987
|
-
<div class="squatch-container ${
|
|
491
|
+
<div class="squatch-container ${e}" style="width:100%">
|
|
988
492
|
<div class="errorheader">
|
|
989
493
|
<button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">×</button>
|
|
990
494
|
<p class="errortitle">Error</p>
|
|
@@ -997,35 +501,26 @@ class Widget {
|
|
|
997
501
|
<br>
|
|
998
502
|
<br>
|
|
999
503
|
<div class="right-align errtxt">
|
|
1000
|
-
Error Code: ${
|
|
504
|
+
Error Code: ${t}
|
|
1001
505
|
</div>
|
|
1002
506
|
</div>
|
|
1003
507
|
</div>
|
|
1004
508
|
</body>
|
|
1005
509
|
</html>`;
|
|
1006
|
-
return errorTemplate;
|
|
1007
510
|
}
|
|
1008
|
-
async _findInnerContainer(
|
|
1009
|
-
const { contentWindow } =
|
|
1010
|
-
if (!
|
|
511
|
+
async _findInnerContainer(t) {
|
|
512
|
+
const { contentWindow: e } = t;
|
|
513
|
+
if (!e)
|
|
1011
514
|
throw new Error("Squatch.js frame inner frame is empty");
|
|
1012
|
-
const
|
|
1013
|
-
function
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
const fallback = containers.length > 0 ? containers[0] : legacyContainers.length > 0 ? legacyContainers[0] : null;
|
|
1017
|
-
return fallback;
|
|
515
|
+
const i = e.document;
|
|
516
|
+
function n() {
|
|
517
|
+
const r = i.getElementsByTagName("sqh-global-container"), a = i.getElementsByClassName("squatch-container");
|
|
518
|
+
return r.length > 0 ? r[0] : a.length > 0 ? a[0] : null;
|
|
1018
519
|
}
|
|
1019
|
-
let
|
|
1020
|
-
for (let
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
await delay(100);
|
|
1024
|
-
}
|
|
1025
|
-
if (!found) {
|
|
1026
|
-
return frameDoc.body;
|
|
1027
|
-
}
|
|
1028
|
-
return found;
|
|
520
|
+
let s = null;
|
|
521
|
+
for (let r = 0; r < 5 && (s = n(), !s); r++)
|
|
522
|
+
await Te(100);
|
|
523
|
+
return s || i.body;
|
|
1029
524
|
}
|
|
1030
525
|
/**
|
|
1031
526
|
* Reloads the current widget, makes updated request to API and renders result.
|
|
@@ -1033,726 +528,255 @@ class Widget {
|
|
|
1033
528
|
* @param param0 Form field values
|
|
1034
529
|
* @param jwt JWT for API authentication
|
|
1035
530
|
*/
|
|
1036
|
-
reload({ email, firstName, lastName },
|
|
1037
|
-
const
|
|
1038
|
-
if (!
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
if (!frameWindow) {
|
|
531
|
+
reload({ email: t, firstName: e, lastName: i }, n) {
|
|
532
|
+
const s = this._findFrame();
|
|
533
|
+
if (!s) throw new Error("Could not find widget iframe");
|
|
534
|
+
const r = s.contentWindow, a = this.context.engagementMedium || "POPUP";
|
|
535
|
+
if (!r)
|
|
1042
536
|
throw new Error("Frame needs a content window");
|
|
1043
|
-
|
|
1044
|
-
let response;
|
|
537
|
+
let c;
|
|
1045
538
|
if (this.context.type === "upsert") {
|
|
1046
539
|
if (!this.context.user) throw new Error("Can't reload without user ids");
|
|
1047
|
-
let
|
|
1048
|
-
email:
|
|
1049
|
-
firstName:
|
|
1050
|
-
lastName:
|
|
540
|
+
let d = {
|
|
541
|
+
email: t || null,
|
|
542
|
+
firstName: e || null,
|
|
543
|
+
lastName: i || null,
|
|
1051
544
|
id: this.context.user.id,
|
|
1052
545
|
accountId: this.context.user.accountId
|
|
1053
546
|
};
|
|
1054
|
-
|
|
1055
|
-
user:
|
|
1056
|
-
engagementMedium,
|
|
547
|
+
c = this.widgetApi.upsertUser({
|
|
548
|
+
user: d,
|
|
549
|
+
engagementMedium: a,
|
|
1057
550
|
widgetType: this.type,
|
|
1058
|
-
jwt
|
|
551
|
+
jwt: n
|
|
1059
552
|
});
|
|
1060
|
-
} else if (this.context.type === "passwordless")
|
|
1061
|
-
|
|
553
|
+
} else if (this.context.type === "passwordless")
|
|
554
|
+
c = this.widgetApi.render({
|
|
1062
555
|
user: void 0,
|
|
1063
|
-
engagementMedium,
|
|
556
|
+
engagementMedium: a,
|
|
1064
557
|
widgetType: this.type,
|
|
1065
558
|
jwt: void 0
|
|
1066
559
|
});
|
|
1067
|
-
|
|
560
|
+
else
|
|
1068
561
|
throw new Error("can't reload an error widget");
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
}
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
}).catch(({ message }) => {
|
|
1083
|
-
_log$8(`${message}`);
|
|
562
|
+
c.then(({ template: d }) => {
|
|
563
|
+
d && (this.content = d, this.__deprecated__register(
|
|
564
|
+
s,
|
|
565
|
+
{ email: t, engagementMedium: a },
|
|
566
|
+
() => {
|
|
567
|
+
this.load(), a === "POPUP" && this.open();
|
|
568
|
+
}
|
|
569
|
+
));
|
|
570
|
+
}).catch(({ message: d }) => {
|
|
571
|
+
w(`${d}`);
|
|
1084
572
|
});
|
|
1085
573
|
}
|
|
1086
|
-
__deprecated__register(
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
showStatsBtn.className = "btn btn-primary";
|
|
1093
|
-
showStatsBtn.id = "show-stats-btn";
|
|
1094
|
-
showStatsBtn.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
|
|
1095
|
-
const widgetStyle = params.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
|
|
1096
|
-
showStatsBtn.setAttribute("style", widgetStyle);
|
|
1097
|
-
showStatsBtn.onclick = onClick;
|
|
1098
|
-
registerForm.style.paddingTop = "30px";
|
|
1099
|
-
registerForm.innerHTML = `<p><strong>${params.email}</strong><br>Has been successfully registered</p>`;
|
|
1100
|
-
registerForm.appendChild(showStatsBtn);
|
|
574
|
+
__deprecated__register(t, e, i) {
|
|
575
|
+
const s = t.contentWindow.document, r = s.createElement("button"), a = s.getElementsByClassName("squatch-register")[0];
|
|
576
|
+
if (a) {
|
|
577
|
+
r.className = "btn btn-primary", r.id = "show-stats-btn", r.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
|
|
578
|
+
const c = e.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
|
|
579
|
+
r.setAttribute("style", c), r.onclick = i, a.style.paddingTop = "30px", a.innerHTML = `<p><strong>${e.email}</strong><br>Has been successfully registered</p>`, a.appendChild(r);
|
|
1101
580
|
}
|
|
1102
581
|
}
|
|
1103
582
|
}
|
|
1104
|
-
function
|
|
1105
|
-
return new Promise((
|
|
1106
|
-
setTimeout(
|
|
583
|
+
function Te(o) {
|
|
584
|
+
return new Promise((t) => {
|
|
585
|
+
setTimeout(t, o);
|
|
1107
586
|
});
|
|
1108
587
|
}
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
<style>
|
|
1117
|
-
* {
|
|
1118
|
-
box-sizing: border-box;
|
|
1119
|
-
padding: 0;
|
|
1120
|
-
margin: 0;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
.widget-container {
|
|
1124
|
-
background: white;
|
|
1125
|
-
width: 100%;
|
|
1126
|
-
max-width: 900px;
|
|
1127
|
-
padding: 40px;
|
|
1128
|
-
border-radius: 12px;
|
|
1129
|
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
|
1130
|
-
box-sizing: border-box;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
@keyframes shimmer {
|
|
1134
|
-
0% {
|
|
1135
|
-
background-position: -100% 0;
|
|
1136
|
-
}
|
|
1137
|
-
100% {
|
|
1138
|
-
background-position: 100% 0;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
.skeleton {
|
|
1143
|
-
background: ${skeletonBackgroundColor};
|
|
1144
|
-
background: linear-gradient(
|
|
1145
|
-
90deg,
|
|
1146
|
-
${skeletonBackgroundColor} 25%,
|
|
1147
|
-
${skeletonShimmerColor} 50%,
|
|
1148
|
-
${skeletonBackgroundColor} 75%
|
|
1149
|
-
);
|
|
1150
|
-
background-size: 200% 100%;
|
|
1151
|
-
animation: shimmer 1.5s infinite linear;
|
|
1152
|
-
border-radius: 6px;
|
|
1153
|
-
margin-bottom: 12px;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
.sk-title-lg {
|
|
1157
|
-
height: 36px;
|
|
1158
|
-
width: 50%;
|
|
1159
|
-
margin-bottom: 16px;
|
|
1160
|
-
}
|
|
1161
|
-
.sk-title-md {
|
|
1162
|
-
height: 28px;
|
|
1163
|
-
width: 30%;
|
|
1164
|
-
margin-bottom: 20px;
|
|
1165
|
-
margin-top: 40px;
|
|
1166
|
-
}
|
|
1167
|
-
.sk-text {
|
|
1168
|
-
height: 16px;
|
|
1169
|
-
width: 80%;
|
|
1170
|
-
margin-bottom: 8px;
|
|
1171
|
-
}
|
|
1172
|
-
.sk-text-short {
|
|
1173
|
-
width: 40%;
|
|
1174
|
-
}
|
|
1175
|
-
.sk-label {
|
|
1176
|
-
height: 14px;
|
|
1177
|
-
width: 25%;
|
|
1178
|
-
margin-bottom: 10px;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
.hero-section {
|
|
1182
|
-
display: flex;
|
|
1183
|
-
gap: 40px;
|
|
1184
|
-
margin-bottom: 40px;
|
|
1185
|
-
border-bottom: 1px solid ${borderColor};
|
|
1186
|
-
padding-bottom: 40px;
|
|
1187
|
-
flex-direction: row;
|
|
1188
|
-
}
|
|
1189
|
-
.hero-content {
|
|
1190
|
-
flex: 1;
|
|
1191
|
-
display: flex;
|
|
1192
|
-
flex-direction: column;
|
|
1193
|
-
justify-content: center;
|
|
1194
|
-
}
|
|
1195
|
-
.hero-image {
|
|
1196
|
-
flex: 1;
|
|
1197
|
-
height: 300px;
|
|
1198
|
-
border-radius: 12px;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
.share-section {
|
|
1202
|
-
margin-bottom: 40px;
|
|
1203
|
-
}
|
|
1204
|
-
.sk-input {
|
|
1205
|
-
height: 50px;
|
|
1206
|
-
width: 100%;
|
|
1207
|
-
border-radius: 8px;
|
|
1208
|
-
margin-bottom: 16px;
|
|
1209
|
-
}
|
|
1210
|
-
.social-buttons {
|
|
1211
|
-
display: flex;
|
|
1212
|
-
gap: 12px;
|
|
1213
|
-
}
|
|
1214
|
-
.sk-btn-social {
|
|
1215
|
-
flex: 1;
|
|
1216
|
-
height: 50px;
|
|
1217
|
-
border-radius: 8px;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
.stats-section {
|
|
1221
|
-
display: flex;
|
|
1222
|
-
gap: 24px;
|
|
1223
|
-
margin-bottom: 40px;
|
|
1224
|
-
padding: 30px 0;
|
|
1225
|
-
border-top: 1px solid ${borderColor};
|
|
1226
|
-
border-bottom: 1px solid ${borderColor};
|
|
1227
|
-
}
|
|
1228
|
-
.stat-card {
|
|
1229
|
-
flex: 1;
|
|
1230
|
-
display: flex;
|
|
1231
|
-
flex-direction: column;
|
|
1232
|
-
align-items: center;
|
|
1233
|
-
}
|
|
1234
|
-
.stat-divider {
|
|
1235
|
-
padding-left: 24px;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
.sk-stat-num {
|
|
1239
|
-
height: 48px;
|
|
1240
|
-
width: 120px;
|
|
1241
|
-
margin-bottom: 8px;
|
|
1242
|
-
}
|
|
1243
|
-
.sk-stat-label {
|
|
1244
|
-
height: 18px;
|
|
1245
|
-
width: 80px;
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
.table-header {
|
|
1249
|
-
display: flex;
|
|
1250
|
-
gap: 16px;
|
|
1251
|
-
margin-bottom: 16px;
|
|
1252
|
-
}
|
|
1253
|
-
.sk-th {
|
|
1254
|
-
height: 16px;
|
|
1255
|
-
}
|
|
1256
|
-
.table-row {
|
|
1257
|
-
display: flex;
|
|
1258
|
-
align-items: center;
|
|
1259
|
-
gap: 16px;
|
|
1260
|
-
padding: 16px 0;
|
|
1261
|
-
border-bottom: 1px solid ${borderColor};
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
.col-user {
|
|
1265
|
-
flex: 2;
|
|
1266
|
-
}
|
|
1267
|
-
.col-status {
|
|
1268
|
-
flex: 1;
|
|
1269
|
-
}
|
|
1270
|
-
.col-reward {
|
|
1271
|
-
flex: 2;
|
|
1272
|
-
}
|
|
1273
|
-
.col-date {
|
|
1274
|
-
flex: 1;
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
.sk-badge {
|
|
1278
|
-
height: 28px;
|
|
1279
|
-
width: 90px;
|
|
1280
|
-
border-radius: 14px;
|
|
1281
|
-
}
|
|
1282
|
-
.sk-reward-block {
|
|
1283
|
-
height: 36px;
|
|
1284
|
-
width: 100%;
|
|
1285
|
-
border-radius: 6px;
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
.pagination {
|
|
1289
|
-
display: flex;
|
|
1290
|
-
justify-content: flex-end;
|
|
1291
|
-
gap: 8px;
|
|
1292
|
-
margin-top: 24px;
|
|
1293
|
-
}
|
|
1294
|
-
.sk-btn-page {
|
|
1295
|
-
height: 36px;
|
|
1296
|
-
width: 64px;
|
|
1297
|
-
border-radius: 6px;
|
|
1298
|
-
margin-bottom: 0;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
@media (max-width: 768px) {
|
|
1302
|
-
body {
|
|
1303
|
-
padding: 20px;
|
|
1304
|
-
}
|
|
1305
|
-
.widget-container {
|
|
1306
|
-
padding: 24px;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
.hero-section {
|
|
1310
|
-
flex-direction: column-reverse;
|
|
1311
|
-
gap: 24px;
|
|
1312
|
-
}
|
|
1313
|
-
.hero-image {
|
|
1314
|
-
height: 220px;
|
|
1315
|
-
width: 100%;
|
|
1316
|
-
}
|
|
1317
|
-
.sk-title-lg {
|
|
1318
|
-
width: 80%;
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
.col-date {
|
|
1322
|
-
display: none;
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
@media (max-width: 480px) {
|
|
1327
|
-
body {
|
|
1328
|
-
padding: 10px;
|
|
1329
|
-
}
|
|
1330
|
-
.widget-container {
|
|
1331
|
-
padding: 16px;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
.sk-stat-num {
|
|
1335
|
-
width: 80px;
|
|
1336
|
-
height: 40px;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
.col-reward {
|
|
1340
|
-
display: none;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
.col-user {
|
|
1344
|
-
flex: 3;
|
|
1345
|
-
}
|
|
1346
|
-
.col-status {
|
|
1347
|
-
flex: 2;
|
|
1348
|
-
display: flex;
|
|
1349
|
-
justify-content: flex-end;
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
</style>
|
|
1353
|
-
|
|
1354
|
-
<div class="widget-container">
|
|
1355
|
-
<div class="hero-section">
|
|
1356
|
-
<div class="hero-content">
|
|
1357
|
-
<div class="skeleton sk-title-lg"></div>
|
|
1358
|
-
<div class="skeleton sk-text"></div>
|
|
1359
|
-
<div class="skeleton sk-text sk-text-short"></div>
|
|
1360
|
-
</div>
|
|
1361
|
-
<div class="skeleton hero-image"></div>
|
|
1362
|
-
</div>
|
|
1363
|
-
|
|
1364
|
-
<div class="share-section">
|
|
1365
|
-
<div class="skeleton sk-label"></div>
|
|
1366
|
-
<div class="skeleton sk-input"></div>
|
|
1367
|
-
<div class="social-buttons">
|
|
1368
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1369
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1370
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1371
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1372
|
-
</div>
|
|
1373
|
-
</div>
|
|
1374
|
-
|
|
1375
|
-
<div
|
|
1376
|
-
class="skeleton sk-title-md"
|
|
1377
|
-
style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"
|
|
1378
|
-
></div>
|
|
1379
|
-
<div
|
|
1380
|
-
class="skeleton sk-text"
|
|
1381
|
-
style="width: 60%; margin-left: auto; margin-right: auto"
|
|
1382
|
-
></div>
|
|
1383
|
-
|
|
1384
|
-
<div class="stats-section">
|
|
1385
|
-
<div class="stat-card">
|
|
1386
|
-
<div class="skeleton sk-stat-num"></div>
|
|
1387
|
-
<div class="skeleton sk-stat-label"></div>
|
|
1388
|
-
</div>
|
|
1389
|
-
<div class="stat-card stat-divider">
|
|
1390
|
-
<div class="skeleton sk-stat-num"></div>
|
|
1391
|
-
<div class="skeleton sk-stat-label"></div>
|
|
1392
|
-
</div>
|
|
1393
|
-
</div>
|
|
1394
|
-
|
|
1395
|
-
<div class="skeleton sk-title-md"></div>
|
|
1396
|
-
|
|
1397
|
-
<div class="table-header">
|
|
1398
|
-
<div class="skeleton sk-th col-user"></div>
|
|
1399
|
-
<div class="skeleton sk-th col-status"></div>
|
|
1400
|
-
<div class="skeleton sk-th col-reward"></div>
|
|
1401
|
-
<div class="skeleton sk-th col-date"></div>
|
|
1402
|
-
</div>
|
|
1403
|
-
|
|
1404
|
-
<div class="table-row">
|
|
1405
|
-
<div class="col-user">
|
|
1406
|
-
<div class="skeleton sk-text" style="width: 70%; margin: 0"></div>
|
|
1407
|
-
</div>
|
|
1408
|
-
<div class="col-status">
|
|
1409
|
-
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1410
|
-
</div>
|
|
1411
|
-
<div class="col-reward">
|
|
1412
|
-
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1413
|
-
</div>
|
|
1414
|
-
<div class="col-date">
|
|
1415
|
-
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1416
|
-
</div>
|
|
1417
|
-
</div>
|
|
1418
|
-
<div class="table-row">
|
|
1419
|
-
<div class="col-user">
|
|
1420
|
-
<div class="skeleton sk-text" style="width: 60%; margin: 0"></div>
|
|
1421
|
-
</div>
|
|
1422
|
-
<div class="col-status">
|
|
1423
|
-
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1424
|
-
</div>
|
|
1425
|
-
<div class="col-reward">
|
|
1426
|
-
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1427
|
-
</div>
|
|
1428
|
-
<div class="col-date">
|
|
1429
|
-
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1430
|
-
</div>
|
|
1431
|
-
</div>
|
|
1432
|
-
<div class="table-row">
|
|
1433
|
-
<div class="col-user">
|
|
1434
|
-
<div class="skeleton sk-text" style="width: 75%; margin: 0"></div>
|
|
1435
|
-
</div>
|
|
1436
|
-
<div class="col-status">
|
|
1437
|
-
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1438
|
-
</div>
|
|
1439
|
-
<div class="col-reward">
|
|
1440
|
-
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1441
|
-
</div>
|
|
1442
|
-
<div class="col-date">
|
|
1443
|
-
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1444
|
-
</div>
|
|
1445
|
-
</div>
|
|
1446
|
-
|
|
1447
|
-
<div class="pagination">
|
|
1448
|
-
<div class="skeleton sk-btn-page"></div>
|
|
1449
|
-
<div class="skeleton sk-btn-page"></div>
|
|
1450
|
-
</div>
|
|
1451
|
-
</div>
|
|
1452
|
-
`;
|
|
1453
|
-
};
|
|
1454
|
-
const _log$7 = browserExports.debug("squatch-js:EMBEDwidget");
|
|
1455
|
-
class EmbedWidget extends Widget {
|
|
1456
|
-
constructor(params, container) {
|
|
1457
|
-
super(params);
|
|
1458
|
-
__publicField(this, "show", this.open);
|
|
1459
|
-
__publicField(this, "hide", this.close);
|
|
1460
|
-
if (container) {
|
|
1461
|
-
this.container = container;
|
|
1462
|
-
}
|
|
588
|
+
const b = E("squatch-js:EMBEDwidget");
|
|
589
|
+
class L extends ce {
|
|
590
|
+
constructor(e, i) {
|
|
591
|
+
super(e);
|
|
592
|
+
l(this, "show", this.open);
|
|
593
|
+
l(this, "hide", this.close);
|
|
594
|
+
i && (this.container = i);
|
|
1463
595
|
}
|
|
1464
596
|
async load() {
|
|
1465
|
-
var
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
console.log({
|
|
1475
|
-
brandingConfig,
|
|
1476
|
-
initialHeight,
|
|
1477
|
-
widgetConfig: this.context.widgetConfig
|
|
1478
|
-
});
|
|
1479
|
-
const skeletonHTML = getSkeleton({
|
|
1480
|
-
height: initialHeight,
|
|
1481
|
-
skeletonBackgroundColor,
|
|
1482
|
-
skeletonShimmerColor,
|
|
1483
|
-
borderColor
|
|
1484
|
-
});
|
|
1485
|
-
const skeletonContainer = document.createElement("div");
|
|
1486
|
-
skeletonContainer.innerHTML = skeletonHTML;
|
|
1487
|
-
const frame = this._createFrame({
|
|
1488
|
-
minWidth,
|
|
1489
|
-
maxWidth,
|
|
1490
|
-
initialHeight
|
|
1491
|
-
});
|
|
1492
|
-
const element = this._findElement();
|
|
1493
|
-
element.innerHTML = skeletonHTML;
|
|
1494
|
-
frame.style.display = "none";
|
|
1495
|
-
const injectContents = (target) => {
|
|
1496
|
-
target.appendChild(skeletonContainer);
|
|
1497
|
-
target.appendChild(frame);
|
|
1498
|
-
};
|
|
1499
|
-
if ((_i = this.context) == null ? void 0 : _i.container) {
|
|
1500
|
-
element.style.visibility = "hidden";
|
|
1501
|
-
element.style.height = "0";
|
|
1502
|
-
element.style["overflow-y"] = "hidden";
|
|
1503
|
-
}
|
|
1504
|
-
if (this.container) {
|
|
1505
|
-
if (element.shadowRoot) {
|
|
1506
|
-
if (((_j = element.shadowRoot.lastChild) == null ? void 0 : _j.nodeName) === "IFRAME") {
|
|
1507
|
-
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1508
|
-
} else {
|
|
1509
|
-
injectContents(element.shadowRoot);
|
|
1510
|
-
}
|
|
1511
|
-
} else if (element.firstChild) {
|
|
1512
|
-
element.innerHTML = "";
|
|
1513
|
-
injectContents(element);
|
|
1514
|
-
} else {
|
|
1515
|
-
injectContents(element);
|
|
1516
|
-
}
|
|
1517
|
-
} else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1518
|
-
injectContents(element);
|
|
1519
|
-
}
|
|
1520
|
-
const { contentWindow } = frame;
|
|
1521
|
-
if (!contentWindow) {
|
|
597
|
+
var m, p, g, f, _, C, Z;
|
|
598
|
+
const e = (p = (m = this.context.widgetConfig) == null ? void 0 : m.values) == null ? void 0 : p.brandingConfig, i = e == null ? void 0 : e.loadingHeight, n = (g = e == null ? void 0 : e.widgetSize) == null ? void 0 : g.embeddedWidgets, s = n != null && n.maxWidth ? M(n.maxWidth) : "", r = n != null && n.minWidth ? M(n.minWidth) : "", a = this._createFrame({
|
|
599
|
+
minWidth: r,
|
|
600
|
+
maxWidth: s,
|
|
601
|
+
initialHeight: i
|
|
602
|
+
}), c = this._findElement();
|
|
603
|
+
(f = this.context) != null && f.container && (c.style.visibility = "hidden", c.style.height = "0", c.style["overflow-y"] = "hidden"), this.container ? c.shadowRoot ? ((_ = c.shadowRoot.lastChild) == null ? void 0 : _.nodeName) === "IFRAME" ? c.shadowRoot.replaceChild(a, c.shadowRoot.lastChild) : c.shadowRoot.appendChild(a) : c.firstChild ? c.replaceChild(a, c.firstChild) : c.appendChild(a) : (!c.firstChild || c.firstChild.nodeName === "#text") && c.appendChild(a);
|
|
604
|
+
const { contentWindow: d } = a;
|
|
605
|
+
if (!d)
|
|
1522
606
|
throw new Error("Frame needs a content window");
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
${((_k = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _k.brandFont) && `
|
|
1530
|
-
<link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
|
|
607
|
+
const h = d.document;
|
|
608
|
+
h.open();
|
|
609
|
+
const u = this.widgetApi.domain;
|
|
610
|
+
h.write(`
|
|
611
|
+
${(C = e == null ? void 0 : e.main) != null && C.brandFont ? `
|
|
612
|
+
<link rel="preconnect" href="https://fast${u === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
|
|
1531
613
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
1532
614
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1533
615
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1534
|
-
(
|
|
1535
|
-
)}" as="style">`}
|
|
1536
|
-
<
|
|
616
|
+
(Z = e == null ? void 0 : e.main) == null ? void 0 : Z.brandFont
|
|
617
|
+
)}" as="style">` : ""}
|
|
618
|
+
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
619
|
+
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
1537
620
|
<style data-styles>
|
|
1538
621
|
html { visibility:hidden;}
|
|
1539
622
|
</style>
|
|
1540
623
|
${this.content}
|
|
1541
624
|
|
|
1542
|
-
`)
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1550
|
-
frame.height = initialHeight || frameDoc.body.scrollHeight;
|
|
1551
|
-
console.log({ height: frameDoc.body.scrollHeight });
|
|
1552
|
-
const ro = new contentWindow["ResizeObserver"]((entries) => {
|
|
1553
|
-
for (const entry of entries) {
|
|
1554
|
-
const { height } = entry.contentRect;
|
|
1555
|
-
frame.height = height;
|
|
625
|
+
`), h.close(), X(h, async () => {
|
|
626
|
+
const ee = d.squatch || d.widgetIdent;
|
|
627
|
+
a.height = i || h.body.scrollHeight;
|
|
628
|
+
const me = new ResizeObserver((ge) => {
|
|
629
|
+
for (const fe of ge) {
|
|
630
|
+
const { height: we } = fe.contentRect;
|
|
631
|
+
a.height = we;
|
|
1556
632
|
}
|
|
1557
|
-
});
|
|
1558
|
-
|
|
1559
|
-
ro.observe(container);
|
|
1560
|
-
if (this._shouldFireLoadEvent()) {
|
|
1561
|
-
this._loadEvent(_sqh);
|
|
1562
|
-
_log$7("loaded");
|
|
1563
|
-
} else if (frameDoc) {
|
|
1564
|
-
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1565
|
-
}
|
|
633
|
+
}), pe = await this._findInnerContainer(a);
|
|
634
|
+
me.observe(pe), this._shouldFireLoadEvent() ? (this._loadEvent(ee), b("loaded")) : h && this._attachLoadEventListener(h, ee);
|
|
1566
635
|
});
|
|
1567
636
|
}
|
|
1568
637
|
/**
|
|
1569
638
|
* Un-hide if element is available and refresh data
|
|
1570
639
|
*/
|
|
1571
640
|
open() {
|
|
1572
|
-
const
|
|
1573
|
-
if (!
|
|
1574
|
-
if (!
|
|
1575
|
-
const
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
this.
|
|
1583
|
-
_log$7("loaded");
|
|
1584
|
-
} else {
|
|
1585
|
-
if (!frame.contentDocument) return;
|
|
1586
|
-
this._attachLoadEventListener(frame.contentDocument, _sqh);
|
|
641
|
+
const e = this._findFrame();
|
|
642
|
+
if (!e) return b("no target element to open");
|
|
643
|
+
if (!e.contentWindow) return b("Frame needs a content window");
|
|
644
|
+
const i = this._findElement();
|
|
645
|
+
i.style.visibility = "unset", i.style.height = "auto", i.style["overflow-y"] = "auto", e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
646
|
+
const n = e.contentWindow.squatch || e.contentWindow.widgetIdent;
|
|
647
|
+
if (this.context.user)
|
|
648
|
+
this._loadEvent(n), b("loaded");
|
|
649
|
+
else {
|
|
650
|
+
if (!e.contentDocument) return;
|
|
651
|
+
this._attachLoadEventListener(e.contentDocument, n);
|
|
1587
652
|
}
|
|
1588
653
|
}
|
|
1589
654
|
close() {
|
|
1590
|
-
const
|
|
1591
|
-
if (!
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
_log$7("Embed widget closed");
|
|
1599
|
-
}
|
|
1600
|
-
_error(rs, mode = "embed", style = "") {
|
|
1601
|
-
return super._error(rs, mode, style);
|
|
655
|
+
const e = this._findFrame();
|
|
656
|
+
if (!e) return b("no target element to close");
|
|
657
|
+
e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
658
|
+
const i = this._findElement();
|
|
659
|
+
i.style.visibility = "hidden", i.style.height = "0", i.style["overflow-y"] = "hidden", b("Embed widget closed");
|
|
660
|
+
}
|
|
661
|
+
_error(e, i = "embed", n = "") {
|
|
662
|
+
return super._error(e, i, n);
|
|
1602
663
|
}
|
|
1603
664
|
_shouldFireLoadEvent() {
|
|
1604
|
-
const
|
|
1605
|
-
|
|
1606
|
-
const isVerified = !!this.context.user;
|
|
1607
|
-
return isVerified && (noContainer || isComponent);
|
|
665
|
+
const e = !this.container, i = this.container instanceof HTMLElement && (this.container.tagName.startsWith("SQUATCH-") || this.container.tagName.startsWith("IMPACT-"));
|
|
666
|
+
return !!this.context.user && (e || i);
|
|
1608
667
|
}
|
|
1609
668
|
}
|
|
1610
|
-
const
|
|
1611
|
-
let
|
|
1612
|
-
class
|
|
1613
|
-
constructor(
|
|
1614
|
-
super(
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
this.trigger =
|
|
1620
|
-
if (this.container) {
|
|
1621
|
-
this.id = "squatchModal";
|
|
1622
|
-
} else {
|
|
1623
|
-
this.id = popupId === 0 ? `squatchModal` : `squatchModal__${popupId}`;
|
|
1624
|
-
popupId = popupId + 1;
|
|
1625
|
-
}
|
|
1626
|
-
document.head.insertAdjacentHTML(
|
|
669
|
+
const k = E("squatch-js:POPUPwidget");
|
|
670
|
+
let R = 0;
|
|
671
|
+
class O extends ce {
|
|
672
|
+
constructor(e, i = ".squatchpop") {
|
|
673
|
+
super(e);
|
|
674
|
+
l(this, "trigger");
|
|
675
|
+
l(this, "id");
|
|
676
|
+
l(this, "show", this.open);
|
|
677
|
+
l(this, "hide", this.close);
|
|
678
|
+
this.trigger = i, this.container ? this.id = "squatchModal" : (this.id = R === 0 ? "squatchModal" : `squatchModal__${R}`, R = R + 1), document.head.insertAdjacentHTML(
|
|
1627
679
|
"beforeend",
|
|
1628
680
|
`<style>#${this.id}::-webkit-scrollbar { display: none; }</style>`
|
|
1629
681
|
);
|
|
1630
682
|
}
|
|
1631
683
|
_initialiseCTA() {
|
|
1632
684
|
if (!this.trigger) return;
|
|
1633
|
-
let
|
|
685
|
+
let e;
|
|
1634
686
|
try {
|
|
1635
|
-
|
|
1636
|
-
if (this.trigger && !triggerElement)
|
|
1637
|
-
_log$6("No element found with trigger selector", this.trigger);
|
|
687
|
+
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && k("No element found with trigger selector", this.trigger);
|
|
1638
688
|
} catch {
|
|
1639
|
-
|
|
1640
|
-
}
|
|
1641
|
-
if (triggerElement) {
|
|
1642
|
-
triggerElement.onclick = () => {
|
|
1643
|
-
this.open();
|
|
1644
|
-
};
|
|
689
|
+
k("Not a valid selector", this.trigger);
|
|
1645
690
|
}
|
|
691
|
+
e && (e.onclick = () => {
|
|
692
|
+
this.open();
|
|
693
|
+
});
|
|
1646
694
|
}
|
|
1647
|
-
_createPopupDialog() {
|
|
1648
|
-
var
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
|
|
1652
|
-
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "auto";
|
|
1653
|
-
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
|
|
1654
|
-
dialog.id = this.id;
|
|
1655
|
-
dialog.setAttribute(
|
|
695
|
+
_createPopupDialog(e) {
|
|
696
|
+
var c;
|
|
697
|
+
const i = document.createElement("dialog"), n = (c = e == null ? void 0 : e.widgetSize) == null ? void 0 : c.popupWidgets, s = n != null && n.minWidth ? M(n.minWidth) : "auto", r = n != null && n.maxWidth ? M(n.maxWidth) : "500px";
|
|
698
|
+
i.id = this.id, i.setAttribute(
|
|
1656
699
|
"style",
|
|
1657
|
-
`width: 100%; min-width: ${
|
|
700
|
+
`width: 100%; min-width: ${s}; max-width: ${r}; border: none; padding: 0;`
|
|
1658
701
|
);
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1661
|
-
if (e.target === dialog) dialog.close();
|
|
702
|
+
const a = (d) => {
|
|
703
|
+
d.stopPropagation(), d.target === i && i.close();
|
|
1662
704
|
};
|
|
1663
|
-
|
|
1664
|
-
return dialog;
|
|
705
|
+
return i.addEventListener("click", a), i;
|
|
1665
706
|
}
|
|
1666
707
|
async load() {
|
|
1667
|
-
var
|
|
1668
|
-
const
|
|
708
|
+
var u, m, p, g, f;
|
|
709
|
+
const e = (m = (u = this.context.widgetConfig) == null ? void 0 : u.values) == null ? void 0 : m.brandingConfig, i = e == null ? void 0 : e.loadingHeight, n = this._createFrame({ initialHeight: i });
|
|
1669
710
|
this._initialiseCTA();
|
|
1670
|
-
const
|
|
1671
|
-
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1674
|
-
if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
|
|
1675
|
-
dialogParent.replaceChild(dialog, dialogParent.lastChild);
|
|
1676
|
-
} else {
|
|
1677
|
-
dialogParent.appendChild(dialog);
|
|
1678
|
-
}
|
|
1679
|
-
const { contentWindow } = frame;
|
|
1680
|
-
if (!contentWindow) {
|
|
711
|
+
const s = this.container ? this._findElement() : document.body, r = s.shadowRoot || s, a = this._createPopupDialog(e);
|
|
712
|
+
a.appendChild(n), ((p = r.lastChild) == null ? void 0 : p.nodeName) === "DIALOG" ? r.replaceChild(a, r.lastChild) : r.appendChild(a);
|
|
713
|
+
const { contentWindow: c } = n;
|
|
714
|
+
if (!c)
|
|
1681
715
|
throw new Error("Frame needs a content window");
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
716
|
+
const d = c.document;
|
|
717
|
+
d.open();
|
|
718
|
+
const h = this.widgetApi.domain;
|
|
719
|
+
d.write(`
|
|
720
|
+
${(g = e == null ? void 0 : e.main) != null && g.brandFont ? `
|
|
721
|
+
<link rel="preconnect" href="https://fast${h === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
|
|
722
|
+
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
723
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
724
|
+
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
725
|
+
(f = e == null ? void 0 : e.main) == null ? void 0 : f.brandFont
|
|
726
|
+
)}" as="style">` : ""}
|
|
727
|
+
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
728
|
+
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
729
|
+
<style data-styles>
|
|
730
|
+
html { visibility:hidden;}
|
|
731
|
+
</style>
|
|
732
|
+
${this.content}
|
|
733
|
+
|
|
734
|
+
`), d.close(), k("Popup template loaded into iframe"), await this._setupResizeHandler(n, i);
|
|
1692
735
|
}
|
|
1693
|
-
async _setupResizeHandler(
|
|
1694
|
-
const { contentWindow } =
|
|
1695
|
-
if (!
|
|
736
|
+
async _setupResizeHandler(e, i) {
|
|
737
|
+
const { contentWindow: n } = e;
|
|
738
|
+
if (!n)
|
|
1696
739
|
throw new Error("Frame needs a content window");
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
for (const entry of entries) {
|
|
1704
|
-
const { top, bottom } = entry.contentRect;
|
|
1705
|
-
const computedHeight = bottom + top;
|
|
1706
|
-
frame.height = computedHeight + "";
|
|
1707
|
-
entry.target.style = ``;
|
|
740
|
+
const s = n.document;
|
|
741
|
+
X(s, async () => {
|
|
742
|
+
s.body.style.overflowY = "hidden", e.height = i || s.body.offsetHeight, new ResizeObserver((a) => {
|
|
743
|
+
for (const c of a) {
|
|
744
|
+
const { top: d, bottom: h } = c.contentRect, u = h + d;
|
|
745
|
+
e.height = u + "", c.target.style = "";
|
|
1708
746
|
}
|
|
1709
|
-
});
|
|
1710
|
-
ro.observe(await this._findInnerContainer(frame));
|
|
747
|
+
}).observe(await this._findInnerContainer(e));
|
|
1711
748
|
});
|
|
1712
749
|
}
|
|
1713
750
|
open() {
|
|
1714
|
-
const
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
const
|
|
1720
|
-
if (!
|
|
1721
|
-
const
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1727
|
-
(_a2 = frame.contentDocument) == null ? void 0 : _a2.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
1728
|
-
if (this.context.user) {
|
|
1729
|
-
this._loadEvent(_sqh);
|
|
1730
|
-
_log$6("Popup opened");
|
|
1731
|
-
} else {
|
|
1732
|
-
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1733
|
-
}
|
|
751
|
+
const e = this.container ? this._findElement() : document.body, n = (e.shadowRoot || e).querySelector(`#${this.id}`);
|
|
752
|
+
if (!n) throw new Error("Could not determine container div");
|
|
753
|
+
n.showModal();
|
|
754
|
+
const s = this._findFrame();
|
|
755
|
+
if (!s) throw new Error("Could not find iframe");
|
|
756
|
+
const { contentWindow: r } = s;
|
|
757
|
+
if (!r) throw new Error("Squatch.js has an empty iframe");
|
|
758
|
+
const a = r.document;
|
|
759
|
+
X(a, () => {
|
|
760
|
+
var d;
|
|
761
|
+
const c = r.squatch || r.widgetIdent;
|
|
762
|
+
(d = s.contentDocument) == null || d.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(c), k("Popup opened")) : this._attachLoadEventListener(a, c);
|
|
1734
763
|
});
|
|
1735
764
|
}
|
|
1736
765
|
close() {
|
|
1737
|
-
const
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
_clickedOutside({ target }) {
|
|
1748
|
-
}
|
|
1749
|
-
_error(rs, mode = "modal", style = "") {
|
|
1750
|
-
const _style = "body { margin: 0; } .modal { box-shadow: none; border: 0; }";
|
|
1751
|
-
return super._error(rs, mode, style || _style);
|
|
766
|
+
const e = this._findFrame();
|
|
767
|
+
e != null && e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
768
|
+
const i = this.container ? this._findElement() : document.body, s = (i.shadowRoot || i).querySelector(`#${this.id}`);
|
|
769
|
+
if (!s) throw new Error("Could not determine container div");
|
|
770
|
+
s.close(), k("Popup closed");
|
|
771
|
+
}
|
|
772
|
+
_clickedOutside({ target: e }) {
|
|
773
|
+
}
|
|
774
|
+
_error(e, i = "modal", n = "") {
|
|
775
|
+
return super._error(e, i, n || "body { margin: 0; } .modal { box-shadow: none; border: 0; }");
|
|
1752
776
|
}
|
|
1753
777
|
}
|
|
1754
|
-
const
|
|
1755
|
-
class
|
|
778
|
+
const y = E("squatch-js:widgets");
|
|
779
|
+
class j {
|
|
1756
780
|
/**
|
|
1757
781
|
* Initialize a new {@link Widgets} instance.
|
|
1758
782
|
*
|
|
@@ -1769,30 +793,27 @@ class Widgets {
|
|
|
1769
793
|
* import {Widgets} from '@saasquatch/squatch-js';
|
|
1770
794
|
* let widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});
|
|
1771
795
|
*/
|
|
1772
|
-
constructor(
|
|
796
|
+
constructor(t) {
|
|
1773
797
|
/**
|
|
1774
798
|
* Instance of {@link WidgetApi}
|
|
1775
799
|
*/
|
|
1776
|
-
|
|
800
|
+
l(this, "api");
|
|
1777
801
|
/**
|
|
1778
802
|
* Tenant alias of SaaSquatch tenant
|
|
1779
803
|
*/
|
|
1780
|
-
|
|
804
|
+
l(this, "tenantAlias");
|
|
1781
805
|
/**
|
|
1782
806
|
* SaaSquatch domain for API requests
|
|
1783
807
|
* @default "https://app.referralsaasquatch.com"
|
|
1784
808
|
*/
|
|
1785
|
-
|
|
809
|
+
l(this, "domain");
|
|
1786
810
|
/**
|
|
1787
811
|
* Hosted CDN for npm packages
|
|
1788
812
|
* @default "https://fast.ssqt.io/npm"
|
|
1789
813
|
*/
|
|
1790
|
-
|
|
1791
|
-
const
|
|
1792
|
-
this.tenantAlias =
|
|
1793
|
-
this.domain = config.domain;
|
|
1794
|
-
this.npmCdn = config.npmCdn;
|
|
1795
|
-
this.api = new WidgetApi(config);
|
|
814
|
+
l(this, "npmCdn");
|
|
815
|
+
const e = W(t);
|
|
816
|
+
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new Y(e);
|
|
1796
817
|
}
|
|
1797
818
|
/**
|
|
1798
819
|
* This function calls the {@link WidgetApi.upsertUser} method, and it renders
|
|
@@ -1810,32 +831,27 @@ class Widgets {
|
|
|
1810
831
|
*
|
|
1811
832
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1812
833
|
*/
|
|
1813
|
-
async upsertUser(
|
|
1814
|
-
const
|
|
1815
|
-
const clean = validateWidgetConfig(raw);
|
|
834
|
+
async upsertUser(t) {
|
|
835
|
+
const i = se(t);
|
|
1816
836
|
try {
|
|
1817
|
-
const
|
|
837
|
+
const n = await this.api.upsertUser(i);
|
|
1818
838
|
return {
|
|
1819
|
-
widget: this._renderWidget(
|
|
839
|
+
widget: this._renderWidget(n, i, {
|
|
1820
840
|
type: "upsert",
|
|
1821
|
-
user:
|
|
1822
|
-
engagementMedium:
|
|
1823
|
-
container:
|
|
1824
|
-
trigger:
|
|
841
|
+
user: i.user,
|
|
842
|
+
engagementMedium: t.engagementMedium,
|
|
843
|
+
container: t.container,
|
|
844
|
+
trigger: t.trigger,
|
|
1825
845
|
widgetConfig: {
|
|
1826
846
|
values: {
|
|
1827
|
-
brandingConfig:
|
|
847
|
+
brandingConfig: n == null ? void 0 : n.brandingConfig
|
|
1828
848
|
}
|
|
1829
849
|
}
|
|
1830
850
|
}),
|
|
1831
|
-
user:
|
|
851
|
+
user: n.user
|
|
1832
852
|
};
|
|
1833
|
-
} catch (
|
|
1834
|
-
|
|
1835
|
-
if (err.apiErrorCode) {
|
|
1836
|
-
this._renderErrorWidget(err, config.engagementMedium);
|
|
1837
|
-
}
|
|
1838
|
-
throw new Error(err);
|
|
853
|
+
} catch (n) {
|
|
854
|
+
throw y(n), n.apiErrorCode && this._renderErrorWidget(n, t.engagementMedium), new Error(n);
|
|
1839
855
|
}
|
|
1840
856
|
}
|
|
1841
857
|
/**
|
|
@@ -1853,30 +869,22 @@ class Widgets {
|
|
|
1853
869
|
*
|
|
1854
870
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1855
871
|
*/
|
|
1856
|
-
async render(
|
|
1857
|
-
const
|
|
1858
|
-
const clean = validatePasswordlessConfig(raw);
|
|
872
|
+
async render(t) {
|
|
873
|
+
const i = re(t);
|
|
1859
874
|
try {
|
|
1860
|
-
const
|
|
875
|
+
const n = await this.api.render(i);
|
|
1861
876
|
return {
|
|
1862
|
-
widget: this._renderWidget(
|
|
877
|
+
widget: this._renderWidget(n, i, {
|
|
1863
878
|
type: "passwordless",
|
|
1864
|
-
engagementMedium:
|
|
1865
|
-
container:
|
|
1866
|
-
trigger:
|
|
1867
|
-
widgetConfig:
|
|
1868
|
-
values: {
|
|
1869
|
-
brandingConfig: response == null ? void 0 : response.brandingConfig
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
879
|
+
engagementMedium: i.engagementMedium,
|
|
880
|
+
container: i.container,
|
|
881
|
+
trigger: i.trigger,
|
|
882
|
+
widgetConfig: n == null ? void 0 : n.widgetConfig
|
|
1872
883
|
}),
|
|
1873
|
-
user:
|
|
884
|
+
user: n.user
|
|
1874
885
|
};
|
|
1875
|
-
} catch (
|
|
1876
|
-
|
|
1877
|
-
this._renderErrorWidget(err, clean.engagementMedium);
|
|
1878
|
-
}
|
|
1879
|
-
throw new Error(err);
|
|
886
|
+
} catch (n) {
|
|
887
|
+
throw n.apiErrorCode && this._renderErrorWidget(n, i.engagementMedium), new Error(n);
|
|
1880
888
|
}
|
|
1881
889
|
}
|
|
1882
890
|
/**
|
|
@@ -1886,33 +894,29 @@ class Widgets {
|
|
|
1886
894
|
* @param selector Element class/id selector, or a callback function
|
|
1887
895
|
* @returns
|
|
1888
896
|
*/
|
|
1889
|
-
async autofill(
|
|
1890
|
-
const
|
|
1891
|
-
if (typeof
|
|
897
|
+
async autofill(t) {
|
|
898
|
+
const e = t;
|
|
899
|
+
if (typeof e == "function") {
|
|
1892
900
|
try {
|
|
1893
|
-
const
|
|
1894
|
-
|
|
1895
|
-
} catch (
|
|
1896
|
-
|
|
1897
|
-
throw new Error(e);
|
|
901
|
+
const s = await this.api.squatchReferralCookie();
|
|
902
|
+
e(s);
|
|
903
|
+
} catch (s) {
|
|
904
|
+
throw y("Autofill error", s), new Error(s);
|
|
1898
905
|
}
|
|
1899
906
|
return;
|
|
1900
907
|
}
|
|
1901
|
-
if (typeof
|
|
908
|
+
if (typeof e != "string")
|
|
1902
909
|
throw new Error("Autofill accepts a string or function");
|
|
1903
|
-
let
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
_log$5("Element id/class or function missing");
|
|
1909
|
-
throw new Error("Element id/class or function missing");
|
|
1910
|
-
}
|
|
910
|
+
let i = document.querySelectorAll(e), n;
|
|
911
|
+
if (i.length > 0)
|
|
912
|
+
n = i[0];
|
|
913
|
+
else
|
|
914
|
+
throw y("Element id/class or function missing"), new Error("Element id/class or function missing");
|
|
1911
915
|
try {
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1914
|
-
} catch (
|
|
1915
|
-
throw new Error(
|
|
916
|
+
const s = await this.api.squatchReferralCookie();
|
|
917
|
+
n.value = s.codes[0];
|
|
918
|
+
} catch (s) {
|
|
919
|
+
throw new Error(s);
|
|
1916
920
|
}
|
|
1917
921
|
}
|
|
1918
922
|
/**
|
|
@@ -1923,74 +927,42 @@ class Widgets {
|
|
|
1923
927
|
* @param {string} config.engagementMedium (POPUP, EMBED)
|
|
1924
928
|
* @returns {Widget} widget (PopupWidget or EmbedWidget)
|
|
1925
929
|
*/
|
|
1926
|
-
_renderWidget(
|
|
1927
|
-
var
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
const params = {
|
|
1934
|
-
content: response.template,
|
|
1935
|
-
type: config.widgetType || ((_a2 = opts.widget) == null ? void 0 : _a2.defaultWidgetType),
|
|
930
|
+
_renderWidget(t, e, i) {
|
|
931
|
+
var c;
|
|
932
|
+
if (y("Rendering Widget..."), !t) throw new Error("Unable to get a response");
|
|
933
|
+
let n, s = !!e.displayOnLoad;
|
|
934
|
+
const r = t.jsOptions || {}, a = {
|
|
935
|
+
content: t.template,
|
|
936
|
+
type: e.widgetType || ((c = r.widget) == null ? void 0 : c.defaultWidgetType),
|
|
1936
937
|
api: this.api,
|
|
1937
938
|
domain: this.domain,
|
|
1938
939
|
npmCdn: this.npmCdn,
|
|
1939
|
-
context
|
|
940
|
+
context: i
|
|
1940
941
|
};
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
_log$5("We found a fuel tank autofill!");
|
|
1958
|
-
opts.fuelTankAutofillUrls.forEach(({ url, formSelector }) => {
|
|
1959
|
-
var _a3, _b, _c;
|
|
1960
|
-
if (Widgets._matchesUrl(url)) {
|
|
1961
|
-
_log$5("Fuel Tank URL matches");
|
|
1962
|
-
if ((_b = (_a3 = response.user) == null ? void 0 : _a3.referredBy) == null ? void 0 : _b.code) {
|
|
1963
|
-
const formAutofill = document.querySelector(formSelector);
|
|
1964
|
-
if (formAutofill) {
|
|
1965
|
-
formAutofill.value = ((_c = response.user.referredBy.referredReward) == null ? void 0 : _c.fuelTankCode) || "";
|
|
1966
|
-
} else {
|
|
1967
|
-
_log$5(
|
|
1968
|
-
new Error(
|
|
1969
|
-
`Element with id/class ${formSelector} was not found.`
|
|
1970
|
-
)
|
|
1971
|
-
);
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
if (config.engagementMedium === "EMBED") {
|
|
1978
|
-
widget2 = this._renderEmbedWidget(params);
|
|
1979
|
-
} else {
|
|
1980
|
-
widget2 = this._renderPopupWidget(params);
|
|
1981
|
-
if (displayOnLoad) widget2.open();
|
|
1982
|
-
}
|
|
1983
|
-
return widget2;
|
|
942
|
+
return r.widgetUrlMappings && r.widgetUrlMappings.forEach((d) => {
|
|
943
|
+
var h, u;
|
|
944
|
+
j._matchesUrl(d.url) && (d.widgetType !== "CONVERSION_WIDGET" || (u = (h = t.user) == null ? void 0 : h.referredBy) != null && u.code ? (s = d.displayOnLoad, y(`Display ${d.widgetType} on ${d.url}`)) : y(
|
|
945
|
+
`Don't display ${d.widgetType} when no referral on widget rule match ${d.url}`
|
|
946
|
+
));
|
|
947
|
+
}), r.fuelTankAutofillUrls && (y("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: d, formSelector: h }) => {
|
|
948
|
+
var u, m, p;
|
|
949
|
+
if (j._matchesUrl(d) && (y("Fuel Tank URL matches"), (m = (u = t.user) == null ? void 0 : u.referredBy) != null && m.code)) {
|
|
950
|
+
const g = document.querySelector(h);
|
|
951
|
+
g ? g.value = ((p = t.user.referredBy.referredReward) == null ? void 0 : p.fuelTankCode) || "" : y(
|
|
952
|
+
new Error(
|
|
953
|
+
`Element with id/class ${h} was not found.`
|
|
954
|
+
)
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
})), e.engagementMedium === "EMBED" ? n = this._renderEmbedWidget(a) : (n = this._renderPopupWidget(a), s && n.open()), n;
|
|
1984
958
|
}
|
|
1985
|
-
_renderPopupWidget(
|
|
1986
|
-
const
|
|
1987
|
-
|
|
1988
|
-
return widget2;
|
|
959
|
+
_renderPopupWidget(t) {
|
|
960
|
+
const e = new O(t, t.context.trigger);
|
|
961
|
+
return e.load(), e;
|
|
1989
962
|
}
|
|
1990
|
-
_renderEmbedWidget(
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
return widget2;
|
|
963
|
+
_renderEmbedWidget(t) {
|
|
964
|
+
const e = new L(t, t.context.container);
|
|
965
|
+
return e.load(), e;
|
|
1994
966
|
}
|
|
1995
967
|
/**
|
|
1996
968
|
* @hidden
|
|
@@ -1998,37 +970,31 @@ class Widgets {
|
|
|
1998
970
|
* @param {string} em The engagementMedium
|
|
1999
971
|
* @returns {void}
|
|
2000
972
|
*/
|
|
2001
|
-
_renderErrorWidget(
|
|
2002
|
-
const { apiErrorCode, rsCode, message } =
|
|
2003
|
-
|
|
2004
|
-
const
|
|
973
|
+
_renderErrorWidget(t, e = "POPUP") {
|
|
974
|
+
const { apiErrorCode: i, rsCode: n, message: s } = t;
|
|
975
|
+
y(new Error(`${i} (${n}) ${s}`));
|
|
976
|
+
const r = {
|
|
2005
977
|
content: "error",
|
|
2006
|
-
rsCode,
|
|
978
|
+
rsCode: n,
|
|
2007
979
|
api: this.api,
|
|
2008
980
|
domain: this.domain,
|
|
2009
981
|
npmCdn: this.npmCdn,
|
|
2010
982
|
type: "ERROR_WIDGET",
|
|
2011
983
|
context: { type: "error" }
|
|
2012
984
|
};
|
|
2013
|
-
let
|
|
2014
|
-
|
|
2015
|
-
widget2 = new EmbedWidget(params);
|
|
2016
|
-
widget2.load();
|
|
2017
|
-
} else if (em === "POPUP") {
|
|
2018
|
-
widget2 = new PopupWidget(params);
|
|
2019
|
-
widget2.load();
|
|
2020
|
-
}
|
|
985
|
+
let a;
|
|
986
|
+
e === "EMBED" ? (a = new L(r), a.load()) : e === "POPUP" && (a = new O(r), a.load());
|
|
2021
987
|
}
|
|
2022
988
|
/**
|
|
2023
989
|
* @hidden
|
|
2024
990
|
* @param {string} rule A regular expression
|
|
2025
991
|
* @returns {boolean} true if rule matches Url, false otherwise
|
|
2026
992
|
*/
|
|
2027
|
-
static _matchesUrl(
|
|
2028
|
-
return window.location.href.match(new RegExp(
|
|
993
|
+
static _matchesUrl(t) {
|
|
994
|
+
return !!window.location.href.match(new RegExp(t));
|
|
2029
995
|
}
|
|
2030
996
|
}
|
|
2031
|
-
class
|
|
997
|
+
class Ue {
|
|
2032
998
|
/**
|
|
2033
999
|
* Initialize a new {@link EventsApi} instance.
|
|
2034
1000
|
*
|
|
@@ -2045,13 +1011,11 @@ class EventsApi {
|
|
|
2045
1011
|
* import {EventsApi} from '@saasquatch/squatch-js';
|
|
2046
1012
|
* let squatchApi = new EventsApi({tenantAlias:'test_12b5bo1b25125'});
|
|
2047
1013
|
*/
|
|
2048
|
-
constructor(
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
const
|
|
2052
|
-
|
|
2053
|
-
this.tenantAlias = clean.tenantAlias;
|
|
2054
|
-
this.domain = clean.domain;
|
|
1014
|
+
constructor(t) {
|
|
1015
|
+
l(this, "tenantAlias");
|
|
1016
|
+
l(this, "domain");
|
|
1017
|
+
const i = W(t);
|
|
1018
|
+
this.tenantAlias = i.tenantAlias, this.domain = i.domain;
|
|
2055
1019
|
}
|
|
2056
1020
|
/**
|
|
2057
1021
|
* Track an event for a user
|
|
@@ -2061,273 +1025,234 @@ class EventsApi {
|
|
|
2061
1025
|
*
|
|
2062
1026
|
* @return An ID to confirm the event has been accepted for asynchronous processing
|
|
2063
1027
|
*/
|
|
2064
|
-
track(
|
|
2065
|
-
const
|
|
2066
|
-
|
|
2067
|
-
const body = _validateEvent(raw);
|
|
2068
|
-
const { jwt } = _validateTrackOptions(rawOpts);
|
|
2069
|
-
const ta = encodeURIComponent(this.tenantAlias);
|
|
2070
|
-
const userId = encodeURIComponent(body.userId);
|
|
2071
|
-
const accountId = encodeURIComponent(body.accountId);
|
|
2072
|
-
const path = `/api/v1/${ta}/open/account/${accountId}/user/${userId}/events`;
|
|
2073
|
-
const url = this.domain + path;
|
|
2074
|
-
return doPost(url, JSON.stringify(body), jwt);
|
|
1028
|
+
track(t, e) {
|
|
1029
|
+
const i = t, n = e, s = Re(i), { jwt: r } = $e(n), a = encodeURIComponent(this.tenantAlias), c = encodeURIComponent(s.userId), d = encodeURIComponent(s.accountId), h = `/api/v1/${a}/open/account/${d}/user/${c}/events`, u = this.domain + h;
|
|
1030
|
+
return V(u, JSON.stringify(s), r);
|
|
2075
1031
|
}
|
|
2076
1032
|
}
|
|
2077
|
-
function
|
|
2078
|
-
if (!
|
|
2079
|
-
if (!(
|
|
2080
|
-
if (!(
|
|
2081
|
-
if (!(
|
|
2082
|
-
const
|
|
2083
|
-
if (!Array.isArray(
|
|
1033
|
+
function Re(o) {
|
|
1034
|
+
if (!I(o)) throw new Error("tracking parameter must be an object");
|
|
1035
|
+
if (!(o != null && o.accountId)) throw new Error("accountId field is required");
|
|
1036
|
+
if (!(o != null && o.events)) throw new Error("events field is required");
|
|
1037
|
+
if (!(o != null && o.userId)) throw new Error("userId field is required");
|
|
1038
|
+
const t = o;
|
|
1039
|
+
if (!Array.isArray(t.events))
|
|
2084
1040
|
throw new Error("'events' should be an array");
|
|
2085
|
-
return
|
|
1041
|
+
return t;
|
|
2086
1042
|
}
|
|
2087
|
-
function
|
|
2088
|
-
if (!
|
|
2089
|
-
return
|
|
1043
|
+
function $e(o) {
|
|
1044
|
+
if (!I(o)) throw new Error("'options' should be an object");
|
|
1045
|
+
return o;
|
|
2090
1046
|
}
|
|
2091
|
-
function
|
|
2092
|
-
var
|
|
2093
|
-
const
|
|
2094
|
-
const cached = ((_a2 = window["_" + namespace]) == null ? void 0 : _a2.ready) || [];
|
|
2095
|
-
const declarativeCache = window.impactOnReady || window.squatchOnReady;
|
|
2096
|
-
const readyFns = [...cached, declarativeCache].filter((a) => !!a);
|
|
1047
|
+
function Pe() {
|
|
1048
|
+
var n;
|
|
1049
|
+
const o = window[J] ? J : U, t = ((n = window["_" + o]) == null ? void 0 : n.ready) || [], e = window.impactOnReady || window.squatchOnReady, i = [...t, e].filter((s) => !!s);
|
|
2097
1050
|
setTimeout(() => {
|
|
2098
|
-
|
|
2099
|
-
window[IMPACT_NAMESPACE] = window[DEFAULT_NAMESPACE];
|
|
2100
|
-
readyFns.forEach((cb) => cb());
|
|
2101
|
-
window[DEFAULT_NAMESPACE]._auto();
|
|
2102
|
-
window["_" + namespace] = void 0;
|
|
2103
|
-
delete window["_" + namespace];
|
|
1051
|
+
window[U] && (window[J] = window[U], i.forEach((s) => s()), window[U]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
2104
1052
|
}, 0);
|
|
2105
1053
|
}
|
|
2106
|
-
const
|
|
2107
|
-
const
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
const replaced = Object.getOwnPropertyNames(source).map((prop) => ({
|
|
2111
|
-
[prop]: isDeep(prop) ? deepMerge(target[prop], source[prop]) : source[prop]
|
|
2112
|
-
})).reduce((a, b) => ({ ...a, ...b }), {});
|
|
1054
|
+
const v = E("squatch-js"), te = (o) => typeof o == "object" && !Array.isArray(o), de = (o, t) => {
|
|
1055
|
+
const e = (n) => te(t[n]) && o.hasOwnProperty(n) && te(o[n]), i = Object.getOwnPropertyNames(t).map((n) => ({
|
|
1056
|
+
[n]: e(n) ? de(o[n], t[n]) : t[n]
|
|
1057
|
+
})).reduce((n, s) => ({ ...n, ...s }), {});
|
|
2113
1058
|
return {
|
|
2114
|
-
...
|
|
2115
|
-
...
|
|
1059
|
+
...o,
|
|
1060
|
+
...i
|
|
2116
1061
|
};
|
|
2117
1062
|
};
|
|
2118
|
-
function
|
|
2119
|
-
const
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
}
|
|
2124
|
-
return new TextDecoder("utf8").decode(bytes);
|
|
1063
|
+
function D(o) {
|
|
1064
|
+
const t = atob(o.replace(/_/g, "/").replace(/-/g, "+")), e = new Uint8Array(t.length);
|
|
1065
|
+
for (let i = 0; i < t.length; i++)
|
|
1066
|
+
e[i] = t.charCodeAt(i);
|
|
1067
|
+
return new TextDecoder("utf8").decode(e);
|
|
2125
1068
|
}
|
|
2126
|
-
function
|
|
2127
|
-
const
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
(byte) => String.fromCodePoint(byte)
|
|
1069
|
+
function ne(o) {
|
|
1070
|
+
const t = new TextEncoder().encode(o), e = Array.from(
|
|
1071
|
+
t,
|
|
1072
|
+
(i) => String.fromCodePoint(i)
|
|
2131
1073
|
).join("");
|
|
2132
|
-
return btoa(
|
|
1074
|
+
return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
2133
1075
|
}
|
|
2134
|
-
function
|
|
2135
|
-
var
|
|
2136
|
-
for (
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
if (document.cookie.indexOf(weird_cookie) > -1) {
|
|
2140
|
-
document.cookie = weird_cookie.split("=")[0] + "=;domain=." + h + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
|
2141
|
-
return h;
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
1076
|
+
function Se() {
|
|
1077
|
+
var o, t, e = "weird_get_top_level_domain=cookie", i = document.location.hostname.split(".");
|
|
1078
|
+
for (o = i.length - 1; o >= 0; o--)
|
|
1079
|
+
if (t = i.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
|
|
1080
|
+
return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
|
|
2144
1081
|
}
|
|
2145
|
-
function
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
if (refParam) {
|
|
2150
|
-
let paramsJSON = "", existingCookie = "", reEncodedCookie = "";
|
|
1082
|
+
function Me() {
|
|
1083
|
+
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
|
|
1084
|
+
if (e) {
|
|
1085
|
+
let i = "", n = "", s = "";
|
|
2151
1086
|
try {
|
|
2152
|
-
|
|
2153
|
-
} catch (
|
|
2154
|
-
|
|
1087
|
+
i = JSON.parse(D(e));
|
|
1088
|
+
} catch (r) {
|
|
1089
|
+
v("Unable to decode params", r);
|
|
2155
1090
|
return;
|
|
2156
1091
|
}
|
|
2157
1092
|
try {
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
_log$4("Unable to retrieve cookie", error);
|
|
1093
|
+
n = JSON.parse(D(S.get("_saasquatch"))), v("existing cookie", n);
|
|
1094
|
+
} catch (r) {
|
|
1095
|
+
v("Unable to retrieve cookie", r);
|
|
2162
1096
|
}
|
|
2163
1097
|
try {
|
|
2164
|
-
const
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
reEncodedCookie = b64encode(JSON.stringify(paramsJSON));
|
|
2172
|
-
_log$4("cookie to store:", paramsJSON);
|
|
2173
|
-
}
|
|
2174
|
-
api$1.set("_saasquatch", reEncodedCookie, {
|
|
1098
|
+
const r = Se();
|
|
1099
|
+
if (v("domain retrieved:", r), n) {
|
|
1100
|
+
const a = de(n, i);
|
|
1101
|
+
s = ne(JSON.stringify(a)), v("cookie to store:", a);
|
|
1102
|
+
} else
|
|
1103
|
+
s = ne(JSON.stringify(i)), v("cookie to store:", i);
|
|
1104
|
+
S.set("_saasquatch", s, {
|
|
2175
1105
|
expires: 365,
|
|
2176
|
-
secure:
|
|
1106
|
+
secure: !1,
|
|
2177
1107
|
sameSite: "Lax",
|
|
2178
|
-
domain,
|
|
1108
|
+
domain: r,
|
|
2179
1109
|
path: "/"
|
|
2180
1110
|
});
|
|
2181
|
-
} catch (
|
|
2182
|
-
|
|
1111
|
+
} catch (r) {
|
|
1112
|
+
v("Unable to set cookie", r);
|
|
2183
1113
|
}
|
|
2184
1114
|
}
|
|
2185
1115
|
}
|
|
2186
|
-
const
|
|
2187
|
-
function
|
|
2188
|
-
var
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
if (!refParam) {
|
|
2193
|
-
_log$3("No _saasquatchExtra param");
|
|
1116
|
+
const $ = E("squatch-js");
|
|
1117
|
+
function Le() {
|
|
1118
|
+
var u;
|
|
1119
|
+
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
|
|
1120
|
+
if (!e) {
|
|
1121
|
+
$("No _saasquatchExtra param");
|
|
2194
1122
|
return;
|
|
2195
1123
|
}
|
|
2196
|
-
const
|
|
1124
|
+
const i = W({
|
|
2197
1125
|
tenantAlias: "UNKNOWN"
|
|
2198
1126
|
});
|
|
2199
|
-
if (!
|
|
2200
|
-
|
|
1127
|
+
if (!i.domain) {
|
|
1128
|
+
$("domain must be provided in config to use _saasquatchExtra");
|
|
2201
1129
|
return;
|
|
2202
1130
|
}
|
|
2203
|
-
let
|
|
1131
|
+
let n;
|
|
2204
1132
|
try {
|
|
2205
|
-
|
|
2206
|
-
} catch
|
|
2207
|
-
|
|
1133
|
+
n = JSON.parse(D(e));
|
|
1134
|
+
} catch {
|
|
1135
|
+
$("Unable to decode _saasquatchExtra config");
|
|
2208
1136
|
return;
|
|
2209
1137
|
}
|
|
2210
|
-
function
|
|
2211
|
-
return
|
|
1138
|
+
function s(m) {
|
|
1139
|
+
return m.replace(/^https?:\/\//, "");
|
|
2212
1140
|
}
|
|
2213
|
-
const
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
_log$3("_saasquatchExtra did not have an expected structure");
|
|
2218
|
-
return void 0;
|
|
1141
|
+
const r = s(i.domain), a = Object.keys((n == null ? void 0 : n[r]) || {})[0], c = (u = n == null ? void 0 : n[r]) == null ? void 0 : u[a];
|
|
1142
|
+
if (!c) {
|
|
1143
|
+
$("_saasquatchExtra did not have an expected structure");
|
|
1144
|
+
return;
|
|
2219
1145
|
}
|
|
2220
|
-
const { autoPopupWidgetType, ...
|
|
1146
|
+
const { autoPopupWidgetType: d, ...h } = c;
|
|
2221
1147
|
return {
|
|
2222
1148
|
widgetConfig: {
|
|
2223
|
-
widgetType:
|
|
2224
|
-
displayOnLoad:
|
|
2225
|
-
...
|
|
1149
|
+
widgetType: d,
|
|
1150
|
+
displayOnLoad: !0,
|
|
1151
|
+
...h
|
|
2226
1152
|
},
|
|
2227
1153
|
squatchConfig: {
|
|
2228
|
-
...
|
|
2229
|
-
tenantAlias
|
|
1154
|
+
...i,
|
|
1155
|
+
tenantAlias: a
|
|
2230
1156
|
}
|
|
2231
1157
|
};
|
|
2232
1158
|
}
|
|
2233
|
-
const
|
|
2234
|
-
function
|
|
2235
|
-
var
|
|
1159
|
+
const Oe = E("squatch-js:decodeUserJwt");
|
|
1160
|
+
function je(o) {
|
|
1161
|
+
var t;
|
|
2236
1162
|
try {
|
|
2237
|
-
const
|
|
2238
|
-
if (
|
|
2239
|
-
const
|
|
2240
|
-
return (
|
|
1163
|
+
const e = o.split(".")[1];
|
|
1164
|
+
if (e === void 0) return null;
|
|
1165
|
+
const i = D(e);
|
|
1166
|
+
return (t = JSON.parse(i)) == null ? void 0 : t.user;
|
|
2241
1167
|
} catch (e) {
|
|
2242
|
-
|
|
2243
|
-
return null;
|
|
1168
|
+
return Oe(e), null;
|
|
2244
1169
|
}
|
|
2245
1170
|
}
|
|
2246
|
-
const
|
|
2247
|
-
class
|
|
1171
|
+
const ie = E("squatch-js:DeclarativeWidget");
|
|
1172
|
+
class le extends HTMLElement {
|
|
2248
1173
|
constructor() {
|
|
2249
1174
|
super();
|
|
2250
1175
|
/**
|
|
2251
1176
|
* Configuration overrides
|
|
2252
1177
|
* @default window.squatchConfig
|
|
2253
1178
|
*/
|
|
2254
|
-
|
|
1179
|
+
l(this, "config");
|
|
2255
1180
|
/**
|
|
2256
1181
|
* Signed JWT containing user information
|
|
2257
1182
|
* @default window.squatchToken
|
|
2258
1183
|
*/
|
|
2259
|
-
|
|
1184
|
+
l(this, "token");
|
|
2260
1185
|
/**
|
|
2261
1186
|
* Tenant alias of SaaSquatch tenant
|
|
2262
1187
|
* @default window.squatchTenant
|
|
2263
1188
|
*/
|
|
2264
|
-
|
|
1189
|
+
l(this, "tenant");
|
|
2265
1190
|
/**
|
|
2266
1191
|
* widgetType of widget to load
|
|
2267
1192
|
*/
|
|
2268
|
-
|
|
1193
|
+
l(this, "widgetType");
|
|
2269
1194
|
/**
|
|
2270
1195
|
* Locale to render the widget in
|
|
2271
1196
|
*/
|
|
2272
|
-
|
|
1197
|
+
l(this, "locale");
|
|
2273
1198
|
/**
|
|
2274
1199
|
* Instance of {@link WidgetApi}
|
|
2275
1200
|
*/
|
|
2276
|
-
|
|
1201
|
+
l(this, "widgetApi");
|
|
2277
1202
|
/**
|
|
2278
1203
|
* Instance of {@link AnalyticsApi}
|
|
2279
1204
|
*/
|
|
2280
|
-
|
|
1205
|
+
l(this, "analyticsApi");
|
|
2281
1206
|
/**
|
|
2282
1207
|
* Instance of {@link EmbedWidget} or {@link PopupWidget}
|
|
2283
1208
|
*/
|
|
2284
|
-
|
|
1209
|
+
l(this, "widgetInstance");
|
|
2285
1210
|
/**
|
|
2286
1211
|
* Determines whether to render the widget as an embedding widget or popup widget
|
|
2287
1212
|
*/
|
|
2288
|
-
|
|
1213
|
+
l(this, "type");
|
|
2289
1214
|
/**
|
|
2290
1215
|
* Container element to contain the widget iframe
|
|
2291
1216
|
* @default this
|
|
2292
1217
|
*/
|
|
2293
|
-
|
|
2294
|
-
|
|
1218
|
+
l(this, "container");
|
|
1219
|
+
l(this, "element");
|
|
2295
1220
|
/**
|
|
2296
1221
|
* Flag for if the component has been loaded or not
|
|
2297
1222
|
* @hidden
|
|
2298
1223
|
*/
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
var
|
|
2302
|
-
const
|
|
1224
|
+
l(this, "loaded");
|
|
1225
|
+
l(this, "_setWidget", (e, i) => {
|
|
1226
|
+
var s;
|
|
1227
|
+
const n = {
|
|
2303
1228
|
api: this.widgetApi,
|
|
2304
|
-
content:
|
|
1229
|
+
content: e.template,
|
|
2305
1230
|
context: {
|
|
2306
|
-
type:
|
|
2307
|
-
user:
|
|
1231
|
+
type: i.type,
|
|
1232
|
+
user: i.user,
|
|
2308
1233
|
container: this.container || void 0,
|
|
2309
1234
|
engagementMedium: this.type,
|
|
2310
|
-
widgetConfig:
|
|
1235
|
+
widgetConfig: e.widgetConfig
|
|
2311
1236
|
},
|
|
2312
1237
|
type: this.widgetType,
|
|
2313
|
-
domain: ((
|
|
2314
|
-
npmCdn:
|
|
1238
|
+
domain: ((s = this.config) == null ? void 0 : s.domain) || A,
|
|
1239
|
+
npmCdn: z,
|
|
2315
1240
|
container: this
|
|
2316
1241
|
};
|
|
2317
|
-
if (this.type === "EMBED")
|
|
2318
|
-
return new
|
|
2319
|
-
|
|
2320
|
-
const
|
|
2321
|
-
return new
|
|
1242
|
+
if (this.type === "EMBED")
|
|
1243
|
+
return new L(n);
|
|
1244
|
+
{
|
|
1245
|
+
const r = this.firstChild ? null : void 0;
|
|
1246
|
+
return new O(n, r);
|
|
2322
1247
|
}
|
|
2323
1248
|
});
|
|
2324
1249
|
/**
|
|
2325
1250
|
* Builds a Widget instance for the default error widget
|
|
2326
1251
|
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
2327
1252
|
*/
|
|
2328
|
-
|
|
2329
|
-
var
|
|
2330
|
-
const
|
|
1253
|
+
l(this, "setErrorWidget", (e) => {
|
|
1254
|
+
var n;
|
|
1255
|
+
const i = {
|
|
2331
1256
|
api: this.widgetApi,
|
|
2332
1257
|
content: "error",
|
|
2333
1258
|
context: {
|
|
@@ -2335,70 +1260,58 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
2335
1260
|
container: this.container || void 0
|
|
2336
1261
|
},
|
|
2337
1262
|
type: "ERROR_WIDGET",
|
|
2338
|
-
domain: ((
|
|
2339
|
-
npmCdn:
|
|
1263
|
+
domain: ((n = this.config) == null ? void 0 : n.domain) || A,
|
|
1264
|
+
npmCdn: z,
|
|
2340
1265
|
container: this
|
|
2341
1266
|
};
|
|
2342
|
-
if (this.type === "EMBED")
|
|
2343
|
-
return new
|
|
2344
|
-
|
|
2345
|
-
const
|
|
2346
|
-
return new
|
|
1267
|
+
if (this.type === "EMBED")
|
|
1268
|
+
return new L(i);
|
|
1269
|
+
{
|
|
1270
|
+
const s = this.firstChild ? null : void 0;
|
|
1271
|
+
return new O(i, s);
|
|
2347
1272
|
}
|
|
2348
1273
|
});
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
1274
|
+
l(this, "reload", this.renderWidget);
|
|
1275
|
+
l(this, "show", this.open);
|
|
1276
|
+
l(this, "hide", this.close);
|
|
2352
1277
|
this.attachShadow({
|
|
2353
1278
|
mode: "open"
|
|
2354
|
-
}).innerHTML =
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
this.container = this;
|
|
2359
|
-
}
|
|
2360
|
-
_setupApis(config) {
|
|
2361
|
-
var _a2, _b;
|
|
1279
|
+
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = Q(), this.token = q(), this.tenant = window.squatchTenant, this.container = this;
|
|
1280
|
+
}
|
|
1281
|
+
_setupApis(e) {
|
|
1282
|
+
var i, n;
|
|
2362
1283
|
if (!this.tenant) throw new Error("tenantAlias not provided");
|
|
2363
|
-
this.widgetApi = new
|
|
2364
|
-
tenantAlias: (
|
|
2365
|
-
domain: (
|
|
2366
|
-
})
|
|
2367
|
-
|
|
2368
|
-
domain: (config == null ? void 0 : config.domain) || ((_b = this.config) == null ? void 0 : _b.domain) || DEFAULT_DOMAIN
|
|
1284
|
+
this.widgetApi = new Y({
|
|
1285
|
+
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
|
+
domain: (e == null ? void 0 : e.domain) || ((n = this.config) == null ? void 0 : n.domain) || A
|
|
2369
1289
|
});
|
|
2370
1290
|
}
|
|
1291
|
+
getWidgetType(e) {
|
|
1292
|
+
return e && (e.includes("websiteReferralWidget") || e.includes("friendWidget")) ? "instant-access" : "verified-access";
|
|
1293
|
+
}
|
|
2371
1294
|
async renderPasswordlessVariant() {
|
|
2372
|
-
this._setupApis()
|
|
2373
|
-
_log$1("Rendering as an Instant Access widget");
|
|
2374
|
-
return await this.widgetApi.render({
|
|
1295
|
+
return this._setupApis(), ie("Rendering as an Instant Access widget"), await this.widgetApi.render({
|
|
2375
1296
|
engagementMedium: this.type,
|
|
2376
1297
|
widgetType: this.widgetType,
|
|
2377
1298
|
locale: this.locale
|
|
2378
|
-
}).then((
|
|
1299
|
+
}).then((e) => this._setWidget(e, { type: "passwordless" })).catch(this.setErrorWidget);
|
|
2379
1300
|
}
|
|
2380
1301
|
async renderUserUpsertVariant() {
|
|
2381
1302
|
this._setupApis();
|
|
2382
|
-
const
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
}
|
|
2386
|
-
_log$1("Rendering as a Verified widget");
|
|
2387
|
-
await this.widgetApi.upsertUser({
|
|
2388
|
-
user: userObj,
|
|
1303
|
+
const e = je(this.token);
|
|
1304
|
+
return e ? (ie("Rendering as a Verified widget"), await this.widgetApi.upsertUser({
|
|
1305
|
+
user: e,
|
|
2389
1306
|
locale: this.locale,
|
|
2390
1307
|
engagementMedium: this.type,
|
|
2391
1308
|
widgetType: this.widgetType,
|
|
2392
1309
|
jwt: this.token
|
|
2393
|
-
})
|
|
2394
|
-
const widgetInstance = await this.widgetApi.render({
|
|
1310
|
+
}), await this.widgetApi.render({
|
|
2395
1311
|
locale: this.locale,
|
|
2396
1312
|
engagementMedium: this.type,
|
|
2397
1313
|
widgetType: this.widgetType
|
|
2398
|
-
}).then((
|
|
2399
|
-
return this._setWidget(res, { type: "upsert", user: userObj });
|
|
2400
|
-
}).catch(this.setErrorWidget);
|
|
2401
|
-
return widgetInstance;
|
|
1314
|
+
}).then((n) => this._setWidget(n, { type: "upsert", user: e })).catch(this.setErrorWidget)) : this.setErrorWidget(Error("No user object in token."));
|
|
2402
1315
|
}
|
|
2403
1316
|
/**
|
|
2404
1317
|
* Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
|
|
@@ -2406,26 +1319,15 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
2406
1319
|
* @throws Throws an Error if `widgetType` is undefined
|
|
2407
1320
|
*/
|
|
2408
1321
|
async getWidgetInstance() {
|
|
2409
|
-
let
|
|
2410
|
-
this.widgetType = this.getAttribute("widget") || void 0;
|
|
2411
|
-
this.
|
|
2412
|
-
if (!this.widgetType) throw new Error("No widget has been specified");
|
|
2413
|
-
if (!this.token) {
|
|
2414
|
-
widgetInstance = await this.renderPasswordlessVariant();
|
|
2415
|
-
} else {
|
|
2416
|
-
widgetInstance = await this.renderUserUpsertVariant();
|
|
2417
|
-
}
|
|
2418
|
-
this.widgetInstance = widgetInstance;
|
|
2419
|
-
if (this.widgetInstance)
|
|
2420
|
-
this.dispatchEvent(new CustomEvent("sq:widget-loaded"));
|
|
2421
|
-
return widgetInstance;
|
|
1322
|
+
let e;
|
|
1323
|
+
if (this.widgetType = this.getAttribute("widget") || void 0, this.locale = this.getAttribute("locale") || this.locale, !this.widgetType) throw new Error("No widget has been specified");
|
|
1324
|
+
return this.token ? e = await this.renderUserUpsertVariant() : e = await this.renderPasswordlessVariant(), this.widgetInstance = e, this.widgetInstance && this.dispatchEvent(new CustomEvent("sq:widget-loaded")), e;
|
|
2422
1325
|
}
|
|
2423
1326
|
/**
|
|
2424
1327
|
* Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM
|
|
2425
1328
|
*/
|
|
2426
1329
|
async renderWidget() {
|
|
2427
|
-
await this.getWidgetInstance();
|
|
2428
|
-
await this.widgetInstance.load();
|
|
1330
|
+
await this.getWidgetInstance(), await this.widgetInstance.load();
|
|
2429
1331
|
}
|
|
2430
1332
|
/**
|
|
2431
1333
|
* Calls `open` method of `widgetInstance`
|
|
@@ -2443,201 +1345,123 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
2443
1345
|
if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
|
|
2444
1346
|
this.widgetInstance.close();
|
|
2445
1347
|
}
|
|
2446
|
-
}
|
|
2447
|
-
class DeclarativeEmbedWidget extends DeclarativeWidget {
|
|
2448
|
-
constructor() {
|
|
2449
|
-
super();
|
|
2450
|
-
this.type = "EMBED";
|
|
2451
|
-
this.loaded = false;
|
|
2452
|
-
}
|
|
2453
1348
|
static get observedAttributes() {
|
|
2454
1349
|
return ["widget", "locale"];
|
|
2455
1350
|
}
|
|
2456
|
-
attributeChangedCallback(
|
|
2457
|
-
if (
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
1351
|
+
attributeChangedCallback(e, i, n) {
|
|
1352
|
+
if (!(i === n || !this.loaded))
|
|
1353
|
+
switch (e) {
|
|
1354
|
+
case "locale":
|
|
1355
|
+
case "widget":
|
|
1356
|
+
this.connectedCallback();
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
2464
1359
|
}
|
|
2465
1360
|
async connectedCallback() {
|
|
2466
|
-
|
|
2467
|
-
this.
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
skeletonContainer.innerHTML = skeletonHTML;
|
|
2479
|
-
if (!this.shadowRoot) {
|
|
2480
|
-
this.attachShadow({ mode: "open" });
|
|
2481
|
-
}
|
|
2482
|
-
if (this.shadowRoot) {
|
|
2483
|
-
this.shadowRoot.innerHTML = skeletonHTML;
|
|
2484
|
-
}
|
|
1361
|
+
this.loaded = !0, this.container = this.getAttribute("container"), this.widgetType = this.getAttribute("widget") || void 0;
|
|
1362
|
+
const e = this.getWidgetType(this.widgetType), { getSkeleton: i } = await import("./SkeletonTemplate-CIRGs_GB.js"), n = i({
|
|
1363
|
+
height: "100%",
|
|
1364
|
+
type: e
|
|
1365
|
+
}), s = document.createElement("div");
|
|
1366
|
+
s.id = "loading-skeleton", s.innerHTML = n;
|
|
1367
|
+
const r = this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
1368
|
+
if (this.type === "POPUP") {
|
|
1369
|
+
const c = r.getElementById("#squatchModal");
|
|
1370
|
+
c && (c.innerHTML = "", c.appendChild(s));
|
|
1371
|
+
} else
|
|
1372
|
+
r.innerHTML = "", r.appendChild(s);
|
|
2485
1373
|
await this.renderWidget();
|
|
2486
|
-
const
|
|
2487
|
-
|
|
2488
|
-
loadingElement.remove();
|
|
2489
|
-
}
|
|
2490
|
-
if (this.getAttribute("open") !== null) this.open();
|
|
1374
|
+
const a = r.getElementById("loading-skeleton");
|
|
1375
|
+
a && a.remove(), this.getAttribute("open") !== null && this.open();
|
|
2491
1376
|
}
|
|
2492
1377
|
}
|
|
2493
|
-
class
|
|
1378
|
+
class he extends le {
|
|
2494
1379
|
constructor() {
|
|
2495
|
-
super();
|
|
2496
|
-
this.type = "POPUP";
|
|
2497
|
-
this.loaded = false;
|
|
2498
|
-
this.addEventListener("click", (e) => {
|
|
2499
|
-
e.stopPropagation();
|
|
2500
|
-
this.open();
|
|
2501
|
-
});
|
|
2502
|
-
}
|
|
2503
|
-
static get observedAttributes() {
|
|
2504
|
-
return ["widget", "locale"];
|
|
1380
|
+
super(), this.type = "EMBED", this.loaded = !1;
|
|
2505
1381
|
}
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
break;
|
|
2513
|
-
}
|
|
2514
|
-
}
|
|
2515
|
-
async connectedCallback() {
|
|
2516
|
-
this.loaded = true;
|
|
2517
|
-
this.container = this.getAttribute("container");
|
|
2518
|
-
const skeletonHTML = `
|
|
2519
|
-
<div>
|
|
2520
|
-
<h1>Dynamic Content</h1>
|
|
2521
|
-
<p>This content was dynamically added to the widget before it loaded.</p>
|
|
2522
|
-
<p>This content comes from the embedded widget class</p>
|
|
2523
|
-
</div>
|
|
2524
|
-
`;
|
|
2525
|
-
const skeletonContainer = document.createElement("div");
|
|
2526
|
-
skeletonContainer.id = "loading-skeleton";
|
|
2527
|
-
skeletonContainer.innerHTML = skeletonHTML;
|
|
2528
|
-
const root = this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
2529
|
-
root.innerHTML = "";
|
|
2530
|
-
root.appendChild(skeletonContainer);
|
|
2531
|
-
await this.renderWidget();
|
|
2532
|
-
const loadingElement = root.getElementById("loading-skeleton");
|
|
2533
|
-
if (loadingElement) {
|
|
2534
|
-
loadingElement.remove();
|
|
2535
|
-
console.log("Skeleton removed successfully");
|
|
2536
|
-
} else {
|
|
2537
|
-
console.warn("Could not find skeleton to remove");
|
|
2538
|
-
}
|
|
2539
|
-
if (this.getAttribute("open") !== null) this.open();
|
|
1382
|
+
}
|
|
1383
|
+
class ue extends le {
|
|
1384
|
+
constructor() {
|
|
1385
|
+
super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (t) => {
|
|
1386
|
+
t.stopPropagation(), this.open();
|
|
1387
|
+
});
|
|
2540
1388
|
}
|
|
2541
1389
|
}
|
|
2542
|
-
class
|
|
1390
|
+
class De extends he {
|
|
2543
1391
|
}
|
|
2544
|
-
class
|
|
1392
|
+
class Ne extends ue {
|
|
2545
1393
|
}
|
|
2546
|
-
class
|
|
1394
|
+
class Fe extends he {
|
|
2547
1395
|
}
|
|
2548
|
-
class
|
|
1396
|
+
class He extends ue {
|
|
2549
1397
|
}
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
window.customElements.define("squatch-popup", SquatchPopup);
|
|
2556
|
-
if (!window.customElements.get("impact-popup"))
|
|
2557
|
-
window.customElements.define("impact-popup", ImpactPopup);
|
|
2558
|
-
function help() {
|
|
1398
|
+
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", De);
|
|
1399
|
+
window.customElements.get("impact-embed") || window.customElements.define("impact-embed", Fe);
|
|
1400
|
+
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Ne);
|
|
1401
|
+
window.customElements.get("impact-popup") || window.customElements.define("impact-popup", He);
|
|
1402
|
+
function Ge() {
|
|
2559
1403
|
console.log(
|
|
2560
|
-
|
|
1404
|
+
"Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
|
|
2561
1405
|
);
|
|
2562
1406
|
}
|
|
2563
|
-
const
|
|
2564
|
-
let
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
function api() {
|
|
2568
|
-
if (!_api) init({});
|
|
2569
|
-
return _api;
|
|
1407
|
+
const x = E("squatch-js");
|
|
1408
|
+
let N = null, F = null, H = null;
|
|
1409
|
+
function ze() {
|
|
1410
|
+
return N || B({}), N;
|
|
2570
1411
|
}
|
|
2571
|
-
function
|
|
2572
|
-
|
|
2573
|
-
return _widgets;
|
|
1412
|
+
function K() {
|
|
1413
|
+
return F || B({}), F;
|
|
2574
1414
|
}
|
|
2575
|
-
function
|
|
2576
|
-
|
|
2577
|
-
return _events;
|
|
1415
|
+
function Ve() {
|
|
1416
|
+
return H || B({}), H;
|
|
2578
1417
|
}
|
|
2579
|
-
function
|
|
2580
|
-
var
|
|
2581
|
-
return (
|
|
1418
|
+
function Xe(o) {
|
|
1419
|
+
var t;
|
|
1420
|
+
return (t = K()) == null ? void 0 : t.render(o);
|
|
2582
1421
|
}
|
|
2583
|
-
function
|
|
2584
|
-
var
|
|
2585
|
-
const
|
|
2586
|
-
if (
|
|
2587
|
-
const { squatchConfig, widgetConfig } =
|
|
2588
|
-
|
|
2589
|
-
return (_a2 = widgets()) == null ? void 0 : _a2.render(widgetConfig);
|
|
1422
|
+
function Qe() {
|
|
1423
|
+
var t;
|
|
1424
|
+
const o = Le();
|
|
1425
|
+
if (o) {
|
|
1426
|
+
const { squatchConfig: e, widgetConfig: i } = o;
|
|
1427
|
+
return B(e), (t = K()) == null ? void 0 : t.render(i);
|
|
2590
1428
|
}
|
|
2591
1429
|
}
|
|
2592
|
-
function
|
|
2593
|
-
const
|
|
2594
|
-
|
|
2595
|
-
if (config.tenantAlias.match("^test") || config.debug) {
|
|
2596
|
-
browserExports.debug.enable("squatch-js*");
|
|
2597
|
-
} else {
|
|
2598
|
-
browserExports.debug.disable();
|
|
2599
|
-
}
|
|
2600
|
-
_log("initializing ...");
|
|
2601
|
-
_api = new WidgetApi(config);
|
|
2602
|
-
_widgets = new Widgets(config);
|
|
2603
|
-
_events = new EventsApi(config);
|
|
2604
|
-
_log("Widget API instance", _api);
|
|
2605
|
-
_log("Widgets instance", _widgets);
|
|
2606
|
-
_log("Events API instance", _events);
|
|
1430
|
+
function B(o) {
|
|
1431
|
+
const e = W(o);
|
|
1432
|
+
e.tenantAlias.match("^test") || e.debug ? Ce("squatch-js*") : ve(), x("initializing ..."), N = new Y(e), F = new j(e), H = new Ue(e), x("Widget API instance", N), x("Widgets instance", F), x("Events API instance", H);
|
|
2607
1433
|
}
|
|
2608
|
-
function
|
|
2609
|
-
|
|
1434
|
+
function Ye(o) {
|
|
1435
|
+
o();
|
|
2610
1436
|
}
|
|
2611
|
-
function
|
|
2612
|
-
|
|
1437
|
+
function Ke(o) {
|
|
1438
|
+
K().autofill(o);
|
|
2613
1439
|
}
|
|
2614
|
-
function
|
|
2615
|
-
|
|
1440
|
+
function Be() {
|
|
1441
|
+
Me();
|
|
2616
1442
|
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
);
|
|
2624
|
-
if (typeof document !== "undefined") asyncLoad();
|
|
1443
|
+
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Be();
|
|
1444
|
+
var oe;
|
|
1445
|
+
(oe = window.squatch) != null && oe.init && x(
|
|
1446
|
+
"Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
|
|
1447
|
+
);
|
|
1448
|
+
typeof document < "u" && Pe();
|
|
2625
1449
|
export {
|
|
2626
|
-
DeclarativeEmbedWidget,
|
|
2627
|
-
DeclarativePopupWidget,
|
|
2628
|
-
EmbedWidget,
|
|
2629
|
-
PopupWidget,
|
|
2630
|
-
WidgetApi,
|
|
2631
|
-
Widgets,
|
|
2632
|
-
_auto,
|
|
2633
|
-
api,
|
|
2634
|
-
autofill,
|
|
2635
|
-
events,
|
|
2636
|
-
help,
|
|
2637
|
-
init,
|
|
2638
|
-
pushCookie,
|
|
2639
|
-
ready,
|
|
2640
|
-
widget,
|
|
2641
|
-
widgets
|
|
1450
|
+
he as DeclarativeEmbedWidget,
|
|
1451
|
+
ue as DeclarativePopupWidget,
|
|
1452
|
+
L as EmbedWidget,
|
|
1453
|
+
O as PopupWidget,
|
|
1454
|
+
Y as WidgetApi,
|
|
1455
|
+
j as Widgets,
|
|
1456
|
+
Qe as _auto,
|
|
1457
|
+
ze as api,
|
|
1458
|
+
Ke as autofill,
|
|
1459
|
+
Ve as events,
|
|
1460
|
+
Ge as help,
|
|
1461
|
+
B as init,
|
|
1462
|
+
Be as pushCookie,
|
|
1463
|
+
Ye as ready,
|
|
1464
|
+
Xe as widget,
|
|
1465
|
+
K as widgets
|
|
2642
1466
|
};
|
|
2643
1467
|
//# sourceMappingURL=squatch.esm.js.map
|