@saasquatch/squatch-js 2.6.0-7 → 2.6.0-9

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +14 -5
  3. package/coverage/clover.xml +582 -566
  4. package/coverage/coverage-final.json +20 -19
  5. package/coverage/lcov.info +964 -930
  6. package/dist/async.d.ts +4 -2
  7. package/dist/globals.d.ts +4 -0
  8. package/dist/squatch.esm.js +59 -49
  9. package/dist/squatch.esm.js.map +1 -1
  10. package/dist/squatch.js +59 -49
  11. package/dist/squatch.js.map +1 -1
  12. package/dist/squatch.min.js +1 -1
  13. package/dist/utils/validate.d.ts +0 -2
  14. package/dist/widgets/PopupWidget.d.ts +2 -2
  15. package/dist/widgets/Widgets.d.ts +8 -8
  16. package/dist/widgets/declarative/DeclarativeWidget.d.ts +10 -5
  17. package/package.json +1 -1
  18. package/coverage/lcov-report/DeclarativeWidget.ts.html +0 -790
  19. package/coverage/lcov-report/WidgetApi.ts.html +0 -631
  20. package/coverage/lcov-report/Widgets.ts.html +0 -1105
  21. package/coverage/lcov-report/api/AnalyticsApi.ts.html +0 -304
  22. package/coverage/lcov-report/api/EventsApi.ts.html +0 -352
  23. package/coverage/lcov-report/api/WidgetApi.ts.html +0 -658
  24. package/coverage/lcov-report/api/graphql.ts.html +0 -130
  25. package/coverage/lcov-report/squatch.ts.html +0 -721
  26. package/coverage/lcov-report/utils/cookieUtils.ts.html +0 -415
  27. package/coverage/lcov-report/utils/decodeUserJwt.ts.html +0 -133
  28. package/coverage/lcov-report/utils/domready.ts.html +0 -160
  29. package/coverage/lcov-report/utils/io.ts.html +0 -400
  30. package/coverage/lcov-report/utils/utmUtils.ts.html +0 -277
  31. package/coverage/lcov-report/utils/validate.ts.html +0 -268
  32. package/coverage/lcov-report/validate.ts.html +0 -268
  33. package/coverage/lcov-report/widgets/EmbedWidget.ts.html +0 -481
  34. package/coverage/lcov-report/widgets/PopupWidget.ts.html +0 -685
  35. package/coverage/lcov-report/widgets/Widget.ts.html +0 -1159
  36. package/coverage/lcov-report/widgets/Widgets.ts.html +0 -1102
  37. package/coverage/lcov-report/widgets/declarative/DeclarativeWidget.ts.html +0 -790
  38. package/coverage/lcov-report/widgets/declarative/DeclarativeWidgets.ts.html +0 -388
  39. package/dist/squatch.min.js.map +0 -1
  40. package/dist/squatch.modern.js +0 -2
  41. package/dist/squatch.modern.js.map +0 -1
  42. package/dist/stats.html +0 -208
  43. package/dist/utils/domUtils.d.ts +0 -1
  44. package/dist/utils/loadEvent.d.ts +0 -2
  45. package/dist/widgets/CtaWidget.d.ts +0 -24
  46. package/dist/widgets/IREmbedWidget.d.ts +0 -29
  47. package/dist/widgets/IRPopupWidget.d.ts +0 -32
  48. package/dist/widgets/declarative/DeclarativeEmbedWidget.d.ts +0 -12
  49. package/stats.json +0 -1
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see squatch.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.squatch=t():e.squatch=t()}(self,(function(){return function(){var e={264:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(615),o=n(787);class i{constructor(e){var t,n=function(e){if(!(0,o.Kn)(e))throw new Error("'options' should be an object");return e}(e);this.domain=(null==n?void 0:n.domain)||(null===(t=(0,o.iE)())||void 0===t?void 0:t.domain)||o.cE}pushAnalyticsLoadEvent(e){if(e.externalUserId&&e.externalAccountId){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),o=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=e.programId?"&programId=".concat(encodeURIComponent(e.programId)):"",s="/a/".concat(t,"/widgets/analytics/loaded?externalAccountId=").concat(n,"&externalUserId=").concat(o,"&engagementMedium=").concat(i).concat(a),c=this.domain+s;return(0,r.Mx)(c,JSON.stringify({}))}}pushAnalyticsShareClickedEvent(e){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),o=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=encodeURIComponent(e.shareMedium),s="/a/".concat(t,"/widgets/analytics/shared?externalAccountId=").concat(n,"&externalUserId=").concat(o,"&engagementMedium=").concat(i,"&shareMedium=").concat(a),c=this.domain+s;return(0,r.Mx)(c,JSON.stringify({}))}}},745:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(615),o=n(787);class i{constructor(e){var t=e,n=(0,o.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain}track(e,t){var n=t,i=function(e){if(!(0,o.Kn)(e))throw new Error("tracking parameter must be an object");if(null==e||!e.accountId)throw new Error("accountId field is required");if(null==e||!e.events)throw new Error("events field is required");if(null==e||!e.userId)throw new Error("userId field is required");var t=e;if(!Array.isArray(t.events))throw new Error("'events' should be an array");return t}(e),{jwt:a}=function(e){if(!(0,o.Kn)(e))throw new Error("'options' should be an object");return e}(n),s=encodeURIComponent(this.tenantAlias),c=encodeURIComponent(i.userId),d=encodeURIComponent(i.accountId),u="/api/v1/".concat(s,"/open/account/").concat(d,"/user/").concat(c,"/events"),l=this.domain+u;return(0,r.Mx)(l,JSON.stringify(i),a)}}},139:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(572),o=n(861),i=n(955),a=n(615),s=n(787);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class u{constructor(e){var t=e,n=(0,s.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain,this.npmCdn=n.npmCdn}upsertUser(e){var t=e,n=(0,s.xW)(t),{widgetType:r,engagementMedium:o="POPUP",jwt:c,locale:d,user:u}=n,l=encodeURIComponent(this.tenantAlias),p=u.accountId?encodeURIComponent(u.accountId):null,h=u.id?encodeURIComponent(u.id):null,f=function(e){var{widgetType:t,engagementMedium:n,locale:r}=e,o=["engagementMedium=".concat(encodeURIComponent(n)),t&&"widgetType=".concat(encodeURIComponent(t)),r&&"locale=".concat(encodeURIComponent(r))].filter((e=>!!e));return"?".concat(o.join("&"))}({widgetType:r,engagementMedium:o,locale:d}),g="/api/v1/".concat(l,"/widget/account/").concat(p,"/user/").concat(h,"/upsert").concat(f),m=this.domain+g,w=(i.Z||window.Cookies).get("_saasquatch");return w&&(u.cookies=w),(0,a.iR)(m,JSON.stringify(u),c)}render(e){var t,n=e,r=(0,s.ZL)(n),{widgetType:i,engagementMedium:c="POPUP",jwt:d,user:u}=r,l=encodeURIComponent(this.tenantAlias),p=null!=u&&u.accountId?encodeURIComponent(u.accountId):null,h=null!=u&&u.id?encodeURIComponent(u.id):null,f=null!==(t=r.locale)&&void 0!==t?t:(0,s.Qb)(navigator.language.replace(/\-/g,"_")),g="/api/v1/".concat(l,"/graphql"),m=this.domain+g;return new Promise(function(){var e=(0,o.Z)((function*(e,t){try{var n,r=yield(0,a.Rf)(m,"\n query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {\n renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {\n template\n user {\n id\n accountId\n }\n jsOptions\n widgetConfig {\n values\n }\n }\n }\n",{user:h&&p?{id:h,accountId:p}:null,engagementMedium:c,widgetType:i,locale:f},d);e(null==r||null===(n=r.data)||void 0===n?void 0:n.renderWidget)}catch(e){t(e)}}));return function(t,n){return e.apply(this,arguments)}}())}squatchReferralCookie(){var e=this;return(0,o.Z)((function*(){var t=encodeURIComponent(e.tenantAlias),n=(i.Z||window.Cookies).get("_saasquatch")||"",r=n?"?cookies=".concat(encodeURIComponent(n)):"",o="".concat(e.domain,"/a/").concat(t,"/widgets/squatchcookiejson").concat(r),s=yield(0,a.gc)(o);return Promise.resolve(d(d({},s),{},{encodedCookie:n}))}))()}}},762:function(e,t,n){"use strict";function r(){var e="impactTBD",t=window[e]?e:"squatch";console.log({namespace:t});var n=window[t]||null,r=window["_"+t]||null;if(n&&r){var o=r.ready||[];setTimeout((()=>window.impactTBD=window.squatch),0),o.forEach((e=>setTimeout((()=>e()),0))),setTimeout((()=>{window.squatch._auto()}),0),window["_"+t]=void 0;try{delete window["_"+t]}catch(e){throw e}}}n.d(t,{Z:function(){return r}})},510:function(e,t,n){"use strict";function r(){console.log("Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes.")}n.d(t,{R:function(){return r}})},518:function(){},998:function(e,t,n){"use strict";n.d(t,{F:function(){return l},b:function(){return h}});var r=n(572),o=n(227),i=n(955);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var c=(0,o.debug)("squatch-js"),d=e=>"object"==typeof e&&!Array.isArray(e),u=(e,t)=>{var n=n=>d(t[n])&&e.hasOwnProperty(n)&&d(e[n]),r=Object.getOwnPropertyNames(t).map((r=>({[r]:n(r)?u(e[r],t[r]):t[r]}))).reduce(((e,t)=>s(s({},e),t)),{});return s(s({},e),r)};function l(e){return atob(e.replace(/_/g,"/").replace(/-/g,"+"))}function p(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function h(){var e=window.location.search,t=new URLSearchParams(e).get("_saasquatch")||"";if(t){var n="",r="",o="";try{n=JSON.parse(l(t))}catch(e){return void c("Unable to decode params",e)}try{r=JSON.parse(l(i.Z.get("_saasquatch"))),c("existing cookie",r)}catch(e){c("Unable to retrieve cookie",e)}try{var a=function(){var e,t,n="weird_get_top_level_domain=cookie",r=document.location.hostname.split(".");for(e=r.length-1;e>=0;e--)if(t=r.slice(e).join("."),document.cookie=n+";domain=."+t+";",document.cookie.indexOf(n)>-1)return document.cookie=n.split("=")[0]+"=;domain=."+t+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",t}();if(c("domain retrieved:",a),r){var s=u(r,n);o=p(JSON.stringify(s)),c("cookie to store:",s)}else o=p(JSON.stringify(n)),c("cookie to store:",n);i.Z.set("_saasquatch",o,{expires:365,secure:!1,sameSite:"Lax",domain:a,path:"/"})}catch(e){c("Unable to set cookie",e)}}}},936:function(e,t,n){"use strict";function r(e,t){var n,r=[],o=e,i=o.documentElement.doScroll,a="DOMContentLoaded",s=(i?/^loaded|^c/:/^loaded|^i|^c/).test(o.readyState);return s||o.addEventListener(a,n=()=>{for(o.removeEventListener(a,n),s=!0;n=r.shift();)n()}),s?setTimeout(t,0):r.push(t)}n.d(t,{V:function(){return r}})},615:function(e,t,n){"use strict";n.d(t,{Mx:function(){return h},Rf:function(){return d},gc:function(){return l},iR:function(){return g}});var r=n(572),o=n(861),i=n(227),a=n(787);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function d(e,t,n,r){return u.apply(this,arguments)}function u(){return(u=(0,o.Z)((function*(e,t,n,r){var o=r||(0,a.LP)(),i=c(c({Accept:"application/json","Content-Type":"application/json"},o?{Authorization:"Bearer ".concat(o)}:{}),{},{"X-SaaSquatch-Referrer":window?window.location.href:""});try{var s=yield fetch(e,{method:"POST",body:JSON.stringify({query:t,variables:n}),headers:i});if(!s.ok)throw new Error(yield s.text());return yield s.json()}catch(e){throw e}}))).apply(this,arguments)}function l(e){return p.apply(this,arguments)}function p(){return p=(0,o.Z)((function*(e){var t={Accept:"application/json","Content-Type":"application/json"},n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||(0,a.LP)();n&&(t["X-SaaSquatch-User-Token"]=n);try{var r=yield fetch(e,{method:"GET",credentials:"include",headers:t}),o=yield r.text();if(!r.ok)throw new Error(o);return o?JSON.parse(o):o}catch(e){throw e}})),p.apply(this,arguments)}function h(e,t,n){return f.apply(this,arguments)}function f(){return(f=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json"},o=n||(0,a.LP)();o&&(r["X-SaaSquatch-User-Token"]=o);try{var i=yield fetch(e,{method:"POST",body:t,headers:r}),s=yield i.text();if(!i.ok)throw new Error(s);return s?JSON.parse(s):s}catch(e){throw e}}))).apply(this,arguments)}function g(e,t,n){return m.apply(this,arguments)}function m(){return(m=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json","X-SaaSquatch-Referrer":window?window.location.href:""},o=n||(0,a.LP)();o&&(r["X-SaaSquatch-User-Token"]=o);try{var i=yield fetch(e,{headers:r,method:"PUT",credentials:"include",body:t}),s=yield i.text();if(!i.ok)throw new Error(s);return s?JSON.parse(s):s}catch(e){throw e}}))).apply(this,arguments)}(0,i.debug)("squatch-js:io")},8:function(e,t,n){"use strict";n.d(t,{G:function(){return u}});var r=n(572);function o(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=n(227),a=n(998);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var d=(0,i.debug)("squatch-js");function u(e){var t=window.location.search,n=new URLSearchParams(t).get("_saasquatchExtra")||"";if(n){var r;try{r=JSON.parse((0,a.F)(n))}catch(e){return void d("Unable to decode _saasquatchExtra config")}var{domain:i,tenantAlias:s,widgetConfig:u}=function(e){var t,n=Object.keys(e||{})[0],r=Object.keys((null==e?void 0:e[n])||{})[0],o=null==e||null===(t=e[n])||void 0===t?void 0:t[r];return{domain:n?"https://".concat(n):void 0,tenantAlias:r,widgetConfig:o}}(r);if(i&&s&&u){var{autoPopupWidgetType:l}=u;return{widgetConfig:c({widgetType:l,displayOnLoad:!0},o(u,["autoPopupWidgetType"])),squatchConfig:c(c({},e?{configIn:e}:{}),{},{domain:i,tenantAlias:s})}}d("_saasquatchExtra did not have an expected structure")}else d("No _saasquatchExtra param")}},787:function(e,t,n){"use strict";n.d(t,{Kn:function(){return a},LP:function(){return u},Qb:function(){return s},ZL:function(){return d},cE:function(){return r},eu:function(){return o},iE:function(){return l},ww:function(){return i},xW:function(){return c}});var r="https://app.referralsaasquatch.com",o="https://fast.ssqt.io/npm";function i(e){if("object"!=typeof e)throw new Error("config must be an object");var t=window.squatchTenant,n=l(),i={tenantAlias:(null==e?void 0:e.tenantAlias)||t,domain:(null==e?void 0:e.domain)||(null==n?void 0:n.domain),npmCdn:(null==e?void 0:e.npmCdn)||(null==n?void 0:n.npmCdn),debug:(null==e?void 0:e.debug)||(null==n?void 0:n.debug)};if("string"!=typeof i.tenantAlias)throw new Error("tenantAlias not provided");return{tenantAlias:i.tenantAlias,domain:"string"==typeof i.domain&&i.domain||r,debug:"boolean"==typeof i.debug&&i.debug||!1,npmCdn:"string"==typeof i.npmCdn&&i.npmCdn||o}}function a(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function s(e){if(e&&/^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(e))return e}function c(e){if(!a(e))throw new Error("Widget properties must be an object");if(null==e||!e.user)throw new Error("Required properties missing.");return e}function d(e){if(!a(e))throw new Error("Widget properties must be an object");return e}function u(){return window.impactTBDToken||window.squatchToken}function l(){return window.impactTBDConfig||window.squatchConfig}},75:function(e,t,n){"use strict";n.d(t,{Z:function(){return d}});var r=n(861),o=n(572),i=n(227),a=n(657),s=n(936),c=(0,i.debug)("squatch-js:EMBEDwidget");class d extends a.Z{constructor(e,t){super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),t&&(this.container=t)}load(){var e=this;return(0,r.Z)((function*(){var t,n=e._createFrame(),o=e._findElement();e.container?o.shadowRoot?"IFRAME"===(null===(t=o.shadowRoot.lastChild)||void 0===t?void 0:t.nodeName)?o.shadowRoot.replaceChild(n,o.shadowRoot.lastChild):o.shadowRoot.appendChild(n):o.firstChild?o.replaceChild(n,o.firstChild):o.appendChild(n):o.firstChild&&"#text"!==o.firstChild.nodeName||o.appendChild(n);var{contentWindow:i}=n;if(!i)throw new Error("Frame needs a content window");var a=i.document;a.open(),a.write(e.content),a.write('<script src="'.concat(e.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),a.close(),(0,s.V)(a,(0,r.Z)((function*(){var t=i.squatch||i.widgetIdent;n.height=a.body.scrollHeight;var r=new i.ResizeObserver((e=>{for(var t of e){var{height:r}=t.contentRect;n.height=r}})),o=yield e._findInnerContainer(n);r.observe(o),e._shouldFireLoadEvent()&&(e._loadEvent(t),c("loaded"))})))}))()}open(){var e,t,n,r=this._findFrame();if(!r)return c("no target element to open");var o=this._findElement();o.style.visibility="unset",o.style.height="auto",o.style["overflow-y"]="auto",null==r||null===(e=r.contentDocument)||void 0===e||e.dispatchEvent(new CustomEvent("sq:refresh"));var i=(null==r||null===(t=r.contentWindow)||void 0===t?void 0:t.squatch)||(null==r||null===(n=r.contentWindow)||void 0===n?void 0:n.widgetIdent);this.context.user&&(this._loadEvent(i),c("loaded"))}close(){if(!this._findFrame())return c("no target element to close");var e=this._findElement();e.style.visibility="hidden",e.style.height="0",e.style["overflow-y"]="hidden",c("Embed widget closed")}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"embed",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n)}_shouldFireLoadEvent(){var e=!this.container,t=this.container instanceof HTMLElement&&this.container.tagName.startsWith("SQUATCH-");return!!this.context.user&&(e||t)}}},658:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(572),i=n(227),a=n(936),s=n(657),c=(0,i.debug)("squatch-js:POPUPwidget"),d=0;class u extends s.Z{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".squatchpop";super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.trigger=t,this.container?this.id="squatchModal":(this.id=0===d?"squatchModal":"squatchModal__".concat(d),d+=1),document.head.insertAdjacentHTML("beforeend","<style>#".concat(this.id,"::-webkit-scrollbar { display: none; }</style>"))}_initialiseCTA(){if(this.trigger){var e;try{e=document.querySelector(this.trigger),this.trigger&&!e&&c("No element found with trigger selector",this.trigger)}catch(e){c("Not a valid selector",this.trigger)}e&&(e.onclick=()=>{this.open()})}}_createPopupDialog(){var e=document.createElement("dialog");return e.id=this.id,e.setAttribute("style","width: 100%; max-width: 500px; border: none; padding: 0;"),e.addEventListener("click",(t=>{t.stopPropagation(),t.target===e&&e.close()})),e}load(){var e,t=this._createFrame();this._initialiseCTA();var n=this.container?this._findElement():document.body,r=n.shadowRoot||n,o=this._createPopupDialog();o.appendChild(t),"DIALOG"===(null===(e=r.lastChild)||void 0===e?void 0:e.nodeName)?r.replaceChild(o,r.lastChild):r.appendChild(o);var{contentWindow:i}=t;if(!i)throw new Error("Frame needs a content window");var a=i.document;a.open(),a.write(this.content),a.write('<script src="'.concat(this.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),a.close(),c("Popup template loaded into iframe"),this._setupResizeHandler(t)}_setupResizeHandler(e){var t=this,{contentWindow:n}=e;if(!n)throw new Error("Frame needs a content window");var o=n.document;(0,a.V)(o,(0,r.Z)((function*(){o.body.style.overflowY="hidden",e.height="".concat(o.body.offsetHeight,"px"),new n.ResizeObserver((t=>{for(var n of t){var{top:r,bottom:o}=n.contentRect,i=o+r;e.height=i+"",n.target.style=""}})).observe(yield t._findInnerContainer(e))})))}open(){var e=this.container?this._findElement():document.body,t=(e.shadowRoot||e).querySelector("#".concat(this.id));if(!t)throw new Error("Could not determine container div");t.showModal();var n=this._findFrame();if(!n)throw new Error("Could not find iframe");var{contentWindow:r}=n;if(!r)throw new Error("Squatch.js has an empty iframe");var o=r.document;(0,a.V)(o,(()=>{var e,t=r.squatch||r.widgetIdent;null===(e=n.contentDocument)||void 0===e||e.dispatchEvent(new CustomEvent("sq:refresh")),this.context.user&&(this._loadEvent(t),c("Popup opened"))}))}close(){var e=this.container?this._findElement():document.body,t=(e.shadowRoot||e).querySelector("#".concat(this.id));if(!t)throw new Error("Could not determine container div");t.close(),c("Popup closed")}_clickedOutside(e){var{target:t}=e}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n||"body { margin: 0; } .modal { box-shadow: none; border: 0; }")}}},657:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(861),o=n(227),i=n(264),a=n(787),s=(0,o.debug)("squatch-js:widget");class c{constructor(e){s("widget initializing ..."),this.content="error"===e.content?this._error(e.rsCode):e.content,this.type=e.type,this.widgetApi=e.api,this.npmCdn=e.npmCdn,this.analyticsApi=new i.Z({domain:e.domain}),this.context=e.context,this.container=e.context.container}_findElement(){var e;if("string"==typeof this.container?(e=document.querySelector(this.container),s("loading widget with selector",e)):this.container instanceof HTMLElement?(e=this.container,s("loading widget with container",e)):this.container?(e=null,s("container must be an HTMLElement or string",this.container)):(e=document.querySelector("#squatchembed")||document.querySelector(".squatchembed"),s("loading widget with default selector",e)),!(e instanceof HTMLElement))throw new Error("element with selector '".concat(this.container||"#squatchembed or .squatchembed","' not found.'"));return e}_createFrame(){var e=document.createElement("iframe");return e.squatchJsApi=this,e.id="squatchFrame",e.width="100%",e.src="about:blank",e.scrolling="no",e.setAttribute("style","border: 0; background-color: none; width: 1px; min-width: 100%;"),e}_findFrame(){var e=this.container?this._findElement():document.body;return(e.shadowRoot||e).querySelector("iframe#squatchFrame")}_loadEvent(e){var t;if(e){if(!(0,a.Kn)(e))throw new Error("Widget Load event identity property is not an object");var n;if("programId"in e){if(!(e.tenantAlias&&e.accountId&&e.userId&&e.engagementMedium))throw new Error("Widget Load event missing required properties");n={tenantAlias:e.tenantAlias,externalAccountId:e.accountId,externalUserId:e.userId,engagementMedium:e.engagementMedium,programId:e.programId}}else{var{analytics:r,mode:o}=e;n={tenantAlias:r.attributes.tenant,externalAccountId:r.attributes.accountId,externalUserId:r.attributes.userId,engagementMedium:o.widgetMode}}null===(t=this.analyticsApi.pushAnalyticsLoadEvent(n))||void 0===t||t.then((e=>{s("".concat(n.engagementMedium," loaded event recorded."))})).catch((e=>{s("ERROR: pushAnalyticsLoadEvent() ".concat(e))}))}}_shareEvent(e,t){e&&this.analyticsApi.pushAnalyticsShareClickedEvent({tenantAlias:e.analytics.attributes.tenant,externalAccountId:e.analytics.attributes.accountId,externalUserId:e.analytics.attributes.userId,engagementMedium:e.mode.widgetMode,shareMedium:t}).then((n=>{s("".concat(e.mode.widgetMode," share ").concat(t," event recorded. ").concat(n))})).catch((e=>{s("ERROR: pushAnalyticsShareClickedEvent() ".concat(e))}))}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal";return'<!DOCTYPE html>\n \x3c!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if gt IE 8]>\x3c!--\x3e<html lang="en">\x3c!--<![endif]--\x3e\n <head>\n <link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">\n <style>\n '.concat(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",'\n </style>\n </head>\n <body>\n\n <div class="squatch-container ').concat(t,'" style="width:100%">\n <div class="errorheader">\n <button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">&times;</button>\n <p class="errortitle">Error</p>\n </div>\n <div class="errorbody">\n <div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>\n <h4>Our referral program is temporarily unavailable.</h4><br>\n <p>Please reload the page or check back later.</p>\n <p>If the persists please contact our support team.</p>\n <br>\n <br>\n <div class="right-align errtxt">\n Error Code: ').concat(e,"\n </div>\n </div>\n </div>\n </body>\n </html>")}_findInnerContainer(e){return(0,r.Z)((function*(){var{contentWindow:t}=e;if(!t)throw new Error("Squatch.js frame inner frame is empty");for(var n,r,o=t.document,i=null,a=0;a<5&&(void 0,void 0,n=o.getElementsByTagName("sqh-global-container"),r=o.getElementsByClassName("squatch-container"),!(i=n.length>0?n[0]:r.length>0?r[0]:null));a++)yield d(100);return i||o.body}))()}reload(e,t){var{email:n,firstName:r,lastName:o}=e,i=this._findFrame();if(!i)throw new Error("Could not find widget iframe");var a,c=i.contentWindow,d=this.context.engagementMedium||"POPUP";if(!c)throw new Error("Frame needs a content window");if("upsert"===this.context.type){if(!this.context.user)throw new Error("Can't reload without user ids");var u={email:n||null,firstName:r||null,lastName:o||null,id:this.context.user.id,accountId:this.context.user.accountId};a=this.widgetApi.upsertUser({user:u,engagementMedium:d,widgetType:this.type,jwt:t})}else{if("passwordless"!==this.context.type)throw new Error("can't reload an error widget");a=this.widgetApi.render({user:void 0,engagementMedium:d,widgetType:this.type,jwt:void 0})}a.then((e=>{var{template:t}=e;t&&(this.content=t,this.__deprecated__register(i,{email:n,engagementMedium:d},(()=>{this.load(),"POPUP"===d&&this.open()})))})).catch((e=>{var{message:t}=e;s("".concat(t))}))}__deprecated__register(e,t,n){var r=e.contentWindow.document,o=r.createElement("button"),i=r.getElementsByClassName("squatch-register")[0];if(i){o.className="btn btn-primary",o.id="show-stats-btn",o.textContent="REFERRER_WIDGET"===this.type?"Show Stats":"Show Reward";var a="POPUP"===t.engagementMedium?"margin-top: 10px; max-width: 130px; width: 100%;":"margin-top: 10px;";o.setAttribute("style",a),o.onclick=n,i.style.paddingTop="30px",i.innerHTML="<p><strong>".concat(t.email,"</strong><br>Has been successfully registered</p>"),i.appendChild(o)}}}function d(e){return new Promise((t=>{setTimeout(t,e)}))}},452:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(227),i=n(139),a=n(787),s=n(75),c=n(658),d=(0,o.debug)("squatch-js:widgets");class u{constructor(e){var t=(0,a.ww)(e);this.tenantAlias=t.tenantAlias,this.domain=t.domain,this.npmCdn=t.npmCdn,this.api=new i.Z(t)}upsertUser(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.xW)(n);try{var o=yield t.api.upsertUser(r);return{widget:t._renderWidget(o,r,{type:"upsert",user:r.user,engagementMedium:e.engagementMedium,container:e.container,trigger:e.trigger}),user:o.user}}catch(n){throw d(n),n.apiErrorCode&&t._renderErrorWidget(n,e.engagementMedium),new Error(n)}}))()}render(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.ZL)(n);try{var o=yield t.api.render(r);return{widget:t._renderWidget(o,r,{type:"passwordless",engagementMedium:r.engagementMedium,container:r.container,trigger:r.trigger}),user:o.user}}catch(e){throw e.apiErrorCode&&t._renderErrorWidget(e,r.engagementMedium),new Error(e)}}))()}autofill(e){var t=this;return(0,r.Z)((function*(){var n=e;if("function"!=typeof n){if("string"!=typeof n)throw new Error("Autofill accepts a string or function");var r,o=document.querySelectorAll(n);if(!(o.length>0))throw d("Element id/class or function missing"),new Error("Element id/class or function missing");r=o[0];try{var i=yield t.api.squatchReferralCookie();r.value=i.codes[0]}catch(e){throw new Error(e)}}else try{n(yield t.api.squatchReferralCookie())}catch(e){throw d("Autofill error",e),new Error(e)}}))()}_renderWidget(e,t,n){var r,o;if(d("Rendering Widget..."),!e)throw new Error("Unable to get a response");var i=!!t.displayOnLoad,a=e.jsOptions||{},s={content:e.template,type:t.widgetType||(null===(r=a.widget)||void 0===r?void 0:r.defaultWidgetType),api:this.api,domain:this.domain,npmCdn:this.npmCdn,context:n};return a.widgetUrlMappings&&a.widgetUrlMappings.forEach((t=>{var n,r;u._matchesUrl(t.url)&&("CONVERSION_WIDGET"!==t.widgetType||null!==(n=e.user)&&void 0!==n&&null!==(r=n.referredBy)&&void 0!==r&&r.code?(i=t.displayOnLoad,d("Display ".concat(t.widgetType," on ").concat(t.url))):d("Don't display ".concat(t.widgetType," when no referral on widget rule match ").concat(t.url)))})),a.fuelTankAutofillUrls&&(d("We found a fuel tank autofill!"),a.fuelTankAutofillUrls.forEach((t=>{var n,r,{url:o,formSelector:i}=t;if(u._matchesUrl(o)&&(d("Fuel Tank URL matches"),null!==(n=e.user)&&void 0!==n&&null!==(r=n.referredBy)&&void 0!==r&&r.code)){var a,s=document.querySelector(i);s?s.value=(null===(a=e.user.referredBy.referredReward)||void 0===a?void 0:a.fuelTankCode)||"":d(new Error("Element with id/class ".concat(i," was not found.")))}}))),"EMBED"===t.engagementMedium?o=this._renderEmbedWidget(s):(o=this._renderPopupWidget(s),i&&o.open()),o}_renderPopupWidget(e){var t=new c.Z(e,e.context.trigger);return t.load(),t}_renderEmbedWidget(e){var t=new s.Z(e,e.context.container);return t.load(),t}_renderErrorWidget(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"POPUP",{apiErrorCode:n,rsCode:r,message:o}=e;d(new Error("".concat(n," (").concat(r,") ").concat(o)));var i={content:"error",rsCode:r,api:this.api,domain:this.domain,npmCdn:this.npmCdn,type:"ERROR_WIDGET",context:{type:"error"}};"EMBED"===t?new s.Z(i).load():"POPUP"===t&&new c.Z(i).load()}static _matchesUrl(e){return!!window.location.href.match(new RegExp(e))}}},22:function(e,t,n){"use strict";n.d(t,{U:function(){return m},n:function(){return w}});var r=n(861),o=n(572),i=n(227),a=n.n(i),s=n(264),c=n(139),d=n(998),u=(0,i.debug)("squatch-js:decodeJwt"),l=n(787),p=n(75),h=n(658),f=a()("squatch-js:DeclarativeWidget");class g extends HTMLElement{constructor(){super(),(0,o.Z)(this,"_setWidget",((e,t)=>{var n,r={api:this.widgetApi,content:e,context:{type:t.type,user:t.user,container:this.container||this,engagementMedium:this.type},type:this.widgetType,domain:(null===(n=this.config)||void 0===n?void 0:n.domain)||l.cE,npmCdn:l.eu};return"EMBED"===this.type?new p.Z(r,r.context.container):new h.Z(r,this.firstChild?null:void 0)})),(0,o.Z)(this,"setErrorWidget",(e=>{var t,n={api:this.widgetApi,content:"error",context:{type:"error",container:this.container||this},type:"ERROR_WIDGET",domain:(null===(t=this.config)||void 0===t?void 0:t.domain)||l.cE,npmCdn:l.eu};return"EMBED"===this.type?new p.Z(n,n.context.container):new h.Z(n,this.firstChild?null:void 0)})),(0,o.Z)(this,"reload",this.renderWidget),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.attachShadow({mode:"open"}).innerHTML="<style>:host { display: contents; }</style><slot></slot>",this.config=(0,l.iE)(),this.token=(0,l.LP)(),this.tenant=window.squatchTenant,this.container=this}_setupApis(e){var t,n;if(!this.tenant)throw new Error("tenantAlias not provided");this.widgetApi=new c.Z({tenantAlias:(null==e?void 0:e.tenantAlias)||this.tenant,domain:(null==e?void 0:e.domain)||(null===(t=this.config)||void 0===t?void 0:t.domain)||l.cE}),this.analyticsApi=new s.Z({domain:(null==e?void 0:e.domain)||(null===(n=this.config)||void 0===n?void 0:n.domain)||l.cE})}renderPasswordlessVariant(){var e=this;return(0,r.Z)((function*(){return e._setupApis(),f("Rendering as an Instant Access widget"),yield e.widgetApi.render({engagementMedium:e.type,widgetType:e.widgetType,locale:e.locale}).then((t=>e._setWidget(t.template,{type:"passwordless"}))).catch(e.setErrorWidget)}))()}renderUserUpsertVariant(){var e=this;return(0,r.Z)((function*(){e._setupApis();var t=function(e){try{var t,n=e.split(".")[1];if(void 0===n)return null;var r=(0,d.F)(n);return null===(t=JSON.parse(r))||void 0===t?void 0:t.user}catch(e){return u(e),null}}(e.token);return t?(f("Rendering as a Verified widget"),yield e.widgetApi.upsertUser({user:t,locale:e.locale,engagementMedium:e.type,widgetType:e.widgetType,jwt:e.token}).then((n=>e._setWidget(n.template,{type:"upsert",user:t}))).catch(e.setErrorWidget)):e.setErrorWidget(Error("No user object in token."))}))()}getWidgetInstance(){var e=this;return(0,r.Z)((function*(){var t;if(e.widgetType=e.getAttribute("widget")||void 0,e.locale=e.getAttribute("locale")||e.locale,!e.widgetType)throw new Error("No widget has been specified");return t=e.token?yield e.renderUserUpsertVariant():yield e.renderPasswordlessVariant(),e.widgetInstance=t,t}))()}renderWidget(){var e=this;return(0,r.Z)((function*(){yield e.getWidgetInstance(),yield e.widgetInstance.load()}))()}open(){if(!this.widgetInstance)throw new Error("Widget has not loaded yet");this.widgetInstance.open()}close(){if(!this.widgetInstance)throw new Error("Widget has not loaded yet");this.widgetInstance.close()}}class m extends g{constructor(){super(),this.type="EMBED"}static get observedAttributes(){return["widget","locale"]}attributeChangedCallback(e,t,n){if(t!==n&&t)switch(e){case"locale":case"widget":this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){var t,n;e.container=e.getAttribute("container")||e,yield e.renderWidget();var r=null===(t=e.shadowRoot&&Array.from(e.shadowRoot.children))||void 0===t?void 0:t.find((e=>"SLOT"===e.tagName));r&&(null===(n=e.shadowRoot)||void 0===n||n.removeChild(r))}))()}}class w extends g{constructor(){super(),this.type="POPUP",this.addEventListener("click",(e=>{e.stopPropagation(),this.open()}))}static get observedAttributes(){return["widget","locale"]}attributeChangedCallback(e,t,n){if(t!==n&&t)switch(e){case"locale":case"widget":this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){e.container=e.getAttribute("container")||e,yield e.renderWidget(),null!==e.getAttribute("open")&&e.open()}))()}}window.customElements.define("squatch-embed",class extends m{}),window.customElements.define("impact-embed",class extends m{}),window.customElements.define("squatch-popup",class extends w{}),window.customElements.define("impact-popup",class extends w{})},227:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":r(console))&&console.log&&(e=console).log.apply(e,arguments)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)}},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.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"],e.exports=n(447)(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:function(e,t,n){"use strict";e.exports=function(e){function t(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){var n;function a(){if(a.enabled){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];var i=a,s=Number(new Date),c=s-(n||s);i.diff=c,i.prev=n,i.curr=s,n=s,t[0]=r.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var d=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(e,n){if("%%"===e)return e;d++;var o=r.formatters[n];if("function"==typeof o){var a=t[d];e=o.call(i,a),t.splice(d,1),d--}return e})),r.formatArgs.call(i,t),(i.log||r.log).apply(i,t)}}return a.namespace=e,a.enabled=r.enabled(e),a.useColors=r.useColors(),a.color=t(e),a.destroy=o,a.extend=i,"function"==typeof r.init&&r.init(a),r.instances.push(a),a}function o(){var e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function i(e,t){return r(this.namespace+(void 0===t?":":t)+e)}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){r.enable("")},r.enable=function(e){var t;r.save(e),r.names=[],r.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){var i=r.instances[t];i.enabled=r.enabled(i.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=n(824),Object.keys(e).forEach((function(t){r[t]=e[t]})),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=t,r.enable(r.load()),r}},824:function(e){var t=1e3,n=60*t,r=60*n,o=24*r;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,a){a=a||{};var s,c,d=typeof e;if("string"===d&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===d&&isFinite(e))return a.long?(s=e,(c=Math.abs(s))>=o?i(s,c,o,"day"):c>=r?i(s,c,r,"hour"):c>=n?i(s,c,n,"minute"):c>=t?i(s,c,t,"second"):s+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},861:function(e,t,n){"use strict";function r(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function s(e){r(a,o,i,s,c,"next",e)}function c(e){r(a,o,i,s,c,"throw",e)}s(void 0)}))}}n.d(t,{Z:function(){return o}})},572:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===r(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:function(){return o}})},955:function(e,t,n){"use strict";function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}n.d(t,{Z:function(){return o}});var o=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=r({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var s in i)i[s]&&(a+="; "+s,!0!==i[s]&&(a+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+a}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(r[s]=t.read(a,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){o(e,"",r({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,r({},this.attributes,t))},withConverter:function(t){return e(r({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";n.r(r),n.d(r,{DeclarativeEmbedWidget:function(){return p.U},DeclarativePopupWidget:function(){return p.n},EmbedWidget:function(){return o.Z},PopupWidget:function(){return i.Z},WidgetApi:function(){return a.Z},Widgets:function(){return t.Z},_auto:function(){return A},api:function(){return C},autofill:function(){return P},events:function(){return O},help:function(){return m.R},init:function(){return j},pushCookie:function(){return _},ready:function(){return I},widget:function(){return x},widgets:function(){return E}});var e=n(227),t=n(452),o=n(75),i=n(658),a=n(139),s=n(745),c=n(762),d=n(787),u=n(998),l=n(8),p=n(22),h=n(518),f={};for(var g in h)["default","Widgets","EmbedWidget","PopupWidget","DeclarativeEmbedWidget","DeclarativePopupWidget","WidgetApi","api","widgets","events","widget","_auto","init","ready","autofill","pushCookie"].indexOf(g)<0&&(f[g]=function(e){return h[e]}.bind(0,g));n.d(r,f);var m=n(510),w=(0,e.debug)("squatch-js"),v=null,y=null,b=null;function C(){return v||j({}),v}function E(){return y||j({}),y}function O(){return b||j({}),b}function x(e){var t;return null===(t=E())||void 0===t?void 0:t.render(e)}function A(e){var t=(0,l.G)(e);if(t){var n,{squatchConfig:r,widgetConfig:o}=t;return j(r),null===(n=E())||void 0===n?void 0:n.render(o)}}function j(n){var r=n,o=(0,d.ww)(r);o.tenantAlias.match("^test")||o.debug?e.debug.enable("squatch-js*"):e.debug.disable(),w("initializing ..."),v=new a.Z(o),y=new t.Z(o),b=new s.Z(o),w("Widget API instance",v),w("Widgets instance",y),w("Events API instance",b)}function I(e){e()}function P(e){E().autofill(e)}function _(){(0,u.b)()}"undefined"==typeof document||window.SaaSquatchDoNotAutoDrop||_(),"undefined"!=typeof document&&(0,c.Z)()}(),r}()}));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.squatch=t():e.squatch=t()}(self,(function(){return function(){var e={264:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(822),o=n(615),i=n(787);class a{constructor(e){var t,n=function(e){if(!(0,i.Kn)(e))throw new Error("'options' should be an object");return e}(e);this.domain=(null==n?void 0:n.domain)||(null===(t=(0,i.iE)())||void 0===t?void 0:t.domain)||r.cE}pushAnalyticsLoadEvent(e){if(e.externalUserId&&e.externalAccountId){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),r=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=e.programId?"&programId=".concat(encodeURIComponent(e.programId)):"",s="/a/".concat(t,"/widgets/analytics/loaded?externalAccountId=").concat(n,"&externalUserId=").concat(r,"&engagementMedium=").concat(i).concat(a),c=this.domain+s;return(0,o.Mx)(c,JSON.stringify({}))}}pushAnalyticsShareClickedEvent(e){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),r=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=encodeURIComponent(e.shareMedium),s="/a/".concat(t,"/widgets/analytics/shared?externalAccountId=").concat(n,"&externalUserId=").concat(r,"&engagementMedium=").concat(i,"&shareMedium=").concat(a),c=this.domain+s;return(0,o.Mx)(c,JSON.stringify({}))}}},745:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(615),o=n(787);class i{constructor(e){var t=e,n=(0,o.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain}track(e,t){var n=t,i=function(e){if(!(0,o.Kn)(e))throw new Error("tracking parameter must be an object");if(null==e||!e.accountId)throw new Error("accountId field is required");if(null==e||!e.events)throw new Error("events field is required");if(null==e||!e.userId)throw new Error("userId field is required");var t=e;if(!Array.isArray(t.events))throw new Error("'events' should be an array");return t}(e),{jwt:a}=function(e){if(!(0,o.Kn)(e))throw new Error("'options' should be an object");return e}(n),s=encodeURIComponent(this.tenantAlias),c=encodeURIComponent(i.userId),d=encodeURIComponent(i.accountId),u="/api/v1/".concat(s,"/open/account/").concat(d,"/user/").concat(c,"/events"),l=this.domain+u;return(0,r.Mx)(l,JSON.stringify(i),a)}}},139:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(572),o=n(861),i=n(955),a=n(615),s=n(787);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class u{constructor(e){var t=e,n=(0,s.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain,this.npmCdn=n.npmCdn}upsertUser(e){var t=e,n=(0,s.xW)(t),{widgetType:r,engagementMedium:o="POPUP",jwt:c,locale:d,user:u}=n,l=encodeURIComponent(this.tenantAlias),p=u.accountId?encodeURIComponent(u.accountId):null,f=u.id?encodeURIComponent(u.id):null,h=function(e){var{widgetType:t,engagementMedium:n,locale:r}=e,o=new URLSearchParams;return o.append("engagementMedium",n),t&&o.append("widgetType",t),r&&o.append("locale",r),"?".concat(o.toString())}({widgetType:r,engagementMedium:o,locale:d}),g="/api/v1/".concat(l,"/widget/account/").concat(p,"/user/").concat(f,"/upsert").concat(h),m=this.domain+g,w=(i.Z||window.Cookies).get("_saasquatch");return w&&(u.cookies=w),(0,a.iR)(m,JSON.stringify(u),c)}render(e){var t,n=e,r=(0,s.ZL)(n),{widgetType:i,engagementMedium:c="POPUP",jwt:d,user:u}=r,l=encodeURIComponent(this.tenantAlias),p=null!=u&&u.accountId?encodeURIComponent(u.accountId):null,f=null!=u&&u.id?encodeURIComponent(u.id):null,h=null!==(t=r.locale)&&void 0!==t?t:(0,s.Qb)(navigator.language.replace(/\-/g,"_")),g="/api/v1/".concat(l,"/graphql"),m=this.domain+g;return new Promise(function(){var e=(0,o.Z)((function*(e,t){try{var n,r=yield(0,a.Rf)(m,"\n query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {\n renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {\n template\n user {\n id\n accountId\n }\n jsOptions\n widgetConfig {\n values\n }\n }\n }\n",{user:f&&p?{id:f,accountId:p}:null,engagementMedium:c,widgetType:i,locale:h},d);e(null==r||null===(n=r.data)||void 0===n?void 0:n.renderWidget)}catch(e){t(e)}}));return function(t,n){return e.apply(this,arguments)}}())}squatchReferralCookie(){var e=this;return(0,o.Z)((function*(){var t=encodeURIComponent(e.tenantAlias),n=(i.Z||window.Cookies).get("_saasquatch")||"",r=n?"?cookies=".concat(encodeURIComponent(n)):"",o="".concat(e.domain,"/a/").concat(t,"/widgets/squatchcookiejson").concat(r),s=yield(0,a.gc)(o);return Promise.resolve(d(d({},s),{},{encodedCookie:n}))}))()}}},762:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(822);function o(){var e=window[r.q9]?r.q9:r.zG,t=window[e]||null,n=window["_"+e]||null,o=window.impactOnReady||window.squatchOnReady;if(setTimeout((()=>window[r.q9]=window[r.zG]),0),o&&setTimeout((()=>o()),0),t){n&&(n.ready||[]).forEach((e=>setTimeout((()=>e()),0))),setTimeout((()=>{window.squatch._auto()}),0),window["_"+e]=void 0;try{delete window["_"+e]}catch(e){throw e}}}},510:function(e,t,n){"use strict";function r(){console.log("Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes.")}n.d(t,{R:function(){return r}})},822:function(e,t,n){"use strict";n.d(t,{cE:function(){return r},eu:function(){return o},q9:function(){return a},zG:function(){return i}});var r="https://app.referralsaasquatch.com",o="https://fast.ssqt.io/npm",i="squatch",a="impact"},518:function(){},998:function(e,t,n){"use strict";n.d(t,{F:function(){return l},b:function(){return f}});var r=n(572),o=n(227),i=n(955);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var c=(0,o.debug)("squatch-js"),d=e=>"object"==typeof e&&!Array.isArray(e),u=(e,t)=>{var n=n=>d(t[n])&&e.hasOwnProperty(n)&&d(e[n]),r=Object.getOwnPropertyNames(t).map((r=>({[r]:n(r)?u(e[r],t[r]):t[r]}))).reduce(((e,t)=>s(s({},e),t)),{});return s(s({},e),r)};function l(e){return atob(e.replace(/_/g,"/").replace(/-/g,"+"))}function p(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(){var e=window.location.search,t=new URLSearchParams(e).get("_saasquatch")||"";if(t){var n="",r="",o="";try{n=JSON.parse(l(t))}catch(e){return void c("Unable to decode params",e)}try{r=JSON.parse(l(i.Z.get("_saasquatch"))),c("existing cookie",r)}catch(e){c("Unable to retrieve cookie",e)}try{var a=function(){var e,t,n="weird_get_top_level_domain=cookie",r=document.location.hostname.split(".");for(e=r.length-1;e>=0;e--)if(t=r.slice(e).join("."),document.cookie=n+";domain=."+t+";",document.cookie.indexOf(n)>-1)return document.cookie=n.split("=")[0]+"=;domain=."+t+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",t}();if(c("domain retrieved:",a),r){var s=u(r,n);o=p(JSON.stringify(s)),c("cookie to store:",s)}else o=p(JSON.stringify(n)),c("cookie to store:",n);i.Z.set("_saasquatch",o,{expires:365,secure:!1,sameSite:"Lax",domain:a,path:"/"})}catch(e){c("Unable to set cookie",e)}}}},936:function(e,t,n){"use strict";function r(e,t){var n,r=[],o=e,i=o.documentElement.doScroll,a="DOMContentLoaded",s=(i?/^loaded|^c/:/^loaded|^i|^c/).test(o.readyState);return s||o.addEventListener(a,n=()=>{for(o.removeEventListener(a,n),s=!0;n=r.shift();)n()}),s?setTimeout(t,0):r.push(t)}n.d(t,{V:function(){return r}})},615:function(e,t,n){"use strict";n.d(t,{Mx:function(){return f},Rf:function(){return d},gc:function(){return l},iR:function(){return g}});var r=n(572),o=n(861),i=n(227),a=n(787);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function d(e,t,n,r){return u.apply(this,arguments)}function u(){return(u=(0,o.Z)((function*(e,t,n,r){var o=r||(0,a.LP)(),i=c(c({Accept:"application/json","Content-Type":"application/json"},o?{Authorization:"Bearer ".concat(o)}:{}),{},{"X-SaaSquatch-Referrer":window?window.location.href:""});try{var s=yield fetch(e,{method:"POST",body:JSON.stringify({query:t,variables:n}),headers:i});if(!s.ok)throw new Error(yield s.text());return yield s.json()}catch(e){throw e}}))).apply(this,arguments)}function l(e){return p.apply(this,arguments)}function p(){return p=(0,o.Z)((function*(e){var t={Accept:"application/json","Content-Type":"application/json"},n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||(0,a.LP)();n&&(t["X-SaaSquatch-User-Token"]=n);try{var r=yield fetch(e,{method:"GET",credentials:"include",headers:t}),o=yield r.text();if(!r.ok)throw new Error(o);return o?JSON.parse(o):o}catch(e){throw e}})),p.apply(this,arguments)}function f(e,t,n){return h.apply(this,arguments)}function h(){return(h=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json"},o=n||(0,a.LP)();o&&(r["X-SaaSquatch-User-Token"]=o);try{var i=yield fetch(e,{method:"POST",body:t,headers:r}),s=yield i.text();if(!i.ok)throw new Error(s);return s?JSON.parse(s):s}catch(e){throw e}}))).apply(this,arguments)}function g(e,t,n){return m.apply(this,arguments)}function m(){return(m=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json","X-SaaSquatch-Referrer":window?window.location.href:""},o=n||(0,a.LP)();o&&(r["X-SaaSquatch-User-Token"]=o);try{var i=yield fetch(e,{headers:r,method:"PUT",credentials:"include",body:t}),s=yield i.text();if(!i.ok)throw new Error(s);return s?JSON.parse(s):s}catch(e){throw e}}))).apply(this,arguments)}(0,i.debug)("squatch-js:io")},8:function(e,t,n){"use strict";n.d(t,{G:function(){return u}});var r=n(572);function o(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=n(227),a=n(998);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var d=(0,i.debug)("squatch-js");function u(e){var t=window.location.search,n=new URLSearchParams(t).get("_saasquatchExtra")||"";if(n){var r;try{r=JSON.parse((0,a.F)(n))}catch(e){return void d("Unable to decode _saasquatchExtra config")}var{domain:i,tenantAlias:s,widgetConfig:u}=function(e){var t,n=Object.keys(e||{})[0],r=Object.keys((null==e?void 0:e[n])||{})[0],o=null==e||null===(t=e[n])||void 0===t?void 0:t[r];return{domain:n?"https://".concat(n):void 0,tenantAlias:r,widgetConfig:o}}(r);if(i&&s&&u){var{autoPopupWidgetType:l}=u;return{widgetConfig:c({widgetType:l,displayOnLoad:!0},o(u,["autoPopupWidgetType"])),squatchConfig:c(c({},e?{configIn:e}:{}),{},{domain:i,tenantAlias:s})}}d("_saasquatchExtra did not have an expected structure")}else d("No _saasquatchExtra param")}},787:function(e,t,n){"use strict";n.d(t,{Kn:function(){return i},LP:function(){return d},Qb:function(){return a},ZL:function(){return c},iE:function(){return u},ww:function(){return o},xW:function(){return s}});var r=n(822);function o(e){if("object"!=typeof e)throw new Error("config must be an object");var t=window.squatchTenant,n=u(),o={tenantAlias:(null==e?void 0:e.tenantAlias)||t,domain:(null==e?void 0:e.domain)||(null==n?void 0:n.domain),npmCdn:(null==e?void 0:e.npmCdn)||(null==n?void 0:n.npmCdn),debug:(null==e?void 0:e.debug)||(null==n?void 0:n.debug)};if("string"!=typeof o.tenantAlias)throw new Error("tenantAlias not provided");return{tenantAlias:o.tenantAlias,domain:"string"==typeof o.domain&&o.domain||r.cE,debug:"boolean"==typeof o.debug&&o.debug||!1,npmCdn:"string"==typeof o.npmCdn&&o.npmCdn||r.eu}}function i(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function a(e){if(e&&/^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(e))return e}function s(e){if(!i(e))throw new Error("Widget properties must be an object");if(null==e||!e.user)throw new Error("Required properties missing.");return e}function c(e){if(!i(e))throw new Error("Widget properties must be an object");return e}function d(){return window.impactToken||window.squatchToken}function u(){return window.impactConfig||window.squatchConfig}},75:function(e,t,n){"use strict";n.d(t,{Z:function(){return d}});var r=n(861),o=n(572),i=n(227),a=n(657),s=n(936),c=(0,i.debug)("squatch-js:EMBEDwidget");class d extends a.Z{constructor(e,t){super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),t&&(this.container=t)}load(){var e=this;return(0,r.Z)((function*(){var t,n=e._createFrame(),o=e._findElement();e.container?o.shadowRoot?"IFRAME"===(null===(t=o.shadowRoot.lastChild)||void 0===t?void 0:t.nodeName)?o.shadowRoot.replaceChild(n,o.shadowRoot.lastChild):o.shadowRoot.appendChild(n):o.firstChild?o.replaceChild(n,o.firstChild):o.appendChild(n):o.firstChild&&"#text"!==o.firstChild.nodeName||o.appendChild(n);var{contentWindow:i}=n;if(!i)throw new Error("Frame needs a content window");var a=i.document;a.open(),a.write(e.content),a.write('<script src="'.concat(e.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),a.close(),(0,s.V)(a,(0,r.Z)((function*(){var t=i.squatch||i.widgetIdent;n.height=a.body.scrollHeight;var r=new i.ResizeObserver((e=>{for(var t of e){var{height:r}=t.contentRect;n.height=r}})),o=yield e._findInnerContainer(n);r.observe(o),e._shouldFireLoadEvent()&&(e._loadEvent(t),c("loaded"))})))}))()}open(){var e=this._findFrame();if(!e)return c("no target element to open");if(!e.contentWindow)return c("Frame needs a content window");var t=this._findElement();t.style.visibility="unset",t.style.height="auto",t.style["overflow-y"]="auto",e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));var n=e.contentWindow.squatch||e.contentWindow.widgetIdent;this.context.user&&(this._loadEvent(n),c("loaded"))}close(){if(!this._findFrame())return c("no target element to close");var e=this._findElement();e.style.visibility="hidden",e.style.height="0",e.style["overflow-y"]="hidden",c("Embed widget closed")}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"embed",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n)}_shouldFireLoadEvent(){var e=!this.container,t=this.container instanceof HTMLElement&&(this.container.tagName.startsWith("SQUATCH-")||this.container.tagName.startsWith("IMPACT-"));return!!this.context.user&&(e||t)}}},658:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(572),i=n(227),a=n(936),s=n(657),c=(0,i.debug)("squatch-js:POPUPwidget"),d=0;class u extends s.Z{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".squatchpop";super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.trigger=t,this.container?this.id="squatchModal":(this.id=0===d?"squatchModal":"squatchModal__".concat(d),d+=1),document.head.insertAdjacentHTML("beforeend","<style>#".concat(this.id,"::-webkit-scrollbar { display: none; }</style>"))}_initialiseCTA(){if(this.trigger){var e;try{e=document.querySelector(this.trigger)||document.querySelector(".impactpop"),this.trigger&&!e&&c("No element found with trigger selector",this.trigger)}catch(e){c("Not a valid selector",this.trigger)}e&&(e.onclick=()=>{this.open()})}}_createPopupDialog(){var e=document.createElement("dialog");return e.id=this.id,e.setAttribute("style","width: 100%; max-width: 500px; border: none; padding: 0;"),e.addEventListener("click",(t=>{t.stopPropagation(),t.target===e&&e.close()})),e}load(){var e=this;return(0,r.Z)((function*(){var t,n=e._createFrame();e._initialiseCTA();var r=e.container?e._findElement():document.body,o=r.shadowRoot||r,i=e._createPopupDialog();i.appendChild(n),"DIALOG"===(null===(t=o.lastChild)||void 0===t?void 0:t.nodeName)?o.replaceChild(i,o.lastChild):o.appendChild(i);var{contentWindow:a}=n;if(!a)throw new Error("Frame needs a content window");var s=a.document;s.open(),s.write(e.content),s.write('<script src="'.concat(e.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),s.close(),c("Popup template loaded into iframe"),yield e._setupResizeHandler(n)}))()}_setupResizeHandler(e){var t=this;return(0,r.Z)((function*(){var{contentWindow:n}=e;if(!n)throw new Error("Frame needs a content window");var o=n.document;(0,a.V)(o,(0,r.Z)((function*(){o.body.style.overflowY="hidden",e.height="".concat(o.body.offsetHeight,"px"),new n.ResizeObserver((t=>{for(var n of t){var{top:r,bottom:o}=n.contentRect,i=o+r;e.height=i+"",n.target.style=""}})).observe(yield t._findInnerContainer(e))})))}))()}open(){var e=this.container?this._findElement():document.body,t=(e.shadowRoot||e).querySelector("#".concat(this.id));if(!t)throw new Error("Could not determine container div");t.showModal();var n=this._findFrame();if(!n)throw new Error("Could not find iframe");var{contentWindow:r}=n;if(!r)throw new Error("Squatch.js has an empty iframe");var o=r.document;(0,a.V)(o,(()=>{var e,t=r.squatch||r.widgetIdent;null===(e=n.contentDocument)||void 0===e||e.dispatchEvent(new CustomEvent("sq:refresh")),this.context.user&&(this._loadEvent(t),c("Popup opened"))}))}close(){var e=this.container?this._findElement():document.body,t=(e.shadowRoot||e).querySelector("#".concat(this.id));if(!t)throw new Error("Could not determine container div");t.close(),c("Popup closed")}_clickedOutside(e){var{target:t}=e}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n||"body { margin: 0; } .modal { box-shadow: none; border: 0; }")}}},657:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(861),o=n(227),i=n(264),a=n(787),s=(0,o.debug)("squatch-js:widget");class c{constructor(e){s("widget initializing ..."),this.content="error"===e.content?this._error(e.rsCode):e.content,this.type=e.type,this.widgetApi=e.api,this.npmCdn=e.npmCdn,this.analyticsApi=new i.Z({domain:e.domain}),this.context=e.context,this.container=e.container||e.context.container}_findElement(){var e;if("string"==typeof this.container?(e=document.querySelector(this.container),s("loading widget with selector",e)):this.container instanceof HTMLElement?(e=this.container,s("loading widget with container",e)):this.container?(e=null,s("container must be an HTMLElement or string",this.container)):(e=document.querySelector("#squatchembed")||document.querySelector(".squatchembed")||document.querySelector("#impactembed")||document.querySelector(".impactembed"),s("loading widget with default selector",e)),!(e instanceof HTMLElement))throw new Error("element with selector '".concat(this.container||"#squatchembed, .squatchembed, #impactembed, or .impactembed","' not found.'"));return e}_createFrame(){var e=document.createElement("iframe");return e.squatchJsApi=this,e.id="squatchFrame",e.width="100%",e.src="about:blank",e.scrolling="no",e.setAttribute("style","border: 0; background-color: none; width: 1px; min-width: 100%;"),e}_findFrame(){var e=this.container?this._findElement():document.body;return(e.shadowRoot||e).querySelector("iframe#squatchFrame")}_loadEvent(e){var t;if(e){if(!(0,a.Kn)(e))throw new Error("Widget Load event identity property is not an object");var n;if("programId"in e){if(!(e.tenantAlias&&e.accountId&&e.userId&&e.engagementMedium))throw new Error("Widget Load event missing required properties");n={tenantAlias:e.tenantAlias,externalAccountId:e.accountId,externalUserId:e.userId,engagementMedium:e.engagementMedium,programId:e.programId}}else{var{analytics:r,mode:o}=e;n={tenantAlias:r.attributes.tenant,externalAccountId:r.attributes.accountId,externalUserId:r.attributes.userId,engagementMedium:o.widgetMode}}null===(t=this.analyticsApi.pushAnalyticsLoadEvent(n))||void 0===t||t.then((e=>{s("".concat(n.engagementMedium," loaded event recorded."))})).catch((e=>{s("ERROR: pushAnalyticsLoadEvent() ".concat(e))}))}}_shareEvent(e,t){e&&this.analyticsApi.pushAnalyticsShareClickedEvent({tenantAlias:e.analytics.attributes.tenant,externalAccountId:e.analytics.attributes.accountId,externalUserId:e.analytics.attributes.userId,engagementMedium:e.mode.widgetMode,shareMedium:t}).then((n=>{s("".concat(e.mode.widgetMode," share ").concat(t," event recorded. ").concat(n))})).catch((e=>{s("ERROR: pushAnalyticsShareClickedEvent() ".concat(e))}))}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal";return'<!DOCTYPE html>\n \x3c!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if gt IE 8]>\x3c!--\x3e<html lang="en">\x3c!--<![endif]--\x3e\n <head>\n <link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">\n <style>\n '.concat(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",'\n </style>\n </head>\n <body>\n\n <div class="squatch-container ').concat(t,'" style="width:100%">\n <div class="errorheader">\n <button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">&times;</button>\n <p class="errortitle">Error</p>\n </div>\n <div class="errorbody">\n <div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>\n <h4>Our referral program is temporarily unavailable.</h4><br>\n <p>Please reload the page or check back later.</p>\n <p>If the persists please contact our support team.</p>\n <br>\n <br>\n <div class="right-align errtxt">\n Error Code: ').concat(e,"\n </div>\n </div>\n </div>\n </body>\n </html>")}_findInnerContainer(e){return(0,r.Z)((function*(){var{contentWindow:t}=e;if(!t)throw new Error("Squatch.js frame inner frame is empty");for(var n,r,o=t.document,i=null,a=0;a<5&&(void 0,void 0,n=o.getElementsByTagName("sqh-global-container"),r=o.getElementsByClassName("squatch-container"),!(i=n.length>0?n[0]:r.length>0?r[0]:null));a++)yield d(100);return i||o.body}))()}reload(e,t){var{email:n,firstName:r,lastName:o}=e,i=this._findFrame();if(!i)throw new Error("Could not find widget iframe");var a,c=i.contentWindow,d=this.context.engagementMedium||"POPUP";if(!c)throw new Error("Frame needs a content window");if("upsert"===this.context.type){if(!this.context.user)throw new Error("Can't reload without user ids");var u={email:n||null,firstName:r||null,lastName:o||null,id:this.context.user.id,accountId:this.context.user.accountId};a=this.widgetApi.upsertUser({user:u,engagementMedium:d,widgetType:this.type,jwt:t})}else{if("passwordless"!==this.context.type)throw new Error("can't reload an error widget");a=this.widgetApi.render({user:void 0,engagementMedium:d,widgetType:this.type,jwt:void 0})}a.then((e=>{var{template:t}=e;t&&(this.content=t,this.__deprecated__register(i,{email:n,engagementMedium:d},(()=>{this.load(),"POPUP"===d&&this.open()})))})).catch((e=>{var{message:t}=e;s("".concat(t))}))}__deprecated__register(e,t,n){var r=e.contentWindow.document,o=r.createElement("button"),i=r.getElementsByClassName("squatch-register")[0];if(i){o.className="btn btn-primary",o.id="show-stats-btn",o.textContent="REFERRER_WIDGET"===this.type?"Show Stats":"Show Reward";var a="POPUP"===t.engagementMedium?"margin-top: 10px; max-width: 130px; width: 100%;":"margin-top: 10px;";o.setAttribute("style",a),o.onclick=n,i.style.paddingTop="30px",i.innerHTML="<p><strong>".concat(t.email,"</strong><br>Has been successfully registered</p>"),i.appendChild(o)}}}function d(e){return new Promise((t=>{setTimeout(t,e)}))}},452:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(227),i=n(139),a=n(787),s=n(75),c=n(658),d=(0,o.debug)("squatch-js:widgets");class u{constructor(e){var t=(0,a.ww)(e);this.tenantAlias=t.tenantAlias,this.domain=t.domain,this.npmCdn=t.npmCdn,this.api=new i.Z(t)}upsertUser(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.xW)(n);try{var o=yield t.api.upsertUser(r);return{widget:t._renderWidget(o,r,{type:"upsert",user:r.user,engagementMedium:e.engagementMedium,container:e.container,trigger:e.trigger}),user:o.user}}catch(n){throw d(n),n.apiErrorCode&&t._renderErrorWidget(n,e.engagementMedium),new Error(n)}}))()}render(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.ZL)(n);try{var o=yield t.api.render(r);return{widget:t._renderWidget(o,r,{type:"passwordless",engagementMedium:r.engagementMedium,container:r.container,trigger:r.trigger}),user:o.user}}catch(e){throw e.apiErrorCode&&t._renderErrorWidget(e,r.engagementMedium),new Error(e)}}))()}autofill(e){var t=this;return(0,r.Z)((function*(){var n=e;if("function"!=typeof n){if("string"!=typeof n)throw new Error("Autofill accepts a string or function");var r,o=document.querySelectorAll(n);if(!(o.length>0))throw d("Element id/class or function missing"),new Error("Element id/class or function missing");r=o[0];try{var i=yield t.api.squatchReferralCookie();r.value=i.codes[0]}catch(e){throw new Error(e)}}else try{n(yield t.api.squatchReferralCookie())}catch(e){throw d("Autofill error",e),new Error(e)}}))()}_renderWidget(e,t,n){var r,o;if(d("Rendering Widget..."),!e)throw new Error("Unable to get a response");var i=!!t.displayOnLoad,a=e.jsOptions||{},s={content:e.template,type:t.widgetType||(null===(r=a.widget)||void 0===r?void 0:r.defaultWidgetType),api:this.api,domain:this.domain,npmCdn:this.npmCdn,context:n};return a.widgetUrlMappings&&a.widgetUrlMappings.forEach((t=>{var n,r;u._matchesUrl(t.url)&&("CONVERSION_WIDGET"!==t.widgetType||null!==(n=e.user)&&void 0!==n&&null!==(r=n.referredBy)&&void 0!==r&&r.code?(i=t.displayOnLoad,d("Display ".concat(t.widgetType," on ").concat(t.url))):d("Don't display ".concat(t.widgetType," when no referral on widget rule match ").concat(t.url)))})),a.fuelTankAutofillUrls&&(d("We found a fuel tank autofill!"),a.fuelTankAutofillUrls.forEach((t=>{var n,r,{url:o,formSelector:i}=t;if(u._matchesUrl(o)&&(d("Fuel Tank URL matches"),null!==(n=e.user)&&void 0!==n&&null!==(r=n.referredBy)&&void 0!==r&&r.code)){var a,s=document.querySelector(i);s?s.value=(null===(a=e.user.referredBy.referredReward)||void 0===a?void 0:a.fuelTankCode)||"":d(new Error("Element with id/class ".concat(i," was not found.")))}}))),"EMBED"===t.engagementMedium?o=this._renderEmbedWidget(s):(o=this._renderPopupWidget(s),i&&o.open()),o}_renderPopupWidget(e){var t=new c.Z(e,e.context.trigger);return t.load(),t}_renderEmbedWidget(e){var t=new s.Z(e,e.context.container);return t.load(),t}_renderErrorWidget(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"POPUP",{apiErrorCode:n,rsCode:r,message:o}=e;d(new Error("".concat(n," (").concat(r,") ").concat(o)));var i={content:"error",rsCode:r,api:this.api,domain:this.domain,npmCdn:this.npmCdn,type:"ERROR_WIDGET",context:{type:"error"}};"EMBED"===t?new s.Z(i).load():"POPUP"===t&&new c.Z(i).load()}static _matchesUrl(e){return!!window.location.href.match(new RegExp(e))}}},22:function(e,t,n){"use strict";n.d(t,{U:function(){return w},n:function(){return v}});var r=n(861),o=n(572),i=n(227),a=n.n(i),s=n(264),c=n(139),d=n(998),u=(0,i.debug)("squatch-js:decodeUserJwt"),l=n(787),p=n(75),f=n(658),h=n(822),g=a()("squatch-js:DeclarativeWidget");class m extends HTMLElement{constructor(){super(),(0,o.Z)(this,"_setWidget",((e,t)=>{var n,r={api:this.widgetApi,content:e,context:{type:t.type,user:t.user,container:this.container||this,engagementMedium:this.type},type:this.widgetType,domain:(null===(n=this.config)||void 0===n?void 0:n.domain)||h.cE,npmCdn:h.eu};if("EMBED"===this.type)return new p.Z(r,r.context.container);var o=this.firstChild?null:void 0;return new f.Z(r,o)})),(0,o.Z)(this,"setErrorWidget",(e=>{var t,n={api:this.widgetApi,content:"error",context:{type:"error",container:this.container||this},type:"ERROR_WIDGET",domain:(null===(t=this.config)||void 0===t?void 0:t.domain)||h.cE,npmCdn:h.eu};if("EMBED"===this.type)return new p.Z(n,n.context.container);var r=this.firstChild?null:void 0;return new f.Z(n,r)})),(0,o.Z)(this,"reload",this.renderWidget),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.attachShadow({mode:"open"}).innerHTML="<style>:host { display: contents; }</style><slot></slot>",this.config=(0,l.iE)(),this.token=(0,l.LP)(),this.tenant=window.squatchTenant,this.container=this}_setupApis(e){var t,n;if(!this.tenant)throw new Error("tenantAlias not provided");this.widgetApi=new c.Z({tenantAlias:(null==e?void 0:e.tenantAlias)||this.tenant,domain:(null==e?void 0:e.domain)||(null===(t=this.config)||void 0===t?void 0:t.domain)||h.cE}),this.analyticsApi=new s.Z({domain:(null==e?void 0:e.domain)||(null===(n=this.config)||void 0===n?void 0:n.domain)||h.cE})}renderPasswordlessVariant(){var e=this;return(0,r.Z)((function*(){return e._setupApis(),g("Rendering as an Instant Access widget"),yield e.widgetApi.render({engagementMedium:e.type,widgetType:e.widgetType,locale:e.locale}).then((t=>e._setWidget(t.template,{type:"passwordless"}))).catch(e.setErrorWidget)}))()}renderUserUpsertVariant(){var e=this;return(0,r.Z)((function*(){e._setupApis();var t=function(e){try{var t,n=e.split(".")[1];if(void 0===n)return null;var r=(0,d.F)(n);return null===(t=JSON.parse(r))||void 0===t?void 0:t.user}catch(e){return u(e),null}}(e.token);return t?(g("Rendering as a Verified widget"),yield e.widgetApi.upsertUser({user:t,locale:e.locale,engagementMedium:e.type,widgetType:e.widgetType,jwt:e.token}).then((n=>e._setWidget(n.template,{type:"upsert",user:t}))).catch(e.setErrorWidget)):e.setErrorWidget(Error("No user object in token."))}))()}getWidgetInstance(){var e=this;return(0,r.Z)((function*(){var t;if(e.widgetType=e.getAttribute("widget")||void 0,e.locale=e.getAttribute("locale")||e.locale,!e.widgetType)throw new Error("No widget has been specified");return t=e.token?yield e.renderUserUpsertVariant():yield e.renderPasswordlessVariant(),e.widgetInstance=t,t}))()}renderWidget(){var e=this;return(0,r.Z)((function*(){yield e.getWidgetInstance(),yield e.widgetInstance.load()}))()}open(){if(!this.widgetInstance)throw new Error("Widget has not loaded yet");this.widgetInstance.open()}close(){if(!this.widgetInstance)throw new Error("Widget has not loaded yet");this.widgetInstance.close()}}class w extends m{constructor(){super(),this.type="EMBED",this.loaded=!1}static get observedAttributes(){return["widget","locale"]}attributeChangedCallback(e,t,n){if(t!==n&&this.loaded)switch(e){case"locale":case"widget":this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){var t,n;e.container=e.getAttribute("container")||e,yield e.renderWidget();var r=null===(t=e.shadowRoot&&Array.from(e.shadowRoot.children))||void 0===t?void 0:t.find((e=>"SLOT"===e.tagName));r&&(null===(n=e.shadowRoot)||void 0===n||n.removeChild(r)),e.loaded=!0}))()}}class v extends m{constructor(){super(),this.type="POPUP",this.loaded=!1,this.addEventListener("click",(e=>{e.stopPropagation(),this.open()}))}static get observedAttributes(){return["widget","locale"]}attributeChangedCallback(e,t,n){if(t!==n&&this.loaded)switch(e){case"locale":case"widget":this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){e.container=e.getAttribute("container")||e,yield e.renderWidget(),null!==e.getAttribute("open")&&e.open(),e.loaded=!0}))()}}window.customElements.define("squatch-embed",class extends w{}),window.customElements.define("impact-embed",class extends w{}),window.customElements.define("squatch-popup",class extends v{}),window.customElements.define("impact-popup",class extends v{})},227:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":r(console))&&console.log&&(e=console).log.apply(e,arguments)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)}},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.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"],e.exports=n(447)(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:function(e,t,n){"use strict";e.exports=function(e){function t(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){var n;function a(){if(a.enabled){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];var i=a,s=Number(new Date),c=s-(n||s);i.diff=c,i.prev=n,i.curr=s,n=s,t[0]=r.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var d=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(e,n){if("%%"===e)return e;d++;var o=r.formatters[n];if("function"==typeof o){var a=t[d];e=o.call(i,a),t.splice(d,1),d--}return e})),r.formatArgs.call(i,t),(i.log||r.log).apply(i,t)}}return a.namespace=e,a.enabled=r.enabled(e),a.useColors=r.useColors(),a.color=t(e),a.destroy=o,a.extend=i,"function"==typeof r.init&&r.init(a),r.instances.push(a),a}function o(){var e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function i(e,t){return r(this.namespace+(void 0===t?":":t)+e)}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){r.enable("")},r.enable=function(e){var t;r.save(e),r.names=[],r.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){var i=r.instances[t];i.enabled=r.enabled(i.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=n(824),Object.keys(e).forEach((function(t){r[t]=e[t]})),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=t,r.enable(r.load()),r}},824:function(e){var t=1e3,n=60*t,r=60*n,o=24*r;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,a){a=a||{};var s,c,d=typeof e;if("string"===d&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===d&&isFinite(e))return a.long?(s=e,(c=Math.abs(s))>=o?i(s,c,o,"day"):c>=r?i(s,c,r,"hour"):c>=n?i(s,c,n,"minute"):c>=t?i(s,c,t,"second"):s+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},861:function(e,t,n){"use strict";function r(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function s(e){r(a,o,i,s,c,"next",e)}function c(e){r(a,o,i,s,c,"throw",e)}s(void 0)}))}}n.d(t,{Z:function(){return o}})},572:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===r(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:function(){return o}})},955:function(e,t,n){"use strict";function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}n.d(t,{Z:function(){return o}});var o=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=r({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var s in i)i[s]&&(a+="; "+s,!0!==i[s]&&(a+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+a}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(r[s]=t.read(a,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){o(e,"",r({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,r({},this.attributes,t))},withConverter:function(t){return e(r({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";n.r(r),n.d(r,{DeclarativeEmbedWidget:function(){return p.U},DeclarativePopupWidget:function(){return p.n},EmbedWidget:function(){return o.Z},PopupWidget:function(){return i.Z},WidgetApi:function(){return a.Z},Widgets:function(){return t.Z},_auto:function(){return A},api:function(){return C},autofill:function(){return I},events:function(){return O},help:function(){return m.R},init:function(){return j},pushCookie:function(){return _},ready:function(){return P},widget:function(){return x},widgets:function(){return E}});var e=n(227),t=n(452),o=n(75),i=n(658),a=n(139),s=n(745),c=n(762),d=n(787),u=n(998),l=n(8),p=n(22),f=n(518),h={};for(var g in f)["default","Widgets","EmbedWidget","PopupWidget","DeclarativeEmbedWidget","DeclarativePopupWidget","WidgetApi","api","widgets","events","widget","_auto","init","ready","autofill","pushCookie"].indexOf(g)<0&&(h[g]=function(e){return f[e]}.bind(0,g));n.d(r,h);var m=n(510),w=(0,e.debug)("squatch-js"),v=null,y=null,b=null;function C(){return v||j({}),v}function E(){return y||j({}),y}function O(){return b||j({}),b}function x(e){var t;return null===(t=E())||void 0===t?void 0:t.render(e)}function A(e){var t=(0,l.G)(e);if(t){var n,{squatchConfig:r,widgetConfig:o}=t;return j(r),null===(n=E())||void 0===n?void 0:n.render(o)}}function j(n){var r=n,o=(0,d.ww)(r);o.tenantAlias.match("^test")||o.debug?e.debug.enable("squatch-js*"):e.debug.disable(),w("initializing ..."),v=new a.Z(o),y=new t.Z(o),b=new s.Z(o),w("Widget API instance",v),w("Widgets instance",y),w("Events API instance",b)}function P(e){e()}function I(e){E().autofill(e)}function _(){(0,u.b)()}"undefined"==typeof document||window.SaaSquatchDoNotAutoDrop||_(),"undefined"!=typeof document&&(0,c.Z)()}(),r}()}));
@@ -1,6 +1,4 @@
1
1
  import { ConfigOptions, WidgetConfig } from "../types";
2
- export declare const DEFAULT_DOMAIN = "https://app.referralsaasquatch.com";
3
- export declare const DEFAULT_NPM_CDN = "https://fast.ssqt.io/npm";
4
2
  type Required<T> = T extends object ? {
5
3
  [P in keyof T]-?: NonNullable<T[P]>;
6
4
  } : T;
@@ -17,8 +17,8 @@ export default class PopupWidget extends Widget {
17
17
  constructor(params: Params, trigger?: string | null);
18
18
  _initialiseCTA(): void;
19
19
  _createPopupDialog(): HTMLDialogElement;
20
- load(): void;
21
- protected _setupResizeHandler(frame: HTMLIFrameElement): void;
20
+ load(): Promise<void>;
21
+ protected _setupResizeHandler(frame: HTMLIFrameElement): Promise<void>;
22
22
  open(): void;
23
23
  close(): void;
24
24
  protected _clickedOutside({ target }: {
@@ -11,11 +11,11 @@ export default class Widgets {
11
11
  */
12
12
  api: WidgetApi;
13
13
  /**
14
- * Tenant alias of SaaSquatch tenant.
14
+ * Tenant alias of SaaSquatch tenant
15
15
  */
16
16
  tenantAlias: string;
17
17
  /**
18
- * SaaSquatch domain for API requests.
18
+ * SaaSquatch domain for API requests
19
19
  * @default "https://app.referralsaasquatch.com"
20
20
  */
21
21
  domain: string;
@@ -49,13 +49,13 @@ export default class Widgets {
49
49
  * @param {Object} config.user The user details
50
50
  * @param {string} config.user.id The user id
51
51
  * @param {string} config.user.accountId The user account id
52
- * @param {WidgetType} config.widgetType The content of the widget.
53
- * @param {EngagementMedium} config.engagementMedium How to display the widget.
52
+ * @param {WidgetType} config.widgetType The content of the widget
53
+ * @param {EngagementMedium} config.engagementMedium How to display the widget
54
54
  * @param {string} config.jwt the JSON Web Token (JWT) that is used to validate the data (can be disabled)
55
55
  * @param {HTMLElement | string | undefined} config.container Element to load the widget into
56
56
  * @param {string | undefined} config.trigger Trigger element for opening the popup widget
57
57
  *
58
- * @return {Promise<WidgetResult>} json object if true, with a Widget and user details.
58
+ * @return {Promise<WidgetResult>} json object if true, with a Widget and user details
59
59
  */
60
60
  upsertUser(config: WithRequired<WidgetConfig, "user">): Promise<{
61
61
  widget: any;
@@ -69,12 +69,12 @@ export default class Widgets {
69
69
  * @param {Object} config.user The user details
70
70
  * @param {string} config.user.id The user id
71
71
  * @param {string} config.user.accountId The user account id
72
- * @param {WidgetType} config.widgetType The content of the widget.
73
- * @param {EngagementMedium} config.engagementMedium How to display the widget.
72
+ * @param {WidgetType} config.widgetType The content of the widget
73
+ * @param {EngagementMedium} config.engagementMedium How to display the widget
74
74
  * @param {string} config.jwt the JSON Web Token (JWT) that is used
75
75
  * to validate the data (can be disabled)
76
76
  *
77
- * @return {Promise<WidgetResult>} json object if true, with a Widget and user details.
77
+ * @return {Promise<WidgetResult>} json object if true, with a Widget and user details
78
78
  */
79
79
  render(config: WidgetConfig): Promise<WidgetResult | undefined>;
80
80
  /**
@@ -4,7 +4,7 @@ import { DeclarativeConfigOptions } from "../../types";
4
4
  import EmbedWidget from "../EmbedWidget";
5
5
  import PopupWidget from "../PopupWidget";
6
6
  /**
7
- * Abstract class for building web-components that render SaaSquatch widgets to the DOM.
7
+ * Abstract class for building web-components that render SaaSquatch widgets to the DOM
8
8
  * @abstract
9
9
  * @example
10
10
  * class TestWidgetElement extends DeclarativeWidget {}
@@ -50,7 +50,7 @@ export default abstract class DeclarativeWidget extends HTMLElement {
50
50
  */
51
51
  widgetInstance: EmbedWidget | PopupWidget;
52
52
  /**
53
- * Determines whether to render the widget as an embedding widget or popup widget.
53
+ * Determines whether to render the widget as an embedding widget or popup widget
54
54
  */
55
55
  type: "EMBED" | "POPUP";
56
56
  /**
@@ -59,23 +59,28 @@ export default abstract class DeclarativeWidget extends HTMLElement {
59
59
  */
60
60
  container: string | HTMLElement | undefined | null;
61
61
  element: HTMLElement | undefined;
62
+ /**
63
+ * Flag for if the component has been loaded or not
64
+ * @hidden
65
+ */
66
+ loaded: boolean;
62
67
  constructor();
63
68
  private _setupApis;
64
69
  private renderPasswordlessVariant;
65
70
  private renderUserUpsertVariant;
66
71
  private _setWidget;
67
72
  /**
68
- * Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM.
73
+ * Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
69
74
  * @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
70
75
  * @throws Throws an Error if `widgetType` is undefined
71
76
  */
72
77
  getWidgetInstance(): Promise<EmbedWidget | PopupWidget>;
73
78
  /**
74
- * Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM.
79
+ * Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM
75
80
  */
76
81
  renderWidget(): Promise<void>;
77
82
  /**
78
- * Builds a Widget instance for the default error widget.
83
+ * Builds a Widget instance for the default error widget
79
84
  * @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
80
85
  */
81
86
  setErrorWidget: (e: Error) => EmbedWidget | PopupWidget;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasquatch/squatch-js",
3
- "version": "2.6.0-7",
3
+ "version": "2.6.0-9",
4
4
  "description": "The official Referral SaaSquatch Javascript Web/Browser SDK https://docs.referralsaasquatch.com/developer/squatchjs/",
5
5
  "license": "MIT",
6
6
  "author": "ReferralSaaSquatch.com, Inc.",