@sesamy/sesamy-js 1.19.1 → 1.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sesamy-js.cjs +1 -1
- package/dist/sesamy-js.iife.js +1 -1
- package/dist/sesamy-js.mjs +1 -1
- package/package.json +1 -1
package/dist/sesamy-js.cjs
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
`,10)+1,o=a.substring(i)+(n?"//# sourceMappingURL="+n:""),c=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(c)}var ms,gs,ys,ta,kw=(ms="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",gs=null,ys=!1,function(e){return ta=ta||$w(ms,gs,ys),new Worker(ta,e)});const ra={};let Pw=class{constructor(t,r){this.cache=t,this.clientId=r,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(t){var r;const n=new Set(((r=await this.cache.get(this.manifestKey))===null||r===void 0?void 0:r.keys)||[]);n.add(t),await this.cache.set(this.manifestKey,{keys:[...n]})}async remove(t){const r=await this.cache.get(this.manifestKey);if(r){const n=new Set(r.keys);return n.delete(t),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(t){return`@@auth0spajs@@::${t}`}};const Tw={memory:()=>new Fu().enclosedCache,localstorage:()=>new pw},ws=e=>Tw[e],bs=e=>{const{openUrl:t,onRedirect:r}=e,n=Ie(e,["openUrl","onRedirect"]);return Object.assign(Object.assign({},n),{openUrl:t===!1||t?t:r})},na=new aw;let Ew=class{constructor(t){let r,n;if(this.userCache=new Fu().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await na.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),t),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),t.authorizationParams)}),typeof window<"u"&&(()=>{if(!Ur())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Ur().subtle===void 0)throw new Error(`
|
|
3
3
|
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
4
4
|
`)})(),t.cache&&t.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),t.cache)n=t.cache;else{if(r=t.cacheLocation||"memory",!ws(r))throw new Error(`Invalid cache location "${r}"`);n=ws(r)()}this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:1e4,this.cookieStorage=t.legacySameSiteCookie===!1?ht:Sw,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(o=>`auth0.${o}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=t.sessionCheckExpiryDays||1;const a=t.useCookiesForTransactions?this.cookieStorage:Iw;var i;this.scope=$r("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new gw(a,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||ju,this.cacheManager=new mw(n,n.allKeys?void 0:new Pw(n,this.options.clientId),this.nowProvider),this.domainUrl=(i=this.options.domain,/^https?:\/\//.test(i)?i:`https://${i}`),this.tokenIssuer=((o,c)=>o?o.startsWith("https://")?o:`https://${o}/`:`${c}/`)(this.options.issuer,this.domainUrl),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&r==="memory"&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new kw)}_url(t){const r=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Cu)));return`${this.domainUrl}${t}&auth0Client=${r}`}_authorizeUrl(t){return this._url(`/authorize?${Aa(t)}`)}async _verifyIdToken(t,r,n){const a=await this.nowProvider();return ww({iss:this.tokenIssuer,aud:this.options.clientId,id_token:t,nonce:r,organization:n,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i!="string"?i:parseInt(i,10)||void 0),now:a});var i}_processOrgHint(t){t?this.cookieStorage.save(this.orgHintCookieName,t,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(t,r,n){const a=vs(ea()),i=vs(ea()),o=ea(),c=(u=>{const s=new Uint8Array(u);return(d=>{const h={"+":"-","/":"_","=":""};return d.replace(/[+/=]/g,m=>h[m])})(window.btoa(String.fromCharCode(...Array.from(s))))})(await(async u=>await Ur().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(o)),l=((u,s,d,h,m,S,g,$)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),d),{scope:$r(s,d.scope),response_type:"code",response_mode:$||"query",state:h,nonce:m,redirect_uri:g||u.authorizationParams.redirect_uri,code_challenge:S,code_challenge_method:"S256"}))(this.options,this.scope,t,a,i,c,t.redirect_uri||this.options.authorizationParams.redirect_uri||n,r==null?void 0:r.response_mode),f=this._authorizeUrl(l);return{nonce:i,code_verifier:o,scope:l.scope,audience:l.audience||"default",redirect_uri:l.redirect_uri,state:a,url:f}}async loginWithPopup(t,r){var n;if(t=t||{},!(r=r||{}).popup&&(r.popup=(c=>{const l=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(c,"auth0:authorize:popup",`left=${l},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!r.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const a=await this._prepareAuthorizeUrl(t.authorizationParams||{},{response_mode:"web_message"},window.location.origin);r.popup.location.href=a.url;const i=await(c=>new Promise((l,f)=>{let u;const s=setInterval(()=>{c.popup&&c.popup.closed&&(clearInterval(s),clearTimeout(d),window.removeEventListener("message",u,!1),f(new cw(c.popup)))},1e3),d=setTimeout(()=>{clearInterval(s),f(new sw(c.popup)),window.removeEventListener("message",u,!1)},1e3*(c.timeoutInSeconds||60));u=function(h){if(h.data&&h.data.type==="authorization_response"){if(clearTimeout(d),clearInterval(s),window.removeEventListener("message",u,!1),c.popup.close(),h.data.response.error)return f(ae.fromPayload(h.data.response));l(h.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},r),{timeoutInSeconds:r.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(a.state!==i.state)throw new ae("state_mismatch","Invalid state");const o=((n=t.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:a.audience,scope:a.scope,code_verifier:a.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:a.redirect_uri},{nonceIn:a.nonce,organization:o})}async getUser(){var t;const r=await this._getIdTokenFromCache();return(t=r==null?void 0:r.decodedToken)===null||t===void 0?void 0:t.user}async getIdTokenClaims(){var t;const r=await this._getIdTokenFromCache();return(t=r==null?void 0:r.decodedToken)===null||t===void 0?void 0:t.claims}async loginWithRedirect(t={}){var r;const n=bs(t),{openUrl:a,fragment:i,appState:o}=n,c=Ie(n,["openUrl","fragment","appState"]),l=((r=c.authorizationParams)===null||r===void 0?void 0:r.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(c.authorizationParams||{}),{url:u}=f,s=Ie(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},s),{appState:o}),l&&{organization:l}));const d=i?`${u}#${i}`:u;a?await a(d):window.location.assign(d)}async handleRedirectCallback(t=window.location.href){const r=t.split("?").slice(1);if(r.length===0)throw new Error("There are no query params available for parsing.");const{state:n,code:a,error:i,error_description:o}=(s=>{s.indexOf("#")>-1&&(s=s.substring(0,s.indexOf("#")));const d=new URLSearchParams(s);return{state:d.get("state"),code:d.get("code")||void 0,error:d.get("error")||void 0,error_description:d.get("error_description")||void 0}})(r.join("")),c=this.transactionManager.get();if(!c)throw new ae("missing_transaction","Invalid state");if(this.transactionManager.remove(),i)throw new ow(i,o||i,n,c.appState);if(!c.code_verifier||c.state&&c.state!==n)throw new ae("state_mismatch","Invalid state");const l=c.organization,f=c.nonce,u=c.redirect_uri;return await this._requestToken(Object.assign({audience:c.audience,scope:c.scope,code_verifier:c.code_verifier,grant_type:"authorization_code",code:a},u?{redirect_uri:u}:{}),{nonceIn:f,organization:l}),{appState:c.appState}}async checkSession(t){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(t)}catch{}}async getTokenSilently(t={}){var r;const n=Object.assign(Object.assign({cacheMode:"on"},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:$r(this.scope,(r=t.authorizationParams)===null||r===void 0?void 0:r.scope)})}),a=await((i,o)=>{let c=ra[o];return c||(c=i().finally(()=>{delete ra[o],c=null}),ra[o]=c),c})(()=>this._getTokenSilently(n),`${this.options.clientId}::${n.authorizationParams.audience}::${n.authorizationParams.scope}`);return t.detailedResponse?a:a==null?void 0:a.access_token}async _getTokenSilently(t){const{cacheMode:r}=t,n=Ie(t,["cacheMode"]);if(r!=="off"){const a=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId});if(a)return a}if(r!=="cache-only"){if(!await(async(a,i=3)=>{for(let o=0;o<i;o++)if(await a())return!0;return!1})(()=>na.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new ja;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),r!=="off"){const f=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const a=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n),{id_token:i,access_token:o,oauthTokenScope:c,expires_in:l}=a;return Object.assign(Object.assign({id_token:i,access_token:o},c?{scope:c}:null),{expires_in:l})}finally{await na.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(t={},r={}){var n;const a=Object.assign(Object.assign({},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:$r(this.scope,(n=t.authorizationParams)===null||n===void 0?void 0:n.scope)})});return r=Object.assign(Object.assign({},iw),r),await this.loginWithPopup(a,r),(await this.cacheManager.get(new Xe({scope:a.authorizationParams.scope,audience:a.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(t){t.clientId!==null?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const r=t.logoutParams||{},{federated:n}=r,a=Ie(r,["federated"]),i=n?"&federated":"";return this._url(`/v2/logout?${Aa(Object.assign({clientId:t.clientId},a))}`)+i}async logout(t={}){const r=bs(t),{openUrl:n}=r,a=Ie(r,["openUrl"]);t.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(t.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const i=this._buildLogoutUrl(a);n?await n(i):n!==!1&&window.location.assign(i)}async _getTokenFromIFrame(t){const r=Object.assign(Object.assign({},t.authorizationParams),{prompt:"none"}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!r.organization&&(r.organization=n);const{url:a,state:i,nonce:o,code_verifier:c,redirect_uri:l,scope:f,audience:u}=await this._prepareAuthorizeUrl(r,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new ae("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const s=t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,d=await((m,S,g=60)=>new Promise(($,P)=>{const b=window.document.createElement("iframe");b.setAttribute("width","0"),b.setAttribute("height","0"),b.style.display="none";const v=()=>{window.document.body.contains(b)&&(window.document.body.removeChild(b),window.removeEventListener("message",I,!1))};let I;const O=setTimeout(()=>{P(new ja),v()},1e3*g);I=function(_){if(_.origin!=S||!_.data||_.data.type!=="authorization_response")return;const C=_.source;C&&C.close(),_.data.response.error?P(ae.fromPayload(_.data.response)):$(_.data.response),clearTimeout(O),window.removeEventListener("message",I,!1),setTimeout(v,2e3)},window.addEventListener("message",I,!1),window.document.body.appendChild(b),b.setAttribute("src",m)}))(a,this.domainUrl,s);if(i!==d.state)throw new ae("state_mismatch","Invalid state");const h=await this._requestToken(Object.assign(Object.assign({},t.authorizationParams),{code_verifier:c,code:d.code,grant_type:"authorization_code",redirect_uri:l,timeout:t.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:o,organization:r.organization});return Object.assign(Object.assign({},h),{scope:f,oauthTokenScope:h.scope,audience:u})}catch(s){throw s.error==="login_required"&&this.logout({openUrl:!1}),s}}async _getTokenUsingRefreshToken(t){const r=await this.cacheManager.get(new Xe({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(r&&r.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw new Du(t.authorizationParams.audience||"default",t.authorizationParams.scope)}const n=t.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,a=typeof t.timeoutInSeconds=="number"?1e3*t.timeoutInSeconds:null;try{const i=await this._requestToken(Object.assign(Object.assign(Object.assign({},t.authorizationParams),{grant_type:"refresh_token",refresh_token:r&&r.refresh_token,redirect_uri:n}),a&&{timeout:a}));return Object.assign(Object.assign({},i),{scope:t.authorizationParams.scope,oauthTokenScope:i.scope,audience:t.authorizationParams.audience||"default"})}catch(i){if((i.message.indexOf("Missing Refresh Token")>-1||i.message&&i.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw i}}async _saveEntryInCache(t){const{id_token:r,decodedToken:n}=t,a=Ie(t,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:r,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(a)}async _getIdTokenFromCache(){const t=this.options.authorizationParams.audience||"default",r=await this.cacheManager.getIdToken(new Xe({clientId:this.options.clientId,audience:t,scope:this.scope})),n=this.userCache.get("@@user@@");return r&&r.id_token===(n==null?void 0:n.id_token)?n:(this.userCache.set("@@user@@",r),r)}async _getEntryFromCache({scope:t,audience:r,clientId:n}){const a=await this.cacheManager.get(new Xe({scope:t,audience:r,clientId:n}),60);if(a&&a.access_token){const{access_token:i,oauthTokenScope:o,expires_in:c}=a,l=await this._getIdTokenFromCache();return l&&Object.assign(Object.assign({id_token:l.id_token,access_token:i},o?{scope:o}:null),{expires_in:c})}}async _requestToken(t,r){const{nonceIn:n,organization:a}=r||{},i=await vw(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},t),this.worker),o=await this._verifyIdToken(i.id_token,n,a);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},i),{decodedToken:o,scope:t.scope,audience:t.audience||"default"}),i.scope?{oauthTokenScope:i.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(a||o.claims.org_id),Object.assign(Object.assign({},i),{decodedToken:o})}};async function Ow(e){const t=new Ew(e);return await t.checkSession(),t}var ye=(e=>(e.READY="sesamyJsReady",e.AUTHENTICATED="sesamyJsAuthenticated",e.LOGOUT="sesamyJsLogout",e.CLEAR_CACHE="sesamyJsClearCache",e.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",e.PURCHASE="sesamyJsPurchase",e))(ye||{});const _w="sesamy.com",Rw="sesamy.dev",Cw="https://sesa.my",Ua="sesamyCacheTimestamp";function xe(e,t){return`https://${e}.${t==="dev"?Rw:_w}`}let ie,Bu;const $t="sesamyAccessToken",aa="sesamyRefreshToken";async function jw(e){if(!e)return null;const t=localStorage.getItem(aa);if(!t)throw new Error("No refresh token available");const r=new URLSearchParams;r.set("client_id",e.iss),r.set("refresh_token",t),r.set("grant_type","refresh_token");const n=new URL(e.iss);n.pathname="/oauth/token",n.searchParams.set("user_id",e.sub);try{const a=await fetch(n.href,{body:r.toString(),method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"}});if(!a.ok)throw localStorage.removeItem(aa),new Error("Renew token failed");const i=await a.json();return localStorage.setItem(aa,i.refresh_token),localStorage.setItem($t,i.access_token),i.access_token}catch{Ku()}}async function Ii(){const e=localStorage.getItem($t);if(!e)return null;const t=Gu(e);if(!t||!t.exp||t.exp<new Date().getTime()/1e3){const r=await jw(t);if(r)return r;localStorage.removeItem($t)}return e}function Ss(e){try{const t=new URL(e).hostname,r=t.split(".");return r.length>1?r.slice(-2).join("."):t}catch{return null}}async function Aw(e){if(e.enabled===!1)return;Bu=e.organization;const t={domain:xe("token",e.environment),clientId:e.clientId,useCookiesForTransactions:!0};if(Ss(window.location.href)!==Ss(xe("auth",e.environment))&&(t.cacheLocation="localstorage",t.useRefreshTokens=!0),ie=await Ow(t),window.location.search.includes("code="))try{await ie.handleRedirectCallback();const r=await ie.getUser();ze(ye.AUTHENTICATED,r);const n=new URL(location.href),a=n.searchParams;a.delete("code"),a.delete("state"),n.search=a.toString(),window.history.replaceState({},document.title,n.toString())}catch(r){console.error(r)}}async function $i(){return await Ii()?!0:ie?ie.isAuthenticated():!1}async function Lw(){return await Ii()?{sub:"local",name:"Local User"}:ie?ie.getUser():null}function ki(e){if(localStorage.removeItem($t),!ie)throw new Error("Auth0 client not initialized");const t=(e==null?void 0:e.authorizationParams)||{};return ie.loginWithRedirect({...e,authorizationParams:{organization:Bu,redirect_uri:window.location.href,...t}})}async function zt(e=!0){const t=Ii();if(t)return t;try{return ie?await ie.getTokenSilently():null}catch(r){if(e)throw r;return null}}async function Ku(e={}){if(localStorage.removeItem($t),ze(ye.LOGOUT,{}),!!ie)return ie.logout({...e,logoutParams:{returnTo:window.location.href,...e.logoutParams}})}function Gu(e){const t=e.split(".");if(t.length!==3)return null;const n=t[1].replace(/-/g,"+").replace(/_/g,"/"),a=decodeURIComponent(atob(n).split("").map(function(i){return"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(a)}async function Wu(e){const t=Gu(e);if(!t||!t.exp||t.exp<new Date().getTime()/1e3)throw new Error("Invalid token");localStorage.setItem($t,e),ze(ye.AUTHENTICATED,t)}const Uw=(e,t)=>t.skipDedupe||t.method!=="GET",xw=(e,t)=>t.method+"@"+e,Nw=e=>e.clone(),Is=({skip:e=Uw,key:t=xw,resolver:r=Nw}={})=>{const n=new Map;return a=>(i,o)=>{if(e(i,o))return a(i,o);const c=t(i,o);if(!n.has(c))n.set(c,[]);else return new Promise((l,f)=>{n.get(c).push([l,f])});try{return a(i,o).then(l=>(n.get(c).forEach(([f])=>f(r(l))),n.delete(c),l)).catch(l=>{throw n.get(c).forEach(([f,u])=>u(l)),n.delete(c),l})}catch(l){return n.delete(c),Promise.reject(l)}}},Dw=(e,t)=>e*t,Mw=e=>e&&e.ok,$s=({delayTimer:e=500,delayRamp:t=Dw,maxAttempts:r=10,until:n=Mw,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:c}={})=>l=>(f,u)=>{let s=0;if(c&&c(f,u))return l(f,u);const d=(h,m)=>Promise.resolve(n(h,m)).then(S=>S?h&&o?h:m?Promise.reject(m):h:(s++,!r||s<=r?new Promise(g=>{const $=t(e,s);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:h,error:m,url:f,options:u})).then((P={})=>{var b,v;g(l((b=P&&P.url)!==null&&b!==void 0?b:f,(v=P&&P.options)!==null&&v!==void 0?v:u))}):g(l(f,u))},$)}).then(d).catch(g=>{if(!i)throw g;return d(null,g)}):h&&o?h:Promise.reject(m||new Error("Number of attempts exceeded."))));return l(f,u).then(d).catch(h=>{if(!i)throw h;return d(null,h)})},Fw="application/json",Vu="Content-Type",ft=Symbol(),Zu=Symbol();function ks(e={}){var t;return(t=Object.entries(e).find(([r])=>r.toLowerCase()===Vu.toLowerCase()))===null||t===void 0?void 0:t[1]}function Ps(e){return/^application\/.*json.*/.test(e)}const Qe=function(e,t,r=!1){return Object.entries(t).reduce((n,[a,i])=>{const o=e[a];return Array.isArray(o)&&Array.isArray(i)?n[a]=r?[...o,...i]:i:typeof o=="object"&&typeof i=="object"?n[a]=Qe(o,i,r):n[a]=i,n},{...e})},kt={options:{},errorType:"text",polyfills:{},polyfill(e,t=!0,r=!1,...n){const a=this.polyfills[e]||(typeof self<"u"?self[e]:null)||(typeof global<"u"?global[e]:null);if(t&&!a)throw new Error(e+" is not defined");return r&&a?new a(...n):a}};function zw(e,t=!1){kt.options=t?e:Qe(kt.options,e)}function Hw(e,t=!1){kt.polyfills=t?e:Qe(kt.polyfills,e)}function Bw(e){kt.errorType=e}const Kw=e=>t=>e.reduceRight((r,n)=>n(r),t)||t;class Yu extends Error{}const Gw=e=>{const t=Object.create(null);e=e._addons.reduce((b,v)=>v.beforeRequest&&v.beforeRequest(b,e._options,t)||b,e);const{_url:r,_options:n,_config:a,_catchers:i,_resolvers:o,_middlewares:c,_addons:l}=e,f=new Map(i),u=Qe(a.options,n);let s=r;const d=Kw(c)((b,v)=>(s=b,a.polyfill("fetch")(b,v)))(r,u),h=new Error,m=d.catch(b=>{throw{[ft]:b}}).then(b=>{if(!b.ok){const v=new Yu;if(v.cause=h,v.stack=v.stack+`
|
|
5
|
-
CAUSE: `+h.stack,v.response=b,v.url=s,b.type==="opaque")throw v;return b.text().then(I=>{var O;if(v.message=I,a.errorType==="json"||((O=b.headers.get("Content-Type"))===null||O===void 0?void 0:O.split(";")[0])==="application/json")try{v.json=JSON.parse(I)}catch{}throw v.text=I,v.status=b.status,v})}return b}),S=b=>b.catch(v=>{const I=v.hasOwnProperty(ft),O=I?v[ft]:v,_=(O==null?void 0:O.status)&&f.get(O.status)||f.get(O==null?void 0:O.name)||I&&f.has(ft)&&f.get(ft);if(_)return _(O,e);const C=f.get(Zu);if(C)return C(O,e);throw O}),g=b=>v=>S(b?m.then(I=>I&&I[b]()).then(I=>v?v(I):I):m.then(I=>v?v(I):I)),$={_wretchReq:e,_fetchReq:d,_sharedState:t,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(b,v){return f.set(b,v),this},badRequest(b){return this.error(400,b)},unauthorized(b){return this.error(401,b)},forbidden(b){return this.error(403,b)},notFound(b){return this.error(404,b)},timeout(b){return this.error(408,b)},internalError(b){return this.error(500,b)},fetchError(b){return this.error(ft,b)}},P=l.reduce((b,v)=>({...b,...typeof v.resolver=="function"?v.resolver(b):v.resolver}),$);return o.reduce((b,v)=>v(b,e),P)},Ww={_url:"",_options:{},_config:kt,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(e){return{...this,_addons:[...this._addons,e],...e.wretch}},errorType(e){return{...this,_config:{...this._config,errorType:e}}},polyfills(e,t=!1){return{...this,_config:{...this._config,polyfills:t?e:Qe(this._config.polyfills,e)}}},url(e,t=!1){if(t)return{...this,_url:e};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+e+"?"+r[1]:this._url+e}},options(e,t=!1){return{...this,_options:t?e:Qe(this._options,e)}},headers(e){const t=e?Array.isArray(e)?Object.fromEntries(e):"entries"in e?Object.fromEntries(e.entries()):e:{};return{...this,_options:Qe(this._options,{headers:t})}},accept(e){return this.headers({Accept:e})},content(e){return this.headers({[Vu]:e})},auth(e){return this.headers({Authorization:e})},catcher(e,t){const r=new Map(this._catchers);return r.set(e,t),{...this,_catchers:r}},catcherFallback(e){return this.catcher(Zu,e)},resolve(e,t=!1){return{...this,_resolvers:t?[e]:[...this._resolvers,e]}},defer(e,t=!1){return{...this,_deferred:t?[e]:[...this._deferred,e]}},middlewares(e,t=!1){return{...this,_middlewares:t?e:[...this._middlewares,...e]}},fetch(e=this._options.method,t="",r=null){let n=this.url(t).options({method:e});const a=ks(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||Ps(a));return n=r?o?n.json(r,a):n.body(r):n,Gw(n._deferred.reduce((c,l)=>l(c,c._url,c._options),n))},get(e=""){return this.fetch("GET",e)},delete(e=""){return this.fetch("DELETE",e)},put(e,t=""){return this.fetch("PUT",t,e)},post(e,t=""){return this.fetch("POST",t,e)},patch(e,t=""){return this.fetch("PATCH",t,e)},head(e=""){return this.fetch("HEAD",e)},opts(e=""){return this.fetch("OPTIONS",e)},body(e){return{...this,_options:{...this._options,body:e}}},json(e,t){const r=ks(this._options.headers);return this.content(t||Ps(r)&&r||Fw).body(JSON.stringify(e))}};function Ce(e="",t={}){return{...Ww,_url:e,_options:t}}Ce.default=Ce;Ce.options=zw;Ce.errorType=Bw;Ce.polyfills=Hw;Ce.WretchError=Yu;function pe(){sessionStorage.removeItem(Ua),ze(ye.CLEAR_CACHE,{})}function Ts(){var r;return(r=(document.documentElement.getAttribute("lang")??"en").split("-")[0])==null?void 0:r.toLocaleLowerCase()}function Vw(e){const t=xe("api2",e.environment),r=w=>async(k,T)=>{let H=sessionStorage.getItem(Ua);H||(H=Date.now().toString(),sessionStorage.setItem(Ua,H));const ee={...T,headers:{...T.headers,"Cache-Timestamp":H}};return w(k,ee)},n=(w=!0)=>k=>async(T,H)=>{let ee=null;if(ee=await zt(w),!ee){if(w)throw new Error("No access token available");return k(T,H)}const Ae={...H,headers:{...H.headers,...ee?{Authorization:`Bearer ${ee}`}:{}}};return k(T,Ae)},a=w=>(k,T)=>{if(T.headers.Authorization)return w(k,T);const H=localStorage.getItem("__anon_id"),ee=btoa(`${H}:`),Ae={...T,headers:{...T.headers,Authorization:`Basic ${ee}`}};return w(k,Ae)},i=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(),Is(),$s({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]),o=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(!1),a,Is(),$s({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]);async function c(){return i.get("/entitlements").json()}async function l(w){const k=await i.get("/entitlements").json();return k==null?void 0:k.find(T=>T.id===w)}async function f(w){return i.get(`/entitlements/${w}/access`).json()}async function u(){return i.get("/contracts").json()}async function s(w){const k=await i.get("/contracts").json();return k==null?void 0:k.find(T=>T.id===w)}async function d(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),i.get("/subscriptions").json()}async function h(){return i.get("/bills").json()}async function m(w){const k=await i.get("/bills").json();return k==null?void 0:k.find(T=>T.id===w)}async function S(){return i.get("/transactions").json()}async function g(w){const k=await i.get("/transactions").json();return k==null?void 0:k.find(T=>T.id===w)}async function $(w,k){const T=await i.url(`/user-metadata/${w}`).put(k).json();return ze(ye.USER_ATTRIBUTE_CHANGED,{}),pe(),T}async function P(w){const k=await i.url(`/user-metadata/${w}`).delete().res();return pe(),k.ok}async function b(w){return(await i.url(`/user-metadata/${w}`).get().json())[w]}async function v(){return await i.url("/user-metadata").get().json()}async function I(){return await i.url("/tags").get().json()}async function O(w){const k=await i.url(`/tags/${w}`).delete().res();return pe(),k.ok}async function _(w){const k=await i.url("/tags").post(w).res();return ze(ye.USER_ATTRIBUTE_CHANGED,{}),pe(),k.ok}async function C(w){return(await o.url("/tallies").get().json())[w]}async function M(){return await o.url("/tallies").get().json()}async function F(w){const k=await o.url(`/tallies/${w}`).delete().res();return pe(),k.ok}async function G(w,k){return await o.url(`/tallies/${w}/push`).post(k).json()}async function L(w){return await i.url(`/products/${w}`).get().json()}async function N(){return await zt(!1)?await i.url("/profile").get().json():null}async function z(w){const k=await i.url("/profile").patch(w).res();return pe(),k.ok}async function R(){return await i.url("/payment-issues").get().json()}async function B(){return(await i.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function V(){return(await i.url("/profile/unlink-spotify").post().res()).ok}async function Te(w){const k=await zt(!1);if(!k)throw new Error("No access token available");const T=new URL(`${xe("spotify-oas",e.environment)}/sesamy-callback`);T.searchParams.set("access_token",k),T.searchParams.set("state",w),window.location.href=T.toString()}async function p(w){const k=await i.url(`/products/${w}/auto-onboard`).post().json();return k.length&&pe(),k}async function y(w,k=3600){const{shortlink:T}=await Ce(Cw).post({url:w,ttl:k}).json();return T}async function E(w){const k=await zt(!1);let T;const H=w.language||Ts();switch(w.target){case"account":T=new URL(`${xe("account",e.environment)}/${H}/subscriptions/${e.clientId}`);break;case"consume":T=new URL(`${xe("consume",e.environment)}/${H}/@${e.clientId}/${w.sku}`),w.episodeId?T.href+=`/${w.episodeId}`:T.href+="/listen";break;default:throw new Error("Invalid target")}return T.searchParams.set("sesamy-redirect-url",w.redirectUrl||window.location.href),k&&(T.hash=`#access_token=${k}`),w.shorten?y(T.href,w.ttl):T.href}async function U(w){return(await o.url("/checkouts").post({language:Ts(),...w,vendorId:e.clientId})).json()}async function x(w,k){return(await o.url(`/checkouts/${w}`).patch(k)).json()}async function D(w){return(await o.url(`/checkouts/${w}`).get()).json()}async function W(){const w=await zt(!1),k=new URL(`${xe("account",e.environment)}/subscriptions/${e.clientId}`);w&&(k.hash=`#access_token=${w}`),window.location.href=k.toString()}return{createCheckout:U,updateCheckout:x,getCheckout:D,getEntitlements:c,getEntitlement:l,getEntitlementAccess:f,getContracts:u,getContract:s,getProfile:N,updateProfile:z,getSubscriptions:d,getBills:h,getBill:m,setUserMetadata:$,deleteUserMetadata:P,getUserMetadata:b,listUserMetadata:v,getTags:I,deleteTag:O,setTag:_,getTally:C,getTallies:M,deleteTally:F,pushTally:G,getTransactions:S,getTransaction:g,getProduct:L,getPaymentIssues:R,autoOnboardProduct:p,isSpotifyLinked:B,unlinkSpotify:V,linkSpotify:Te,generateLink:E,openHostedAccountPage:W}}const Ju="@sesamy/sesamy-js",Pi="1.13.2";function Es(e,t,r,n,a){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:a;return e===a?r:e}var kr="undefined",Os="object",xa=function(){},Xu="any",qu="*",rt="__",Gr=typeof process<"u"?process:{};Gr.env&&Gr.env.NODE_ENV;var Z=typeof document<"u";Gr.versions!=null&&Gr.versions.node!=null;typeof Deno<"u"&&Deno.core;Z&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Qu(e,t){return t.charAt(0)[e]()+t.slice(1)}var Zw=Qu.bind(null,"toUpperCase"),Yw=Qu.bind(null,"toLowerCase");function Jw(e){return el(e)?Zw("null"):typeof e=="object"?eb(e):Object.prototype.toString.call(e).slice(8,-1)}function Wr(e,t){t===void 0&&(t=!0);var r=Jw(e);return t?Yw(r):r}function ur(e,t){return typeof t===e}var re=ur.bind(null,"function"),Me=ur.bind(null,"string"),mt=ur.bind(null,"undefined"),Xw=ur.bind(null,"boolean");ur.bind(null,"symbol");function el(e){return e===null}function qw(e){return Wr(e)==="number"&&!isNaN(e)}function tl(e){return Wr(e)==="array"}function te(e){if(!Qw(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Qw(e){return e&&(typeof e=="object"||e!==null)}function eb(e){return re(e.constructor)?e.constructor.name:null}function tb(e){return e instanceof Error||Me(e.message)&&e.constructor&&qw(e.constructor.stackTraceLimit)}function rl(e,t){if(typeof t!="object"||el(t))return!1;if(t instanceof e)return!0;var r=Wr(new e(""));if(tb(t))for(;t;){if(Wr(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}rl.bind(null,TypeError);rl.bind(null,SyntaxError);function on(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?rb(e,t):r}function rb(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function sn(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}sn(on,"form");sn(on,"button");sn(on,"input");sn(on,"select");function nb(e){return e?tl(e)?e:[e]:[]}function _s(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function ab(){if(Z){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function ib(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function ob(e){return function(t){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(t);){var i=_s(r[1]),o=_s(r[2]);i.substring(i.length-2)==="[]"?(n[i=i.substring(0,i.length-2)]||(n[i]=[])).push(o):n[i]=o===""||o}for(var c in n){var l=c.split("[");l.length>1&&(sb(n,l.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),n[c]),delete n[c])}return n}(function(t){return Z&&window.location.search.substring(1)}())}function sb(e,t,r){for(var n=t.length-1,a=0;a<n;++a){var i=t[a];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[n]]=r}function cn(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],a=15&r;e+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}function cb(e,t){var r,n,a,i=null,o=0,c=function(){o=new Date,i=null,a=e.apply(r,n)};return function(){var l=new Date;o||(o=l);var f=t-(l-o);return r=this,n=arguments,f<=0?(clearTimeout(i),i=null,o=l,a=e.apply(r,n)):i||(i=setTimeout(c,f)),a}}var Xt="global",Pt=rt+"global"+rt,Tt=typeof self===Os&&self.self===self&&self||typeof global===Os&&global.global===global&&global||void 0;function nt(e){return Tt[Pt][e]}function at(e,t){return Tt[Pt][e]=t}function jt(e){delete Tt[Pt][e]}function At(e,t,r){var n;try{if(Ti(e)){var a=window[e];n=a[t].bind(a)}}catch{}return n||r}Tt[Pt]||(Tt[Pt]={});var Pr={};function Ti(e){if(typeof Pr[e]!==kr)return Pr[e];try{var t=window[e];t.setItem(kr,kr),t.removeItem(kr)}catch{return Pr[e]=!1}return Pr[e]=!0}function A(){return A=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},A.apply(this,arguments)}var Ne="function",Re="undefined",ub="@@redux/"+Math.random().toString(36),Rs=function(){return typeof Symbol===Ne&&Symbol.observable||"@@observable"}(),Tr=" != "+Ne;function nl(e,t,r){var n;if(typeof t===Ne&&typeof r===Re&&(r=t,t=void 0),typeof r!==Re){if(typeof r!==Ne)throw new Error("enhancer"+Tr);return r(nl)(e,t)}if(typeof e!==Ne)throw new Error("reducer"+Tr);var a=e,i=t,o=[],c=o,l=!1;function f(){c===o&&(c=o.slice())}function u(){return i}function s(h){if(typeof h!==Ne)throw new Error("Listener"+Tr);var m=!0;return f(),c.push(h),function(){if(m){m=!1,f();var S=c.indexOf(h);c.splice(S,1)}}}function d(h){if(!te(h))throw new Error("Act != obj");if(typeof h.type===Re)throw new Error("ActType "+Re);if(l)throw new Error("Dispatch in reducer");try{l=!0,i=a(i,h)}finally{l=!1}for(var m=o=c,S=0;S<m.length;S++)(0,m[S])();return h}return d({type:"@@redux/INIT"}),(n={dispatch:d,subscribe:s,getState:u,replaceReducer:function(h){if(typeof h!==Ne)throw new Error("next reducer"+Tr);a=h,d({type:"@@redux/INIT"})}})[Rs]=function(){var h,m=s;return(h={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function g(){S.next&&S.next(u())}return g(),{unsubscribe:m(g)}}})[Rs]=function(){return this},h},n}function lb(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+Re}function Et(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,r){return function(){return t(r.apply(void 0,[].slice.call(arguments)))}})}function fb(){var e=arguments;return function(t){return function(r,n,a){var i,o=t(r,n,a),c=o.dispatch,l={getState:o.getState,dispatch:function(f){return c(f)}};return i=[].slice.call(e).map(function(f){return f(l)}),A({},o,{dispatch:c=Et.apply(void 0,i)(o.dispatch)})}}}var Fe=rt+"anon_id",et=rt+"user_id",yt=rt+"user_traits",Ue="userId",gt="anonymousId",xr=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],Na=["name","EVENTS","config","loaded"],j=xr.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),Cs=/^utm_/,js=/^an_prop_/,As=/^an_trait_/;function db(e){var t=e.storage.setItem;return function(r){return function(n){return function(a){if(a.type===j.bootstrap){var i=a.params,o=a.user,c=a.persistedUser,l=a.initialUser,f=c.userId===o.userId;c.anonymousId!==o.anonymousId&&t(Fe,o.anonymousId),f||t(et,o.userId),l.traits&&t(yt,A({},f&&c.traits?c.traits:{},l.traits));var u=Object.keys(a.params);if(u.length){var s=i.an_uid,d=i.an_event,h=u.reduce(function(m,S){if(S.match(Cs)||S.match(/^(d|g)clid/)){var g=S.replace(Cs,"");m.campaign[g==="campaign"?"name":g]=i[S]}return S.match(js)&&(m.props[S.replace(js,"")]=i[S]),S.match(As)&&(m.traits[S.replace(As,"")]=i[S]),m},{campaign:{},props:{},traits:{}});r.dispatch(A({type:j.params,raw:i},h,s?{userId:s}:{})),s&&setTimeout(function(){return e.identify(s,h.traits)},0),d&&setTimeout(function(){return e.track(d,h.props)},0),Object.keys(h.campaign).length&&r.dispatch({type:j.campaign,campaign:h.campaign})}}return n(a)}}}}function hb(e){return function(t,r){if(t===void 0&&(t={}),r===void 0&&(r={}),r.type===j.setItemEnd){if(r.key===Fe)return A({},t,{anonymousId:r.value});if(r.key===et)return A({},t,{userId:r.value})}switch(r.type){case j.identify:return Object.assign({},t,{userId:r.userId,traits:A({},t.traits,r.traits)});case j.reset:return[et,Fe,yt].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function Ls(e){return{userId:e.getItem(et),anonymousId:e.getItem(Fe),traits:e.getItem(yt)}}var Da=function(e){return rt+"TEMP"+rt+e};function vb(e){var t=e.storage,r=t.setItem,n=t.removeItem,a=t.getItem;return function(i){return function(o){return function(c){var l=c.userId,f=c.traits,u=c.options;if(c.type===j.reset&&([et,yt,Fe].forEach(function(h){n(h)}),[Ue,gt,"traits"].forEach(function(h){jt(Da(h))})),c.type===j.identify){a(Fe)||r(Fe,cn());var s=a(et),d=a(yt)||{};s&&s!==l&&i.dispatch({type:j.userIdChanged,old:{userId:s,traits:d},new:{userId:l,traits:f},options:u}),l&&r(et,l),f&&r(yt,A({},d,f))}return o(c)}}}}var Wt={};function Us(e,t){Wt[e]&&re(Wt[e])&&(Wt[e](t),delete Wt[e])}function al(e,t,r){return new Promise(function(n,a){return t()?n(e):r<1?a(A({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return al(e,t,r-10).then(n,a)})})}function pb(e){return{abort:e}}function il(e,t,r){var n={},a=t(),i=e.getState(),o=i.plugins,c=i.queue,l=i.user;if(!i.context.offline&&c&&c.actions&&c.actions.length){var f=c.actions.reduce(function(s,d,h){return o[d.plugin].loaded?(s.process.push(d),s.processIndex.push(h)):(s.requeue.push(d),s.requeueIndex.push(h)),s},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(s){var d=c.actions[s],h=d.plugin,m=d.payload.type,S=a[h][m];if(S&&re(S)){var g,$=function(v,I){return v===void 0&&(v={}),I===void 0&&(I={}),[Ue,gt].reduce(function(O,_){return v.hasOwnProperty(_)&&I[_]&&I[_]!==v[_]&&(O[_]=I[_]),O},v)}(d.payload,l),P=n[$.meta.rid];if(!P&&(g=S({payload:$,config:o[h].config,instance:r,abort:pb}))&&te(g)&&g.abort)return void(n[$.meta.rid]=!0);if(!P){var b=m+":"+h;e.dispatch(A({},$,{type:b,_:{called:b,from:"queueDrain"}}))}}});var u=c.actions.filter(function(s,d){return!~f.processIndex.indexOf(d)});c.actions=u}}}var ia=function(e){var t=e.data,r=e.action,n=e.instance,a=e.state,i=e.allPlugins,o=e.allMatches,c=e.store,l=e.EVENTS;try{var f=a.plugins,u=a.context,s=r.type,d=s.match(wt),h=t.exact.map(function(g){return g.pluginName});d&&(h=o.during.map(function(g){return g.pluginName}));var m=function(g,$){return function(P,b,v){var I=b.config,O=b.name,_=O+"."+P.type;v&&(_=v.event);var C=P.type.match(wt)?function(M,F,G,L,N){return function(z,R){var B=L?L.name:M,V=R&&rr(R)?R:G;if(L&&(!(V=R&&rr(R)?R:[M]).includes(M)||V.length!==1))throw new Error("Method "+F+" can only abort "+M+" plugin. "+JSON.stringify(V)+" input valid");return A({},N,{abort:{reason:z,plugins:V,caller:F,_:B}})}}(O,_,$,v,P):function(M,F){return function(){throw new Error(M.type+" action not cancellable. Remove abort in "+F)}}(P,_);return{payload:mb(P),instance:g,config:I||{},abort:C}}}(n,h),S=t.exact.reduce(function(g,$){var P=$.pluginName,b=$.methodName,v=!1;return b.match(/^initialize/)||b.match(/^reset/)||(v=!f[P].loaded),u.offline&&b.match(/^(page|track|identify)/)&&(v=!0),g[""+P]=v,g},{});return Promise.resolve(t.exact.reduce(function(g,$,P){try{var b=$.pluginName;return Promise.resolve(g).then(function(v){function I(){return Promise.resolve(v)}var O=function(){if(t.namespaced&&t.namespaced[b])return Promise.resolve(t.namespaced[b].reduce(function(_,C,M){try{return Promise.resolve(_).then(function(F){return C.method&&re(C.method)?(function(z,R){var B=Hs(z);if(B&&B.name===R){var V=Hs(B.method);throw new Error([R+" plugin is calling method "+z,"Plugins cant call self","Use "+B.method+" "+(V?"or "+V.method:"")+" in "+R+" plugin insteadof "+z].join(`
|
|
5
|
+
CAUSE: `+h.stack,v.response=b,v.url=s,b.type==="opaque")throw v;return b.text().then(I=>{var O;if(v.message=I,a.errorType==="json"||((O=b.headers.get("Content-Type"))===null||O===void 0?void 0:O.split(";")[0])==="application/json")try{v.json=JSON.parse(I)}catch{}throw v.text=I,v.status=b.status,v})}return b}),S=b=>b.catch(v=>{const I=v.hasOwnProperty(ft),O=I?v[ft]:v,_=(O==null?void 0:O.status)&&f.get(O.status)||f.get(O==null?void 0:O.name)||I&&f.has(ft)&&f.get(ft);if(_)return _(O,e);const C=f.get(Zu);if(C)return C(O,e);throw O}),g=b=>v=>S(b?m.then(I=>I&&I[b]()).then(I=>v?v(I):I):m.then(I=>v?v(I):I)),$={_wretchReq:e,_fetchReq:d,_sharedState:t,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(b,v){return f.set(b,v),this},badRequest(b){return this.error(400,b)},unauthorized(b){return this.error(401,b)},forbidden(b){return this.error(403,b)},notFound(b){return this.error(404,b)},timeout(b){return this.error(408,b)},internalError(b){return this.error(500,b)},fetchError(b){return this.error(ft,b)}},P=l.reduce((b,v)=>({...b,...typeof v.resolver=="function"?v.resolver(b):v.resolver}),$);return o.reduce((b,v)=>v(b,e),P)},Ww={_url:"",_options:{},_config:kt,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(e){return{...this,_addons:[...this._addons,e],...e.wretch}},errorType(e){return{...this,_config:{...this._config,errorType:e}}},polyfills(e,t=!1){return{...this,_config:{...this._config,polyfills:t?e:Qe(this._config.polyfills,e)}}},url(e,t=!1){if(t)return{...this,_url:e};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+e+"?"+r[1]:this._url+e}},options(e,t=!1){return{...this,_options:t?e:Qe(this._options,e)}},headers(e){const t=e?Array.isArray(e)?Object.fromEntries(e):"entries"in e?Object.fromEntries(e.entries()):e:{};return{...this,_options:Qe(this._options,{headers:t})}},accept(e){return this.headers({Accept:e})},content(e){return this.headers({[Vu]:e})},auth(e){return this.headers({Authorization:e})},catcher(e,t){const r=new Map(this._catchers);return r.set(e,t),{...this,_catchers:r}},catcherFallback(e){return this.catcher(Zu,e)},resolve(e,t=!1){return{...this,_resolvers:t?[e]:[...this._resolvers,e]}},defer(e,t=!1){return{...this,_deferred:t?[e]:[...this._deferred,e]}},middlewares(e,t=!1){return{...this,_middlewares:t?e:[...this._middlewares,...e]}},fetch(e=this._options.method,t="",r=null){let n=this.url(t).options({method:e});const a=ks(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||Ps(a));return n=r?o?n.json(r,a):n.body(r):n,Gw(n._deferred.reduce((c,l)=>l(c,c._url,c._options),n))},get(e=""){return this.fetch("GET",e)},delete(e=""){return this.fetch("DELETE",e)},put(e,t=""){return this.fetch("PUT",t,e)},post(e,t=""){return this.fetch("POST",t,e)},patch(e,t=""){return this.fetch("PATCH",t,e)},head(e=""){return this.fetch("HEAD",e)},opts(e=""){return this.fetch("OPTIONS",e)},body(e){return{...this,_options:{...this._options,body:e}}},json(e,t){const r=ks(this._options.headers);return this.content(t||Ps(r)&&r||Fw).body(JSON.stringify(e))}};function Ce(e="",t={}){return{...Ww,_url:e,_options:t}}Ce.default=Ce;Ce.options=zw;Ce.errorType=Bw;Ce.polyfills=Hw;Ce.WretchError=Yu;function pe(){sessionStorage.removeItem(Ua),ze(ye.CLEAR_CACHE,{})}function Ts(){var r;return(r=(document.documentElement.getAttribute("lang")??"en").split("-")[0])==null?void 0:r.toLocaleLowerCase()}function Vw(e){const t=xe("api2",e.environment),r=w=>async(k,T)=>{let H=sessionStorage.getItem(Ua);H||(H=Date.now().toString(),sessionStorage.setItem(Ua,H));const ee={...T,headers:{...T.headers,"Cache-Timestamp":H}};return w(k,ee)},n=(w=!0)=>k=>async(T,H)=>{let ee=null;if(ee=await zt(w),!ee){if(w)throw new Error("No access token available");return k(T,H)}const Ae={...H,headers:{...H.headers,...ee?{Authorization:`Bearer ${ee}`}:{}}};return k(T,Ae)},a=w=>(k,T)=>{if(T.headers.Authorization)return w(k,T);const H=localStorage.getItem("__anon_id"),ee=btoa(`${H}:`),Ae={...T,headers:{...T.headers,Authorization:`Basic ${ee}`}};return w(k,Ae)},i=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(),Is(),$s({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]),o=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(!1),a,Is(),$s({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]);async function c(){return i.get("/entitlements").json()}async function l(w){const k=await i.get("/entitlements").json();return k==null?void 0:k.find(T=>T.id===w)}async function f(w){return i.get(`/entitlements/${w}/access`).json()}async function u(){return i.get("/contracts").json()}async function s(w){const k=await i.get("/contracts").json();return k==null?void 0:k.find(T=>T.id===w)}async function d(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),i.get("/subscriptions").json()}async function h(){return i.get("/bills").json()}async function m(w){const k=await i.get("/bills").json();return k==null?void 0:k.find(T=>T.id===w)}async function S(){return i.get("/transactions").json()}async function g(w){const k=await i.get("/transactions").json();return k==null?void 0:k.find(T=>T.id===w)}async function $(w,k){const T=await i.url(`/user-metadata/${w}`).put(k).json();return ze(ye.USER_ATTRIBUTE_CHANGED,{}),pe(),T}async function P(w){const k=await i.url(`/user-metadata/${w}`).delete().res();return pe(),k.ok}async function b(w){return(await i.url(`/user-metadata/${w}`).get().json())[w]}async function v(){return await i.url("/user-metadata").get().json()}async function I(){return await i.url("/tags").get().json()}async function O(w){const k=await i.url(`/tags/${w}`).delete().res();return pe(),k.ok}async function _(w){const k=await i.url("/tags").post(w).res();return ze(ye.USER_ATTRIBUTE_CHANGED,{}),pe(),k.ok}async function C(w){return(await o.url("/tallies").get().json())[w]}async function M(){return await o.url("/tallies").get().json()}async function F(w){const k=await o.url(`/tallies/${w}`).delete().res();return pe(),k.ok}async function G(w,k){return await o.url(`/tallies/${w}/push`).post(k).json()}async function L(w){return await i.url(`/products/${w}`).get().json()}async function N(){return await zt(!1)?await i.url("/profile").get().json():null}async function z(w){const k=await i.url("/profile").patch(w).res();return pe(),k.ok}async function R(){return await i.url("/payment-issues").get().json()}async function B(){return(await i.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function V(){return(await i.url("/profile/unlink-spotify").post().res()).ok}async function Te(w){const k=await zt(!1);if(!k)throw new Error("No access token available");const T=new URL(`${xe("spotify-oas",e.environment)}/sesamy-callback`);T.searchParams.set("access_token",k),T.searchParams.set("state",w),window.location.href=T.toString()}async function p(w){const k=await i.url(`/products/${w}/auto-onboard`).post().json();return k.length&&pe(),k}async function y(w,k=3600){const{shortlink:T}=await Ce(Cw).post({url:w,ttl:k}).json();return T}async function E(w){const k=await zt(!1);let T;const H=w.language||Ts();switch(w.target){case"account":T=new URL(`${xe("account",e.environment)}/${H}/subscriptions/${e.clientId}`);break;case"consume":T=new URL(`${xe("consume",e.environment)}/${H}/@${e.clientId}/${w.sku}`),w.episodeId?T.href+=`/${w.episodeId}`:T.href+="/listen";break;default:throw new Error("Invalid target")}return T.searchParams.set("sesamy-redirect-url",w.redirectUrl||window.location.href),k&&(T.hash=`#access_token=${k}`),w.shorten?y(T.href,w.ttl):T.href}async function U(w){return(await o.url("/checkouts").post({language:Ts(),...w,vendorId:e.clientId})).json()}async function x(w,k){return(await o.url(`/checkouts/${w}`).patch(k)).json()}async function D(w){return(await o.url(`/checkouts/${w}`).get()).json()}async function W(){const w=await zt(!1),k=new URL(`${xe("account",e.environment)}/subscriptions/${e.clientId}`);w&&(k.hash=`#access_token=${w}`),window.location.href=k.toString()}return{createCheckout:U,updateCheckout:x,getCheckout:D,getEntitlements:c,getEntitlement:l,getEntitlementAccess:f,getContracts:u,getContract:s,getProfile:N,updateProfile:z,getSubscriptions:d,getBills:h,getBill:m,setUserMetadata:$,deleteUserMetadata:P,getUserMetadata:b,listUserMetadata:v,getTags:I,deleteTag:O,setTag:_,getTally:C,getTallies:M,deleteTally:F,pushTally:G,getTransactions:S,getTransaction:g,getProduct:L,getPaymentIssues:R,autoOnboardProduct:p,isSpotifyLinked:B,unlinkSpotify:V,linkSpotify:Te,generateLink:E,openHostedAccountPage:W}}const Ju="@sesamy/sesamy-js",Pi="1.19.1";function Es(e,t,r,n,a){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:a;return e===a?r:e}var kr="undefined",Os="object",xa=function(){},Xu="any",qu="*",rt="__",Gr=typeof process<"u"?process:{};Gr.env&&Gr.env.NODE_ENV;var Z=typeof document<"u";Gr.versions!=null&&Gr.versions.node!=null;typeof Deno<"u"&&Deno.core;Z&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Qu(e,t){return t.charAt(0)[e]()+t.slice(1)}var Zw=Qu.bind(null,"toUpperCase"),Yw=Qu.bind(null,"toLowerCase");function Jw(e){return el(e)?Zw("null"):typeof e=="object"?eb(e):Object.prototype.toString.call(e).slice(8,-1)}function Wr(e,t){t===void 0&&(t=!0);var r=Jw(e);return t?Yw(r):r}function ur(e,t){return typeof t===e}var re=ur.bind(null,"function"),Me=ur.bind(null,"string"),mt=ur.bind(null,"undefined"),Xw=ur.bind(null,"boolean");ur.bind(null,"symbol");function el(e){return e===null}function qw(e){return Wr(e)==="number"&&!isNaN(e)}function tl(e){return Wr(e)==="array"}function te(e){if(!Qw(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Qw(e){return e&&(typeof e=="object"||e!==null)}function eb(e){return re(e.constructor)?e.constructor.name:null}function tb(e){return e instanceof Error||Me(e.message)&&e.constructor&&qw(e.constructor.stackTraceLimit)}function rl(e,t){if(typeof t!="object"||el(t))return!1;if(t instanceof e)return!0;var r=Wr(new e(""));if(tb(t))for(;t;){if(Wr(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}rl.bind(null,TypeError);rl.bind(null,SyntaxError);function on(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?rb(e,t):r}function rb(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function sn(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}sn(on,"form");sn(on,"button");sn(on,"input");sn(on,"select");function nb(e){return e?tl(e)?e:[e]:[]}function _s(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function ab(){if(Z){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function ib(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function ob(e){return function(t){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(t);){var i=_s(r[1]),o=_s(r[2]);i.substring(i.length-2)==="[]"?(n[i=i.substring(0,i.length-2)]||(n[i]=[])).push(o):n[i]=o===""||o}for(var c in n){var l=c.split("[");l.length>1&&(sb(n,l.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),n[c]),delete n[c])}return n}(function(t){return Z&&window.location.search.substring(1)}())}function sb(e,t,r){for(var n=t.length-1,a=0;a<n;++a){var i=t[a];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[n]]=r}function cn(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],a=15&r;e+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}function cb(e,t){var r,n,a,i=null,o=0,c=function(){o=new Date,i=null,a=e.apply(r,n)};return function(){var l=new Date;o||(o=l);var f=t-(l-o);return r=this,n=arguments,f<=0?(clearTimeout(i),i=null,o=l,a=e.apply(r,n)):i||(i=setTimeout(c,f)),a}}var Xt="global",Pt=rt+"global"+rt,Tt=typeof self===Os&&self.self===self&&self||typeof global===Os&&global.global===global&&global||void 0;function nt(e){return Tt[Pt][e]}function at(e,t){return Tt[Pt][e]=t}function jt(e){delete Tt[Pt][e]}function At(e,t,r){var n;try{if(Ti(e)){var a=window[e];n=a[t].bind(a)}}catch{}return n||r}Tt[Pt]||(Tt[Pt]={});var Pr={};function Ti(e){if(typeof Pr[e]!==kr)return Pr[e];try{var t=window[e];t.setItem(kr,kr),t.removeItem(kr)}catch{return Pr[e]=!1}return Pr[e]=!0}function A(){return A=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},A.apply(this,arguments)}var Ne="function",Re="undefined",ub="@@redux/"+Math.random().toString(36),Rs=function(){return typeof Symbol===Ne&&Symbol.observable||"@@observable"}(),Tr=" != "+Ne;function nl(e,t,r){var n;if(typeof t===Ne&&typeof r===Re&&(r=t,t=void 0),typeof r!==Re){if(typeof r!==Ne)throw new Error("enhancer"+Tr);return r(nl)(e,t)}if(typeof e!==Ne)throw new Error("reducer"+Tr);var a=e,i=t,o=[],c=o,l=!1;function f(){c===o&&(c=o.slice())}function u(){return i}function s(h){if(typeof h!==Ne)throw new Error("Listener"+Tr);var m=!0;return f(),c.push(h),function(){if(m){m=!1,f();var S=c.indexOf(h);c.splice(S,1)}}}function d(h){if(!te(h))throw new Error("Act != obj");if(typeof h.type===Re)throw new Error("ActType "+Re);if(l)throw new Error("Dispatch in reducer");try{l=!0,i=a(i,h)}finally{l=!1}for(var m=o=c,S=0;S<m.length;S++)(0,m[S])();return h}return d({type:"@@redux/INIT"}),(n={dispatch:d,subscribe:s,getState:u,replaceReducer:function(h){if(typeof h!==Ne)throw new Error("next reducer"+Tr);a=h,d({type:"@@redux/INIT"})}})[Rs]=function(){var h,m=s;return(h={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function g(){S.next&&S.next(u())}return g(),{unsubscribe:m(g)}}})[Rs]=function(){return this},h},n}function lb(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+Re}function Et(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,r){return function(){return t(r.apply(void 0,[].slice.call(arguments)))}})}function fb(){var e=arguments;return function(t){return function(r,n,a){var i,o=t(r,n,a),c=o.dispatch,l={getState:o.getState,dispatch:function(f){return c(f)}};return i=[].slice.call(e).map(function(f){return f(l)}),A({},o,{dispatch:c=Et.apply(void 0,i)(o.dispatch)})}}}var Fe=rt+"anon_id",et=rt+"user_id",yt=rt+"user_traits",Ue="userId",gt="anonymousId",xr=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],Na=["name","EVENTS","config","loaded"],j=xr.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),Cs=/^utm_/,js=/^an_prop_/,As=/^an_trait_/;function db(e){var t=e.storage.setItem;return function(r){return function(n){return function(a){if(a.type===j.bootstrap){var i=a.params,o=a.user,c=a.persistedUser,l=a.initialUser,f=c.userId===o.userId;c.anonymousId!==o.anonymousId&&t(Fe,o.anonymousId),f||t(et,o.userId),l.traits&&t(yt,A({},f&&c.traits?c.traits:{},l.traits));var u=Object.keys(a.params);if(u.length){var s=i.an_uid,d=i.an_event,h=u.reduce(function(m,S){if(S.match(Cs)||S.match(/^(d|g)clid/)){var g=S.replace(Cs,"");m.campaign[g==="campaign"?"name":g]=i[S]}return S.match(js)&&(m.props[S.replace(js,"")]=i[S]),S.match(As)&&(m.traits[S.replace(As,"")]=i[S]),m},{campaign:{},props:{},traits:{}});r.dispatch(A({type:j.params,raw:i},h,s?{userId:s}:{})),s&&setTimeout(function(){return e.identify(s,h.traits)},0),d&&setTimeout(function(){return e.track(d,h.props)},0),Object.keys(h.campaign).length&&r.dispatch({type:j.campaign,campaign:h.campaign})}}return n(a)}}}}function hb(e){return function(t,r){if(t===void 0&&(t={}),r===void 0&&(r={}),r.type===j.setItemEnd){if(r.key===Fe)return A({},t,{anonymousId:r.value});if(r.key===et)return A({},t,{userId:r.value})}switch(r.type){case j.identify:return Object.assign({},t,{userId:r.userId,traits:A({},t.traits,r.traits)});case j.reset:return[et,Fe,yt].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function Ls(e){return{userId:e.getItem(et),anonymousId:e.getItem(Fe),traits:e.getItem(yt)}}var Da=function(e){return rt+"TEMP"+rt+e};function vb(e){var t=e.storage,r=t.setItem,n=t.removeItem,a=t.getItem;return function(i){return function(o){return function(c){var l=c.userId,f=c.traits,u=c.options;if(c.type===j.reset&&([et,yt,Fe].forEach(function(h){n(h)}),[Ue,gt,"traits"].forEach(function(h){jt(Da(h))})),c.type===j.identify){a(Fe)||r(Fe,cn());var s=a(et),d=a(yt)||{};s&&s!==l&&i.dispatch({type:j.userIdChanged,old:{userId:s,traits:d},new:{userId:l,traits:f},options:u}),l&&r(et,l),f&&r(yt,A({},d,f))}return o(c)}}}}var Wt={};function Us(e,t){Wt[e]&&re(Wt[e])&&(Wt[e](t),delete Wt[e])}function al(e,t,r){return new Promise(function(n,a){return t()?n(e):r<1?a(A({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return al(e,t,r-10).then(n,a)})})}function pb(e){return{abort:e}}function il(e,t,r){var n={},a=t(),i=e.getState(),o=i.plugins,c=i.queue,l=i.user;if(!i.context.offline&&c&&c.actions&&c.actions.length){var f=c.actions.reduce(function(s,d,h){return o[d.plugin].loaded?(s.process.push(d),s.processIndex.push(h)):(s.requeue.push(d),s.requeueIndex.push(h)),s},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(s){var d=c.actions[s],h=d.plugin,m=d.payload.type,S=a[h][m];if(S&&re(S)){var g,$=function(v,I){return v===void 0&&(v={}),I===void 0&&(I={}),[Ue,gt].reduce(function(O,_){return v.hasOwnProperty(_)&&I[_]&&I[_]!==v[_]&&(O[_]=I[_]),O},v)}(d.payload,l),P=n[$.meta.rid];if(!P&&(g=S({payload:$,config:o[h].config,instance:r,abort:pb}))&&te(g)&&g.abort)return void(n[$.meta.rid]=!0);if(!P){var b=m+":"+h;e.dispatch(A({},$,{type:b,_:{called:b,from:"queueDrain"}}))}}});var u=c.actions.filter(function(s,d){return!~f.processIndex.indexOf(d)});c.actions=u}}}var ia=function(e){var t=e.data,r=e.action,n=e.instance,a=e.state,i=e.allPlugins,o=e.allMatches,c=e.store,l=e.EVENTS;try{var f=a.plugins,u=a.context,s=r.type,d=s.match(wt),h=t.exact.map(function(g){return g.pluginName});d&&(h=o.during.map(function(g){return g.pluginName}));var m=function(g,$){return function(P,b,v){var I=b.config,O=b.name,_=O+"."+P.type;v&&(_=v.event);var C=P.type.match(wt)?function(M,F,G,L,N){return function(z,R){var B=L?L.name:M,V=R&&rr(R)?R:G;if(L&&(!(V=R&&rr(R)?R:[M]).includes(M)||V.length!==1))throw new Error("Method "+F+" can only abort "+M+" plugin. "+JSON.stringify(V)+" input valid");return A({},N,{abort:{reason:z,plugins:V,caller:F,_:B}})}}(O,_,$,v,P):function(M,F){return function(){throw new Error(M.type+" action not cancellable. Remove abort in "+F)}}(P,_);return{payload:mb(P),instance:g,config:I||{},abort:C}}}(n,h),S=t.exact.reduce(function(g,$){var P=$.pluginName,b=$.methodName,v=!1;return b.match(/^initialize/)||b.match(/^reset/)||(v=!f[P].loaded),u.offline&&b.match(/^(page|track|identify)/)&&(v=!0),g[""+P]=v,g},{});return Promise.resolve(t.exact.reduce(function(g,$,P){try{var b=$.pluginName;return Promise.resolve(g).then(function(v){function I(){return Promise.resolve(v)}var O=function(){if(t.namespaced&&t.namespaced[b])return Promise.resolve(t.namespaced[b].reduce(function(_,C,M){try{return Promise.resolve(_).then(function(F){return C.method&&re(C.method)?(function(z,R){var B=Hs(z);if(B&&B.name===R){var V=Hs(B.method);throw new Error([R+" plugin is calling method "+z,"Plugins cant call self","Use "+B.method+" "+(V?"or "+V.method:"")+" in "+R+" plugin insteadof "+z].join(`
|
|
6
6
|
`))}}(C.methodName,C.pluginName),Promise.resolve(C.method({payload:F,instance:n,abort:(G=F,L=b,N=C.pluginName,function(z,R){return A({},G,{abort:{reason:z,plugins:R||[L],caller:s,from:N||L}})}),config:Ds(C.pluginName,f,i),plugins:f})).then(function(z){var R=te(z)?z:{};return Promise.resolve(A({},F,R))})):F;var G,L,N})}catch(F){return Promise.reject(F)}},Promise.resolve(r))).then(function(_){v[b]=_});v[b]=r}();return O&&O.then?O.then(I):I()})}catch(v){return Promise.reject(v)}},Promise.resolve({}))).then(function(g){return Promise.resolve(t.exact.reduce(function($,P,b){try{var v=t.exact.length===b+1,I=P.pluginName,O=i[I];return Promise.resolve($).then(function(_){var C=g[I]?g[I]:{};if(d&&(C=_),sa(C,I))return oa({data:C,method:s,instance:n,pluginName:I,store:c}),Promise.resolve(_);if(sa(_,I))return v&&oa({data:_,method:s,instance:n,store:c}),Promise.resolve(_);if(S.hasOwnProperty(I)&&S[I]===!0)return c.dispatch({type:"queue",plugin:I,payload:C,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(_);var M=m(g[I],i[I]);return Promise.resolve(O[s]({abort:M.abort,payload:C,instance:n,config:Ds(I,f,i),plugins:f})).then(function(F){var G=te(F)?F:{},L=A({},_,G),N=g[I];if(sa(N,I))oa({data:N,method:s,instance:n,pluginName:I,store:c});else{var z=s+":"+I;(z.match(/:/g)||[]).length<2&&!s.match(xs)&&!s.match(Ns)&&n.dispatch(A({},d?L:C,{type:z,_:{called:z,from:"submethod"}}))}return Promise.resolve(L)})})}catch(_){return Promise.reject(_)}},Promise.resolve(r))).then(function($){if(!(s.match(wt)||s.match(/^registerPlugin/)||s.match(Ns)||s.match(xs)||s.match(/^params/)||s.match(/^userIdChanged/))){if(l.plugins.includes(s),$._&&$._.originalAction===s)return $;var P=A({},$,{_:{originalAction:$.type,called:$.type,from:"engineEnd"}});ol($,t.exact.length)&&!s.match(/End$/)&&(P=A({},P,{type:$.type+"Aborted"})),c.dispatch(P)}return $})})}catch(g){return Promise.reject(g)}},wt=/Start$/,xs=/^bootstrap/,Ns=/^ready/;function oa(e){var t=e.pluginName,r=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(A({},e.data,{type:r,_:{called:r,from:"abort"}}))}function Ds(e,t,r){var n=t[e]||r[e];return n&&n.config?n.config:{}}function Ms(e,t){return t.reduce(function(r,n){return n[e]?r.concat({methodName:e,pluginName:n.name,method:n[e]}):r},[])}function Fs(e,t){var r=e.replace(wt,""),n=t?":"+t:"";return[""+e+n,""+r+n,r+"End"+n]}function sa(e,t){var r=e.abort;return!!r&&(r===!0||zs(r,t)||r&&zs(r.plugins,t))}function ol(e,t){var r=e.abort;if(!r)return!1;if(r===!0||Me(r))return!0;var n=r.plugins;return rr(r)&&r.length===t||rr(n)&&n.length===t}function rr(e){return Array.isArray(e)}function zs(e,t){return!(!e||!rr(e))&&e.includes(t)}function Hs(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function mb(e){return Object.keys(e).reduce(function(t,r){return r==="type"||(t[r]=te(e[r])?Object.assign({},e[r]):e[r]),t},{})}function gb(e,t,r){var n={};return function(a){return function(i){return function(o){try{var c,l=function(v){return c?v:i(s)},f=o.type,u=o.plugins,s=o;if(o.abort)return Promise.resolve(i(o));if(f===j.enablePlugin&&a.dispatch({type:j.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:o.meta}),f===j.disablePlugin&&setTimeout(function(){return Us(o.meta.rid,{payload:o})},0),f===j.initializeEnd){var d=t(),h=Object.keys(d),m=h.filter(function(v){return u.includes(v)}).map(function(v){return d[v]}),S=[],g=[],$=o.disabled,P=m.map(function(v){var I=v.loaded,O=v.name,_=v.config;return al(v,function(){return I({config:_})},1e4).then(function(C){return n[O]||(a.dispatch({type:j.pluginReadyType(O),name:O,events:Object.keys(v).filter(function(M){return!Na.includes(M)})}),n[O]=!0),S=S.concat(O),v}).catch(function(C){if(C instanceof Error)throw new Error(C);return g=g.concat(C.name),C})});Promise.all(P).then(function(v){var I={plugins:S,failed:g,disabled:$};setTimeout(function(){h.length===P.length+$.length&&a.dispatch(A({},{type:j.ready},I))},0)})}var b=function(){if(f!==j.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return il(a,t,e)},0),Promise.resolve(function(v,I,O,_,C){try{var M=re(I)?I():I,F=v.type,G=F.replace(wt,"");if(v._&&v._.called)return Promise.resolve(v);var L=O.getState(),N=(B=M,(V=L.plugins)===void 0&&(V={}),(Te=v.options)===void 0&&(Te={}),Object.keys(B).filter(function(p){var y=Te.plugins||{};return Xw(y[p])?y[p]:y.all!==!1&&(!V[p]||V[p].enabled!==!1)}).map(function(p){return B[p]}));F===j.initializeStart&&v.fromEnable&&(N=Object.keys(L.plugins).filter(function(p){var y=L.plugins[p];return v.plugins.includes(p)&&!y.initialized}).map(function(p){return M[p]}));var z=N.map(function(p){return p.name}),R=function(p,y,E){var U=Fs(p).map(function(x){return Ms(x,y)});return y.reduce(function(x,D){var W=D.name,w=Fs(p,W).map(function(ee){return Ms(ee,y)}),k=w[0],T=w[1],H=w[2];return k.length&&(x.beforeNS[W]=k),T.length&&(x.duringNS[W]=T),H.length&&(x.afterNS[W]=H),x},{before:U[0],beforeNS:{},during:U[1],duringNS:{},after:U[2],afterNS:{}})}(F,N);return Promise.resolve(ia({action:v,data:{exact:R.before,namespaced:R.beforeNS},state:L,allPlugins:M,allMatches:R,instance:O,store:_,EVENTS:C})).then(function(p){function y(){var x=function(){if(F.match(wt))return Promise.resolve(ia({action:A({},E,{type:G+"End"}),data:{exact:R.after,namespaced:R.afterNS},state:L,allPlugins:M,allMatches:R,instance:O,store:_,EVENTS:C})).then(function(D){D.meta&&D.meta.hasCallback&&Us(D.meta.rid,{payload:D})})}();return x&&x.then?x.then(function(){return p}):p}if(ol(p,z.length))return p;var E,U=function(){if(F!==G)return Promise.resolve(ia({action:A({},p,{type:G}),data:{exact:R.during,namespaced:R.duringNS},state:L,allPlugins:M,allMatches:R,instance:O,store:_,EVENTS:C})).then(function(x){E=x});E=p}();return U&&U.then?U.then(y):y()})}catch(p){return Promise.reject(p)}var B,V,Te}(o,t,e,a,r)).then(function(v){return c=1,i(v)})}();return Promise.resolve(b&&b.then?b.then(l):l(b))}catch(v){return Promise.reject(v)}}}}}function yb(e){return function(t){return function(r){return function(n){var a=n.type,i=n.key,o=n.value,c=n.options;if(a===j.setItem||a===j.removeItem){if(n.abort)return r(n);a===j.setItem?e.setItem(i,o,c):e.removeItem(i,c)}return r(n)}}}}var wb=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,r){e[r]=e[r].concat(t)},this.removeMiddleware=function(t,r){var n=e[r].findIndex(function(a){return a===t});n!==-1&&(e[r]=[].concat(e[r].slice(0,n),e[r].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(r){return function(n){return function(a){var i={getState:r.getState,dispatch:function(c){return r.dispatch(c)}},o=e[t].map(function(c){return c(i)});return Et.apply(void 0,o)(n)(a)}}}}};function bb(e){return function(t,r){t===void 0&&(t={});var n={};if(r.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(r.type)){var a=Bs(r.type,"registerPlugin"),i=e()[a];if(!i||!a)return t;var o=r.enabled,c=i.config;return n[a]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:c}),config:c},A({},t,n)}if(/^initialize:([^:]*)$/.test(r.type)){var l=Bs(r.type,j.initialize),f=e()[l];return f&&l?(n[l]=A({},t[l],{initialized:!0,loaded:!!f.loaded({config:f.config})}),A({},t,n)):t}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=A({},t[r.name],{loaded:!0}),A({},t,n);switch(r.type){case j.disablePlugin:return A({},t,Ks(r.plugins,!1,t));case j.enablePlugin:return A({},t,Ks(r.plugins,!0,t));default:return t}}}function Bs(e,t){return e.substring(t.length+1,e.length)}function Ks(e,t,r){return e.reduce(function(n,a){return n[a]=A({},r[a],{enabled:t}),n},r)}function sl(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var Sb={last:{},history:[]};function Ib(e,t){e===void 0&&(e=Sb);var r=t.options,n=t.meta;if(t.type===j.track){var a=sl(A({event:t.event,properties:t.properties},Object.keys(r).length&&{options:r},{meta:n}));return A({},e,{last:a,history:e.history.concat(a)})}return e}var $b={actions:[]};function kb(e,t){e===void 0&&(e=$b);var r=t.payload;switch(t.type){case"queue":var n;return n=r&&r.type&&r.type===j.identify?[t].concat(e.actions):e.actions.concat(t),A({},e,{actions:n});case"dequeue":return[];default:return e}}var cl=/#.*$/;function Pb(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(cl,""):"")}var ul,ll,fl,dl,Tb=function(e){if(e===void 0&&(e={}),!Z)return e;var t=document,r=t.title,n=t.referrer,a=window,i=a.location,o=a.innerWidth,c=a.innerHeight,l=i.hash,f=i.search,u=function(d){var h=function(){if(Z){for(var m,S=document.getElementsByTagName("link"),g=0;m=S[g];g++)if(m.getAttribute("rel")==="canonical")return m.getAttribute("href")}}();return h?h.match(/\?/)?h:h+d:window.location.href.replace(cl,"")}(f),s={title:r,url:u,path:Pb(u),hash:l,search:f,width:o,height:c};return n&&n!==""&&(s.referrer=n),A({},s,e)},Eb={last:{},history:[]};function Ob(e,t){e===void 0&&(e=Eb);var r=t.options;if(t.type===j.page){var n=sl(A({properties:t.properties,meta:t.meta},Object.keys(r).length&&{options:r}));return A({},e,{last:n,history:e.history.concat(n)})}return e}ul=function(){if(!Z)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),ll=Z?document.referrer:null,fl=ab(),dl=ib();var Gs={initialized:!1,sessionId:cn(),app:null,version:null,debug:!1,offline:!!Z&&!navigator.onLine,os:{name:ul},userAgent:Z?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.13"},timezone:dl,locale:fl,campaign:{},referrer:ll};function _b(e,t){e===void 0&&(e=Gs);var r=e.initialized,n=t.campaign;switch(t.type){case j.campaign:return A({},e,{campaign:n});case j.offline:return A({},e,{offline:!0});case j.online:return A({},e,{offline:!1});default:return r?e:A({},Gs,e,{initialized:!0})}}var Rb=["plugins","reducers","storage"];function Cb(e,t,r){if(Z){var n=window[(r?"add":"remove")+"EventListener"];e.split(" ").forEach(function(a){n(a,t)})}}function jb(e){var t=Cb.bind(null,"online offline",function(r){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(r){return t(!1)}}function hl(){return at("analytics",[]),function(e){return function(t,r,n){var a=e(t,r,n),i=a.dispatch;return Object.assign(a,{dispatch:function(o){return Tt[Pt].analytics.push(o.action||o),i(o)}})}}}function Ws(e){return function(){return Et(Et.apply(null,arguments),hl())}}function ca(e){return e?tl(e)?e:[e]:[]}function Vs(e,t,r){e===void 0&&(e={});var n,a,i=cn();return t&&(Wt[i]=(n=t,a=function(o){for(var c,l=o||Array.prototype.slice.call(arguments),f=0;f<l.length;f++)if(re(l[f])){c=l[f];break}return c}(r),function(o){a&&a(o),n(o)})),A({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function Ab(e){e===void 0&&(e={});var t=e.reducers||{},r=e.initialUser||{},n=(e.plugins||[]).reduce(function(p,y){if(re(y))return p.middlewares=p.middlewares.concat(y),p;if(y.NAMESPACE&&(y.name=y.NAMESPACE),!y.name)throw new Error("https://lytics.dev/errors/1");y.config||(y.config={});var E=y.EVENTS?Object.keys(y.EVENTS).map(function(D){return y.EVENTS[D]}):[];p.pluginEnabled[y.name]=!(y.enabled===!1||y.config.enabled===!1),delete y.enabled,y.methods&&(p.methods[y.name]=Object.keys(y.methods).reduce(function(D,W){var w;return D[W]=(w=y.methods[W],function(){for(var k=Array.prototype.slice.call(arguments),T=new Array(w.length),H=0;H<k.length;H++)T[H]=k[H];return T[T.length]=I,w.apply({instance:I},T)}),D},{}),delete y.methods);var U=Object.keys(y).concat(E),x=new Set(p.events.concat(U));if(p.events=Array.from(x),p.pluginsArray=p.pluginsArray.concat(y),p.plugins[y.name])throw new Error(y.name+"AlreadyLoaded");return p.plugins[y.name]=y,p.plugins[y.name].loaded||(p.plugins[y.name].loaded=function(){return!0}),p},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),a=e.storage?e.storage:{getItem:nt,setItem:at,removeItem:jt},i=function(p){return function(y,E,U){return E.getState("user")[y]||(U&&te(U)&&U[y]?U[y]:Ls(p)[y]||nt(Da(y))||null)}}(a),o=n.plugins,c=n.events.filter(function(p){return!Na.includes(p)}).sort(),l=new Set(c.concat(xr).filter(function(p){return!Na.includes(p)})),f=Array.from(l).sort(),u=function(){return o},s=new wb,d=s.addMiddleware,h=s.removeMiddleware,m=s.dynamicMiddlewares,S=function(){throw new Error("Abort disabled inListener")},g=ob(),$=Ls(a),P=A({},$,r,g.an_uid?{userId:g.an_uid}:{},g.an_aid?{anonymousId:g.an_aid}:{});P.anonymousId||(P.anonymousId=cn());var b=A({enable:function(p,y){return new Promise(function(E){R.dispatch({type:j.enablePlugin,plugins:ca(p),_:{originalAction:j.enablePlugin}},E,[y])})},disable:function(p,y){return new Promise(function(E){R.dispatch({type:j.disablePlugin,plugins:ca(p),_:{originalAction:j.disablePlugin}},E,[y])})}},n.methods),v=!1,I={identify:function(p,y,E,U){try{var x=Me(p)?p:null,D=te(p)?p:y,W=E||{},w=I.user();at(Da(Ue),x);var k=x||D.userId||i(Ue,I,D);return Promise.resolve(new Promise(function(T){R.dispatch(A({type:j.identifyStart,userId:k,traits:D||{},options:W,anonymousId:w.anonymousId},w.id&&w.id!==x&&{previousId:w.id}),T,[y,E,U])}))}catch(T){return Promise.reject(T)}},track:function(p,y,E,U){try{var x=te(p)?p.event:p;if(!x||!Me(x))throw new Error("EventMissing");var D=te(p)?p:y||{},W=te(E)?E:{};return Promise.resolve(new Promise(function(w){R.dispatch({type:j.trackStart,event:x,properties:D,options:W,userId:i(Ue,I,y),anonymousId:i(gt,I,y)},w,[y,E,U])}))}catch(w){return Promise.reject(w)}},page:function(p,y,E){try{var U=te(p)?p:{},x=te(y)?y:{};return Promise.resolve(new Promise(function(D){R.dispatch({type:j.pageStart,properties:Tb(U),options:x,userId:i(Ue,I,U),anonymousId:i(gt,I,U)},D,[p,y,E])}))}catch(D){return Promise.reject(D)}},user:function(p){if(p===Ue||p==="id")return i(Ue,I);if(p===gt||p==="anonId")return i(gt,I);var y=I.getState("user");return p?Es(y,p):y},reset:function(p){return new Promise(function(y){R.dispatch({type:j.resetStart},y,p)})},ready:function(p){return v&&p({plugins:b,instance:I}),I.on(j.ready,function(y){p(y),v=!0})},on:function(p,y){if(!p||!re(y))return!1;if(p===j.bootstrap)throw new Error(".on disabled for "+p);var E=/Start$|Start:/;if(p==="*"){var U=function(w){return function(k){return function(T){return T.type.match(E)&&y({payload:T,instance:I,plugins:o}),k(T)}}},x=function(w){return function(k){return function(T){return T.type.match(E)||y({payload:T,instance:I,plugins:o}),k(T)}}};return d(U,Er),d(x,Or),function(){h(U,Er),h(x,Or)}}var D=p.match(E)?Er:Or,W=function(w){return function(k){return function(T){return T.type===p&&y({payload:T,instance:I,plugins:o,abort:S}),k(T)}}};return d(W,D),function(){return h(W,D)}},once:function(p,y){if(!p||!re(y))return!1;if(p===j.bootstrap)throw new Error(".once disabled for "+p);var E=I.on(p,function(U){y({payload:U.payload,instance:I,plugins:o,abort:S}),E()});return E},getState:function(p){var y=R.getState();return p?Es(y,p):Object.assign({},y)},dispatch:function(p){var y=Me(p)?{type:p}:p;if(xr.includes(y.type))throw new Error("reserved action "+y.type);var E=A({},y,{_:A({originalAction:y.type},p._||{})});R.dispatch(E)},enablePlugin:b.enable,disablePlugin:b.disable,plugins:b,storage:{getItem:a.getItem,setItem:function(p,y,E){R.dispatch({type:j.setItemStart,key:p,value:y,options:E})},removeItem:function(p,y){R.dispatch({type:j.removeItemStart,key:p,options:y})}},setAnonymousId:function(p,y){I.storage.setItem(Fe,p,y)},events:{core:xr,plugins:c}},O=n.middlewares.concat([function(p){return function(y){return function(E){return E.meta||(E.meta=Vs()),y(E)}}},m(Er),gb(I,u,{all:f,plugins:c}),yb(a),db(I),vb(I),m(Or)]),_={context:_b,user:hb(a),page:Ob,track:Ib,plugins:bb(u),queue:kb},C=Et,M=Et;if(Z&&e.debug){var F=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;F&&(C=F({trace:!0,traceLimit:25})),M=function(){return arguments.length===0?hl():te(typeof arguments[0])?Ws():Ws().apply(null,arguments)}}var G,L=function(p){return Object.keys(p).reduce(function(y,E){return Rb.includes(E)||(y[E]=p[E]),y},{})}(e),N=n.pluginsArray.reduce(function(p,y){var E=y.name,U=y.config,x=y.loaded,D=n.pluginEnabled[E];return p[E]={enabled:D,initialized:!!D&&!y.initialize,loaded:!!x({config:U}),config:U},p},{}),z={context:L,user:P,plugins:N},R=nl(function(p){for(var y=Object.keys(p),E={},U=0;U<y.length;U++){var x=y[U];typeof p[x]===Ne&&(E[x]=p[x])}var D,W=Object.keys(E);try{(function(w){Object.keys(w).forEach(function(k){var T=w[k];if(typeof T(void 0,{type:"@@redux/INIT"})===Re||typeof T(void 0,{type:ub})===Re)throw new Error("reducer "+k+" "+Re)})})(E)}catch(w){D=w}return function(w,k){if(w===void 0&&(w={}),D)throw D;for(var T=!1,H={},ee=0;ee<W.length;ee++){var Ae=W[ee],Ai=w[Ae],fn=(0,E[Ae])(Ai,k);if(typeof fn===Re){var El=lb(Ae,k);throw new Error(El)}H[Ae]=fn,T=T||fn!==Ai}return T?H:w}}(A({},_,t)),z,M(C(fb.apply(void 0,O))));R.dispatch=(G=R.dispatch,function(p,y,E){var U=A({},p,{meta:Vs(p.meta,y,ca(E))});return G.apply(null,[U])});var B=Object.keys(o);R.dispatch({type:j.bootstrap,plugins:B,config:L,params:g,user:P,initialUser:r,persistedUser:$});var V=B.filter(function(p){return n.pluginEnabled[p]}),Te=B.filter(function(p){return!n.pluginEnabled[p]});return R.dispatch({type:j.registerPlugins,plugins:B,enabled:n.pluginEnabled}),n.pluginsArray.map(function(p,y){var E=p.bootstrap,U=p.config,x=p.name;E&&re(E)&&E({instance:I,config:U,payload:p}),R.dispatch({type:j.registerPluginType(x),name:x,enabled:n.pluginEnabled[x],plugin:p}),n.pluginsArray.length===y+1&&R.dispatch({type:j.initializeStart,plugins:V,disabled:Te})}),jb(function(p){R.dispatch({type:p?j.offline:j.online})}),function(p,y,E){setInterval(function(){return il(p,y,E)},3e3)}(R,u,I),I}var Er="before",Or="after",qt="cookie",Ye=ml(),vl=un,Lb=un;function pl(e){return Ye?un(e,"",-1):jt(e)}function ml(){if(Ye!==void 0)return Ye;var e="cookiecookie";try{un(e,e),Ye=document.cookie.indexOf(e)!==-1,pl(e)}catch{Ye=!1}return Ye}function un(e,t,r,n,a,i){if(typeof window<"u"){var o=arguments.length>1;return Ye===!1&&(o?at(e,t):nt(e)),o?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(a?"; domain="+a:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Qt="localStorage",Ub=Ti.bind(null,"localStorage");At("localStorage","getItem",nt);At("localStorage","setItem",at);At("localStorage","removeItem",jt);var er="sessionStorage",xb=Ti.bind(null,"sessionStorage");At("sessionStorage","getItem",nt);At("sessionStorage","setItem",at);At("sessionStorage","removeItem",jt);function bt(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(te(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var Nb=Ub(),Db=xb(),Mb=ml();function gl(e,t){if(e){var r=Ei(t),n=!Ci(r),a=Oi(r)?bt(localStorage.getItem(e)):void 0;if(n&&!mt(a))return a;var i=_i(r)?bt(vl(e)):void 0;if(n&&i)return i;var o=Ri(r)?bt(sessionStorage.getItem(e)):void 0;if(n&&o)return o;var c=nt(e);return n?c:{localStorage:a,sessionStorage:o,cookie:i,global:c}}}function Fb(e,t,r){if(e&&!mt(t)){var n={},a=Ei(r),i=JSON.stringify(t),o=!Ci(a);return Oi(a)&&(n[Qt]=_r(Qt,t,bt(localStorage.getItem(e))),localStorage.setItem(e,i),o)?n[Qt]:_i(a)&&(n[qt]=_r(qt,t,bt(vl(e))),Lb(e,i),o)?n[qt]:Ri(a)&&(n[er]=_r(er,t,bt(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),o)?n[er]:(n[Xt]=_r(Xt,t,nt(e)),at(e,t),o?n[Xt]:n)}}function zb(e,t){if(e){var r=Ei(t),n=gl(e,qu),a={};return!mt(n.localStorage)&&Oi(r)&&(localStorage.removeItem(e),a[Qt]=n.localStorage),!mt(n.cookie)&&_i(r)&&(pl(e),a[qt]=n.cookie),!mt(n.sessionStorage)&&Ri(r)&&(sessionStorage.removeItem(e),a[er]=n.sessionStorage),!mt(n.global)&&ln(r,Xt)&&(jt(e),a[Xt]=n.global),a}}function Ei(e){return e?Me(e)?e:e.storage:Xu}function Oi(e){return Nb&&ln(e,Qt)}function _i(e){return Mb&&ln(e,qt)}function Ri(e){return Db&&ln(e,er)}function Ci(e){return e===qu||e==="all"}function ln(e,t){return e===Xu||e===t||Ci(e)}function _r(e,t,r){return{location:e,current:t,previous:r}}var Hb={setItem:Fb,getItem:gl,removeItem:zb};function Bb(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Zs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ys(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Zs(Object(r),!0).forEach(function(n){Bb(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Zs(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Kb(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:Hb};return Ab(Ys(Ys({},t),e))}function Gb(e,t){t=t||{};var r,n,a=[],i=t.max||1/0;function o(){clearInterval(r),e(a.splice(0,i)),c()}function c(){r=setInterval(o,t.interval||1e4)}return c(),{flush:o,push:function(l){return n=a.push(l),n>=i&&o(),n},size:function(){return a.length},end:function(l){l&&o(),clearInterval(r)}}}function Wb(e){if(typeof window>"u")return;const{addEventListener:t,history:r,location:n}=window;let a=n.pathname;t("popstate",()=>e(n.pathname)),["push","replace"].map(i=>{const o=`${i}State`;if(o!=="pushState"&&o!=="replaceState")return;const c=r[o];r[o]=function(...l){var s;const f=((s=l[2])==null?void 0:s.toString())||"",u=Zb(f);return a!==u&&(a=u,setTimeout(()=>e(f),0)),c.apply(r,l)}})}function Vb(e,t){const r=e.indexOf(t);return r>-1?e.slice(0,r):e}function Zb(e){return["#","?"].forEach(t=>e=Vb(e,t)),e}function Yb(){Wb(()=>{_e.page()})}function Jb(e){if(e===void 0&&(e={}),!Z)return xa;var t=Xs(),r=Ma(),n=Js(),a=Rr(n,t),i=Rr(r,t),o=[],c=[],l=[],f=n,u=a,s=i,d=Object.keys(e);if(!d.length)return xa;var h=d.map(function(S){return Number(S)}),m=cb(function(){var S=Xs(),g=function(L,N){return N.map(function(z){return z===100?L-5:L*(z/100)})}(S,h),$=Ma(),P=Js(),b=Rr(P,S),v=Rr($,S);if(u=b>u?b:u,s=v<s?v:s,!(o.length>=h.length)){var I=f===P,O="up";I?O="initial":f<=P&&(O="down");var _=g,C=h;(O==="up"||I)&&(_=g.slice().reverse(),C=h.slice().reverse());var M=C.reduce(function(L,N,z){var R=_[z];return l.includes(N)&&P<=R&&(l=l.filter(function(B){return B!==N}),L.singleFunction=N),O==="down"&&!o.includes(N)&&P>=R&&N>i?(c.push(N),L.callbacks=L.callbacks.concat(N),L):O==="up"&&!o.includes(N)&&P<=R&&N<=b?(L.foundFunc=[N],L):(I&&P>=R&&L.foundFunc.length===0&&(L.foundFunc=[N]),!c.includes(N)&&P>=R&&(c.push(N),L.singleFunction?l.push(N):L.singleFunction=N),L)},{foundFunc:[],singleFunction:null,callbacks:[],direction:O});if(f=P,O==="down"&&M.callbacks&&M.callbacks.forEach(function(L){re(e[L])&&(e[L]({trigger:L,direction:O,scrollMin:s,scrollMax:u,range:[s,u]}),o.push(L))}),M.singleFunction){var F=M.singleFunction,G=M.direction;re(e[F])&&e[F]({trigger:F,direction:G,scrollMin:s,scrollMax:u,range:[s,u]}),o.push(F)}}},500);return window.addEventListener("scroll",m),function(){return window.removeEventListener("scroll",m)}}function Ma(){return Z?document.body.scrollTop||document.documentElement.scrollTop:0}function Xb(){return Z?window.innerHeight||document.documentElement.clientHeight:0}function Js(){return Math.round(Ma()+Xb())}function Xs(){if(!Z)return 0;var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)}function Rr(e,t){return Math.round(e/t*100)}var qs="EventListener";function qb(e){return function(t,r,n,a){var i=n||xa,o=a||!1;if(!Z)return i;var c=Vr(r),l=Vr(t,!0);if(!l.length)throw new Error("noElements");if(!c.length)throw new Error("noEvent");var f=[];return function u(s){s&&(f=[]);for(var d=s?"add"+qs:"remove"+qs,h=0;h<l.length;h++){var m=l[h];f[h]=s?o&&o.once?Qb(i):i:f[h]||i;for(var S=0;S<c.length;S++)m[d]?m["on"+c[S]]=s?f[h]:null:m[d](c[S],f[h],o)}return u.bind(null,!s)}(e)}}function Vr(e,t){if(Me(e))return t?Vr(document.querySelectorAll(e)):(r=e).split(r.indexOf(",")>-1?",":" ").map(function(o){return o.trim()});var r;if(NodeList.prototype.isPrototypeOf(e)){for(var n=[],a=e.length>>>0;a--;)n[a]=e[a];return n}var i=nb(e);return t?i.map(function(o){return Me(o)?Vr(o,!0):o}).flat():i}function Qb(e,t){var r;return function(){return e&&(r=e.apply(this,arguments),e=null),r}}var ua=qb("Event");function yl(e,t){return Z&&re(window[e])?(r=window[e],n=t,(a=window)===void 0&&(a=null),re(r)?function(){r.apply(a,arguments),n.apply(a,arguments)}:n):window[e]=t;var r,n,a}yl.bind(null,"onerror");yl.bind(null,"onload");var wl=typeof window>"u",Qs="hidden";function eS(e){if(wl)return!1;var t=tS(),r="".concat(t.replace(/[H|h]idden/,""),"visibilitychange"),n=function(){return e(!!document[t])},a=function(){return document.addEventListener(r,n)};return a(),function(){return document.removeEventListener(r,n),a}}function tS(){var e=["webkit","moz","ms","o"];return wl||Qs in document?Qs:e.reduce(function(t,r){var n=r+"Hidden";return!t&&n in document?n:t},null)}var rS=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function nS(e,t){t===void 0&&(t={});var r=function(o,c){var l=this,f=!1;return function(u){f||(o.call(l,u),f=!0,setTimeout(function(){return f=!1},c))}}(e,t.throttle||1e4),n=[];function a(){var o=eS(function(c){c||r({type:"tabVisible"})});return n=[o].concat(rS.map(function(c){return ua(document,c,r)})).concat(ua(window,"load",r)).concat(ua(window,"scroll",r,{capture:!0,passive:!0})),i}function i(){n.map(function(o){return o()})}return a(),function(){return i(),a}}function aS(e){var t,r,n=e.onIdle,a=e.onWakeUp,i=e.onHeartbeat,o=e.timeout,c=o===void 0?1e4:o,l=e.throttle,f=l===void 0?2e3:l,u=!1,s=!1,d=new Date,h=function(){return clearTimeout(t)};function m(g){h(),i&&!u&&i(Ht(d),g),a&&u&&(u=!1,a(Ht(r),g),d=new Date),t=setTimeout(function(){u=!0,n&&(r=new Date,n(Ht(d),g))},c)}var S=nS(m,{throttle:f});return{disable:function(){s=!0,u=!1,h();var g=S();return function(){return s=!1,d=new Date,m({type:"load"}),g()}},getStatus:function(){return{isIdle:u,isDisabled:s,active:u?0:Ht(d,s),idle:u?Ht(r,s):0}}}}function Ht(e,t){return t?0:Math.round((new Date-e)/1e3)}const ec=5e3;class iS{constructor(t){oe(this,"element");oe(this,"isInViewport",!1);oe(this,"isAwake",!1);oe(this,"isFlushing");oe(this,"observer");oe(this,"lastEventAt",Date.now());oe(this,"registeredView",!1);oe(this,"viewCallback");oe(this,"activeDurationCallback");oe(this,"idleDurationCallback");oe(this,"scrollCallback");this.element=t.element,this.viewCallback=t.viewCallback,this.activeDurationCallback=t.activeDurationCallback,this.idleDurationCallback=t.idleDurationCallback,this.scrollCallback=t.scrollCallback,this.observer=new IntersectionObserver(r=>{r.forEach(n=>{this.handleInViewPort(n.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),aS({onIdle:r=>this.handleAwake(!1,r),onWakeUp:r=>this.handleAwake(!0,r),timeout:ec}),Jb({25:this.handleScroll.bind(this),50:this.handleScroll.bind(this),75:this.handleScroll.bind(this),90:this.handleScroll.bind(this),100:this.handleScroll.bind(this)})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake)}handleInViewPort(t){t?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=t}handleAwake(t,r=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=t,this.lastEventAt=t?Date.now()-r*ec:Date.now(),this.isInViewport&&this.trackAwake(t,r)}handleScroll(t){this.scrollCallback&&this.scrollCallback(t)}handleVisibilityChange(){this.isAwake=!1;const t=Math.round((Date.now()-this.lastEventAt)/1e3);t>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,t))}trackAwake(t,r){!t&&this.activeDurationCallback&&this.activeDurationCallback(r,this.isFlushing,this.lastEventAt),t&&this.idleDurationCallback&&this.idleDurationCallback(r,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const tc="sesamy_session_id";function oS(){let e=sessionStorage.getItem(tc);return e||(e=Math.random().toString(36).slice(2,9),sessionStorage.setItem(tc,e)),e}let bl=!1,Fa,rc,Zr;function sS({clientId:e,enabled:t=!0,environment:r}){if(Fa=e,rc=t,Zr=`${xe("logs",r)}/events`,!rc)return;Yb();const n=new iS({element:document.body,viewCallback:()=>{_e.page()},activeDurationCallback:(a,i,o)=>{_e.track("activeDuration",{duration:a,durationStart:o,flushing:i})},idleDurationCallback:(a,i,o)=>{_e.track("idleDuration",{duration:a,durationStart:o,flushing:i})},scrollCallback:a=>{_e.track("scroll",{scroll:a.scrollMax})}});lS(document.body,()=>{n.flush()}),fS(document.body,()=>{n.handleVisibilityChange()}),window.addEventListener(ye.AUTHENTICATED,async a=>{const i=a;await _e.identify(i.detail.sub)}),window.addEventListener(ye.LOGOUT,async()=>{await _e.track("logout",{}),ji.flush(),await _e.reset()})}function Sl(e){return JSON.stringify(e.map(t=>({...t,clientId:Fa,requestId:Math.random().toString(36).slice(2,9),sessionId:oS(),timestamp:new Date().toISOString(),version:Pi,event:t.event,context:{page:{url:window.location.hostname,path:window.location.pathname,title:document.title,search:window.location.search,referrer:document.referrer},locale:navigator.language,library:Ju,userAgent:navigator.userAgent,clientId:Fa}})))}const ji=Gb(async e=>{if(e.length>0){const t=Sl(e);bl?navigator.sendBeacon(Zr,t):(await fetch(Zr,{method:"POST",body:t,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function la(e){var t;if(e.anonymousId)if((t=e.properties)!=null&&t.flushing){const r={...e};delete r.properties.flushing,navigator.sendBeacon(Zr,Sl([r]))}else ji.push(e)}const _e=Kb({app:Ju,version:Pi,plugins:[{name:"custom-analytics-plugin",page:({payload:e})=>{const{properties:t,anonymousId:r,userId:n,event:a}=e;la({anonymousId:r,userId:n,properties:t,event:a,type:"page"})},track:({payload:e})=>{const{properties:t,anonymousId:r,userId:n,event:a}=e;la({anonymousId:r,userId:n,properties:t,event:a,type:"track"})},identify:({payload:e})=>{const{properties:t,anonymousId:r,userId:n}=e;la({anonymousId:r,userId:n,properties:t,type:"identify"})}}]});function cS(e,t){_e.track(e,t)}function uS(){return bl=!0,ji.flush()}const Il=new Map;function lS(e,t){Il.set(e,t)}window.addEventListener("beforeunload",()=>{Il.forEach((e,t)=>{e.bind(t)()}),uS()});const $l=new Map;function fS(e,t){$l.set(e,t)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&$l.forEach((e,t)=>{e.bind(t)()})});const kl="sesamySignedURLs";function Pl(){const e=sessionStorage.getItem(kl);return e?JSON.parse(e):[]}function dS(e){const t=Pl();t.push(e),sessionStorage.setItem(kl,JSON.stringify(t))}function hS(e){const{createCheckout:t,getCheckout:r,updateCheckout:n,getEntitlement:a,getEntitlements:i,getEntitlementAccess:o,getSubscriptions:c,getContract:l,getContracts:f,getBill:u,getBills:s,getTransaction:d,getTransactions:h,getProfile:m,updateProfile:S,getTags:g,deleteTag:$,setTag:P,getUserMetadata:b,listUserMetadata:v,setUserMetadata:I,deleteUserMetadata:O,getTally:_,getTallies:C,pushTally:M,deleteTally:F,getProduct:G,getPaymentIssues:L,isSpotifyLinked:N,unlinkSpotify:z,linkSpotify:R,autoOnboardProduct:B,openHostedAccountPage:V,generateLink:Te}=Vw(e),p={auth:{getUser:m,isAuthenticated:$i,loginWithRedirect:ki,logout:Ku,setToken:Wu},checkouts:{get:r,create:t,update:n},profile:{get:m,update:S,openHostedAccountPage:V,isSpotifyLinked:N,unlinkSpotify:z},analytics:{track:cS},tags:{list:g,set:P,delete:$},entitlements:{get:a,list:i,access:o,signedLinks:Pl},contracts:{get:l,list:f},bills:{get:u,list:s},userMetadata:{get:b,list:v,set:I,delete:O},tallies:{get:_,list:C,push:M,delete:F},subscriptions:{list:c},transactions:{get:d,list:h},products:{get:G,autoOnboard:B,linkSpotify:R},getVersion:vS,getPaymentIssues:L,generateLink:Te,clearCache:pe};return e.namespace&&(window[e.namespace]=p),p}function vS(){return Pi}async function pS({enabled:e=!1,rules:t}){if(!e)return;const r=await $i(),n=window.location.href;for(const a of t){const i=document.querySelectorAll(a.selector);if(!(a.path&&!new RegExp(a.path).test(n))){for(const o of i)if(!(a.authenticated!==void 0&&a.authenticated!==r))switch(a.transform){case"insert":if(a.contentType==="selector"&&a.content){const c=document.querySelector(a.content);c?o.innerHTML+=c.innerHTML:console.warn(`Source element for selector '${a.content}' not found`)}else if(a.contentType==="url"&&a.content){const c=await nc(a.content);c?o.innerHTML+=c:console.warn(`Failed to fetch content from URL '${a.content}'`)}else a.content&&(o.innerHTML+=a.content);break;case"replace":if(a.contentType==="selector"&&a.content){const c=document.querySelector(a.content);c?o.innerHTML=c.innerHTML:console.warn(`Source element for selector '${a.content}' not found`)}else if(a.contentType==="url"&&a.content){const c=await nc(a.content);c?o.innerHTML=c:console.warn(`Failed to fetch content from URL '${a.content}'`)}else a.content&&(o.innerHTML=a.content);break;case"remove":o.remove();break;default:console.warn(`Unknown transform type: ${a.transform}`)}}}}async function nc(e){try{const t=await fetch(e);return t.ok?await t.text():(console.error(`Failed to fetch content from ${e}: ${t.statusText}`),null)}catch(t){return console.error(`Error fetching content from ${e}:`,t),null}}function mS(){const e=new URLSearchParams(window.location.hash.substring(1)),t=e.get("access_token");if(t){Wu(t);const r=new URL(window.location.href);e.delete("access_token"),r.hash=e.toString(),window.history.replaceState(null,"",r)}}const ac="sesamy-refresh",ic="force-refetch-entitlements";function gS(){const e=new URLSearchParams(window.location.search),t=e.get(ic),r=e.get(ac);if(t!==null||r!==null){const n=new URL(window.location.href);e.delete(ic),e.delete(ac),n.search=e.toString(),pe(),window.history.replaceState(null,"",n)}}function yS(){const e=new URLSearchParams(window.location.search),t=e.get("token"),r=e.get("se");if(!r||!t)return;const n=parseInt(r,10);if(Number.isNaN(n)||n<Date.now())return;dS({url:window.location.href.split("?")[0],token:t,expiresAt:n,publisherContentId:e.get("sp")??void 0});const a=new URL(window.location.href);a.searchParams.delete("ss"),a.searchParams.delete("se"),a.searchParams.delete("sp"),a.searchParams.delete("so"),a.searchParams.delete("token"),window.history.replaceState(null,"",a)}const oc="sesamy-user";async function wS(){const t=new URLSearchParams(window.location.search).get(oc);if(!t)return;const r=await Lw();(r==null?void 0:r.email)!==t&&(pe(),ki({authorizationParams:{email_hint:t,login_hint:t}}));const n=new URL(window.location.href);n.searchParams.delete(oc),window.history.replaceState(null,"",n)}const sc="sesamy-purchase";function bS(){const e=new URLSearchParams(window.location.search),t=e.get(sc);if(t!==null){const r=new URL(window.location.href);e.delete(sc),r.search=e.toString(),ze(ye.PURCHASE,{itemSrc:t}),pe(),window.history.replaceState(null,"",r)}}const cc="sesamy-login";async function SS(){if(!new URLSearchParams(window.location.search).get(cc))return;await $i()||ki();const n=new URL(window.location.href);n.searchParams.delete(cc),window.history.replaceState(null,"",n)}async function Tl(e){sS({clientId:e.clientId,environment:e.environment,...e.analytics}),await Aw({clientId:e.clientId,organization:e.organization,environment:e.environment,...e.auth}),e.transform&&await pS(e.transform);const t=hS({clientId:e.clientId,environment:e.environment,...e.api});return ze(ye.READY,{}),mS(),gS(),yS(),await SS(),await wS(),bS(),t}if(typeof document<"u"){const e=document.getElementById("sesamy-js");if(e!=null&&e.textContent)try{const t=JSON.parse(e.textContent);Tl(t)}catch(t){console.error("Failed to parse config",t)}}exports.init=Tl;
|
package/dist/sesamy-js.iife.js
CHANGED
|
@@ -2,5 +2,5 @@ var sesamyJs=function(Ee){"use strict";var SS=Object.defineProperty;var IS=(Ee,o
|
|
|
2
2
|
`,10)+1,o=a.substring(i)+(n?"//# sourceMappingURL="+n:""),c=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(c)}var Kc,Gc,Wc,ai,Iw=(Kc="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Gc=null,Wc=!1,function(e){return ai=ai||Sw(Kc,Gc,Wc),new Worker(ai,e)});const ii={};let $w=class{constructor(t,r){this.cache=t,this.clientId=r,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(t){var r;const n=new Set(((r=await this.cache.get(this.manifestKey))===null||r===void 0?void 0:r.keys)||[]);n.add(t),await this.cache.set(this.manifestKey,{keys:[...n]})}async remove(t){const r=await this.cache.get(this.manifestKey);if(r){const n=new Set(r.keys);return n.delete(t),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(t){return`@@auth0spajs@@::${t}`}};const kw={memory:()=>new zc().enclosedCache,localstorage:()=>new hw},Vc=e=>kw[e],Zc=e=>{const{openUrl:t,onRedirect:r}=e,n=Te(e,["openUrl","onRedirect"]);return Object.assign(Object.assign({},n),{openUrl:t===!1||t?t:r})},oi=new rw;let Pw=class{constructor(t){let r,n;if(this.userCache=new zc().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await oi.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),t),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),t.authorizationParams)}),typeof window<"u"&&(()=>{if(!Wr())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Wr().subtle===void 0)throw new Error(`
|
|
3
3
|
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
4
4
|
`)})(),t.cache&&t.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),t.cache)n=t.cache;else{if(r=t.cacheLocation||"memory",!Vc(r))throw new Error(`Invalid cache location "${r}"`);n=Vc(r)()}this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:1e4,this.cookieStorage=t.legacySameSiteCookie===!1?It:ww,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(o=>`auth0.${o}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=t.sessionCheckExpiryDays||1;const a=t.useCookiesForTransactions?this.cookieStorage:bw;var i;this.scope=Vr("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new pw(a,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||xc,this.cacheManager=new vw(n,n.allKeys?void 0:new $w(n,this.options.clientId),this.nowProvider),this.domainUrl=(i=this.options.domain,/^https?:\/\//.test(i)?i:`https://${i}`),this.tokenIssuer=((o,c)=>o?o.startsWith("https://")?o:`https://${o}/`:`${c}/`)(this.options.issuer,this.domainUrl),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&r==="memory"&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new Iw)}_url(t){const r=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Uc)));return`${this.domainUrl}${t}&auth0Client=${r}`}_authorizeUrl(t){return this._url(`/authorize?${ni(t)}`)}async _verifyIdToken(t,r,n){const a=await this.nowProvider();return gw({iss:this.tokenIssuer,aud:this.options.clientId,id_token:t,nonce:r,organization:n,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i!="string"?i:parseInt(i,10)||void 0),now:a});var i}_processOrgHint(t){t?this.cookieStorage.save(this.orgHintCookieName,t,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(t,r,n){const a=Mc(ri()),i=Mc(ri()),o=ri(),c=(u=>{const s=new Uint8Array(u);return(d=>{const h={"+":"-","/":"_","=":""};return d.replace(/[+/=]/g,m=>h[m])})(window.btoa(String.fromCharCode(...Array.from(s))))})(await(async u=>await Wr().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(o)),l=((u,s,d,h,m,S,g,$)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),d),{scope:Vr(s,d.scope),response_type:"code",response_mode:$||"query",state:h,nonce:m,redirect_uri:g||u.authorizationParams.redirect_uri,code_challenge:S,code_challenge_method:"S256"}))(this.options,this.scope,t,a,i,c,t.redirect_uri||this.options.authorizationParams.redirect_uri||n,r==null?void 0:r.response_mode),f=this._authorizeUrl(l);return{nonce:i,code_verifier:o,scope:l.scope,audience:l.audience||"default",redirect_uri:l.redirect_uri,state:a,url:f}}async loginWithPopup(t,r){var n;if(t=t||{},!(r=r||{}).popup&&(r.popup=(c=>{const l=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(c,"auth0:authorize:popup",`left=${l},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!r.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const a=await this._prepareAuthorizeUrl(t.authorizationParams||{},{response_mode:"web_message"},window.location.origin);r.popup.location.href=a.url;const i=await(c=>new Promise((l,f)=>{let u;const s=setInterval(()=>{c.popup&&c.popup.closed&&(clearInterval(s),clearTimeout(d),window.removeEventListener("message",u,!1),f(new ow(c.popup)))},1e3),d=setTimeout(()=>{clearInterval(s),f(new iw(c.popup)),window.removeEventListener("message",u,!1)},1e3*(c.timeoutInSeconds||60));u=function(h){if(h.data&&h.data.type==="authorization_response"){if(clearTimeout(d),clearInterval(s),window.removeEventListener("message",u,!1),c.popup.close(),h.data.response.error)return f(ae.fromPayload(h.data.response));l(h.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},r),{timeoutInSeconds:r.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(a.state!==i.state)throw new ae("state_mismatch","Invalid state");const o=((n=t.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:a.audience,scope:a.scope,code_verifier:a.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:a.redirect_uri},{nonceIn:a.nonce,organization:o})}async getUser(){var t;const r=await this._getIdTokenFromCache();return(t=r==null?void 0:r.decodedToken)===null||t===void 0?void 0:t.user}async getIdTokenClaims(){var t;const r=await this._getIdTokenFromCache();return(t=r==null?void 0:r.decodedToken)===null||t===void 0?void 0:t.claims}async loginWithRedirect(t={}){var r;const n=Zc(t),{openUrl:a,fragment:i,appState:o}=n,c=Te(n,["openUrl","fragment","appState"]),l=((r=c.authorizationParams)===null||r===void 0?void 0:r.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(c.authorizationParams||{}),{url:u}=f,s=Te(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},s),{appState:o}),l&&{organization:l}));const d=i?`${u}#${i}`:u;a?await a(d):window.location.assign(d)}async handleRedirectCallback(t=window.location.href){const r=t.split("?").slice(1);if(r.length===0)throw new Error("There are no query params available for parsing.");const{state:n,code:a,error:i,error_description:o}=(s=>{s.indexOf("#")>-1&&(s=s.substring(0,s.indexOf("#")));const d=new URLSearchParams(s);return{state:d.get("state"),code:d.get("code")||void 0,error:d.get("error")||void 0,error_description:d.get("error_description")||void 0}})(r.join("")),c=this.transactionManager.get();if(!c)throw new ae("missing_transaction","Invalid state");if(this.transactionManager.remove(),i)throw new aw(i,o||i,n,c.appState);if(!c.code_verifier||c.state&&c.state!==n)throw new ae("state_mismatch","Invalid state");const l=c.organization,f=c.nonce,u=c.redirect_uri;return await this._requestToken(Object.assign({audience:c.audience,scope:c.scope,code_verifier:c.code_verifier,grant_type:"authorization_code",code:a},u?{redirect_uri:u}:{}),{nonceIn:f,organization:l}),{appState:c.appState}}async checkSession(t){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(t)}catch{}}async getTokenSilently(t={}){var r;const n=Object.assign(Object.assign({cacheMode:"on"},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:Vr(this.scope,(r=t.authorizationParams)===null||r===void 0?void 0:r.scope)})}),a=await((i,o)=>{let c=ii[o];return c||(c=i().finally(()=>{delete ii[o],c=null}),ii[o]=c),c})(()=>this._getTokenSilently(n),`${this.options.clientId}::${n.authorizationParams.audience}::${n.authorizationParams.scope}`);return t.detailedResponse?a:a==null?void 0:a.access_token}async _getTokenSilently(t){const{cacheMode:r}=t,n=Te(t,["cacheMode"]);if(r!=="off"){const a=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId});if(a)return a}if(r!=="cache-only"){if(!await(async(a,i=3)=>{for(let o=0;o<i;o++)if(await a())return!0;return!1})(()=>oi.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new ti;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),r!=="off"){const f=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const a=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n),{id_token:i,access_token:o,oauthTokenScope:c,expires_in:l}=a;return Object.assign(Object.assign({id_token:i,access_token:o},c?{scope:c}:null),{expires_in:l})}finally{await oi.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(t={},r={}){var n;const a=Object.assign(Object.assign({},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:Vr(this.scope,(n=t.authorizationParams)===null||n===void 0?void 0:n.scope)})});return r=Object.assign(Object.assign({},nw),r),await this.loginWithPopup(a,r),(await this.cacheManager.get(new et({scope:a.authorizationParams.scope,audience:a.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(t){t.clientId!==null?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const r=t.logoutParams||{},{federated:n}=r,a=Te(r,["federated"]),i=n?"&federated":"";return this._url(`/v2/logout?${ni(Object.assign({clientId:t.clientId},a))}`)+i}async logout(t={}){const r=Zc(t),{openUrl:n}=r,a=Te(r,["openUrl"]);t.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(t.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const i=this._buildLogoutUrl(a);n?await n(i):n!==!1&&window.location.assign(i)}async _getTokenFromIFrame(t){const r=Object.assign(Object.assign({},t.authorizationParams),{prompt:"none"}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!r.organization&&(r.organization=n);const{url:a,state:i,nonce:o,code_verifier:c,redirect_uri:l,scope:f,audience:u}=await this._prepareAuthorizeUrl(r,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new ae("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const s=t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,d=await((m,S,g=60)=>new Promise(($,P)=>{const b=window.document.createElement("iframe");b.setAttribute("width","0"),b.setAttribute("height","0"),b.style.display="none";const v=()=>{window.document.body.contains(b)&&(window.document.body.removeChild(b),window.removeEventListener("message",I,!1))};let I;const O=setTimeout(()=>{P(new ti),v()},1e3*g);I=function(_){if(_.origin!=S||!_.data||_.data.type!=="authorization_response")return;const A=_.source;A&&A.close(),_.data.response.error?P(ae.fromPayload(_.data.response)):$(_.data.response),clearTimeout(O),window.removeEventListener("message",I,!1),setTimeout(v,2e3)},window.addEventListener("message",I,!1),window.document.body.appendChild(b),b.setAttribute("src",m)}))(a,this.domainUrl,s);if(i!==d.state)throw new ae("state_mismatch","Invalid state");const h=await this._requestToken(Object.assign(Object.assign({},t.authorizationParams),{code_verifier:c,code:d.code,grant_type:"authorization_code",redirect_uri:l,timeout:t.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:o,organization:r.organization});return Object.assign(Object.assign({},h),{scope:f,oauthTokenScope:h.scope,audience:u})}catch(s){throw s.error==="login_required"&&this.logout({openUrl:!1}),s}}async _getTokenUsingRefreshToken(t){const r=await this.cacheManager.get(new et({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(r&&r.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw new Nc(t.authorizationParams.audience||"default",t.authorizationParams.scope)}const n=t.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,a=typeof t.timeoutInSeconds=="number"?1e3*t.timeoutInSeconds:null;try{const i=await this._requestToken(Object.assign(Object.assign(Object.assign({},t.authorizationParams),{grant_type:"refresh_token",refresh_token:r&&r.refresh_token,redirect_uri:n}),a&&{timeout:a}));return Object.assign(Object.assign({},i),{scope:t.authorizationParams.scope,oauthTokenScope:i.scope,audience:t.authorizationParams.audience||"default"})}catch(i){if((i.message.indexOf("Missing Refresh Token")>-1||i.message&&i.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw i}}async _saveEntryInCache(t){const{id_token:r,decodedToken:n}=t,a=Te(t,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:r,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(a)}async _getIdTokenFromCache(){const t=this.options.authorizationParams.audience||"default",r=await this.cacheManager.getIdToken(new et({clientId:this.options.clientId,audience:t,scope:this.scope})),n=this.userCache.get("@@user@@");return r&&r.id_token===(n==null?void 0:n.id_token)?n:(this.userCache.set("@@user@@",r),r)}async _getEntryFromCache({scope:t,audience:r,clientId:n}){const a=await this.cacheManager.get(new et({scope:t,audience:r,clientId:n}),60);if(a&&a.access_token){const{access_token:i,oauthTokenScope:o,expires_in:c}=a,l=await this._getIdTokenFromCache();return l&&Object.assign(Object.assign({id_token:l.id_token,access_token:i},o?{scope:o}:null),{expires_in:c})}}async _requestToken(t,r){const{nonceIn:n,organization:a}=r||{},i=await dw(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},t),this.worker),o=await this._verifyIdToken(i.id_token,n,a);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},i),{decodedToken:o,scope:t.scope,audience:t.audience||"default"}),i.scope?{oauthTokenScope:i.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(a||o.claims.org_id),Object.assign(Object.assign({},i),{decodedToken:o})}};async function Tw(e){const t=new Pw(e);return await t.checkSession(),t}var we=(e=>(e.READY="sesamyJsReady",e.AUTHENTICATED="sesamyJsAuthenticated",e.LOGOUT="sesamyJsLogout",e.CLEAR_CACHE="sesamyJsClearCache",e.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",e.PURCHASE="sesamyJsPurchase",e))(we||{});const Ew="sesamy.com",Ow="sesamy.dev",_w="https://sesa.my",si="sesamyCacheTimestamp";function ze(e,t){return`https://${e}.${t==="dev"?Ow:Ew}`}let ie,Yc;const $t="sesamyAccessToken",ci="sesamyRefreshToken";async function Rw(e){if(!e)return null;const t=localStorage.getItem(ci);if(!t)throw new Error("No refresh token available");const r=new URLSearchParams;r.set("client_id",e.iss),r.set("refresh_token",t),r.set("grant_type","refresh_token");const n=new URL(e.iss);n.pathname="/oauth/token",n.searchParams.set("user_id",e.sub);try{const a=await fetch(n.href,{body:r.toString(),method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"}});if(!a.ok)throw localStorage.removeItem(ci),new Error("Renew token failed");const i=await a.json();return localStorage.setItem(ci,i.refresh_token),localStorage.setItem($t,i.access_token),i.access_token}catch{Xc()}}async function ui(){const e=localStorage.getItem($t);if(!e)return null;const t=qc(e);if(!t||!t.exp||t.exp<new Date().getTime()/1e3){const r=await Rw(t);if(r)return r;localStorage.removeItem($t)}return e}function Jc(e){try{const t=new URL(e).hostname,r=t.split(".");return r.length>1?r.slice(-2).join("."):t}catch{return null}}async function Cw(e){if(e.enabled===!1)return;Yc=e.organization;const t={domain:ze("token",e.environment),clientId:e.clientId,useCookiesForTransactions:!0};if(Jc(window.location.href)!==Jc(ze("auth",e.environment))&&(t.cacheLocation="localstorage",t.useRefreshTokens=!0),ie=await Tw(t),window.location.search.includes("code="))try{await ie.handleRedirectCallback();const r=await ie.getUser();Fe(we.AUTHENTICATED,r);const n=new URL(location.href),a=n.searchParams;a.delete("code"),a.delete("state"),n.search=a.toString(),window.history.replaceState({},document.title,n.toString())}catch(r){console.error(r)}}async function li(){return await ui()?!0:ie?ie.isAuthenticated():!1}async function jw(){return await ui()?{sub:"local",name:"Local User"}:ie?ie.getUser():null}function fi(e){if(localStorage.removeItem($t),!ie)throw new Error("Auth0 client not initialized");const t=(e==null?void 0:e.authorizationParams)||{};return ie.loginWithRedirect({...e,authorizationParams:{organization:Yc,redirect_uri:window.location.href,...t}})}async function nr(e=!0){const t=ui();if(t)return t;try{return ie?await ie.getTokenSilently():null}catch(r){if(e)throw r;return null}}async function Xc(e={}){if(localStorage.removeItem($t),Fe(we.LOGOUT,{}),!!ie)return ie.logout({...e,logoutParams:{returnTo:window.location.href,...e.logoutParams}})}function qc(e){const t=e.split(".");if(t.length!==3)return null;const n=t[1].replace(/-/g,"+").replace(/_/g,"/"),a=decodeURIComponent(atob(n).split("").map(function(i){return"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(a)}async function Qc(e){const t=qc(e);if(!t||!t.exp||t.exp<new Date().getTime()/1e3)throw new Error("Invalid token");localStorage.setItem($t,e),Fe(we.AUTHENTICATED,t)}const Aw=(e,t)=>t.skipDedupe||t.method!=="GET",Lw=(e,t)=>t.method+"@"+e,Uw=e=>e.clone(),eu=({skip:e=Aw,key:t=Lw,resolver:r=Uw}={})=>{const n=new Map;return a=>(i,o)=>{if(e(i,o))return a(i,o);const c=t(i,o);if(!n.has(c))n.set(c,[]);else return new Promise((l,f)=>{n.get(c).push([l,f])});try{return a(i,o).then(l=>(n.get(c).forEach(([f])=>f(r(l))),n.delete(c),l)).catch(l=>{throw n.get(c).forEach(([f,u])=>u(l)),n.delete(c),l})}catch(l){return n.delete(c),Promise.reject(l)}}},xw=(e,t)=>e*t,Nw=e=>e&&e.ok,tu=({delayTimer:e=500,delayRamp:t=xw,maxAttempts:r=10,until:n=Nw,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:c}={})=>l=>(f,u)=>{let s=0;if(c&&c(f,u))return l(f,u);const d=(h,m)=>Promise.resolve(n(h,m)).then(S=>S?h&&o?h:m?Promise.reject(m):h:(s++,!r||s<=r?new Promise(g=>{const $=t(e,s);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:h,error:m,url:f,options:u})).then((P={})=>{var b,v;g(l((b=P&&P.url)!==null&&b!==void 0?b:f,(v=P&&P.options)!==null&&v!==void 0?v:u))}):g(l(f,u))},$)}).then(d).catch(g=>{if(!i)throw g;return d(null,g)}):h&&o?h:Promise.reject(m||new Error("Number of attempts exceeded."))));return l(f,u).then(d).catch(h=>{if(!i)throw h;return d(null,h)})},Dw="application/json",ru="Content-Type",kt=Symbol(),nu=Symbol();function au(e={}){var t;return(t=Object.entries(e).find(([r])=>r.toLowerCase()===ru.toLowerCase()))===null||t===void 0?void 0:t[1]}function iu(e){return/^application\/.*json.*/.test(e)}const rt=function(e,t,r=!1){return Object.entries(t).reduce((n,[a,i])=>{const o=e[a];return Array.isArray(o)&&Array.isArray(i)?n[a]=r?[...o,...i]:i:typeof o=="object"&&typeof i=="object"?n[a]=rt(o,i,r):n[a]=i,n},{...e})},Pt={options:{},errorType:"text",polyfills:{},polyfill(e,t=!0,r=!1,...n){const a=this.polyfills[e]||(typeof self<"u"?self[e]:null)||(typeof global<"u"?global[e]:null);if(t&&!a)throw new Error(e+" is not defined");return r&&a?new a(...n):a}};function Mw(e,t=!1){Pt.options=t?e:rt(Pt.options,e)}function Fw(e,t=!1){Pt.polyfills=t?e:rt(Pt.polyfills,e)}function zw(e){Pt.errorType=e}const Hw=e=>t=>e.reduceRight((r,n)=>n(r),t)||t;class ou extends Error{}const Bw=e=>{const t=Object.create(null);e=e._addons.reduce((b,v)=>v.beforeRequest&&v.beforeRequest(b,e._options,t)||b,e);const{_url:r,_options:n,_config:a,_catchers:i,_resolvers:o,_middlewares:c,_addons:l}=e,f=new Map(i),u=rt(a.options,n);let s=r;const d=Hw(c)((b,v)=>(s=b,a.polyfill("fetch")(b,v)))(r,u),h=new Error,m=d.catch(b=>{throw{[kt]:b}}).then(b=>{if(!b.ok){const v=new ou;if(v.cause=h,v.stack=v.stack+`
|
|
5
|
-
CAUSE: `+h.stack,v.response=b,v.url=s,b.type==="opaque")throw v;return b.text().then(I=>{var O;if(v.message=I,a.errorType==="json"||((O=b.headers.get("Content-Type"))===null||O===void 0?void 0:O.split(";")[0])==="application/json")try{v.json=JSON.parse(I)}catch{}throw v.text=I,v.status=b.status,v})}return b}),S=b=>b.catch(v=>{const I=v.hasOwnProperty(kt),O=I?v[kt]:v,_=(O==null?void 0:O.status)&&f.get(O.status)||f.get(O==null?void 0:O.name)||I&&f.has(kt)&&f.get(kt);if(_)return _(O,e);const A=f.get(nu);if(A)return A(O,e);throw O}),g=b=>v=>S(b?m.then(I=>I&&I[b]()).then(I=>v?v(I):I):m.then(I=>v?v(I):I)),$={_wretchReq:e,_fetchReq:d,_sharedState:t,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(b,v){return f.set(b,v),this},badRequest(b){return this.error(400,b)},unauthorized(b){return this.error(401,b)},forbidden(b){return this.error(403,b)},notFound(b){return this.error(404,b)},timeout(b){return this.error(408,b)},internalError(b){return this.error(500,b)},fetchError(b){return this.error(kt,b)}},P=l.reduce((b,v)=>({...b,...typeof v.resolver=="function"?v.resolver(b):v.resolver}),$);return o.reduce((b,v)=>v(b,e),P)},Kw={_url:"",_options:{},_config:Pt,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(e){return{...this,_addons:[...this._addons,e],...e.wretch}},errorType(e){return{...this,_config:{...this._config,errorType:e}}},polyfills(e,t=!1){return{...this,_config:{...this._config,polyfills:t?e:rt(this._config.polyfills,e)}}},url(e,t=!1){if(t)return{...this,_url:e};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+e+"?"+r[1]:this._url+e}},options(e,t=!1){return{...this,_options:t?e:rt(this._options,e)}},headers(e){const t=e?Array.isArray(e)?Object.fromEntries(e):"entries"in e?Object.fromEntries(e.entries()):e:{};return{...this,_options:rt(this._options,{headers:t})}},accept(e){return this.headers({Accept:e})},content(e){return this.headers({[ru]:e})},auth(e){return this.headers({Authorization:e})},catcher(e,t){const r=new Map(this._catchers);return r.set(e,t),{...this,_catchers:r}},catcherFallback(e){return this.catcher(nu,e)},resolve(e,t=!1){return{...this,_resolvers:t?[e]:[...this._resolvers,e]}},defer(e,t=!1){return{...this,_deferred:t?[e]:[...this._deferred,e]}},middlewares(e,t=!1){return{...this,_middlewares:t?e:[...this._middlewares,...e]}},fetch(e=this._options.method,t="",r=null){let n=this.url(t).options({method:e});const a=au(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||iu(a));return n=r?o?n.json(r,a):n.body(r):n,Bw(n._deferred.reduce((c,l)=>l(c,c._url,c._options),n))},get(e=""){return this.fetch("GET",e)},delete(e=""){return this.fetch("DELETE",e)},put(e,t=""){return this.fetch("PUT",t,e)},post(e,t=""){return this.fetch("POST",t,e)},patch(e,t=""){return this.fetch("PATCH",t,e)},head(e=""){return this.fetch("HEAD",e)},opts(e=""){return this.fetch("OPTIONS",e)},body(e){return{...this,_options:{...this._options,body:e}}},json(e,t){const r=au(this._options.headers);return this.content(t||iu(r)&&r||Dw).body(JSON.stringify(e))}};function Ce(e="",t={}){return{...Kw,_url:e,_options:t}}Ce.default=Ce,Ce.options=Mw,Ce.errorType=zw,Ce.polyfills=Fw,Ce.WretchError=ou;function be(){sessionStorage.removeItem(si),Fe(we.CLEAR_CACHE,{})}function su(){var r;return(r=(document.documentElement.getAttribute("lang")??"en").split("-")[0])==null?void 0:r.toLocaleLowerCase()}function Gw(e){const t=ze("api2",e.environment),r=w=>async(k,T)=>{let H=sessionStorage.getItem(si);H||(H=Date.now().toString(),sessionStorage.setItem(si,H));const ne={...T,headers:{...T.headers,"Cache-Timestamp":H}};return w(k,ne)},n=(w=!0)=>k=>async(T,H)=>{let ne=null;if(ne=await nr(w),!ne){if(w)throw new Error("No access token available");return k(T,H)}const We={...H,headers:{...H.headers,...ne?{Authorization:`Bearer ${ne}`}:{}}};return k(T,We)},a=w=>(k,T)=>{if(T.headers.Authorization)return w(k,T);const H=localStorage.getItem("__anon_id"),ne=btoa(`${H}:`),We={...T,headers:{...T.headers,Authorization:`Basic ${ne}`}};return w(k,We)},i=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(),eu(),tu({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]),o=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(!1),a,eu(),tu({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]);async function c(){return i.get("/entitlements").json()}async function l(w){const k=await i.get("/entitlements").json();return k==null?void 0:k.find(T=>T.id===w)}async function f(w){return i.get(`/entitlements/${w}/access`).json()}async function u(){return i.get("/contracts").json()}async function s(w){const k=await i.get("/contracts").json();return k==null?void 0:k.find(T=>T.id===w)}async function d(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),i.get("/subscriptions").json()}async function h(){return i.get("/bills").json()}async function m(w){const k=await i.get("/bills").json();return k==null?void 0:k.find(T=>T.id===w)}async function S(){return i.get("/transactions").json()}async function g(w){const k=await i.get("/transactions").json();return k==null?void 0:k.find(T=>T.id===w)}async function $(w,k){const T=await i.url(`/user-metadata/${w}`).put(k).json();return Fe(we.USER_ATTRIBUTE_CHANGED,{}),be(),T}async function P(w){const k=await i.url(`/user-metadata/${w}`).delete().res();return be(),k.ok}async function b(w){return(await i.url(`/user-metadata/${w}`).get().json())[w]}async function v(){return await i.url("/user-metadata").get().json()}async function I(){return await i.url("/tags").get().json()}async function O(w){const k=await i.url(`/tags/${w}`).delete().res();return be(),k.ok}async function _(w){const k=await i.url("/tags").post(w).res();return Fe(we.USER_ATTRIBUTE_CHANGED,{}),be(),k.ok}async function A(w){return(await o.url("/tallies").get().json())[w]}async function M(){return await o.url("/tallies").get().json()}async function F(w){const k=await o.url(`/tallies/${w}`).delete().res();return be(),k.ok}async function W(w,k){return await o.url(`/tallies/${w}/push`).post(k).json()}async function L(w){return await i.url(`/products/${w}`).get().json()}async function N(){return await nr(!1)?await i.url("/profile").get().json():null}async function z(w){const k=await i.url("/profile").patch(w).res();return be(),k.ok}async function R(){return await i.url("/payment-issues").get().json()}async function K(){return(await i.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function Z(){return(await i.url("/profile/unlink-spotify").post().res()).ok}async function Le(w){const k=await nr(!1);if(!k)throw new Error("No access token available");const T=new URL(`${ze("spotify-oas",e.environment)}/sesamy-callback`);T.searchParams.set("access_token",k),T.searchParams.set("state",w),window.location.href=T.toString()}async function p(w){const k=await i.url(`/products/${w}/auto-onboard`).post().json();return k.length&&be(),k}async function y(w,k=3600){const{shortlink:T}=await Ce(_w).post({url:w,ttl:k}).json();return T}async function E(w){const k=await nr(!1);let T;const H=w.language||su();switch(w.target){case"account":T=new URL(`${ze("account",e.environment)}/${H}/subscriptions/${e.clientId}`);break;case"consume":T=new URL(`${ze("consume",e.environment)}/${H}/@${e.clientId}/${w.sku}`),w.episodeId?T.href+=`/${w.episodeId}`:T.href+="/listen";break;default:throw new Error("Invalid target")}return T.searchParams.set("sesamy-redirect-url",w.redirectUrl||window.location.href),k&&(T.hash=`#access_token=${k}`),w.shorten?y(T.href,w.ttl):T.href}async function U(w){return(await o.url("/checkouts").post({language:su(),...w,vendorId:e.clientId})).json()}async function x(w,k){return(await o.url(`/checkouts/${w}`).patch(k)).json()}async function D(w){return(await o.url(`/checkouts/${w}`).get()).json()}async function V(){const w=await nr(!1),k=new URL(`${ze("account",e.environment)}/subscriptions/${e.clientId}`);w&&(k.hash=`#access_token=${w}`),window.location.href=k.toString()}return{createCheckout:U,updateCheckout:x,getCheckout:D,getEntitlements:c,getEntitlement:l,getEntitlementAccess:f,getContracts:u,getContract:s,getProfile:N,updateProfile:z,getSubscriptions:d,getBills:h,getBill:m,setUserMetadata:$,deleteUserMetadata:P,getUserMetadata:b,listUserMetadata:v,getTags:I,deleteTag:O,setTag:_,getTally:A,getTallies:M,deleteTally:F,pushTally:W,getTransactions:S,getTransaction:g,getProduct:L,getPaymentIssues:R,autoOnboardProduct:p,isSpotifyLinked:K,unlinkSpotify:Z,linkSpotify:Le,generateLink:E,openHostedAccountPage:V}}const cu="@sesamy/sesamy-js",di="1.13.2";function uu(e,t,r,n,a){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:a;return e===a?r:e}var Zr="undefined",lu="object",hi=function(){},fu="any",du="*",nt="__",Yr=typeof process<"u"?process:{};Yr.env&&Yr.env.NODE_ENV;var Y=typeof document<"u";Yr.versions!=null&&Yr.versions.node!=null,typeof Deno<"u"&&Deno.core,Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function hu(e,t){return t.charAt(0)[e]()+t.slice(1)}var Ww=hu.bind(null,"toUpperCase"),Vw=hu.bind(null,"toLowerCase");function Zw(e){return vu(e)?Ww("null"):typeof e=="object"?qw(e):Object.prototype.toString.call(e).slice(8,-1)}function Jr(e,t){t===void 0&&(t=!0);var r=Zw(e);return t?Vw(r):r}function ar(e,t){return typeof t===e}var te=ar.bind(null,"function"),He=ar.bind(null,"string"),Tt=ar.bind(null,"undefined"),Yw=ar.bind(null,"boolean");ar.bind(null,"symbol");function vu(e){return e===null}function Jw(e){return Jr(e)==="number"&&!isNaN(e)}function pu(e){return Jr(e)==="array"}function re(e){if(!Xw(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Xw(e){return e&&(typeof e=="object"||e!==null)}function qw(e){return te(e.constructor)?e.constructor.name:null}function Qw(e){return e instanceof Error||He(e.message)&&e.constructor&&Jw(e.constructor.stackTraceLimit)}function mu(e,t){if(typeof t!="object"||vu(t))return!1;if(t instanceof e)return!0;var r=Jr(new e(""));if(Qw(t))for(;t;){if(Jr(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}mu.bind(null,TypeError),mu.bind(null,SyntaxError);function Xr(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?eb(e,t):r}function eb(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function qr(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}qr(Xr,"form"),qr(Xr,"button"),qr(Xr,"input"),qr(Xr,"select");function tb(e){return e?pu(e)?e:[e]:[]}function gu(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function rb(){if(Y){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function nb(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function ab(e){return function(t){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(t);){var i=gu(r[1]),o=gu(r[2]);i.substring(i.length-2)==="[]"?(n[i=i.substring(0,i.length-2)]||(n[i]=[])).push(o):n[i]=o===""||o}for(var c in n){var l=c.split("[");l.length>1&&(ib(n,l.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),n[c]),delete n[c])}return n}(function(t){return Y&&window.location.search.substring(1)}())}function ib(e,t,r){for(var n=t.length-1,a=0;a<n;++a){var i=t[a];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[n]]=r}function Qr(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],a=15&r;e+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}function ob(e,t){var r,n,a,i=null,o=0,c=function(){o=new Date,i=null,a=e.apply(r,n)};return function(){var l=new Date;o||(o=l);var f=t-(l-o);return r=this,n=arguments,f<=0?(clearTimeout(i),i=null,o=l,a=e.apply(r,n)):i||(i=setTimeout(c,f)),a}}var ir="global",Et=nt+"global"+nt,Ot=typeof self===lu&&self.self===self&&self||typeof global===lu&&global.global===global&&global||void 0;function at(e){return Ot[Et][e]}function it(e,t){return Ot[Et][e]=t}function _t(e){delete Ot[Et][e]}function Rt(e,t,r){var n;try{if(vi(e)){var a=window[e];n=a[t].bind(a)}}catch{}return n||r}Ot[Et]||(Ot[Et]={});var en={};function vi(e){if(typeof en[e]!==Zr)return en[e];try{var t=window[e];t.setItem(Zr,Zr),t.removeItem(Zr)}catch{return en[e]=!1}return en[e]=!0}function C(){return C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},C.apply(this,arguments)}var Be="function",je="undefined",sb="@@redux/"+Math.random().toString(36),yu=function(){return typeof Symbol===Be&&Symbol.observable||"@@observable"}(),tn=" != "+Be;function wu(e,t,r){var n;if(typeof t===Be&&typeof r===je&&(r=t,t=void 0),typeof r!==je){if(typeof r!==Be)throw new Error("enhancer"+tn);return r(wu)(e,t)}if(typeof e!==Be)throw new Error("reducer"+tn);var a=e,i=t,o=[],c=o,l=!1;function f(){c===o&&(c=o.slice())}function u(){return i}function s(h){if(typeof h!==Be)throw new Error("Listener"+tn);var m=!0;return f(),c.push(h),function(){if(m){m=!1,f();var S=c.indexOf(h);c.splice(S,1)}}}function d(h){if(!re(h))throw new Error("Act != obj");if(typeof h.type===je)throw new Error("ActType "+je);if(l)throw new Error("Dispatch in reducer");try{l=!0,i=a(i,h)}finally{l=!1}for(var m=o=c,S=0;S<m.length;S++)(0,m[S])();return h}return d({type:"@@redux/INIT"}),(n={dispatch:d,subscribe:s,getState:u,replaceReducer:function(h){if(typeof h!==Be)throw new Error("next reducer"+tn);a=h,d({type:"@@redux/INIT"})}})[yu]=function(){var h,m=s;return(h={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function g(){S.next&&S.next(u())}return g(),{unsubscribe:m(g)}}})[yu]=function(){return this},h},n}function cb(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+je}function Ct(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,r){return function(){return t(r.apply(void 0,[].slice.call(arguments)))}})}function ub(){var e=arguments;return function(t){return function(r,n,a){var i,o=t(r,n,a),c=o.dispatch,l={getState:o.getState,dispatch:function(f){return c(f)}};return i=[].slice.call(e).map(function(f){return f(l)}),C({},o,{dispatch:c=Ct.apply(void 0,i)(o.dispatch)})}}}var Ke=nt+"anon_id",ot=nt+"user_id",jt=nt+"user_traits",Ge="userId",At="anonymousId",rn=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],pi=["name","EVENTS","config","loaded"],j=rn.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),bu=/^utm_/,Su=/^an_prop_/,Iu=/^an_trait_/;function lb(e){var t=e.storage.setItem;return function(r){return function(n){return function(a){if(a.type===j.bootstrap){var i=a.params,o=a.user,c=a.persistedUser,l=a.initialUser,f=c.userId===o.userId;c.anonymousId!==o.anonymousId&&t(Ke,o.anonymousId),f||t(ot,o.userId),l.traits&&t(jt,C({},f&&c.traits?c.traits:{},l.traits));var u=Object.keys(a.params);if(u.length){var s=i.an_uid,d=i.an_event,h=u.reduce(function(m,S){if(S.match(bu)||S.match(/^(d|g)clid/)){var g=S.replace(bu,"");m.campaign[g==="campaign"?"name":g]=i[S]}return S.match(Su)&&(m.props[S.replace(Su,"")]=i[S]),S.match(Iu)&&(m.traits[S.replace(Iu,"")]=i[S]),m},{campaign:{},props:{},traits:{}});r.dispatch(C({type:j.params,raw:i},h,s?{userId:s}:{})),s&&setTimeout(function(){return e.identify(s,h.traits)},0),d&&setTimeout(function(){return e.track(d,h.props)},0),Object.keys(h.campaign).length&&r.dispatch({type:j.campaign,campaign:h.campaign})}}return n(a)}}}}function fb(e){return function(t,r){if(t===void 0&&(t={}),r===void 0&&(r={}),r.type===j.setItemEnd){if(r.key===Ke)return C({},t,{anonymousId:r.value});if(r.key===ot)return C({},t,{userId:r.value})}switch(r.type){case j.identify:return Object.assign({},t,{userId:r.userId,traits:C({},t.traits,r.traits)});case j.reset:return[ot,Ke,jt].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function $u(e){return{userId:e.getItem(ot),anonymousId:e.getItem(Ke),traits:e.getItem(jt)}}var mi=function(e){return nt+"TEMP"+nt+e};function db(e){var t=e.storage,r=t.setItem,n=t.removeItem,a=t.getItem;return function(i){return function(o){return function(c){var l=c.userId,f=c.traits,u=c.options;if(c.type===j.reset&&([ot,jt,Ke].forEach(function(h){n(h)}),[Ge,At,"traits"].forEach(function(h){_t(mi(h))})),c.type===j.identify){a(Ke)||r(Ke,Qr());var s=a(ot),d=a(jt)||{};s&&s!==l&&i.dispatch({type:j.userIdChanged,old:{userId:s,traits:d},new:{userId:l,traits:f},options:u}),l&&r(ot,l),f&&r(jt,C({},d,f))}return o(c)}}}}var or={};function ku(e,t){or[e]&&te(or[e])&&(or[e](t),delete or[e])}function Pu(e,t,r){return new Promise(function(n,a){return t()?n(e):r<1?a(C({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return Pu(e,t,r-10).then(n,a)})})}function hb(e){return{abort:e}}function Tu(e,t,r){var n={},a=t(),i=e.getState(),o=i.plugins,c=i.queue,l=i.user;if(!i.context.offline&&c&&c.actions&&c.actions.length){var f=c.actions.reduce(function(s,d,h){return o[d.plugin].loaded?(s.process.push(d),s.processIndex.push(h)):(s.requeue.push(d),s.requeueIndex.push(h)),s},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(s){var d=c.actions[s],h=d.plugin,m=d.payload.type,S=a[h][m];if(S&&te(S)){var g,$=function(v,I){return v===void 0&&(v={}),I===void 0&&(I={}),[Ge,At].reduce(function(O,_){return v.hasOwnProperty(_)&&I[_]&&I[_]!==v[_]&&(O[_]=I[_]),O},v)}(d.payload,l),P=n[$.meta.rid];if(!P&&(g=S({payload:$,config:o[h].config,instance:r,abort:hb}))&&re(g)&&g.abort)return void(n[$.meta.rid]=!0);if(!P){var b=m+":"+h;e.dispatch(C({},$,{type:b,_:{called:b,from:"queueDrain"}}))}}});var u=c.actions.filter(function(s,d){return!~f.processIndex.indexOf(d)});c.actions=u}}}var gi=function(e){var t=e.data,r=e.action,n=e.instance,a=e.state,i=e.allPlugins,o=e.allMatches,c=e.store,l=e.EVENTS;try{var f=a.plugins,u=a.context,s=r.type,d=s.match(Lt),h=t.exact.map(function(g){return g.pluginName});d&&(h=o.during.map(function(g){return g.pluginName}));var m=function(g,$){return function(P,b,v){var I=b.config,O=b.name,_=O+"."+P.type;v&&(_=v.event);var A=P.type.match(Lt)?function(M,F,W,L,N){return function(z,R){var K=L?L.name:M,Z=R&&sr(R)?R:W;if(L&&(!(Z=R&&sr(R)?R:[M]).includes(M)||Z.length!==1))throw new Error("Method "+F+" can only abort "+M+" plugin. "+JSON.stringify(Z)+" input valid");return C({},N,{abort:{reason:z,plugins:Z,caller:F,_:K}})}}(O,_,$,v,P):function(M,F){return function(){throw new Error(M.type+" action not cancellable. Remove abort in "+F)}}(P,_);return{payload:vb(P),instance:g,config:I||{},abort:A}}}(n,h),S=t.exact.reduce(function(g,$){var P=$.pluginName,b=$.methodName,v=!1;return b.match(/^initialize/)||b.match(/^reset/)||(v=!f[P].loaded),u.offline&&b.match(/^(page|track|identify)/)&&(v=!0),g[""+P]=v,g},{});return Promise.resolve(t.exact.reduce(function(g,$,P){try{var b=$.pluginName;return Promise.resolve(g).then(function(v){function I(){return Promise.resolve(v)}var O=function(){if(t.namespaced&&t.namespaced[b])return Promise.resolve(t.namespaced[b].reduce(function(_,A,M){try{return Promise.resolve(_).then(function(F){return A.method&&te(A.method)?(function(z,R){var K=Lu(z);if(K&&K.name===R){var Z=Lu(K.method);throw new Error([R+" plugin is calling method "+z,"Plugins cant call self","Use "+K.method+" "+(Z?"or "+Z.method:"")+" in "+R+" plugin insteadof "+z].join(`
|
|
5
|
+
CAUSE: `+h.stack,v.response=b,v.url=s,b.type==="opaque")throw v;return b.text().then(I=>{var O;if(v.message=I,a.errorType==="json"||((O=b.headers.get("Content-Type"))===null||O===void 0?void 0:O.split(";")[0])==="application/json")try{v.json=JSON.parse(I)}catch{}throw v.text=I,v.status=b.status,v})}return b}),S=b=>b.catch(v=>{const I=v.hasOwnProperty(kt),O=I?v[kt]:v,_=(O==null?void 0:O.status)&&f.get(O.status)||f.get(O==null?void 0:O.name)||I&&f.has(kt)&&f.get(kt);if(_)return _(O,e);const A=f.get(nu);if(A)return A(O,e);throw O}),g=b=>v=>S(b?m.then(I=>I&&I[b]()).then(I=>v?v(I):I):m.then(I=>v?v(I):I)),$={_wretchReq:e,_fetchReq:d,_sharedState:t,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(b,v){return f.set(b,v),this},badRequest(b){return this.error(400,b)},unauthorized(b){return this.error(401,b)},forbidden(b){return this.error(403,b)},notFound(b){return this.error(404,b)},timeout(b){return this.error(408,b)},internalError(b){return this.error(500,b)},fetchError(b){return this.error(kt,b)}},P=l.reduce((b,v)=>({...b,...typeof v.resolver=="function"?v.resolver(b):v.resolver}),$);return o.reduce((b,v)=>v(b,e),P)},Kw={_url:"",_options:{},_config:Pt,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(e){return{...this,_addons:[...this._addons,e],...e.wretch}},errorType(e){return{...this,_config:{...this._config,errorType:e}}},polyfills(e,t=!1){return{...this,_config:{...this._config,polyfills:t?e:rt(this._config.polyfills,e)}}},url(e,t=!1){if(t)return{...this,_url:e};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+e+"?"+r[1]:this._url+e}},options(e,t=!1){return{...this,_options:t?e:rt(this._options,e)}},headers(e){const t=e?Array.isArray(e)?Object.fromEntries(e):"entries"in e?Object.fromEntries(e.entries()):e:{};return{...this,_options:rt(this._options,{headers:t})}},accept(e){return this.headers({Accept:e})},content(e){return this.headers({[ru]:e})},auth(e){return this.headers({Authorization:e})},catcher(e,t){const r=new Map(this._catchers);return r.set(e,t),{...this,_catchers:r}},catcherFallback(e){return this.catcher(nu,e)},resolve(e,t=!1){return{...this,_resolvers:t?[e]:[...this._resolvers,e]}},defer(e,t=!1){return{...this,_deferred:t?[e]:[...this._deferred,e]}},middlewares(e,t=!1){return{...this,_middlewares:t?e:[...this._middlewares,...e]}},fetch(e=this._options.method,t="",r=null){let n=this.url(t).options({method:e});const a=au(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||iu(a));return n=r?o?n.json(r,a):n.body(r):n,Bw(n._deferred.reduce((c,l)=>l(c,c._url,c._options),n))},get(e=""){return this.fetch("GET",e)},delete(e=""){return this.fetch("DELETE",e)},put(e,t=""){return this.fetch("PUT",t,e)},post(e,t=""){return this.fetch("POST",t,e)},patch(e,t=""){return this.fetch("PATCH",t,e)},head(e=""){return this.fetch("HEAD",e)},opts(e=""){return this.fetch("OPTIONS",e)},body(e){return{...this,_options:{...this._options,body:e}}},json(e,t){const r=au(this._options.headers);return this.content(t||iu(r)&&r||Dw).body(JSON.stringify(e))}};function Ce(e="",t={}){return{...Kw,_url:e,_options:t}}Ce.default=Ce,Ce.options=Mw,Ce.errorType=zw,Ce.polyfills=Fw,Ce.WretchError=ou;function be(){sessionStorage.removeItem(si),Fe(we.CLEAR_CACHE,{})}function su(){var r;return(r=(document.documentElement.getAttribute("lang")??"en").split("-")[0])==null?void 0:r.toLocaleLowerCase()}function Gw(e){const t=ze("api2",e.environment),r=w=>async(k,T)=>{let H=sessionStorage.getItem(si);H||(H=Date.now().toString(),sessionStorage.setItem(si,H));const ne={...T,headers:{...T.headers,"Cache-Timestamp":H}};return w(k,ne)},n=(w=!0)=>k=>async(T,H)=>{let ne=null;if(ne=await nr(w),!ne){if(w)throw new Error("No access token available");return k(T,H)}const We={...H,headers:{...H.headers,...ne?{Authorization:`Bearer ${ne}`}:{}}};return k(T,We)},a=w=>(k,T)=>{if(T.headers.Authorization)return w(k,T);const H=localStorage.getItem("__anon_id"),ne=btoa(`${H}:`),We={...T,headers:{...T.headers,Authorization:`Basic ${ne}`}};return w(k,We)},i=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(),eu(),tu({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]),o=Ce(t).headers({"Content-Type":"application/json"}).middlewares([r,n(!1),a,eu(),tu({delayTimer:1e3,delayRamp:(w,k)=>w*k,maxAttempts:3,until:w=>!!(w&&(w.ok||w.status>=400&&w.status<500)),retryOnNetworkError:!1})]);async function c(){return i.get("/entitlements").json()}async function l(w){const k=await i.get("/entitlements").json();return k==null?void 0:k.find(T=>T.id===w)}async function f(w){return i.get(`/entitlements/${w}/access`).json()}async function u(){return i.get("/contracts").json()}async function s(w){const k=await i.get("/contracts").json();return k==null?void 0:k.find(T=>T.id===w)}async function d(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),i.get("/subscriptions").json()}async function h(){return i.get("/bills").json()}async function m(w){const k=await i.get("/bills").json();return k==null?void 0:k.find(T=>T.id===w)}async function S(){return i.get("/transactions").json()}async function g(w){const k=await i.get("/transactions").json();return k==null?void 0:k.find(T=>T.id===w)}async function $(w,k){const T=await i.url(`/user-metadata/${w}`).put(k).json();return Fe(we.USER_ATTRIBUTE_CHANGED,{}),be(),T}async function P(w){const k=await i.url(`/user-metadata/${w}`).delete().res();return be(),k.ok}async function b(w){return(await i.url(`/user-metadata/${w}`).get().json())[w]}async function v(){return await i.url("/user-metadata").get().json()}async function I(){return await i.url("/tags").get().json()}async function O(w){const k=await i.url(`/tags/${w}`).delete().res();return be(),k.ok}async function _(w){const k=await i.url("/tags").post(w).res();return Fe(we.USER_ATTRIBUTE_CHANGED,{}),be(),k.ok}async function A(w){return(await o.url("/tallies").get().json())[w]}async function M(){return await o.url("/tallies").get().json()}async function F(w){const k=await o.url(`/tallies/${w}`).delete().res();return be(),k.ok}async function W(w,k){return await o.url(`/tallies/${w}/push`).post(k).json()}async function L(w){return await i.url(`/products/${w}`).get().json()}async function N(){return await nr(!1)?await i.url("/profile").get().json():null}async function z(w){const k=await i.url("/profile").patch(w).res();return be(),k.ok}async function R(){return await i.url("/payment-issues").get().json()}async function K(){return(await i.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function Z(){return(await i.url("/profile/unlink-spotify").post().res()).ok}async function Le(w){const k=await nr(!1);if(!k)throw new Error("No access token available");const T=new URL(`${ze("spotify-oas",e.environment)}/sesamy-callback`);T.searchParams.set("access_token",k),T.searchParams.set("state",w),window.location.href=T.toString()}async function p(w){const k=await i.url(`/products/${w}/auto-onboard`).post().json();return k.length&&be(),k}async function y(w,k=3600){const{shortlink:T}=await Ce(_w).post({url:w,ttl:k}).json();return T}async function E(w){const k=await nr(!1);let T;const H=w.language||su();switch(w.target){case"account":T=new URL(`${ze("account",e.environment)}/${H}/subscriptions/${e.clientId}`);break;case"consume":T=new URL(`${ze("consume",e.environment)}/${H}/@${e.clientId}/${w.sku}`),w.episodeId?T.href+=`/${w.episodeId}`:T.href+="/listen";break;default:throw new Error("Invalid target")}return T.searchParams.set("sesamy-redirect-url",w.redirectUrl||window.location.href),k&&(T.hash=`#access_token=${k}`),w.shorten?y(T.href,w.ttl):T.href}async function U(w){return(await o.url("/checkouts").post({language:su(),...w,vendorId:e.clientId})).json()}async function x(w,k){return(await o.url(`/checkouts/${w}`).patch(k)).json()}async function D(w){return(await o.url(`/checkouts/${w}`).get()).json()}async function V(){const w=await nr(!1),k=new URL(`${ze("account",e.environment)}/subscriptions/${e.clientId}`);w&&(k.hash=`#access_token=${w}`),window.location.href=k.toString()}return{createCheckout:U,updateCheckout:x,getCheckout:D,getEntitlements:c,getEntitlement:l,getEntitlementAccess:f,getContracts:u,getContract:s,getProfile:N,updateProfile:z,getSubscriptions:d,getBills:h,getBill:m,setUserMetadata:$,deleteUserMetadata:P,getUserMetadata:b,listUserMetadata:v,getTags:I,deleteTag:O,setTag:_,getTally:A,getTallies:M,deleteTally:F,pushTally:W,getTransactions:S,getTransaction:g,getProduct:L,getPaymentIssues:R,autoOnboardProduct:p,isSpotifyLinked:K,unlinkSpotify:Z,linkSpotify:Le,generateLink:E,openHostedAccountPage:V}}const cu="@sesamy/sesamy-js",di="1.19.1";function uu(e,t,r,n,a){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:a;return e===a?r:e}var Zr="undefined",lu="object",hi=function(){},fu="any",du="*",nt="__",Yr=typeof process<"u"?process:{};Yr.env&&Yr.env.NODE_ENV;var Y=typeof document<"u";Yr.versions!=null&&Yr.versions.node!=null,typeof Deno<"u"&&Deno.core,Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function hu(e,t){return t.charAt(0)[e]()+t.slice(1)}var Ww=hu.bind(null,"toUpperCase"),Vw=hu.bind(null,"toLowerCase");function Zw(e){return vu(e)?Ww("null"):typeof e=="object"?qw(e):Object.prototype.toString.call(e).slice(8,-1)}function Jr(e,t){t===void 0&&(t=!0);var r=Zw(e);return t?Vw(r):r}function ar(e,t){return typeof t===e}var te=ar.bind(null,"function"),He=ar.bind(null,"string"),Tt=ar.bind(null,"undefined"),Yw=ar.bind(null,"boolean");ar.bind(null,"symbol");function vu(e){return e===null}function Jw(e){return Jr(e)==="number"&&!isNaN(e)}function pu(e){return Jr(e)==="array"}function re(e){if(!Xw(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Xw(e){return e&&(typeof e=="object"||e!==null)}function qw(e){return te(e.constructor)?e.constructor.name:null}function Qw(e){return e instanceof Error||He(e.message)&&e.constructor&&Jw(e.constructor.stackTraceLimit)}function mu(e,t){if(typeof t!="object"||vu(t))return!1;if(t instanceof e)return!0;var r=Jr(new e(""));if(Qw(t))for(;t;){if(Jr(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}mu.bind(null,TypeError),mu.bind(null,SyntaxError);function Xr(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?eb(e,t):r}function eb(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function qr(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}qr(Xr,"form"),qr(Xr,"button"),qr(Xr,"input"),qr(Xr,"select");function tb(e){return e?pu(e)?e:[e]:[]}function gu(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function rb(){if(Y){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function nb(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function ab(e){return function(t){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(t);){var i=gu(r[1]),o=gu(r[2]);i.substring(i.length-2)==="[]"?(n[i=i.substring(0,i.length-2)]||(n[i]=[])).push(o):n[i]=o===""||o}for(var c in n){var l=c.split("[");l.length>1&&(ib(n,l.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),n[c]),delete n[c])}return n}(function(t){return Y&&window.location.search.substring(1)}())}function ib(e,t,r){for(var n=t.length-1,a=0;a<n;++a){var i=t[a];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[n]]=r}function Qr(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],a=15&r;e+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}function ob(e,t){var r,n,a,i=null,o=0,c=function(){o=new Date,i=null,a=e.apply(r,n)};return function(){var l=new Date;o||(o=l);var f=t-(l-o);return r=this,n=arguments,f<=0?(clearTimeout(i),i=null,o=l,a=e.apply(r,n)):i||(i=setTimeout(c,f)),a}}var ir="global",Et=nt+"global"+nt,Ot=typeof self===lu&&self.self===self&&self||typeof global===lu&&global.global===global&&global||void 0;function at(e){return Ot[Et][e]}function it(e,t){return Ot[Et][e]=t}function _t(e){delete Ot[Et][e]}function Rt(e,t,r){var n;try{if(vi(e)){var a=window[e];n=a[t].bind(a)}}catch{}return n||r}Ot[Et]||(Ot[Et]={});var en={};function vi(e){if(typeof en[e]!==Zr)return en[e];try{var t=window[e];t.setItem(Zr,Zr),t.removeItem(Zr)}catch{return en[e]=!1}return en[e]=!0}function C(){return C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},C.apply(this,arguments)}var Be="function",je="undefined",sb="@@redux/"+Math.random().toString(36),yu=function(){return typeof Symbol===Be&&Symbol.observable||"@@observable"}(),tn=" != "+Be;function wu(e,t,r){var n;if(typeof t===Be&&typeof r===je&&(r=t,t=void 0),typeof r!==je){if(typeof r!==Be)throw new Error("enhancer"+tn);return r(wu)(e,t)}if(typeof e!==Be)throw new Error("reducer"+tn);var a=e,i=t,o=[],c=o,l=!1;function f(){c===o&&(c=o.slice())}function u(){return i}function s(h){if(typeof h!==Be)throw new Error("Listener"+tn);var m=!0;return f(),c.push(h),function(){if(m){m=!1,f();var S=c.indexOf(h);c.splice(S,1)}}}function d(h){if(!re(h))throw new Error("Act != obj");if(typeof h.type===je)throw new Error("ActType "+je);if(l)throw new Error("Dispatch in reducer");try{l=!0,i=a(i,h)}finally{l=!1}for(var m=o=c,S=0;S<m.length;S++)(0,m[S])();return h}return d({type:"@@redux/INIT"}),(n={dispatch:d,subscribe:s,getState:u,replaceReducer:function(h){if(typeof h!==Be)throw new Error("next reducer"+tn);a=h,d({type:"@@redux/INIT"})}})[yu]=function(){var h,m=s;return(h={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function g(){S.next&&S.next(u())}return g(),{unsubscribe:m(g)}}})[yu]=function(){return this},h},n}function cb(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+je}function Ct(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,r){return function(){return t(r.apply(void 0,[].slice.call(arguments)))}})}function ub(){var e=arguments;return function(t){return function(r,n,a){var i,o=t(r,n,a),c=o.dispatch,l={getState:o.getState,dispatch:function(f){return c(f)}};return i=[].slice.call(e).map(function(f){return f(l)}),C({},o,{dispatch:c=Ct.apply(void 0,i)(o.dispatch)})}}}var Ke=nt+"anon_id",ot=nt+"user_id",jt=nt+"user_traits",Ge="userId",At="anonymousId",rn=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],pi=["name","EVENTS","config","loaded"],j=rn.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),bu=/^utm_/,Su=/^an_prop_/,Iu=/^an_trait_/;function lb(e){var t=e.storage.setItem;return function(r){return function(n){return function(a){if(a.type===j.bootstrap){var i=a.params,o=a.user,c=a.persistedUser,l=a.initialUser,f=c.userId===o.userId;c.anonymousId!==o.anonymousId&&t(Ke,o.anonymousId),f||t(ot,o.userId),l.traits&&t(jt,C({},f&&c.traits?c.traits:{},l.traits));var u=Object.keys(a.params);if(u.length){var s=i.an_uid,d=i.an_event,h=u.reduce(function(m,S){if(S.match(bu)||S.match(/^(d|g)clid/)){var g=S.replace(bu,"");m.campaign[g==="campaign"?"name":g]=i[S]}return S.match(Su)&&(m.props[S.replace(Su,"")]=i[S]),S.match(Iu)&&(m.traits[S.replace(Iu,"")]=i[S]),m},{campaign:{},props:{},traits:{}});r.dispatch(C({type:j.params,raw:i},h,s?{userId:s}:{})),s&&setTimeout(function(){return e.identify(s,h.traits)},0),d&&setTimeout(function(){return e.track(d,h.props)},0),Object.keys(h.campaign).length&&r.dispatch({type:j.campaign,campaign:h.campaign})}}return n(a)}}}}function fb(e){return function(t,r){if(t===void 0&&(t={}),r===void 0&&(r={}),r.type===j.setItemEnd){if(r.key===Ke)return C({},t,{anonymousId:r.value});if(r.key===ot)return C({},t,{userId:r.value})}switch(r.type){case j.identify:return Object.assign({},t,{userId:r.userId,traits:C({},t.traits,r.traits)});case j.reset:return[ot,Ke,jt].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function $u(e){return{userId:e.getItem(ot),anonymousId:e.getItem(Ke),traits:e.getItem(jt)}}var mi=function(e){return nt+"TEMP"+nt+e};function db(e){var t=e.storage,r=t.setItem,n=t.removeItem,a=t.getItem;return function(i){return function(o){return function(c){var l=c.userId,f=c.traits,u=c.options;if(c.type===j.reset&&([ot,jt,Ke].forEach(function(h){n(h)}),[Ge,At,"traits"].forEach(function(h){_t(mi(h))})),c.type===j.identify){a(Ke)||r(Ke,Qr());var s=a(ot),d=a(jt)||{};s&&s!==l&&i.dispatch({type:j.userIdChanged,old:{userId:s,traits:d},new:{userId:l,traits:f},options:u}),l&&r(ot,l),f&&r(jt,C({},d,f))}return o(c)}}}}var or={};function ku(e,t){or[e]&&te(or[e])&&(or[e](t),delete or[e])}function Pu(e,t,r){return new Promise(function(n,a){return t()?n(e):r<1?a(C({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return Pu(e,t,r-10).then(n,a)})})}function hb(e){return{abort:e}}function Tu(e,t,r){var n={},a=t(),i=e.getState(),o=i.plugins,c=i.queue,l=i.user;if(!i.context.offline&&c&&c.actions&&c.actions.length){var f=c.actions.reduce(function(s,d,h){return o[d.plugin].loaded?(s.process.push(d),s.processIndex.push(h)):(s.requeue.push(d),s.requeueIndex.push(h)),s},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(s){var d=c.actions[s],h=d.plugin,m=d.payload.type,S=a[h][m];if(S&&te(S)){var g,$=function(v,I){return v===void 0&&(v={}),I===void 0&&(I={}),[Ge,At].reduce(function(O,_){return v.hasOwnProperty(_)&&I[_]&&I[_]!==v[_]&&(O[_]=I[_]),O},v)}(d.payload,l),P=n[$.meta.rid];if(!P&&(g=S({payload:$,config:o[h].config,instance:r,abort:hb}))&&re(g)&&g.abort)return void(n[$.meta.rid]=!0);if(!P){var b=m+":"+h;e.dispatch(C({},$,{type:b,_:{called:b,from:"queueDrain"}}))}}});var u=c.actions.filter(function(s,d){return!~f.processIndex.indexOf(d)});c.actions=u}}}var gi=function(e){var t=e.data,r=e.action,n=e.instance,a=e.state,i=e.allPlugins,o=e.allMatches,c=e.store,l=e.EVENTS;try{var f=a.plugins,u=a.context,s=r.type,d=s.match(Lt),h=t.exact.map(function(g){return g.pluginName});d&&(h=o.during.map(function(g){return g.pluginName}));var m=function(g,$){return function(P,b,v){var I=b.config,O=b.name,_=O+"."+P.type;v&&(_=v.event);var A=P.type.match(Lt)?function(M,F,W,L,N){return function(z,R){var K=L?L.name:M,Z=R&&sr(R)?R:W;if(L&&(!(Z=R&&sr(R)?R:[M]).includes(M)||Z.length!==1))throw new Error("Method "+F+" can only abort "+M+" plugin. "+JSON.stringify(Z)+" input valid");return C({},N,{abort:{reason:z,plugins:Z,caller:F,_:K}})}}(O,_,$,v,P):function(M,F){return function(){throw new Error(M.type+" action not cancellable. Remove abort in "+F)}}(P,_);return{payload:vb(P),instance:g,config:I||{},abort:A}}}(n,h),S=t.exact.reduce(function(g,$){var P=$.pluginName,b=$.methodName,v=!1;return b.match(/^initialize/)||b.match(/^reset/)||(v=!f[P].loaded),u.offline&&b.match(/^(page|track|identify)/)&&(v=!0),g[""+P]=v,g},{});return Promise.resolve(t.exact.reduce(function(g,$,P){try{var b=$.pluginName;return Promise.resolve(g).then(function(v){function I(){return Promise.resolve(v)}var O=function(){if(t.namespaced&&t.namespaced[b])return Promise.resolve(t.namespaced[b].reduce(function(_,A,M){try{return Promise.resolve(_).then(function(F){return A.method&&te(A.method)?(function(z,R){var K=Lu(z);if(K&&K.name===R){var Z=Lu(K.method);throw new Error([R+" plugin is calling method "+z,"Plugins cant call self","Use "+K.method+" "+(Z?"or "+Z.method:"")+" in "+R+" plugin insteadof "+z].join(`
|
|
6
6
|
`))}}(A.methodName,A.pluginName),Promise.resolve(A.method({payload:F,instance:n,abort:(W=F,L=b,N=A.pluginName,function(z,R){return C({},W,{abort:{reason:z,plugins:R||[L],caller:s,from:N||L}})}),config:_u(A.pluginName,f,i),plugins:f})).then(function(z){var R=re(z)?z:{};return Promise.resolve(C({},F,R))})):F;var W,L,N})}catch(F){return Promise.reject(F)}},Promise.resolve(r))).then(function(_){v[b]=_});v[b]=r}();return O&&O.then?O.then(I):I()})}catch(v){return Promise.reject(v)}},Promise.resolve({}))).then(function(g){return Promise.resolve(t.exact.reduce(function($,P,b){try{var v=t.exact.length===b+1,I=P.pluginName,O=i[I];return Promise.resolve($).then(function(_){var A=g[I]?g[I]:{};if(d&&(A=_),wi(A,I))return yi({data:A,method:s,instance:n,pluginName:I,store:c}),Promise.resolve(_);if(wi(_,I))return v&&yi({data:_,method:s,instance:n,store:c}),Promise.resolve(_);if(S.hasOwnProperty(I)&&S[I]===!0)return c.dispatch({type:"queue",plugin:I,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(_);var M=m(g[I],i[I]);return Promise.resolve(O[s]({abort:M.abort,payload:A,instance:n,config:_u(I,f,i),plugins:f})).then(function(F){var W=re(F)?F:{},L=C({},_,W),N=g[I];if(wi(N,I))yi({data:N,method:s,instance:n,pluginName:I,store:c});else{var z=s+":"+I;(z.match(/:/g)||[]).length<2&&!s.match(Eu)&&!s.match(Ou)&&n.dispatch(C({},d?L:A,{type:z,_:{called:z,from:"submethod"}}))}return Promise.resolve(L)})})}catch(_){return Promise.reject(_)}},Promise.resolve(r))).then(function($){if(!(s.match(Lt)||s.match(/^registerPlugin/)||s.match(Ou)||s.match(Eu)||s.match(/^params/)||s.match(/^userIdChanged/))){if(l.plugins.includes(s),$._&&$._.originalAction===s)return $;var P=C({},$,{_:{originalAction:$.type,called:$.type,from:"engineEnd"}});ju($,t.exact.length)&&!s.match(/End$/)&&(P=C({},P,{type:$.type+"Aborted"})),c.dispatch(P)}return $})})}catch(g){return Promise.reject(g)}},Lt=/Start$/,Eu=/^bootstrap/,Ou=/^ready/;function yi(e){var t=e.pluginName,r=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(C({},e.data,{type:r,_:{called:r,from:"abort"}}))}function _u(e,t,r){var n=t[e]||r[e];return n&&n.config?n.config:{}}function Ru(e,t){return t.reduce(function(r,n){return n[e]?r.concat({methodName:e,pluginName:n.name,method:n[e]}):r},[])}function Cu(e,t){var r=e.replace(Lt,""),n=t?":"+t:"";return[""+e+n,""+r+n,r+"End"+n]}function wi(e,t){var r=e.abort;return!!r&&(r===!0||Au(r,t)||r&&Au(r.plugins,t))}function ju(e,t){var r=e.abort;if(!r)return!1;if(r===!0||He(r))return!0;var n=r.plugins;return sr(r)&&r.length===t||sr(n)&&n.length===t}function sr(e){return Array.isArray(e)}function Au(e,t){return!(!e||!sr(e))&&e.includes(t)}function Lu(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function vb(e){return Object.keys(e).reduce(function(t,r){return r==="type"||(t[r]=re(e[r])?Object.assign({},e[r]):e[r]),t},{})}function pb(e,t,r){var n={};return function(a){return function(i){return function(o){try{var c,l=function(v){return c?v:i(s)},f=o.type,u=o.plugins,s=o;if(o.abort)return Promise.resolve(i(o));if(f===j.enablePlugin&&a.dispatch({type:j.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:o.meta}),f===j.disablePlugin&&setTimeout(function(){return ku(o.meta.rid,{payload:o})},0),f===j.initializeEnd){var d=t(),h=Object.keys(d),m=h.filter(function(v){return u.includes(v)}).map(function(v){return d[v]}),S=[],g=[],$=o.disabled,P=m.map(function(v){var I=v.loaded,O=v.name,_=v.config;return Pu(v,function(){return I({config:_})},1e4).then(function(A){return n[O]||(a.dispatch({type:j.pluginReadyType(O),name:O,events:Object.keys(v).filter(function(M){return!pi.includes(M)})}),n[O]=!0),S=S.concat(O),v}).catch(function(A){if(A instanceof Error)throw new Error(A);return g=g.concat(A.name),A})});Promise.all(P).then(function(v){var I={plugins:S,failed:g,disabled:$};setTimeout(function(){h.length===P.length+$.length&&a.dispatch(C({},{type:j.ready},I))},0)})}var b=function(){if(f!==j.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Tu(a,t,e)},0),Promise.resolve(function(v,I,O,_,A){try{var M=te(I)?I():I,F=v.type,W=F.replace(Lt,"");if(v._&&v._.called)return Promise.resolve(v);var L=O.getState(),N=(K=M,(Z=L.plugins)===void 0&&(Z={}),(Le=v.options)===void 0&&(Le={}),Object.keys(K).filter(function(p){var y=Le.plugins||{};return Yw(y[p])?y[p]:y.all!==!1&&(!Z[p]||Z[p].enabled!==!1)}).map(function(p){return K[p]}));F===j.initializeStart&&v.fromEnable&&(N=Object.keys(L.plugins).filter(function(p){var y=L.plugins[p];return v.plugins.includes(p)&&!y.initialized}).map(function(p){return M[p]}));var z=N.map(function(p){return p.name}),R=function(p,y,E){var U=Cu(p).map(function(x){return Ru(x,y)});return y.reduce(function(x,D){var V=D.name,w=Cu(p,V).map(function(ne){return Ru(ne,y)}),k=w[0],T=w[1],H=w[2];return k.length&&(x.beforeNS[V]=k),T.length&&(x.duringNS[V]=T),H.length&&(x.afterNS[V]=H),x},{before:U[0],beforeNS:{},during:U[1],duringNS:{},after:U[2],afterNS:{}})}(F,N);return Promise.resolve(gi({action:v,data:{exact:R.before,namespaced:R.beforeNS},state:L,allPlugins:M,allMatches:R,instance:O,store:_,EVENTS:A})).then(function(p){function y(){var x=function(){if(F.match(Lt))return Promise.resolve(gi({action:C({},E,{type:W+"End"}),data:{exact:R.after,namespaced:R.afterNS},state:L,allPlugins:M,allMatches:R,instance:O,store:_,EVENTS:A})).then(function(D){D.meta&&D.meta.hasCallback&&ku(D.meta.rid,{payload:D})})}();return x&&x.then?x.then(function(){return p}):p}if(ju(p,z.length))return p;var E,U=function(){if(F!==W)return Promise.resolve(gi({action:C({},p,{type:W}),data:{exact:R.during,namespaced:R.duringNS},state:L,allPlugins:M,allMatches:R,instance:O,store:_,EVENTS:A})).then(function(x){E=x});E=p}();return U&&U.then?U.then(y):y()})}catch(p){return Promise.reject(p)}var K,Z,Le}(o,t,e,a,r)).then(function(v){return c=1,i(v)})}();return Promise.resolve(b&&b.then?b.then(l):l(b))}catch(v){return Promise.reject(v)}}}}}function mb(e){return function(t){return function(r){return function(n){var a=n.type,i=n.key,o=n.value,c=n.options;if(a===j.setItem||a===j.removeItem){if(n.abort)return r(n);a===j.setItem?e.setItem(i,o,c):e.removeItem(i,c)}return r(n)}}}}var gb=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,r){e[r]=e[r].concat(t)},this.removeMiddleware=function(t,r){var n=e[r].findIndex(function(a){return a===t});n!==-1&&(e[r]=[].concat(e[r].slice(0,n),e[r].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(r){return function(n){return function(a){var i={getState:r.getState,dispatch:function(c){return r.dispatch(c)}},o=e[t].map(function(c){return c(i)});return Ct.apply(void 0,o)(n)(a)}}}}};function yb(e){return function(t,r){t===void 0&&(t={});var n={};if(r.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(r.type)){var a=Uu(r.type,"registerPlugin"),i=e()[a];if(!i||!a)return t;var o=r.enabled,c=i.config;return n[a]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:c}),config:c},C({},t,n)}if(/^initialize:([^:]*)$/.test(r.type)){var l=Uu(r.type,j.initialize),f=e()[l];return f&&l?(n[l]=C({},t[l],{initialized:!0,loaded:!!f.loaded({config:f.config})}),C({},t,n)):t}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=C({},t[r.name],{loaded:!0}),C({},t,n);switch(r.type){case j.disablePlugin:return C({},t,xu(r.plugins,!1,t));case j.enablePlugin:return C({},t,xu(r.plugins,!0,t));default:return t}}}function Uu(e,t){return e.substring(t.length+1,e.length)}function xu(e,t,r){return e.reduce(function(n,a){return n[a]=C({},r[a],{enabled:t}),n},r)}function Nu(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var wb={last:{},history:[]};function bb(e,t){e===void 0&&(e=wb);var r=t.options,n=t.meta;if(t.type===j.track){var a=Nu(C({event:t.event,properties:t.properties},Object.keys(r).length&&{options:r},{meta:n}));return C({},e,{last:a,history:e.history.concat(a)})}return e}var Sb={actions:[]};function Ib(e,t){e===void 0&&(e=Sb);var r=t.payload;switch(t.type){case"queue":var n;return n=r&&r.type&&r.type===j.identify?[t].concat(e.actions):e.actions.concat(t),C({},e,{actions:n});case"dequeue":return[];default:return e}}var Du=/#.*$/;function $b(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Du,""):"")}var Mu,Fu,zu,Hu,kb=function(e){if(e===void 0&&(e={}),!Y)return e;var t=document,r=t.title,n=t.referrer,a=window,i=a.location,o=a.innerWidth,c=a.innerHeight,l=i.hash,f=i.search,u=function(d){var h=function(){if(Y){for(var m,S=document.getElementsByTagName("link"),g=0;m=S[g];g++)if(m.getAttribute("rel")==="canonical")return m.getAttribute("href")}}();return h?h.match(/\?/)?h:h+d:window.location.href.replace(Du,"")}(f),s={title:r,url:u,path:$b(u),hash:l,search:f,width:o,height:c};return n&&n!==""&&(s.referrer=n),C({},s,e)},Pb={last:{},history:[]};function Tb(e,t){e===void 0&&(e=Pb);var r=t.options;if(t.type===j.page){var n=Nu(C({properties:t.properties,meta:t.meta},Object.keys(r).length&&{options:r}));return C({},e,{last:n,history:e.history.concat(n)})}return e}Mu=function(){if(!Y)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),Fu=Y?document.referrer:null,zu=rb(),Hu=nb();var Bu={initialized:!1,sessionId:Qr(),app:null,version:null,debug:!1,offline:!!Y&&!navigator.onLine,os:{name:Mu},userAgent:Y?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.13"},timezone:Hu,locale:zu,campaign:{},referrer:Fu};function Eb(e,t){e===void 0&&(e=Bu);var r=e.initialized,n=t.campaign;switch(t.type){case j.campaign:return C({},e,{campaign:n});case j.offline:return C({},e,{offline:!0});case j.online:return C({},e,{offline:!1});default:return r?e:C({},Bu,e,{initialized:!0})}}var Ob=["plugins","reducers","storage"];function _b(e,t,r){if(Y){var n=window[(r?"add":"remove")+"EventListener"];e.split(" ").forEach(function(a){n(a,t)})}}function Rb(e){var t=_b.bind(null,"online offline",function(r){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(r){return t(!1)}}function Ku(){return it("analytics",[]),function(e){return function(t,r,n){var a=e(t,r,n),i=a.dispatch;return Object.assign(a,{dispatch:function(o){return Ot[Et].analytics.push(o.action||o),i(o)}})}}}function Gu(e){return function(){return Ct(Ct.apply(null,arguments),Ku())}}function bi(e){return e?pu(e)?e:[e]:[]}function Wu(e,t,r){e===void 0&&(e={});var n,a,i=Qr();return t&&(or[i]=(n=t,a=function(o){for(var c,l=o||Array.prototype.slice.call(arguments),f=0;f<l.length;f++)if(te(l[f])){c=l[f];break}return c}(r),function(o){a&&a(o),n(o)})),C({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function Cb(e){e===void 0&&(e={});var t=e.reducers||{},r=e.initialUser||{},n=(e.plugins||[]).reduce(function(p,y){if(te(y))return p.middlewares=p.middlewares.concat(y),p;if(y.NAMESPACE&&(y.name=y.NAMESPACE),!y.name)throw new Error("https://lytics.dev/errors/1");y.config||(y.config={});var E=y.EVENTS?Object.keys(y.EVENTS).map(function(D){return y.EVENTS[D]}):[];p.pluginEnabled[y.name]=!(y.enabled===!1||y.config.enabled===!1),delete y.enabled,y.methods&&(p.methods[y.name]=Object.keys(y.methods).reduce(function(D,V){var w;return D[V]=(w=y.methods[V],function(){for(var k=Array.prototype.slice.call(arguments),T=new Array(w.length),H=0;H<k.length;H++)T[H]=k[H];return T[T.length]=I,w.apply({instance:I},T)}),D},{}),delete y.methods);var U=Object.keys(y).concat(E),x=new Set(p.events.concat(U));if(p.events=Array.from(x),p.pluginsArray=p.pluginsArray.concat(y),p.plugins[y.name])throw new Error(y.name+"AlreadyLoaded");return p.plugins[y.name]=y,p.plugins[y.name].loaded||(p.plugins[y.name].loaded=function(){return!0}),p},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),a=e.storage?e.storage:{getItem:at,setItem:it,removeItem:_t},i=function(p){return function(y,E,U){return E.getState("user")[y]||(U&&re(U)&&U[y]?U[y]:$u(p)[y]||at(mi(y))||null)}}(a),o=n.plugins,c=n.events.filter(function(p){return!pi.includes(p)}).sort(),l=new Set(c.concat(rn).filter(function(p){return!pi.includes(p)})),f=Array.from(l).sort(),u=function(){return o},s=new gb,d=s.addMiddleware,h=s.removeMiddleware,m=s.dynamicMiddlewares,S=function(){throw new Error("Abort disabled inListener")},g=ab(),$=$u(a),P=C({},$,r,g.an_uid?{userId:g.an_uid}:{},g.an_aid?{anonymousId:g.an_aid}:{});P.anonymousId||(P.anonymousId=Qr());var b=C({enable:function(p,y){return new Promise(function(E){R.dispatch({type:j.enablePlugin,plugins:bi(p),_:{originalAction:j.enablePlugin}},E,[y])})},disable:function(p,y){return new Promise(function(E){R.dispatch({type:j.disablePlugin,plugins:bi(p),_:{originalAction:j.disablePlugin}},E,[y])})}},n.methods),v=!1,I={identify:function(p,y,E,U){try{var x=He(p)?p:null,D=re(p)?p:y,V=E||{},w=I.user();it(mi(Ge),x);var k=x||D.userId||i(Ge,I,D);return Promise.resolve(new Promise(function(T){R.dispatch(C({type:j.identifyStart,userId:k,traits:D||{},options:V,anonymousId:w.anonymousId},w.id&&w.id!==x&&{previousId:w.id}),T,[y,E,U])}))}catch(T){return Promise.reject(T)}},track:function(p,y,E,U){try{var x=re(p)?p.event:p;if(!x||!He(x))throw new Error("EventMissing");var D=re(p)?p:y||{},V=re(E)?E:{};return Promise.resolve(new Promise(function(w){R.dispatch({type:j.trackStart,event:x,properties:D,options:V,userId:i(Ge,I,y),anonymousId:i(At,I,y)},w,[y,E,U])}))}catch(w){return Promise.reject(w)}},page:function(p,y,E){try{var U=re(p)?p:{},x=re(y)?y:{};return Promise.resolve(new Promise(function(D){R.dispatch({type:j.pageStart,properties:kb(U),options:x,userId:i(Ge,I,U),anonymousId:i(At,I,U)},D,[p,y,E])}))}catch(D){return Promise.reject(D)}},user:function(p){if(p===Ge||p==="id")return i(Ge,I);if(p===At||p==="anonId")return i(At,I);var y=I.getState("user");return p?uu(y,p):y},reset:function(p){return new Promise(function(y){R.dispatch({type:j.resetStart},y,p)})},ready:function(p){return v&&p({plugins:b,instance:I}),I.on(j.ready,function(y){p(y),v=!0})},on:function(p,y){if(!p||!te(y))return!1;if(p===j.bootstrap)throw new Error(".on disabled for "+p);var E=/Start$|Start:/;if(p==="*"){var U=function(w){return function(k){return function(T){return T.type.match(E)&&y({payload:T,instance:I,plugins:o}),k(T)}}},x=function(w){return function(k){return function(T){return T.type.match(E)||y({payload:T,instance:I,plugins:o}),k(T)}}};return d(U,nn),d(x,an),function(){h(U,nn),h(x,an)}}var D=p.match(E)?nn:an,V=function(w){return function(k){return function(T){return T.type===p&&y({payload:T,instance:I,plugins:o,abort:S}),k(T)}}};return d(V,D),function(){return h(V,D)}},once:function(p,y){if(!p||!te(y))return!1;if(p===j.bootstrap)throw new Error(".once disabled for "+p);var E=I.on(p,function(U){y({payload:U.payload,instance:I,plugins:o,abort:S}),E()});return E},getState:function(p){var y=R.getState();return p?uu(y,p):Object.assign({},y)},dispatch:function(p){var y=He(p)?{type:p}:p;if(rn.includes(y.type))throw new Error("reserved action "+y.type);var E=C({},y,{_:C({originalAction:y.type},p._||{})});R.dispatch(E)},enablePlugin:b.enable,disablePlugin:b.disable,plugins:b,storage:{getItem:a.getItem,setItem:function(p,y,E){R.dispatch({type:j.setItemStart,key:p,value:y,options:E})},removeItem:function(p,y){R.dispatch({type:j.removeItemStart,key:p,options:y})}},setAnonymousId:function(p,y){I.storage.setItem(Ke,p,y)},events:{core:rn,plugins:c}},O=n.middlewares.concat([function(p){return function(y){return function(E){return E.meta||(E.meta=Wu()),y(E)}}},m(nn),pb(I,u,{all:f,plugins:c}),mb(a),lb(I),db(I),m(an)]),_={context:Eb,user:fb(a),page:Tb,track:bb,plugins:yb(u),queue:Ib},A=Ct,M=Ct;if(Y&&e.debug){var F=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;F&&(A=F({trace:!0,traceLimit:25})),M=function(){return arguments.length===0?Ku():re(typeof arguments[0])?Gu():Gu().apply(null,arguments)}}var W,L=function(p){return Object.keys(p).reduce(function(y,E){return Ob.includes(E)||(y[E]=p[E]),y},{})}(e),N=n.pluginsArray.reduce(function(p,y){var E=y.name,U=y.config,x=y.loaded,D=n.pluginEnabled[E];return p[E]={enabled:D,initialized:!!D&&!y.initialize,loaded:!!x({config:U}),config:U},p},{}),z={context:L,user:P,plugins:N},R=wu(function(p){for(var y=Object.keys(p),E={},U=0;U<y.length;U++){var x=y[U];typeof p[x]===Be&&(E[x]=p[x])}var D,V=Object.keys(E);try{(function(w){Object.keys(w).forEach(function(k){var T=w[k];if(typeof T(void 0,{type:"@@redux/INIT"})===je||typeof T(void 0,{type:sb})===je)throw new Error("reducer "+k+" "+je)})})(E)}catch(w){D=w}return function(w,k){if(w===void 0&&(w={}),D)throw D;for(var T=!1,H={},ne=0;ne<V.length;ne++){var We=V[ne],Sl=w[We],Ci=(0,E[We])(Sl,k);if(typeof Ci===je){var bS=cb(We,k);throw new Error(bS)}H[We]=Ci,T=T||Ci!==Sl}return T?H:w}}(C({},_,t)),z,M(A(ub.apply(void 0,O))));R.dispatch=(W=R.dispatch,function(p,y,E){var U=C({},p,{meta:Wu(p.meta,y,bi(E))});return W.apply(null,[U])});var K=Object.keys(o);R.dispatch({type:j.bootstrap,plugins:K,config:L,params:g,user:P,initialUser:r,persistedUser:$});var Z=K.filter(function(p){return n.pluginEnabled[p]}),Le=K.filter(function(p){return!n.pluginEnabled[p]});return R.dispatch({type:j.registerPlugins,plugins:K,enabled:n.pluginEnabled}),n.pluginsArray.map(function(p,y){var E=p.bootstrap,U=p.config,x=p.name;E&&te(E)&&E({instance:I,config:U,payload:p}),R.dispatch({type:j.registerPluginType(x),name:x,enabled:n.pluginEnabled[x],plugin:p}),n.pluginsArray.length===y+1&&R.dispatch({type:j.initializeStart,plugins:Z,disabled:Le})}),Rb(function(p){R.dispatch({type:p?j.offline:j.online})}),function(p,y,E){setInterval(function(){return Tu(p,y,E)},3e3)}(R,u,I),I}var nn="before",an="after",cr="cookie",st=Yu(),Vu=on,jb=on;function Zu(e){return st?on(e,"",-1):_t(e)}function Yu(){if(st!==void 0)return st;var e="cookiecookie";try{on(e,e),st=document.cookie.indexOf(e)!==-1,Zu(e)}catch{st=!1}return st}function on(e,t,r,n,a,i){if(typeof window<"u"){var o=arguments.length>1;return st===!1&&(o?it(e,t):at(e)),o?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(a?"; domain="+a:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var ur="localStorage",Ab=vi.bind(null,"localStorage");Rt("localStorage","getItem",at),Rt("localStorage","setItem",it),Rt("localStorage","removeItem",_t);var lr="sessionStorage",Lb=vi.bind(null,"sessionStorage");Rt("sessionStorage","getItem",at),Rt("sessionStorage","setItem",it),Rt("sessionStorage","removeItem",_t);function Ut(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(re(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var Ub=Ab(),xb=Lb(),Nb=Yu();function Ju(e,t){if(e){var r=Si(t),n=!Pi(r),a=Ii(r)?Ut(localStorage.getItem(e)):void 0;if(n&&!Tt(a))return a;var i=$i(r)?Ut(Vu(e)):void 0;if(n&&i)return i;var o=ki(r)?Ut(sessionStorage.getItem(e)):void 0;if(n&&o)return o;var c=at(e);return n?c:{localStorage:a,sessionStorage:o,cookie:i,global:c}}}function Db(e,t,r){if(e&&!Tt(t)){var n={},a=Si(r),i=JSON.stringify(t),o=!Pi(a);return Ii(a)&&(n[ur]=cn(ur,t,Ut(localStorage.getItem(e))),localStorage.setItem(e,i),o)?n[ur]:$i(a)&&(n[cr]=cn(cr,t,Ut(Vu(e))),jb(e,i),o)?n[cr]:ki(a)&&(n[lr]=cn(lr,t,Ut(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),o)?n[lr]:(n[ir]=cn(ir,t,at(e)),it(e,t),o?n[ir]:n)}}function Mb(e,t){if(e){var r=Si(t),n=Ju(e,du),a={};return!Tt(n.localStorage)&&Ii(r)&&(localStorage.removeItem(e),a[ur]=n.localStorage),!Tt(n.cookie)&&$i(r)&&(Zu(e),a[cr]=n.cookie),!Tt(n.sessionStorage)&&ki(r)&&(sessionStorage.removeItem(e),a[lr]=n.sessionStorage),!Tt(n.global)&&sn(r,ir)&&(_t(e),a[ir]=n.global),a}}function Si(e){return e?He(e)?e:e.storage:fu}function Ii(e){return Ub&&sn(e,ur)}function $i(e){return Nb&&sn(e,cr)}function ki(e){return xb&&sn(e,lr)}function Pi(e){return e===du||e==="all"}function sn(e,t){return e===fu||e===t||Pi(e)}function cn(e,t,r){return{location:e,current:t,previous:r}}var Fb={setItem:Db,getItem:Ju,removeItem:Mb};function zb(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Xu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function qu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Xu(Object(r),!0).forEach(function(n){zb(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Hb(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:Fb};return Cb(qu(qu({},t),e))}function Bb(e,t){t=t||{};var r,n,a=[],i=t.max||1/0;function o(){clearInterval(r),e(a.splice(0,i)),c()}function c(){r=setInterval(o,t.interval||1e4)}return c(),{flush:o,push:function(l){return n=a.push(l),n>=i&&o(),n},size:function(){return a.length},end:function(l){l&&o(),clearInterval(r)}}}function Kb(e){if(typeof window>"u")return;const{addEventListener:t,history:r,location:n}=window;let a=n.pathname;t("popstate",()=>e(n.pathname)),["push","replace"].map(i=>{const o=`${i}State`;if(o!=="pushState"&&o!=="replaceState")return;const c=r[o];r[o]=function(...l){var s;const f=((s=l[2])==null?void 0:s.toString())||"",u=Wb(f);return a!==u&&(a=u,setTimeout(()=>e(f),0)),c.apply(r,l)}})}function Gb(e,t){const r=e.indexOf(t);return r>-1?e.slice(0,r):e}function Wb(e){return["#","?"].forEach(t=>e=Gb(e,t)),e}function Vb(){Kb(()=>{Ae.page()})}function Zb(e){if(e===void 0&&(e={}),!Y)return hi;var t=el(),r=Ti(),n=Qu(),a=un(n,t),i=un(r,t),o=[],c=[],l=[],f=n,u=a,s=i,d=Object.keys(e);if(!d.length)return hi;var h=d.map(function(S){return Number(S)}),m=ob(function(){var S=el(),g=function(L,N){return N.map(function(z){return z===100?L-5:L*(z/100)})}(S,h),$=Ti(),P=Qu(),b=un(P,S),v=un($,S);if(u=b>u?b:u,s=v<s?v:s,!(o.length>=h.length)){var I=f===P,O="up";I?O="initial":f<=P&&(O="down");var _=g,A=h;(O==="up"||I)&&(_=g.slice().reverse(),A=h.slice().reverse());var M=A.reduce(function(L,N,z){var R=_[z];return l.includes(N)&&P<=R&&(l=l.filter(function(K){return K!==N}),L.singleFunction=N),O==="down"&&!o.includes(N)&&P>=R&&N>i?(c.push(N),L.callbacks=L.callbacks.concat(N),L):O==="up"&&!o.includes(N)&&P<=R&&N<=b?(L.foundFunc=[N],L):(I&&P>=R&&L.foundFunc.length===0&&(L.foundFunc=[N]),!c.includes(N)&&P>=R&&(c.push(N),L.singleFunction?l.push(N):L.singleFunction=N),L)},{foundFunc:[],singleFunction:null,callbacks:[],direction:O});if(f=P,O==="down"&&M.callbacks&&M.callbacks.forEach(function(L){te(e[L])&&(e[L]({trigger:L,direction:O,scrollMin:s,scrollMax:u,range:[s,u]}),o.push(L))}),M.singleFunction){var F=M.singleFunction,W=M.direction;te(e[F])&&e[F]({trigger:F,direction:W,scrollMin:s,scrollMax:u,range:[s,u]}),o.push(F)}}},500);return window.addEventListener("scroll",m),function(){return window.removeEventListener("scroll",m)}}function Ti(){return Y?document.body.scrollTop||document.documentElement.scrollTop:0}function Yb(){return Y?window.innerHeight||document.documentElement.clientHeight:0}function Qu(){return Math.round(Ti()+Yb())}function el(){if(!Y)return 0;var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)}function un(e,t){return Math.round(e/t*100)}var tl="EventListener";function Jb(e){return function(t,r,n,a){var i=n||hi,o=a||!1;if(!Y)return i;var c=ln(r),l=ln(t,!0);if(!l.length)throw new Error("noElements");if(!c.length)throw new Error("noEvent");var f=[];return function u(s){s&&(f=[]);for(var d=s?"add"+tl:"remove"+tl,h=0;h<l.length;h++){var m=l[h];f[h]=s?o&&o.once?Xb(i):i:f[h]||i;for(var S=0;S<c.length;S++)m[d]?m["on"+c[S]]=s?f[h]:null:m[d](c[S],f[h],o)}return u.bind(null,!s)}(e)}}function ln(e,t){if(He(e))return t?ln(document.querySelectorAll(e)):(r=e).split(r.indexOf(",")>-1?",":" ").map(function(o){return o.trim()});var r;if(NodeList.prototype.isPrototypeOf(e)){for(var n=[],a=e.length>>>0;a--;)n[a]=e[a];return n}var i=tb(e);return t?i.map(function(o){return He(o)?ln(o,!0):o}).flat():i}function Xb(e,t){var r;return function(){return e&&(r=e.apply(this,arguments),e=null),r}}var Ei=Jb("Event");function rl(e,t){return Y&&te(window[e])?(r=window[e],n=t,(a=window)===void 0&&(a=null),te(r)?function(){r.apply(a,arguments),n.apply(a,arguments)}:n):window[e]=t;var r,n,a}rl.bind(null,"onerror"),rl.bind(null,"onload");var nl=typeof window>"u",al="hidden";function qb(e){if(nl)return!1;var t=Qb(),r="".concat(t.replace(/[H|h]idden/,""),"visibilitychange"),n=function(){return e(!!document[t])},a=function(){return document.addEventListener(r,n)};return a(),function(){return document.removeEventListener(r,n),a}}function Qb(){var e=["webkit","moz","ms","o"];return nl||al in document?al:e.reduce(function(t,r){var n=r+"Hidden";return!t&&n in document?n:t},null)}var eS=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function tS(e,t){t===void 0&&(t={});var r=function(o,c){var l=this,f=!1;return function(u){f||(o.call(l,u),f=!0,setTimeout(function(){return f=!1},c))}}(e,t.throttle||1e4),n=[];function a(){var o=qb(function(c){c||r({type:"tabVisible"})});return n=[o].concat(eS.map(function(c){return Ei(document,c,r)})).concat(Ei(window,"load",r)).concat(Ei(window,"scroll",r,{capture:!0,passive:!0})),i}function i(){n.map(function(o){return o()})}return a(),function(){return i(),a}}function rS(e){var t,r,n=e.onIdle,a=e.onWakeUp,i=e.onHeartbeat,o=e.timeout,c=o===void 0?1e4:o,l=e.throttle,f=l===void 0?2e3:l,u=!1,s=!1,d=new Date,h=function(){return clearTimeout(t)};function m(g){h(),i&&!u&&i(fr(d),g),a&&u&&(u=!1,a(fr(r),g),d=new Date),t=setTimeout(function(){u=!0,n&&(r=new Date,n(fr(d),g))},c)}var S=tS(m,{throttle:f});return{disable:function(){s=!0,u=!1,h();var g=S();return function(){return s=!1,d=new Date,m({type:"load"}),g()}},getStatus:function(){return{isIdle:u,isDisabled:s,active:u?0:fr(d,s),idle:u?fr(r,s):0}}}}function fr(e,t){return t?0:Math.round((new Date-e)/1e3)}const il=5e3;class nS{constructor(t){ve(this,"element");ve(this,"isInViewport",!1);ve(this,"isAwake",!1);ve(this,"isFlushing");ve(this,"observer");ve(this,"lastEventAt",Date.now());ve(this,"registeredView",!1);ve(this,"viewCallback");ve(this,"activeDurationCallback");ve(this,"idleDurationCallback");ve(this,"scrollCallback");this.element=t.element,this.viewCallback=t.viewCallback,this.activeDurationCallback=t.activeDurationCallback,this.idleDurationCallback=t.idleDurationCallback,this.scrollCallback=t.scrollCallback,this.observer=new IntersectionObserver(r=>{r.forEach(n=>{this.handleInViewPort(n.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),rS({onIdle:r=>this.handleAwake(!1,r),onWakeUp:r=>this.handleAwake(!0,r),timeout:il}),Zb({25:this.handleScroll.bind(this),50:this.handleScroll.bind(this),75:this.handleScroll.bind(this),90:this.handleScroll.bind(this),100:this.handleScroll.bind(this)})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake)}handleInViewPort(t){t?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=t}handleAwake(t,r=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=t,this.lastEventAt=t?Date.now()-r*il:Date.now(),this.isInViewport&&this.trackAwake(t,r)}handleScroll(t){this.scrollCallback&&this.scrollCallback(t)}handleVisibilityChange(){this.isAwake=!1;const t=Math.round((Date.now()-this.lastEventAt)/1e3);t>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,t))}trackAwake(t,r){!t&&this.activeDurationCallback&&this.activeDurationCallback(r,this.isFlushing,this.lastEventAt),t&&this.idleDurationCallback&&this.idleDurationCallback(r,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const ol="sesamy_session_id";function aS(){let e=sessionStorage.getItem(ol);return e||(e=Math.random().toString(36).slice(2,9),sessionStorage.setItem(ol,e)),e}let sl=!1,Oi,cl,fn;function iS({clientId:e,enabled:t=!0,environment:r}){if(Oi=e,cl=t,fn=`${ze("logs",r)}/events`,!cl)return;Vb();const n=new nS({element:document.body,viewCallback:()=>{Ae.page()},activeDurationCallback:(a,i,o)=>{Ae.track("activeDuration",{duration:a,durationStart:o,flushing:i})},idleDurationCallback:(a,i,o)=>{Ae.track("idleDuration",{duration:a,durationStart:o,flushing:i})},scrollCallback:a=>{Ae.track("scroll",{scroll:a.scrollMax})}});cS(document.body,()=>{n.flush()}),uS(document.body,()=>{n.handleVisibilityChange()}),window.addEventListener(we.AUTHENTICATED,async a=>{const i=a;await Ae.identify(i.detail.sub)}),window.addEventListener(we.LOGOUT,async()=>{await Ae.track("logout",{}),_i.flush(),await Ae.reset()})}function ul(e){return JSON.stringify(e.map(t=>({...t,clientId:Oi,requestId:Math.random().toString(36).slice(2,9),sessionId:aS(),timestamp:new Date().toISOString(),version:di,event:t.event,context:{page:{url:window.location.hostname,path:window.location.pathname,title:document.title,search:window.location.search,referrer:document.referrer},locale:navigator.language,library:cu,userAgent:navigator.userAgent,clientId:Oi}})))}const _i=Bb(async e=>{if(e.length>0){const t=ul(e);sl?navigator.sendBeacon(fn,t):(await fetch(fn,{method:"POST",body:t,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Ri(e){var t;if(e.anonymousId)if((t=e.properties)!=null&&t.flushing){const r={...e};delete r.properties.flushing,navigator.sendBeacon(fn,ul([r]))}else _i.push(e)}const Ae=Hb({app:cu,version:di,plugins:[{name:"custom-analytics-plugin",page:({payload:e})=>{const{properties:t,anonymousId:r,userId:n,event:a}=e;Ri({anonymousId:r,userId:n,properties:t,event:a,type:"page"})},track:({payload:e})=>{const{properties:t,anonymousId:r,userId:n,event:a}=e;Ri({anonymousId:r,userId:n,properties:t,event:a,type:"track"})},identify:({payload:e})=>{const{properties:t,anonymousId:r,userId:n}=e;Ri({anonymousId:r,userId:n,properties:t,type:"identify"})}}]});function oS(e,t){Ae.track(e,t)}function sS(){return sl=!0,_i.flush()}const ll=new Map;function cS(e,t){ll.set(e,t)}window.addEventListener("beforeunload",()=>{ll.forEach((e,t)=>{e.bind(t)()}),sS()});const fl=new Map;function uS(e,t){fl.set(e,t)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&fl.forEach((e,t)=>{e.bind(t)()})});const dl="sesamySignedURLs";function hl(){const e=sessionStorage.getItem(dl);return e?JSON.parse(e):[]}function lS(e){const t=hl();t.push(e),sessionStorage.setItem(dl,JSON.stringify(t))}function fS(e){const{createCheckout:t,getCheckout:r,updateCheckout:n,getEntitlement:a,getEntitlements:i,getEntitlementAccess:o,getSubscriptions:c,getContract:l,getContracts:f,getBill:u,getBills:s,getTransaction:d,getTransactions:h,getProfile:m,updateProfile:S,getTags:g,deleteTag:$,setTag:P,getUserMetadata:b,listUserMetadata:v,setUserMetadata:I,deleteUserMetadata:O,getTally:_,getTallies:A,pushTally:M,deleteTally:F,getProduct:W,getPaymentIssues:L,isSpotifyLinked:N,unlinkSpotify:z,linkSpotify:R,autoOnboardProduct:K,openHostedAccountPage:Z,generateLink:Le}=Gw(e),p={auth:{getUser:m,isAuthenticated:li,loginWithRedirect:fi,logout:Xc,setToken:Qc},checkouts:{get:r,create:t,update:n},profile:{get:m,update:S,openHostedAccountPage:Z,isSpotifyLinked:N,unlinkSpotify:z},analytics:{track:oS},tags:{list:g,set:P,delete:$},entitlements:{get:a,list:i,access:o,signedLinks:hl},contracts:{get:l,list:f},bills:{get:u,list:s},userMetadata:{get:b,list:v,set:I,delete:O},tallies:{get:_,list:A,push:M,delete:F},subscriptions:{list:c},transactions:{get:d,list:h},products:{get:W,autoOnboard:K,linkSpotify:R},getVersion:dS,getPaymentIssues:L,generateLink:Le,clearCache:be};return e.namespace&&(window[e.namespace]=p),p}function dS(){return di}async function hS({enabled:e=!1,rules:t}){if(!e)return;const r=await li(),n=window.location.href;for(const a of t){const i=document.querySelectorAll(a.selector);if(!(a.path&&!new RegExp(a.path).test(n))){for(const o of i)if(!(a.authenticated!==void 0&&a.authenticated!==r))switch(a.transform){case"insert":if(a.contentType==="selector"&&a.content){const c=document.querySelector(a.content);c?o.innerHTML+=c.innerHTML:console.warn(`Source element for selector '${a.content}' not found`)}else if(a.contentType==="url"&&a.content){const c=await vl(a.content);c?o.innerHTML+=c:console.warn(`Failed to fetch content from URL '${a.content}'`)}else a.content&&(o.innerHTML+=a.content);break;case"replace":if(a.contentType==="selector"&&a.content){const c=document.querySelector(a.content);c?o.innerHTML=c.innerHTML:console.warn(`Source element for selector '${a.content}' not found`)}else if(a.contentType==="url"&&a.content){const c=await vl(a.content);c?o.innerHTML=c:console.warn(`Failed to fetch content from URL '${a.content}'`)}else a.content&&(o.innerHTML=a.content);break;case"remove":o.remove();break;default:console.warn(`Unknown transform type: ${a.transform}`)}}}}async function vl(e){try{const t=await fetch(e);return t.ok?await t.text():(console.error(`Failed to fetch content from ${e}: ${t.statusText}`),null)}catch(t){return console.error(`Error fetching content from ${e}:`,t),null}}function vS(){const e=new URLSearchParams(window.location.hash.substring(1)),t=e.get("access_token");if(t){Qc(t);const r=new URL(window.location.href);e.delete("access_token"),r.hash=e.toString(),window.history.replaceState(null,"",r)}}const pl="sesamy-refresh",ml="force-refetch-entitlements";function pS(){const e=new URLSearchParams(window.location.search),t=e.get(ml),r=e.get(pl);if(t!==null||r!==null){const n=new URL(window.location.href);e.delete(ml),e.delete(pl),n.search=e.toString(),be(),window.history.replaceState(null,"",n)}}function mS(){const e=new URLSearchParams(window.location.search),t=e.get("token"),r=e.get("se");if(!r||!t)return;const n=parseInt(r,10);if(Number.isNaN(n)||n<Date.now())return;lS({url:window.location.href.split("?")[0],token:t,expiresAt:n,publisherContentId:e.get("sp")??void 0});const a=new URL(window.location.href);a.searchParams.delete("ss"),a.searchParams.delete("se"),a.searchParams.delete("sp"),a.searchParams.delete("so"),a.searchParams.delete("token"),window.history.replaceState(null,"",a)}const gl="sesamy-user";async function gS(){const t=new URLSearchParams(window.location.search).get(gl);if(!t)return;const r=await jw();(r==null?void 0:r.email)!==t&&(be(),fi({authorizationParams:{email_hint:t,login_hint:t}}));const n=new URL(window.location.href);n.searchParams.delete(gl),window.history.replaceState(null,"",n)}const yl="sesamy-purchase";function yS(){const e=new URLSearchParams(window.location.search),t=e.get(yl);if(t!==null){const r=new URL(window.location.href);e.delete(yl),r.search=e.toString(),Fe(we.PURCHASE,{itemSrc:t}),be(),window.history.replaceState(null,"",r)}}const wl="sesamy-login";async function wS(){if(!new URLSearchParams(window.location.search).get(wl))return;await li()||fi();const n=new URL(window.location.href);n.searchParams.delete(wl),window.history.replaceState(null,"",n)}async function bl(e){iS({clientId:e.clientId,environment:e.environment,...e.analytics}),await Cw({clientId:e.clientId,organization:e.organization,environment:e.environment,...e.auth}),e.transform&&await hS(e.transform);const t=fS({clientId:e.clientId,environment:e.environment,...e.api});return Fe(we.READY,{}),vS(),pS(),mS(),await wS(),await gS(),yS(),t}if(typeof document<"u"){const e=document.getElementById("sesamy-js");if(e!=null&&e.textContent)try{const t=JSON.parse(e.textContent);bl(t)}catch(t){console.error("Failed to parse config",t)}}return Ee.init=bl,Object.defineProperty(Ee,Symbol.toStringTag,{value:"Module"}),Ee}({});
|
package/dist/sesamy-js.mjs
CHANGED
|
@@ -3155,7 +3155,7 @@ function Ww(e) {
|
|
|
3155
3155
|
openHostedAccountPage: W
|
|
3156
3156
|
};
|
|
3157
3157
|
}
|
|
3158
|
-
const Ju = "@sesamy/sesamy-js", Pi = "1.
|
|
3158
|
+
const Ju = "@sesamy/sesamy-js", Pi = "1.19.1";
|
|
3159
3159
|
function Es(e, t, r, n, a) {
|
|
3160
3160
|
for (t = t.split ? t.split(".") : t, n = 0; n < t.length; n++) e = e ? e[t[n]] : a;
|
|
3161
3161
|
return e === a ? r : e;
|