@saasquatch/squatch-js 2.8.3-28 → 2.8.3-29

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.
@@ -58,13 +58,13 @@ function re(o) {
58
58
  ).join("");
59
59
  return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
60
60
  }
61
- function Te() {
61
+ function Se() {
62
62
  var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
63
63
  for (o = n.length - 1; o >= 0; o--)
64
64
  if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
65
65
  return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
66
66
  }
67
- function Se() {
67
+ function Te() {
68
68
  const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
69
69
  if (e) {
70
70
  let n = "", i = "", s = "";
@@ -80,7 +80,7 @@ function Se() {
80
80
  A("Unable to retrieve cookie", r);
81
81
  }
82
82
  try {
83
- const r = Te();
83
+ const r = Se();
84
84
  if (A("domain retrieved:", r), i) {
85
85
  const a = ce(i, n);
86
86
  s = re(JSON.stringify(a)), A("cookie to store:", a);
@@ -117,20 +117,20 @@ function q(o) {
117
117
  npmCdn: a
118
118
  };
119
119
  }
120
- function T(o) {
120
+ function S(o) {
121
121
  return typeof o == "object" && !Array.isArray(o) && o !== null;
122
122
  }
123
- function xe(o) {
123
+ function $e(o) {
124
124
  if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
125
125
  return o;
126
126
  }
127
127
  function de(o) {
128
- if (!T(o)) throw new Error("Widget properties must be an object");
128
+ if (!S(o)) throw new Error("Widget properties must be an object");
129
129
  if (!(o != null && o.user)) throw new Error("Required properties missing.");
130
130
  return o;
131
131
  }
132
132
  function le(o) {
133
- if (!T(o)) throw new Error("Widget properties must be an object");
133
+ if (!S(o)) throw new Error("Widget properties must be an object");
134
134
  return o;
135
135
  }
136
136
  function W() {
@@ -150,7 +150,7 @@ function B(o) {
150
150
  const s = new Error(i);
151
151
  return t && (s.apiErrorCode = t), e && (s.rsCode = e), n !== void 0 && (s.statusCode = n), s;
152
152
  }
153
- async function $e(o, t, e, n) {
153
+ async function xe(o, t, e, n) {
154
154
  const i = n || W(), s = {
155
155
  Accept: "application/json",
156
156
  "Content-Type": "application/json",
@@ -294,8 +294,8 @@ class Z {
294
294
  widgetType: i,
295
295
  engagementMedium: s,
296
296
  locale: a
297
- }), p = `/api/v1/${d}/widget/account/${h}/user/${u}/upsert${m}`, g = this.domain + p, w = V("_saasquatch");
298
- return w && (c.cookies = w), We(g, JSON.stringify(c), r);
297
+ }), p = `/api/v1/${d}/widget/account/${h}/user/${u}/upsert${m}`, g = this.domain + p, f = V("_saasquatch");
298
+ return f && (c.cookies = f), We(g, JSON.stringify(c), r);
299
299
  }
300
300
  /**
301
301
  * Requests widget template
@@ -311,11 +311,11 @@ class Z {
311
311
  * @return {Promise} template html if true.
312
312
  */
313
313
  render(t) {
314
- const n = le(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, c = encodeURIComponent(this.tenantAlias), d = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? xe(navigator.language.replace(/\-/g, "_")), m = `/api/v1/${c}/graphql`, p = this.domain + m;
315
- return new Promise(async (g, w) => {
314
+ const n = le(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, c = encodeURIComponent(this.tenantAlias), d = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? $e(navigator.language.replace(/\-/g, "_")), m = `/api/v1/${c}/graphql`, p = this.domain + m;
315
+ return new Promise(async (g, f) => {
316
316
  var b;
317
317
  try {
318
- const f = await $e(
318
+ const w = await xe(
319
319
  p,
320
320
  Me,
321
321
  {
@@ -326,9 +326,9 @@ class Z {
326
326
  },
327
327
  r
328
328
  );
329
- g((b = f == null ? void 0 : f.data) == null ? void 0 : b.renderWidget);
330
- } catch (f) {
331
- w(f);
329
+ g((b = w == null ? void 0 : w.data) == null ? void 0 : b.renderWidget);
330
+ } catch (w) {
331
+ f(w);
332
332
  }
333
333
  });
334
334
  }
@@ -357,7 +357,7 @@ function Ue({
357
357
  * domready (c) Dustin Diaz 2014 - License MIT
358
358
  *
359
359
  */
360
- function $(o, t) {
360
+ function x(o, t) {
361
361
  let e = [], n, i = o, s = i.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(i.readyState);
362
362
  return a || i.addEventListener(
363
363
  r,
@@ -395,8 +395,8 @@ class ue {
395
395
  }
396
396
  pushAnalyticsLoadEvent(t) {
397
397
  if (!t.externalUserId || !t.externalAccountId) return;
398
- 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}`, c = this.domain + a;
399
- return Q(c, JSON.stringify({}));
398
+ const e = window.location.search, n = new URLSearchParams(e), i = n == null ? void 0 : n.get("rsShareMedium"), s = encodeURIComponent(t.tenantAlias), r = encodeURIComponent(t.externalAccountId), a = encodeURIComponent(t.externalUserId), c = encodeURIComponent(t.engagementMedium), d = t.programId ? `&programId=${encodeURIComponent(t.programId)}` : "", h = i ? `&shareMedium=${encodeURIComponent(i)}` : "", u = `/a/${s}/widgets/analytics/loaded?externalAccountId=${r}&externalUserId=${a}&engagementMedium=${c}${h}${d}`, m = this.domain + u;
399
+ return Q(m, JSON.stringify({}));
400
400
  }
401
401
  pushAnalyticsShareClickedEvent(t) {
402
402
  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}`, c = this.domain + a;
@@ -404,7 +404,7 @@ class ue {
404
404
  }
405
405
  }
406
406
  function Re(o) {
407
- if (!T(o)) throw new Error("'options' should be an object");
407
+ if (!S(o)) throw new Error("'options' should be an object");
408
408
  return o;
409
409
  }
410
410
  const y = C("squatch-js:widget");
@@ -432,7 +432,7 @@ class me {
432
432
  */
433
433
  async _getContent() {
434
434
  if (this.content === "error" && this.errorInfo) {
435
- const { getErrorTemplate: t } = await import("./ErrorTemplate-qH6JPm8K.js");
435
+ const { getErrorTemplate: t } = await import("./ErrorTemplate-md163BNI.js");
436
436
  return t({
437
437
  rsCode: this.errorInfo.rsCode,
438
438
  apiErrorCode: this.errorInfo.apiErrorCode,
@@ -491,7 +491,7 @@ class me {
491
491
  _loadEvent(t) {
492
492
  var n;
493
493
  if (!t) return;
494
- if (!T(t))
494
+ if (!S(t))
495
495
  throw new Error("Widget Load event identity property is not an object");
496
496
  let e;
497
497
  if ("programId" in t) {
@@ -665,19 +665,19 @@ class D extends me {
665
665
  n && (this.container = n);
666
666
  }
667
667
  async load() {
668
- var g, w, b, f, S, ee, te, ne, ie;
669
- 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 ? O(s.maxWidth) : "", a = s != null && s.minWidth ? O(s.minWidth) : "", c = this._createFrame({
668
+ var g, f, b, w, T, ee, te, ne, ie;
669
+ const e = (f = (g = this.context.widgetConfig) == null ? void 0 : g.values) == null ? void 0 : f.brandingConfig, n = (b = this.content) == null ? void 0 : b.includes("mint-components"), i = (e == null ? void 0 : e.loadingHeight) || 500, s = (w = e == null ? void 0 : e.widgetSize) == null ? void 0 : w.embeddedWidgets, r = s != null && s.maxWidth ? O(s.maxWidth) : "", a = s != null && s.minWidth ? O(s.minWidth) : "", c = this._createFrame({
670
670
  minWidth: a,
671
671
  maxWidth: r,
672
672
  initialHeight: i
673
673
  }), d = this._findElement();
674
- (S = this.context) != null && S.container && (d.style.visibility = "hidden", d.style.height = "0", d.style["overflow-y"] = "hidden"), this.container ? d.shadowRoot ? ((ee = d.shadowRoot.lastChild) == null ? void 0 : ee.nodeName) === "IFRAME" ? d.shadowRoot.replaceChild(c, d.shadowRoot.lastChild) : d.shadowRoot.appendChild(c) : d.firstChild ? d.replaceChild(c, d.firstChild) : d.appendChild(c) : (!d.firstChild || d.firstChild.nodeName === "#text") && d.appendChild(c);
674
+ (T = this.context) != null && T.container && (d.style.visibility = "hidden", d.style.height = "0", d.style["overflow-y"] = "hidden"), this.container ? d.shadowRoot ? ((ee = d.shadowRoot.lastChild) == null ? void 0 : ee.nodeName) === "IFRAME" ? d.shadowRoot.replaceChild(c, d.shadowRoot.lastChild) : d.shadowRoot.appendChild(c) : d.firstChild ? d.replaceChild(c, d.firstChild) : d.appendChild(c) : (!d.firstChild || d.firstChild.nodeName === "#text") && d.appendChild(c);
675
675
  const { contentWindow: h } = c;
676
676
  if (!h)
677
677
  throw new Error("Frame needs a content window");
678
678
  const u = h.document;
679
679
  if (u.open(), this.content === "error") {
680
- u.write(await this._getContent()), u.close(), $(u, () => {
680
+ u.write(await this._getContent()), u.close(), x(u, () => {
681
681
  c.height = u.body.scrollHeight;
682
682
  });
683
683
  return;
@@ -686,7 +686,7 @@ class D extends me {
686
686
  u.write(`
687
687
  ${(te = e == null ? void 0 : e.main) != null && te.brandFont ? `
688
688
  <link rel="preconnect" href="https://fast${p}.ssqt.io">
689
- <link rel="preconnect" href="https://fonts.gstatic.com">
689
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
690
690
  <link rel="preconnect" href="https://fonts.googleapis.com">
691
691
  <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
692
692
  (ne = e == null ? void 0 : e.main) == null ? void 0 : ne.brandFont
@@ -699,16 +699,16 @@ class D extends me {
699
699
  </style>` : ""}
700
700
  ${await this._getSkeletonPreloadHTML(n, (ie = e == null ? void 0 : e.color) == null ? void 0 : ie.backgroundColor)}
701
701
  ${await this._getContent()}
702
- `), u.close(), $(u, async () => {
702
+ `), u.close(), x(u, async () => {
703
703
  const oe = h.squatch || h.widgetIdent;
704
704
  c.height = i;
705
- const we = new h.ResizeObserver((Ee) => {
705
+ const fe = new h.ResizeObserver((Ee) => {
706
706
  for (const Ce of Ee) {
707
707
  const { height: be } = Ce.contentRect;
708
708
  c.height = be;
709
709
  }
710
710
  }), ye = await this._findInnerContainer(c);
711
- we.observe(ye), this._shouldFireLoadEvent() ? (this._loadEvent(oe), I("loaded")) : u && this._attachLoadEventListener(u, oe);
711
+ fe.observe(ye), this._shouldFireLoadEvent() ? (this._loadEvent(oe), I("loaded")) : u && this._attachLoadEventListener(u, oe);
712
712
  });
713
713
  }
714
714
  /**
@@ -782,17 +782,17 @@ class j extends me {
782
782
  return n.addEventListener("click", a), n;
783
783
  }
784
784
  async load() {
785
- var m, p, g, w, b, f, S;
785
+ var m, p, g, f, b, w, T;
786
786
  const e = (p = (m = this.context.widgetConfig) == null ? void 0 : m.values) == null ? void 0 : p.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (g = this.content) == null ? void 0 : g.includes("mint-components"), s = this._createFrame();
787
787
  s.style.height = n + "px", this._initialiseCTA();
788
788
  const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r, c = this._createPopupDialog(e);
789
- c.appendChild(s), ((w = a.lastChild) == null ? void 0 : w.nodeName) === "DIALOG" ? a.replaceChild(c, a.lastChild) : a.appendChild(c);
789
+ c.appendChild(s), ((f = a.lastChild) == null ? void 0 : f.nodeName) === "DIALOG" ? a.replaceChild(c, a.lastChild) : a.appendChild(c);
790
790
  const { contentWindow: d } = s;
791
791
  if (!d)
792
792
  throw new Error("Frame needs a content window");
793
793
  const h = d.document;
794
794
  if (h.open(), this.content === "error") {
795
- h.write(await this._getContent()), h.close(), $(h, () => {
795
+ h.write(await this._getContent()), h.close(), x(h, () => {
796
796
  s.height = h.body.scrollHeight;
797
797
  }), v("Popup error template loaded into iframe");
798
798
  return;
@@ -801,10 +801,10 @@ class j extends me {
801
801
  h.write(`
802
802
  ${(b = e == null ? void 0 : e.main) != null && b.brandFont ? `
803
803
  <link rel="preconnect" href="https://fast${u === "https://staging.referralsaasquatch.com" ? "-staging" : ""}.ssqt.io">
804
- <link rel="preconnect" href="https://fonts.gstatic.com">
804
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
805
805
  <link rel="preconnect" href="https://fonts.googleapis.com">
806
806
  <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
807
- (f = e == null ? void 0 : e.main) == null ? void 0 : f.brandFont
807
+ (w = e == null ? void 0 : e.main) == null ? void 0 : w.brandFont
808
808
  )}" as="style">` : ""}
809
809
  <link rel="dns-prefetch" href="https://res.cloudinary.com">
810
810
  <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
@@ -812,7 +812,7 @@ class j extends me {
812
812
  <style data-styles>
813
813
  html { visibility: hidden; }
814
814
  </style>` : ""}
815
- ${await this._getSkeletonPreloadHTML(i, (S = e == null ? void 0 : e.color) == null ? void 0 : S.backgroundColor)}
815
+ ${await this._getSkeletonPreloadHTML(i, (T = e == null ? void 0 : e.color) == null ? void 0 : T.backgroundColor)}
816
816
  ${await this._getContent()}
817
817
  `), h.close(), v("Popup template loaded into iframe"), await this._setupResizeHandler(s);
818
818
  }
@@ -821,7 +821,7 @@ class j extends me {
821
821
  if (!n)
822
822
  throw new Error("Frame needs a content window");
823
823
  const i = n.document;
824
- $(i, async () => {
824
+ x(i, async () => {
825
825
  i.body.style.overflowY = "hidden";
826
826
  let s = !0;
827
827
  new n.ResizeObserver((a) => {
@@ -841,7 +841,7 @@ class j extends me {
841
841
  const { contentWindow: r } = s;
842
842
  if (!r) throw new Error("Squatch.js has an empty iframe");
843
843
  const a = r.document;
844
- $(a, () => {
844
+ x(a, () => {
845
845
  var d;
846
846
  const c = r.squatch || r.widgetIdent;
847
847
  (d = s.contentDocument) == null || d.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(c), v("Popup opened")) : this._attachLoadEventListener(a, c);
@@ -1117,7 +1117,7 @@ class Oe {
1117
1117
  }
1118
1118
  }
1119
1119
  function De(o) {
1120
- if (!T(o)) throw new Error("tracking parameter must be an object");
1120
+ if (!S(o)) throw new Error("tracking parameter must be an object");
1121
1121
  if (!(o != null && o.accountId)) throw new Error("accountId field is required");
1122
1122
  if (!(o != null && o.events)) throw new Error("events field is required");
1123
1123
  if (!(o != null && o.userId)) throw new Error("userId field is required");
@@ -1127,7 +1127,7 @@ function De(o) {
1127
1127
  return t;
1128
1128
  }
1129
1129
  function je(o) {
1130
- if (!T(o)) throw new Error("'options' should be an object");
1130
+ if (!S(o)) throw new Error("'options' should be an object");
1131
1131
  return o;
1132
1132
  }
1133
1133
  function Ne() {
@@ -1361,11 +1361,9 @@ class ge extends HTMLElement {
1361
1361
  this.widgetType = this.getAttribute("widget") || void 0, this.locale = this.getAttribute("locale") || this.locale;
1362
1362
  const n = this.getWidgetType(this.widgetType);
1363
1363
  if (!this.widgetType) throw new Error("No widget has been specified");
1364
- return !this.token && n === "verified-access" && (P(
1365
- "[SquatchJS] Authentication token is required for this widget type."
1366
- ), console.log(
1364
+ return !this.token && n === "verified-access" && P(
1367
1365
  "[SquatchJS] Authentication token is required for this widget type."
1368
- )), this.token ? e = await this.renderUserUpsertVariant() : e = await this.renderPasswordlessVariant(), this.widgetInstance = e, this.widgetInstance && this.dispatchEvent(new CustomEvent("sq:widget-loaded")), e;
1366
+ ), this.token ? e = await this.renderUserUpsertVariant() : e = await this.renderPasswordlessVariant(), this.widgetInstance = e, this.widgetInstance && this.dispatchEvent(new CustomEvent("sq:widget-loaded")), e;
1369
1367
  }
1370
1368
  /**
1371
1369
  * Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM
@@ -1429,7 +1427,7 @@ class pe extends ge {
1429
1427
  super(), this.type = "EMBED", this.loaded = !1;
1430
1428
  }
1431
1429
  }
1432
- class fe extends ge {
1430
+ class we extends ge {
1433
1431
  constructor() {
1434
1432
  super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (t) => {
1435
1433
  t.stopPropagation(), this.open();
@@ -1438,11 +1436,11 @@ class fe extends ge {
1438
1436
  }
1439
1437
  class Be extends pe {
1440
1438
  }
1441
- class Ge extends fe {
1439
+ class Ge extends we {
1442
1440
  }
1443
1441
  class ze extends pe {
1444
1442
  }
1445
- class Ve extends fe {
1443
+ class Ve extends we {
1446
1444
  }
1447
1445
  window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", Be);
1448
1446
  window.customElements.get("impact-embed") || window.customElements.define("impact-embed", ze);
@@ -1453,7 +1451,7 @@ function Ye() {
1453
1451
  "Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
1454
1452
  );
1455
1453
  }
1456
- const x = C("squatch-js");
1454
+ const $ = C("squatch-js");
1457
1455
  let F = null, H = null, J = null;
1458
1456
  function Ze() {
1459
1457
  return F || G({}), F;
@@ -1478,7 +1476,7 @@ function tt() {
1478
1476
  }
1479
1477
  function G(o) {
1480
1478
  const e = q(o);
1481
- e.tenantAlias.match("^test") || e.debug ? ve("squatch-js*") : _e(), x("initializing ..."), F = new Z(e), H = new N(e), J = new Oe(e), x("Widget API instance", F), x("Widgets instance", H), x("Events API instance", J);
1479
+ e.tenantAlias.match("^test") || e.debug ? ve("squatch-js*") : _e(), $("initializing ..."), F = new Z(e), H = new N(e), J = new Oe(e), $("Widget API instance", F), $("Widgets instance", H), $("Events API instance", J);
1482
1480
  }
1483
1481
  function nt(o) {
1484
1482
  o();
@@ -1487,17 +1485,17 @@ function it(o) {
1487
1485
  K().autofill(o);
1488
1486
  }
1489
1487
  function Xe() {
1490
- Se();
1488
+ Te();
1491
1489
  }
1492
1490
  typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Xe();
1493
1491
  var ae;
1494
- (ae = window.squatch) != null && ae.init && x(
1492
+ (ae = window.squatch) != null && ae.init && $(
1495
1493
  "Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
1496
1494
  );
1497
1495
  typeof document < "u" && Ne();
1498
1496
  export {
1499
1497
  pe as DeclarativeEmbedWidget,
1500
- fe as DeclarativePopupWidget,
1498
+ we as DeclarativePopupWidget,
1501
1499
  D as EmbedWidget,
1502
1500
  j as PopupWidget,
1503
1501
  Z as WidgetApi,