@saasquatch/squatch-js 2.8.3-3 → 2.8.3-5

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