@sesamy/sesamy-js 1.10.3 → 1.10.4

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.
@@ -3,4 +3,4 @@
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
  `)})(),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)r=e.cache;else{if(n=e.cacheLocation||"memory",!tn(n))throw new Error(`Invalid cache location "${n}"`);r=tn(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Ie:ri,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(a=>`auth0.${a}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const i=e.useCookiesForTransactions?this.cookieStorage:ii;var o;this.scope=He("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Qr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Hn,this.cacheManager=new qr(r,r.allKeys?void 0:new si(r,this.options.clientId),this.nowProvider),this.domainUrl=(o=this.options.domain,/^https?:\/\//.test(o)?o:`https://${o}`),this.tokenIssuer=((a,s)=>a?a.startsWith("https://")?a:`https://${a}/`:`${s}/`)(this.options.issuer,this.domainUrl),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&n==="memory"&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ai)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Fn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${St(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return ti({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:n,organization:r,leeway:this.options.leeway,max_age:(o=this.options.authorizationParams.max_age,typeof o!="string"?o:parseInt(o,10)||void 0),now:i});var o}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(e,n,r){const i=Gt(dt()),o=Gt(dt()),a=dt(),s=(u=>{const c=new Uint8Array(u);return(m=>{const d={"+":"-","/":"_","=":""};return m.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Qe().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),f=((u,c,m,d,w,k,v,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),m),{scope:He(c,m.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:v||u.authorizationParams.redirect_uri,code_challenge:k,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),p=this._authorizeUrl(f);return{nonce:o,code_verifier:a,scope:f.scope,audience:f.audience||"default",redirect_uri:f.redirect_uri,state:i,url:p}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const f=window.screenX+(window.innerWidth-400)/2,p=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${f},top=${p},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((f,p)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(m),window.removeEventListener("message",u,!1),p(new Fr(s.popup)))},1e3),m=setTimeout(()=>{clearInterval(c),p(new Wr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(m),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return p(G.fromPayload(d.data.response));f(d.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(i.state!==o.state)throw new G("state_mismatch","Invalid state");const a=((r=e.authorizationParams)===null||r===void 0?void 0:r.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:a})}async getUser(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.user}async getIdTokenClaims(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.claims}async loginWithRedirect(e={}){var n;const r=nn(e),{openUrl:i,fragment:o,appState:a}=r,s=ne(r,["openUrl","fragment","appState"]),f=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,p=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=p,c=ne(p,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),f&&{organization:f}));const m=o?`${u}#${o}`:u;i?await i(m):window.location.assign(m)}async handleRedirectCallback(e=window.location.href){const n=e.split("?").slice(1);if(n.length===0)throw new Error("There are no query params available for parsing.");const{state:r,code:i,error:o,error_description:a}=(c=>{c.indexOf("#")>-1&&(c=c.substring(0,c.indexOf("#")));const m=new URLSearchParams(c);return{state:m.get("state"),code:m.get("code")||void 0,error:m.get("error")||void 0,error_description:m.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new G("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Kr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new G("state_mismatch","Invalid state");const f=s.organization,p=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:p,organization:f}),{appState:s.appState}}async checkSession(e){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(e)}catch{}}async getTokenSilently(e={}){var n;const r=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:He(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=ft[a];return s||(s=o().finally(()=>{delete ft[a],s=null}),ft[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=ne(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>pt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new It;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const p=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(p)return p}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:f}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:f})}finally{await pt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:He(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Zr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new pe({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId!==null?e.clientId=e.clientId||this.options.clientId:delete e.clientId;const n=e.logoutParams||{},{federated:r}=n,i=ne(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${St(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=nn(e),{openUrl:r}=n,i=ne(n,["openUrl"]);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.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 o=this._buildLogoutUrl(i);r?await r(o):r!==!1&&window.location.assign(o)}async _getTokenFromIFrame(e){const n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);const{url:i,state:o,nonce:a,code_verifier:s,redirect_uri:f,scope:p,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new G("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const c=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,m=await((w,k,v=60)=>new Promise((_,S)=>{const y=window.document.createElement("iframe");y.setAttribute("width","0"),y.setAttribute("height","0"),y.style.display="none";const l=()=>{window.document.body.contains(y)&&(window.document.body.removeChild(y),window.removeEventListener("message",b,!1))};let b;const T=setTimeout(()=>{S(new It),l()},1e3*v);b=function(O){if(O.origin!=k||!O.data||O.data.type!=="authorization_response")return;const C=O.source;C&&C.close(),O.data.response.error?S(G.fromPayload(O.data.response)):_(O.data.response),clearTimeout(T),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(y),y.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==m.state)throw new G("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:m.code,grant_type:"authorization_code",redirect_uri:f,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:p,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new pe({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(n&&n.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new Bn(e.authorizationParams.audience||"default",e.authorizationParams.scope)}const r=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,i=typeof e.timeoutInSeconds=="number"?1e3*e.timeoutInSeconds:null;try{const o=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:r}),i&&{timeout:i}));return Object.assign(Object.assign({},o),{scope:e.authorizationParams.scope,oauthTokenScope:o.scope,audience:e.authorizationParams.audience||"default"})}catch(o){if((o.message.indexOf("Missing Refresh Token")>-1||o.message&&o.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw o}}async _saveEntryInCache(e){const{id_token:n,decodedToken:r}=e,i=ne(e,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:n,decodedToken:r}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(i)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||"default",n=await this.cacheManager.getIdToken(new pe({clientId:this.options.clientId,audience:e,scope:this.scope})),r=this.userCache.get("@@user@@");return n&&n.id_token===(r==null?void 0:r.id_token)?r:(this.userCache.set("@@user@@",n),n)}async _getEntryFromCache({scope:e,audience:n,clientId:r}){const i=await this.cacheManager.get(new pe({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,f=await this._getIdTokenFromCache();return f&&Object.assign(Object.assign({id_token:f.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Gr(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},e),this.worker),a=await this._verifyIdToken(o.id_token,r,i);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:a,scope:e.scope,audience:e.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||a.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:a})}};async function li(t){const e=new ui(t);return await e.checkSession(),e}const Et="sesamy.com",di="https://logs.sesamy.com/events",Pt="sesamyCacheTimestamp";var Q=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(Q||{});let B,Tt;const Ut="sesamyAccessToken",zt="sesamyExpires";function Rt(){const t=localStorage.getItem(zt);if(!(t&&parseInt(t,10)<new Date().getTime()))return localStorage.getItem(Ut)}async function hi(t){if(t.enabled!==!1&&(Tt=t.organization,B=await li({domain:t.endpoint||`token.${Et}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await B.handleRedirectCallback();const e=await B.getUser();ue(Q.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),r.delete("state"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function Lt(){if(Rt())return!0;if(!B)throw new Error("Auth0 client not initialized");return B.isAuthenticated()}async function fi(){if(Rt())return{sub:"local",name:"Local User"};if(!B)throw new Error("Auth0 client not initialized");return B.getUser()}function Dt(t){if(!B)throw new Error("Auth0 client not initialized");const e={redirect_uri:window.location.href};return t!=null&&t.email&&(e.login_hint=t.email),Tt&&(e.organization=Tt),B.loginWithRedirect({authorizationParams:e})}async function rn(t=!0){const e=Rt();if(e)return e;try{if(!B)throw new Error("Auth0 client not initialized");return await B.getTokenSilently()}catch(n){if(t)throw n;return null}}async function pi(){if(localStorage.removeItem(Ut),localStorage.removeItem(zt),!B)throw new Error("Auth0 client not initialized");return ue(Q.LOGOUT,{}),B.logout({logoutParams:{returnTo:window.location.href}})}function mi(t){const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT token format.");const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}async function nr(t,e){localStorage.setItem(Ut,t),e&&localStorage.setItem(zt,JSON.stringify(e*1e3+new Date().getTime()));const n=mi(t);ue(Q.AUTHENTICATED,n)}const gi=(t,e)=>e.skipDedupe||e.method!=="GET",yi=(t,e)=>e.method+"@"+t,vi=t=>t.clone(),on=({skip:t=gi,key:e=yi,resolver:n=vi}={})=>{const r=new Map;return i=>(o,a)=>{if(t(o,a))return i(o,a);const s=e(o,a);if(!r.has(s))r.set(s,[]);else return new Promise((f,p)=>{r.get(s).push([f,p])});try{return i(o,a).then(f=>(r.get(s).forEach(([p])=>p(n(f))),r.delete(s),f)).catch(f=>{throw r.get(s).forEach(([p,u])=>u(f)),r.delete(s),f})}catch(f){return r.delete(s),Promise.reject(f)}}},wi=(t,e)=>t*e,bi=t=>t&&t.ok,an=({delayTimer:t=500,delayRamp:e=wi,maxAttempts:n=10,until:r=bi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>f=>(p,u)=>{let c=0;if(s&&s(p,u))return f(p,u);const m=(d,w)=>Promise.resolve(r(d,w)).then(k=>k?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(v=>{const _=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:p,options:u})).then((S={})=>{var y,l;v(f((y=S&&S.url)!==null&&y!==void 0?y:p,(l=S&&S.options)!==null&&l!==void 0?l:u))}):v(f(p,u))},_)}).then(m).catch(v=>{if(!o)throw v;return m(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return f(p,u).then(m).catch(d=>{if(!o)throw d;return m(null,d)})},ki="application/json",rr="Content-Type",ke=Symbol(),ir=Symbol();function sn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===rr.toLowerCase()))===null||e===void 0?void 0:e[1]}function cn(t){return/^application\/.*json.*/.test(t)}const ge=function(t,e,n=!1){return Object.entries(e).reduce((r,[i,o])=>{const a=t[i];return Array.isArray(a)&&Array.isArray(o)?r[i]=n?[...a,...o]:o:typeof a=="object"&&typeof o=="object"?r[i]=ge(a,o,n):r[i]=o,r},{...t})},Oe={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function Ii(t,e=!1){Oe.options=e?t:ge(Oe.options,t)}function Si(t,e=!1){Oe.polyfills=e?t:ge(Oe.polyfills,t)}function _i(t){Oe.errorType=t}const Ei=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class or extends Error{}const Pi=t=>{const e=Object.create(null);t=t._addons.reduce((y,l)=>l.beforeRequest&&l.beforeRequest(y,t._options,e)||y,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:f}=t,p=new Map(o),u=ge(i.options,r);let c=n;const m=Ei(s)((y,l)=>(c=y,i.polyfill("fetch")(y,l)))(n,u),d=new Error,w=m.catch(y=>{throw{[ke]:y}}).then(y=>{if(!y.ok){const l=new or;if(l.cause=d,l.stack=l.stack+`
5
5
  CAUSE: `+d.stack,l.response=y,l.url=c,y.type==="opaque")throw l;return y.text().then(b=>{var T;if(l.message=b,i.errorType==="json"||((T=y.headers.get("Content-Type"))===null||T===void 0?void 0:T.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=y.status,l})}return y}),k=y=>y.catch(l=>{const b=l.hasOwnProperty(ke),T=b?l[ke]:l,O=(T==null?void 0:T.status)&&p.get(T.status)||p.get(T==null?void 0:T.name)||b&&p.has(ke)&&p.get(ke);if(O)return O(T,t);const C=p.get(ir);if(C)return C(T,t);throw T}),v=y=>l=>k(y?w.then(b=>b&&b[y]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),_={_wretchReq:t,_fetchReq:m,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(y,l){return p.set(y,l),this},badRequest(y){return this.error(400,y)},unauthorized(y){return this.error(401,y)},forbidden(y){return this.error(403,y)},notFound(y){return this.error(404,y)},timeout(y){return this.error(408,y)},internalError(y){return this.error(500,y)},fetchError(y){return this.error(ke,y)}},S=f.reduce((y,l)=>({...y,...typeof l.resolver=="function"?l.resolver(y):l.resolver}),_);return a.reduce((y,l)=>l(y,t),S)},Ti={_url:"",_options:{},_config:Oe,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:ge(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const n=this._url.split("?");return{...this,_url:n.length>1?n[0]+t+"?"+n[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:ge(this._options,t)}},headers(t){const e=t?Array.isArray(t)?Object.fromEntries(t):"entries"in t?Object.fromEntries(t.entries()):t:{};return{...this,_options:ge(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[rr]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const n=new Map(this._catchers);return n.set(t,e),{...this,_catchers:n}},catcherFallback(t){return this.catcher(ir,t)},resolve(t,e=!1){return{...this,_resolvers:e?[t]:[...this._resolvers,t]}},defer(t,e=!1){return{...this,_deferred:e?[t]:[...this._deferred,t]}},middlewares(t,e=!1){return{...this,_middlewares:e?t:[...this._middlewares,...t]}},fetch(t=this._options.method,e="",n=null){let r=this.url(e).options({method:t});const i=sn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||cn(i));return r=n?o?r.json(n,i):r.body(n):r,Pi(r._deferred.reduce((a,s)=>s(a,a._url,a._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=sn(this._options.headers);return this.content(e||cn(n)&&n||ki).body(JSON.stringify(t))}};function le(t="",e={}){return{...Ti,_url:t,_options:e}}le.default=le;le.options=Ii;le.errorType=_i;le.polyfills=Si;le.WretchError=or;function te(){sessionStorage.removeItem(Pt),ue(Q.CLEAR_CACHE,{})}function Oi(t){const e=t.endpoint||`https://api2.${Et}`,n=I=>async(E,W)=>{let h=sessionStorage.getItem(Pt);h||(h=Date.now().toString(),sessionStorage.setItem(Pt,h));const g={...W,headers:{...W.headers,"Cache-Timestamp":h}};return I(E,g)},r=(I=!0)=>E=>async(W,h)=>{let g=null;if(g=await rn(I),!g){if(I)throw new Error("No access token available");return E(W,h)}const P={...h,headers:{...h.headers,...g?{Authorization:`Bearer ${g}`}:{}}};return E(W,P)},i=I=>(E,W)=>{if(W.headers.Authorization)return I(E,W);const h=localStorage.getItem("__anon_id"),g=btoa(`${h}:`),P={...W,headers:{...W.headers,Authorization:`Basic ${g}`}};return I(E,P)},o=le(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),on(),an({delayTimer:1e3,delayRamp:(I,E)=>I*E,maxAttempts:3,until:I=>!!(I&&(I.ok||I.status>=400&&I.status<500)),retryOnNetworkError:!1})]),a=le(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,on(),an({delayTimer:1e3,delayRamp:(I,E)=>I*E,maxAttempts:3,until:I=>!!(I&&(I.ok||I.status>=400&&I.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function f(I){const E=await o.get("/entitlements").json();return E==null?void 0:E.find(W=>W.id===I)}async function p(I){return o.get(`/entitlements/${I}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(I){const E=await o.get("/contracts").json();return E==null?void 0:E.find(W=>W.id===I)}async function m(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function w(I){const E=await o.get("/bills").json();return E==null?void 0:E.find(W=>W.id===I)}async function k(I,E){const W=await o.url(`/user-metadata/${I}`).put(E).json();return ue(Q.USER_ATTRIBUTE_CHANGED,{}),te(),W}async function v(I){const E=await o.url(`/user-metadata/${I}`).delete().res();return te(),E.ok}async function _(I){return(await o.url(`/user-metadata/${I}`).get().json())[I]}async function S(){return await o.url("/user-metadata").get().json()}async function y(){return await o.url("/tags").get().json()}async function l(I){const E=await o.url(`/tags/${I}`).delete().res();return te(),E.ok}async function b(I){const E=await o.url("/tags").post(I).res();return ue(Q.USER_ATTRIBUTE_CHANGED,{}),te(),E.ok}async function T(I){return(await a.url("/tallies").get().json())[I]}async function O(){return await a.url("/tallies").get().json()}async function C(I){const E=await a.url(`/tallies/${I}`).delete().res();return te(),E.ok}async function L(I,E){return await a.url(`/tallies/${I}/push`).post(E).json()}async function z(I){return await o.url(`/products/${I}`).get().json()}async function H(){return await Lt()?await o.url("/profile").get().json():null}async function $(I){const E=await o.url("/profile").patch(I).res();return te(),E.ok}async function R(){return await o.url("/payment-issues").get().json()}async function K(I){const E=await o.url(`/products/${I}/auto-onboard`).post().json();return E.length&&te(),E}async function j(){const I=await rn(!1),E=new URL(`https://account.${Et}/subscriptions/${t.clientId}`);I&&(E.hash=`#access_token=${I}`),window.location.href=E.toString()}return{getEntitlements:s,getEntitlement:f,getEntitlementAccess:p,getContracts:u,getContract:c,getProfile:H,updateProfile:$,getSubscriptions:m,getBills:d,getBill:w,setUserMetadata:k,deleteUserMetadata:v,getUserMetadata:_,listUserMetadata:S,getTags:y,deleteTag:l,setTag:b,getTally:T,getTallies:O,deleteTally:C,pushTally:L,getProduct:z,getPaymentIssues:R,autoOnboardProduct:K,openHostedAccountPage:j}}const ar="@sesamy/sesamy-js",Mt="1.3.2";function un(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Je="undefined",ln="object",Ot=function(){},sr="any",cr="*",ve="__",tt=typeof process<"u"?process:{};tt.env&&tt.env.NODE_ENV;var X=typeof document<"u";tt.versions!=null&&tt.versions.node!=null;typeof Deno<"u"&&Deno.core;X&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function ur(t,e){return e.charAt(0)[t]()+e.slice(1)}var ji=ur.bind(null,"toUpperCase"),Ci=ur.bind(null,"toLowerCase");function xi(t){return lr(t)?ji("null"):typeof t=="object"?Ui(t):Object.prototype.toString.call(t).slice(8,-1)}function nt(t,e){e===void 0&&(e=!0);var n=xi(t);return e?Ci(n):n}function We(t,e){return typeof e===t}var Y=We.bind(null,"function"),se=We.bind(null,"string"),Se=We.bind(null,"undefined"),Ai=We.bind(null,"boolean");We.bind(null,"symbol");function lr(t){return t===null}function $i(t){return nt(t)==="number"&&!isNaN(t)}function dr(t){return nt(t)==="array"}function V(t){if(!Ni(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ni(t){return t&&(typeof t=="object"||t!==null)}function Ui(t){return Y(t.constructor)?t.constructor.name:null}function zi(t){return t instanceof Error||se(t.message)&&t.constructor&&$i(t.constructor.stackTraceLimit)}function hr(t,e){if(typeof e!="object"||lr(e))return!1;if(e instanceof t)return!0;var n=nt(new t(""));if(zi(e))for(;e;){if(nt(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}hr.bind(null,TypeError);hr.bind(null,SyntaxError);function ot(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ri(t,e):n}function Ri(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function at(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}at(ot,"form");at(ot,"button");at(ot,"input");at(ot,"select");function Li(t){return t?dr(t)?t:[t]:[]}function dn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Di(){if(X){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Mi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Zi(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=dn(n[1]),a=dn(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var f=s.split("[");f.length>1&&(Ki(r,f.map(function(p){return p.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return X&&window.location.search.substring(1)}(t))}function Ki(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function st(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Wi(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var f=new Date;a||(a=f);var p=e-(f-a);return n=this,r=arguments,p<=0?(clearTimeout(o),o=null,a=f,i=t.apply(n,r)):o||(o=setTimeout(s,p)),i}}var Le="global",je=ve+"global"+ve,Ce=typeof self===ln&&self.self===self&&self||typeof global===ln&&global.global===global&&global||void 0;function we(t){return Ce[je][t]}function be(t,e){return Ce[je][t]=e}function Ae(t){delete Ce[je][t]}function $e(t,e,n){var r;try{if(Zt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Ce[je]||(Ce[je]={});var Xe={};function Zt(t){if(typeof Xe[t]!==Je)return Xe[t];try{var e=window[t];e.setItem(Je,Je),e.removeItem(Je)}catch{return Xe[t]=!1}return Xe[t]=!0}function A(){return A=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},A.apply(this,arguments)}var ae="function",ie="undefined",Fi="@@redux/"+Math.random().toString(36),hn=function(){return typeof Symbol===ae&&Symbol.observable||"@@observable"}(),Ve=" != "+ae;function fr(t,e,n){var r;if(typeof e===ae&&typeof n===ie&&(n=e,e=void 0),typeof n!==ie){if(typeof n!==ae)throw new Error("enhancer"+Ve);return n(fr)(t,e)}if(typeof t!==ae)throw new Error("reducer"+Ve);var i=t,o=e,a=[],s=a,f=!1;function p(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ae)throw new Error("Listener"+Ve);var w=!0;return p(),s.push(d),function(){if(w){w=!1,p();var k=s.indexOf(d);s.splice(k,1)}}}function m(d){if(!V(d))throw new Error("Act != obj");if(typeof d.type===ie)throw new Error("ActType "+ie);if(f)throw new Error("Dispatch in reducer");try{f=!0,o=i(o,d)}finally{f=!1}for(var w=a=s,k=0;k<w.length;k++)(0,w[k])();return d}return m({type:"@@redux/INIT"}),(r={dispatch:m,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ae)throw new Error("next reducer"+Ve);i=d,m({type:"@@redux/INIT"})}})[hn]=function(){var d,w=c;return(d={subscribe:function(k){if(typeof k!="object")throw new TypeError("Observer != obj");function v(){k.next&&k.next(u())}return v(),{unsubscribe:w(v)}}})[hn]=function(){return this},d},r}function Hi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ie}function xe(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function Ji(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,f={getState:a.getState,dispatch:function(p){return s(p)}};return o=[].slice.call(t).map(function(p){return p(f)}),A({},a,{dispatch:s=xe.apply(void 0,o)(a.dispatch)})}}}var ce=ve+"anon_id",ye=ve+"user_id",Ee=ve+"user_traits",oe="userId",_e="anonymousId",et=["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"],jt=["name","EVENTS","config","loaded"],x=et.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),fn=/^utm_/,pn=/^an_prop_/,mn=/^an_trait_/;function Xi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===x.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,f=i.initialUser,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ce,a.anonymousId),p||e(ye,a.userId),f.traits&&e(Ee,A({},p&&s.traits?s.traits:{},f.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,m=o.an_event,d=u.reduce(function(w,k){if(k.match(fn)||k.match(/^(d|g)clid/)){var v=k.replace(fn,"");w.campaign[v==="campaign"?"name":v]=o[k]}return k.match(pn)&&(w.props[k.replace(pn,"")]=o[k]),k.match(mn)&&(w.traits[k.replace(mn,"")]=o[k]),w},{campaign:{},props:{},traits:{}});n.dispatch(A({type:x.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),m&&setTimeout(function(){return t.track(m,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:x.campaign,campaign:d.campaign})}}return r(i)}}}}function Vi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===x.setItemEnd){if(n.key===ce)return A({},e,{anonymousId:n.value});if(n.key===ye)return A({},e,{userId:n.value})}switch(n.type){case x.identify:return Object.assign({},e,{userId:n.userId,traits:A({},e.traits,n.traits)});case x.reset:return[ye,ce,Ee].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function gn(t){return{userId:t.getItem(ye),anonymousId:t.getItem(ce),traits:t.getItem(Ee)}}var Ct=function(t){return ve+"TEMP"+ve+t};function Yi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var f=s.userId,p=s.traits,u=s.options;if(s.type===x.reset&&([ye,Ee,ce].forEach(function(d){r(d)}),[oe,_e,"traits"].forEach(function(d){Ae(Ct(d))})),s.type===x.identify){i(ce)||n(ce,st());var c=i(ye),m=i(Ee)||{};c&&c!==f&&o.dispatch({type:x.userIdChanged,old:{userId:c,traits:m},new:{userId:f,traits:p},options:u}),f&&n(ye,f),p&&n(Ee,A({},m,p))}return a(s)}}}}var Re={};function yn(t,e){Re[t]&&Y(Re[t])&&(Re[t](e),delete Re[t])}function pr(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(A({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return pr(t,e,n-10).then(r,i)})})}function Gi(t){return{abort:t}}function mr(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,f=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var p=s.actions.reduce(function(c,m,d){return a[m.plugin].loaded?(c.process.push(m),c.processIndex.push(d)):(c.requeue.push(m),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(p.processIndex&&p.processIndex.length){p.processIndex.forEach(function(c){var m=s.actions[c],d=m.plugin,w=m.payload.type,k=i[d][w];if(k&&Y(k)){var v,_=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[oe,_e].reduce(function(T,O){return l.hasOwnProperty(O)&&b[O]&&b[O]!==l[O]&&(T[O]=b[O]),T},l)}(m.payload,f),S=r[_.meta.rid];if(!S&&(v=k({payload:_,config:a[d].config,instance:n,abort:Gi}))&&V(v)&&v.abort)return void(r[_.meta.rid]=!0);if(!S){var y=w+":"+d;t.dispatch(A({},_,{type:y,_:{called:y,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,m){return!~p.processIndex.indexOf(m)});s.actions=u}}}var mt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,f=t.EVENTS;try{var p=i.plugins,u=i.context,c=n.type,m=c.match(Pe),d=e.exact.map(function(v){return v.pluginName});m&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,_){return function(S,y,l){var b=y.config,T=y.name,O=T+"."+S.type;l&&(O=l.event);var C=S.type.match(Pe)?function(L,z,H,$,R){return function(K,j){var I=$?$.name:L,E=j&&Ke(j)?j:H;if($&&(!(E=j&&Ke(j)?j:[L]).includes(L)||E.length!==1))throw new Error("Method "+z+" can only abort "+L+" plugin. "+JSON.stringify(E)+" input valid");return A({},R,{abort:{reason:K,plugins:E,caller:z,_:I}})}}(T,O,_,l,S):function(L,z){return function(){throw new Error(L.type+" action not cancellable. Remove abort in "+z)}}(S,O);return{payload:Bi(S),instance:v,config:b||{},abort:C}}}(r,d),k=e.exact.reduce(function(v,_){var S=_.pluginName,y=_.methodName,l=!1;return y.match(/^initialize/)||y.match(/^reset/)||(l=!p[S].loaded),u.offline&&y.match(/^(page|track|identify)/)&&(l=!0),v[""+S]=l,v},{});return Promise.resolve(e.exact.reduce(function(v,_,S){try{var y=_.pluginName;return Promise.resolve(v).then(function(l){function b(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(O,C,L){try{return Promise.resolve(O).then(function(z){return C.method&&Y(C.method)?(function(K,j){var I=_n(K);if(I&&I.name===j){var E=_n(I.method);throw new Error([j+" plugin is calling method "+K,"Plugins cant call self","Use "+I.method+" "+(E?"or "+E.method:"")+" in "+j+" plugin insteadof "+K].join(`
6
- `))}}(C.methodName,C.pluginName),Promise.resolve(C.method({payload:z,instance:r,abort:(H=z,$=y,R=C.pluginName,function(K,j){return A({},H,{abort:{reason:K,plugins:j||[$],caller:c,from:R||$}})}),config:bn(C.pluginName,p,o),plugins:p})).then(function(K){var j=V(K)?K:{};return Promise.resolve(A({},z,j))})):z;var H,$,R})}catch(z){return Promise.reject(z)}},Promise.resolve(n))).then(function(O){l[y]=O});l[y]=n}();return T&&T.then?T.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(_,S,y){try{var l=e.exact.length===y+1,b=S.pluginName,T=o[b];return Promise.resolve(_).then(function(O){var C=v[b]?v[b]:{};if(m&&(C=O),yt(C,b))return gt({data:C,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(O);if(yt(O,b))return l&&gt({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:C,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var L=w(v[b],o[b]);return Promise.resolve(T[c]({abort:L.abort,payload:C,instance:r,config:bn(b,p,o),plugins:p})).then(function(z){var H=V(z)?z:{},$=A({},O,H),R=v[b];if(yt(R,b))gt({data:R,method:c,instance:r,pluginName:b,store:s});else{var K=c+":"+b;(K.match(/:/g)||[]).length<2&&!c.match(vn)&&!c.match(wn)&&r.dispatch(A({},m?$:C,{type:K,_:{called:K,from:"submethod"}}))}return Promise.resolve($)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(_){if(!(c.match(Pe)||c.match(/^registerPlugin/)||c.match(wn)||c.match(vn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(f.plugins.includes(c),_._&&_._.originalAction===c)return _;var S=A({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});gr(_,e.exact.length)&&!c.match(/End$/)&&(S=A({},S,{type:_.type+"Aborted"})),s.dispatch(S)}return _})})}catch(v){return Promise.reject(v)}},Pe=/Start$/,vn=/^bootstrap/,wn=/^ready/;function gt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(A({},t.data,{type:n,_:{called:n,from:"abort"}}))}function bn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function kn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function In(t,e){var n=t.replace(Pe,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||Sn(n,e)||n&&Sn(n.plugins,e))}function gr(t,e){var n=t.abort;if(!n)return!1;if(n===!0||se(n))return!0;var r=n.plugins;return Ke(n)&&n.length===e||Ke(r)&&r.length===e}function Ke(t){return Array.isArray(t)}function Sn(t,e){return!(!t||!Ke(t))&&t.includes(e)}function _n(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Bi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=V(t[n])?Object.assign({},t[n]):t[n]),e},{})}function qi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,f=function(l){return s?l:o(c)},p=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(p===x.enablePlugin&&i.dispatch({type:x.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===x.disablePlugin&&setTimeout(function(){return yn(a.meta.rid,{payload:a})},0),p===x.initializeEnd){var m=e(),d=Object.keys(m),w=d.filter(function(l){return u.includes(l)}).map(function(l){return m[l]}),k=[],v=[],_=a.disabled,S=w.map(function(l){var b=l.loaded,T=l.name,O=l.config;return pr(l,function(){return b({config:O})},1e4).then(function(C){return r[T]||(i.dispatch({type:x.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(L){return!jt.includes(L)})}),r[T]=!0),k=k.concat(T),l}).catch(function(C){if(C instanceof Error)throw new Error(C);return v=v.concat(C.name),C})});Promise.all(S).then(function(l){var b={plugins:k,failed:v,disabled:_};setTimeout(function(){d.length===S.length+_.length&&i.dispatch(A({},{type:x.ready},b))},0)})}var y=function(){if(p!==x.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return mr(i,e,t)},0),Promise.resolve(function(l,b,T,O,C){try{var L=Y(b)?b():b,z=l.type,H=z.replace(Pe,"");if(l._&&l._.called)return Promise.resolve(l);var $=T.getState(),R=(I=L,(E=$.plugins)===void 0&&(E={}),(W=l.options)===void 0&&(W={}),Object.keys(I).filter(function(h){var g=W.plugins||{};return Ai(g[h])?g[h]:g.all!==!1&&(!E[h]||E[h].enabled!==!1)}).map(function(h){return I[h]}));z===x.initializeStart&&l.fromEnable&&(R=Object.keys($.plugins).filter(function(h){var g=$.plugins[h];return l.plugins.includes(h)&&!g.initialized}).map(function(h){return L[h]}));var K=R.map(function(h){return h.name}),j=function(h,g,P){var N=In(h).map(function(U){return kn(U,g)});return g.reduce(function(U,D){var J=D.name,Z=In(h,J).map(function(Ne){return kn(Ne,g)}),F=Z[0],M=Z[1],ee=Z[2];return F.length&&(U.beforeNS[J]=F),M.length&&(U.duringNS[J]=M),ee.length&&(U.afterNS[J]=ee),U},{before:N[0],beforeNS:{},during:N[1],duringNS:{},after:N[2],afterNS:{}})}(z,R);return Promise.resolve(mt({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(h){function g(){var U=function(){if(z.match(Pe))return Promise.resolve(mt({action:A({},P,{type:H+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(D){D.meta&&D.meta.hasCallback&&yn(D.meta.rid,{payload:D})})}();return U&&U.then?U.then(function(){return h}):h}if(gr(h,K.length))return h;var P,N=function(){if(z!==H)return Promise.resolve(mt({action:A({},h,{type:H}),data:{exact:j.during,namespaced:j.duringNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(U){P=U});P=h}();return N&&N.then?N.then(g):g()})}catch(h){return Promise.reject(h)}var I,E,W}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(f):f(y))}catch(l){return Promise.reject(l)}}}}}function Qi(t){return function(e){return function(n){return function(r){var i=r.type,o=r.key,a=r.value,s=r.options;if(i===x.setItem||i===x.removeItem){if(r.abort)return n(r);i===x.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var eo=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,n){t[n]=t[n].concat(e)},this.removeMiddleware=function(e,n){var r=t[n].findIndex(function(i){return i===e});r!==-1&&(t[n]=[].concat(t[n].slice(0,r),t[n].slice(r+1)))},this.dynamicMiddlewares=function(e){return function(n){return function(r){return function(i){var o={getState:n.getState,dispatch:function(s){return n.dispatch(s)}},a=t[e].map(function(s){return s(o)});return xe.apply(void 0,a)(r)(i)}}}}};function to(t){return function(e,n){e===void 0&&(e={});var r={};if(n.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(n.type)){var i=En(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},A({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var f=En(n.type,x.initialize),p=t()[f];return p&&f?(r[f]=A({},e[f],{initialized:!0,loaded:!!p.loaded({config:p.config})}),A({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=A({},e[n.name],{loaded:!0}),A({},e,r);switch(n.type){case x.disablePlugin:return A({},e,Pn(n.plugins,!1,e));case x.enablePlugin:return A({},e,Pn(n.plugins,!0,e));default:return e}}}function En(t,e){return t.substring(e.length+1,t.length)}function Pn(t,e,n){return t.reduce(function(r,i){return r[i]=A({},n[i],{enabled:e}),r},n)}function yr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var no={last:{},history:[]};function ro(t,e){t===void 0&&(t=no);var n=e.options,r=e.meta;if(e.type===x.track){var i=yr(A({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return A({},t,{last:i,history:t.history.concat(i)})}return t}var io={actions:[]};function oo(t,e){t===void 0&&(t=io);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===x.identify?[e].concat(t.actions):t.actions.concat(e),A({},t,{actions:r});case"dequeue":return[];default:return t}}var vr=/#.*$/;function ao(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(vr,""):"")}var wr,br,kr,Ir,so=function(t){if(t===void 0&&(t={}),!X)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,f=o.hash,p=o.search,u=function(m){var d=function(){if(X){for(var w,k=document.getElementsByTagName("link"),v=0;w=k[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+m:window.location.href.replace(vr,"")}(p),c={title:n,url:u,path:ao(u),hash:f,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),A({},c,t)},co={last:{},history:[]};function uo(t,e){t===void 0&&(t=co);var n=e.options;if(e.type===x.page){var r=yr(A({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return A({},t,{last:r,history:t.history.concat(r)})}return t}wr=function(){if(!X)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),br=X?document.referrer:null,kr=Di(),Ir=Mi();var Tn={initialized:!1,sessionId:st(),app:null,version:null,debug:!1,offline:!!X&&!navigator.onLine,os:{name:wr},userAgent:X?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Ir,locale:kr,campaign:{},referrer:br};function lo(t,e){t===void 0&&(t=Tn);var n=t.initialized,r=e.campaign;switch(e.type){case x.campaign:return A({},t,{campaign:r});case x.offline:return A({},t,{offline:!0});case x.online:return A({},t,{offline:!1});default:return n?t:A({},Tn,t,{initialized:!0})}}var ho=["plugins","reducers","storage"];function fo(t,e,n){if(X){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function po(t){var e=fo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function Sr(){return be("analytics",[]),function(t){return function(e,n,r){var i=t(e,n,r),o=i.dispatch;return Object.assign(i,{dispatch:function(a){return Ce[je].analytics.push(a.action||a),o(a)}})}}}function On(t){return function(){return xe(xe.apply(null,arguments),Sr())}}function vt(t){return t?dr(t)?t:[t]:[]}function jn(t,e,n){t===void 0&&(t={});var r,i,o=st();return e&&(Re[o]=(r=e,i=function(a){for(var s,f=a||Array.prototype.slice.call(arguments),p=0;p<f.length;p++)if(Y(f[p])){s=f[p];break}return s}(n),function(a){i&&i(a),r(a)})),A({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function mo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(h,g){if(Y(g))return h.middlewares=h.middlewares.concat(g),h;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var P=g.EVENTS?Object.keys(g.EVENTS).map(function(D){return g.EVENTS[D]}):[];h.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(h.methods[g.name]=Object.keys(g.methods).reduce(function(D,J){var Z;return D[J]=(Z=g.methods[J],function(){for(var F=Array.prototype.slice.call(arguments),M=new Array(Z.length),ee=0;ee<F.length;ee++)M[ee]=F[ee];return M[M.length]=b,Z.apply({instance:b},M)}),D},{}),delete g.methods);var N=Object.keys(g).concat(P),U=new Set(h.events.concat(N));if(h.events=Array.from(U),h.pluginsArray=h.pluginsArray.concat(g),h.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return h.plugins[g.name]=g,h.plugins[g.name].loaded||(h.plugins[g.name].loaded=function(){return!0}),h},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:we,setItem:be,removeItem:Ae},o=function(h){return function(g,P,N){return P.getState("user")[g]||(N&&V(N)&&N[g]?N[g]:gn(h)[g]||we(Ct(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(h){return!jt.includes(h)}).sort(),f=new Set(s.concat(et).filter(function(h){return!jt.includes(h)})),p=Array.from(f).sort(),u=function(){return a},c=new eo,m=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Zi(),_=gn(i),S=A({},_,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=st());var y=A({enable:function(h,g){return new Promise(function(P){j.dispatch({type:x.enablePlugin,plugins:vt(h),_:{originalAction:x.enablePlugin}},P,[g])})},disable:function(h,g){return new Promise(function(P){j.dispatch({type:x.disablePlugin,plugins:vt(h),_:{originalAction:x.disablePlugin}},P,[g])})}},r.methods),l=!1,b={identify:function(h,g,P,N){try{var U=se(h)?h:null,D=V(h)?h:g,J=P||{},Z=b.user();be(Ct(oe),U);var F=U||D.userId||o(oe,b,D);return Promise.resolve(new Promise(function(M){j.dispatch(A({type:x.identifyStart,userId:F,traits:D||{},options:J,anonymousId:Z.anonymousId},Z.id&&Z.id!==U&&{previousId:Z.id}),M,[g,P,N])}))}catch(M){return Promise.reject(M)}},track:function(h,g,P,N){try{var U=V(h)?h.event:h;if(!U||!se(U))throw new Error("EventMissing");var D=V(h)?h:g||{},J=V(P)?P:{};return Promise.resolve(new Promise(function(Z){j.dispatch({type:x.trackStart,event:U,properties:D,options:J,userId:o(oe,b,g),anonymousId:o(_e,b,g)},Z,[g,P,N])}))}catch(Z){return Promise.reject(Z)}},page:function(h,g,P){try{var N=V(h)?h:{},U=V(g)?g:{};return Promise.resolve(new Promise(function(D){j.dispatch({type:x.pageStart,properties:so(N),options:U,userId:o(oe,b,N),anonymousId:o(_e,b,N)},D,[h,g,P])}))}catch(D){return Promise.reject(D)}},user:function(h){if(h===oe||h==="id")return o(oe,b);if(h===_e||h==="anonId")return o(_e,b);var g=b.getState("user");return h?un(g,h):g},reset:function(h){return new Promise(function(g){j.dispatch({type:x.resetStart},g,h)})},ready:function(h){return l&&h({plugins:y,instance:b}),b.on(x.ready,function(g){h(g),l=!0})},on:function(h,g){if(!h||!Y(g))return!1;if(h===x.bootstrap)throw new Error(".on disabled for "+h);var P=/Start$|Start:/;if(h==="*"){var N=function(Z){return function(F){return function(M){return M.type.match(P)&&g({payload:M,instance:b,plugins:a}),F(M)}}},U=function(Z){return function(F){return function(M){return M.type.match(P)||g({payload:M,instance:b,plugins:a}),F(M)}}};return m(N,Ye),m(U,Ge),function(){d(N,Ye),d(U,Ge)}}var D=h.match(P)?Ye:Ge,J=function(Z){return function(F){return function(M){return M.type===h&&g({payload:M,instance:b,plugins:a,abort:k}),F(M)}}};return m(J,D),function(){return d(J,D)}},once:function(h,g){if(!h||!Y(g))return!1;if(h===x.bootstrap)throw new Error(".once disabled for "+h);var P=b.on(h,function(N){g({payload:N.payload,instance:b,plugins:a,abort:k}),P()});return P},getState:function(h){var g=j.getState();return h?un(g,h):Object.assign({},g)},dispatch:function(h){var g=se(h)?{type:h}:h;if(et.includes(g.type))throw new Error("reserved action "+g.type);var P=A({},g,{_:A({originalAction:g.type},h._||{})});j.dispatch(P)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(h,g,P){j.dispatch({type:x.setItemStart,key:h,value:g,options:P})},removeItem:function(h,g){j.dispatch({type:x.removeItemStart,key:h,options:g})}},setAnonymousId:function(h,g){b.storage.setItem(ce,h,g)},events:{core:et,plugins:s}},T=r.middlewares.concat([function(h){return function(g){return function(P){return P.meta||(P.meta=jn()),g(P)}}},w(Ye),qi(b,u,{all:p,plugins:s}),Qi(i),Xi(b),Yi(b),w(Ge)]),O={context:lo,user:Vi(i),page:uo,track:ro,plugins:to(u),queue:oo},C=xe,L=xe;if(X&&t.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(C=z({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?Sr():V(typeof arguments[0])?On():On().apply(null,arguments)}}var H,$=function(h){return Object.keys(h).reduce(function(g,P){return ho.includes(P)||(g[P]=h[P]),g},{})}(t),R=r.pluginsArray.reduce(function(h,g){var P=g.name,N=g.config,U=g.loaded,D=r.pluginEnabled[P];return h[P]={enabled:D,initialized:!!D&&!g.initialize,loaded:!!U({config:N}),config:N},h},{}),K={context:$,user:S,plugins:R},j=fr(function(h){for(var g=Object.keys(h),P={},N=0;N<g.length;N++){var U=g[N];typeof h[U]===ae&&(P[U]=h[U])}var D,J=Object.keys(P);try{(function(Z){Object.keys(Z).forEach(function(F){var M=Z[F];if(typeof M(void 0,{type:"@@redux/INIT"})===ie||typeof M(void 0,{type:Fi})===ie)throw new Error("reducer "+F+" "+ie)})})(P)}catch(Z){D=Z}return function(Z,F){if(Z===void 0&&(Z={}),D)throw D;for(var M=!1,ee={},Ne=0;Ne<J.length;Ne++){var Fe=J[Ne],Vt=Z[Fe],lt=(0,P[Fe])(Vt,F);if(typeof lt===ie){var Rr=Hi(Fe,F);throw new Error(Rr)}ee[Fe]=lt,M=M||lt!==Vt}return M?ee:Z}}(A({},O,e)),K,L(C(Ji.apply(void 0,T))));j.dispatch=(H=j.dispatch,function(h,g,P){var N=A({},h,{meta:jn(h.meta,g,vt(P))});return H.apply(null,[N])});var I=Object.keys(a);j.dispatch({type:x.bootstrap,plugins:I,config:$,params:v,user:S,initialUser:n,persistedUser:_});var E=I.filter(function(h){return r.pluginEnabled[h]}),W=I.filter(function(h){return!r.pluginEnabled[h]});return j.dispatch({type:x.registerPlugins,plugins:I,enabled:r.pluginEnabled}),r.pluginsArray.map(function(h,g){var P=h.bootstrap,N=h.config,U=h.name;P&&Y(P)&&P({instance:b,config:N,payload:h}),j.dispatch({type:x.registerPluginType(U),name:U,enabled:r.pluginEnabled[U],plugin:h}),r.pluginsArray.length===g+1&&j.dispatch({type:x.initializeStart,plugins:E,disabled:W})}),po(function(h){j.dispatch({type:h?x.offline:x.online})}),function(h,g,P){setInterval(function(){return mr(h,g,P)},3e3)}(j,u,b),b}var Ye="before",Ge="after",De="cookie",fe=Pr(),_r=ct,go=ct;function Er(t){return fe?ct(t,"",-1):Ae(t)}function Pr(){if(fe!==void 0)return fe;var t="cookiecookie";try{ct(t,t),fe=document.cookie.indexOf(t)!==-1,Er(t)}catch{fe=!1}return fe}function ct(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return fe===!1&&(a?be(t,e):we(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var Me="localStorage",yo=Zt.bind(null,"localStorage");$e("localStorage","getItem",we);$e("localStorage","setItem",be);$e("localStorage","removeItem",Ae);var Ze="sessionStorage",vo=Zt.bind(null,"sessionStorage");$e("sessionStorage","getItem",we);$e("sessionStorage","setItem",be);$e("sessionStorage","removeItem",Ae);function Te(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(V(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var wo=yo(),bo=vo(),ko=Pr();function Tr(t,e){if(t){var n=Kt(e),r=!Jt(n),i=Wt(n)?Te(localStorage.getItem(t)):void 0;if(r&&!Se(i))return i;var o=Ft(n)?Te(_r(t)):void 0;if(r&&o)return o;var a=Ht(n)?Te(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=we(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function Io(t,e,n){if(t&&!Se(e)){var r={},i=Kt(n),o=JSON.stringify(e),a=!Jt(i);return Wt(i)&&(r[Me]=Be(Me,e,Te(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Me]:Ft(i)&&(r[De]=Be(De,e,Te(_r(t))),go(t,o),a)?r[De]:Ht(i)&&(r[Ze]=Be(Ze,e,Te(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ze]:(r[Le]=Be(Le,e,we(t)),be(t,e),a?r[Le]:r)}}function So(t,e){if(t){var n=Kt(e),r=Tr(t,cr),i={};return!Se(r.localStorage)&&Wt(n)&&(localStorage.removeItem(t),i[Me]=r.localStorage),!Se(r.cookie)&&Ft(n)&&(Er(t),i[De]=r.cookie),!Se(r.sessionStorage)&&Ht(n)&&(sessionStorage.removeItem(t),i[Ze]=r.sessionStorage),!Se(r.global)&&ut(n,Le)&&(Ae(t),i[Le]=r.global),i}}function Kt(t){return t?se(t)?t:t.storage:sr}function Wt(t){return wo&&ut(t,Me)}function Ft(t){return ko&&ut(t,De)}function Ht(t){return bo&&ut(t,Ze)}function Jt(t){return t===cr||t==="all"}function ut(t,e){return t===sr||t===e||Jt(t)}function Be(t,e,n){return{location:t,current:e,previous:n}}var _o={setItem:Io,getItem:Tr,removeItem:So};function Eo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Cn(Object(n),!0).forEach(function(r){Eo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Cn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Po(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:_o};return mo(xn(xn({},e),t))}function To(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(f){return r=i.push(f),r>=o&&a(),r},size:function(){return i.length},end:function(f){f&&a(),clearInterval(n)}}}function Oo(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...f){var c;const p=((c=f[2])==null?void 0:c.toString())||"",u=Co(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,f)}})}function jo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Co(t){return["#","?"].forEach(e=>t=jo(t,e)),t}function xo(){Oo(()=>{re.page()})}function Ao(t){if(t===void 0&&(t={}),!X)return Ot;var e=$n(),n=xt(),r=An(),i=qe(r,e),o=qe(n,e),a=[],s=[],f=[],p=r,u=i,c=o,m=Object.keys(t);if(!m.length)return Ot;var d=m.map(function(k){return Number(k)}),w=Wi(function(){var k=$n(),v=function($,R){return R.map(function(K){return K===100?$-5:$*(K/100)})}(k,d),_=xt(),S=An(),y=qe(S,k),l=qe(_,k);if(u=y>u?y:u,c=l<c?l:c,!(a.length>=d.length)){var b=p===S,T="up";b?T="initial":p<=S&&(T="down");var O=v,C=d;(T==="up"||b)&&(O=v.slice().reverse(),C=d.slice().reverse());var L=C.reduce(function($,R,K){var j=O[K];return f.includes(R)&&S<=j&&(f=f.filter(function(I){return I!==R}),$.singleFunction=R),T==="down"&&!a.includes(R)&&S>=j&&R>o?(s.push(R),$.callbacks=$.callbacks.concat(R),$):T==="up"&&!a.includes(R)&&S<=j&&R<=y?($.foundFunc=[R],$):(b&&S>=j&&$.foundFunc.length===0&&($.foundFunc=[R]),!s.includes(R)&&S>=j&&(s.push(R),$.singleFunction?f.push(R):$.singleFunction=R),$)},{foundFunc:[],singleFunction:null,callbacks:[],direction:T});if(p=S,T==="down"&&L.callbacks&&L.callbacks.forEach(function($){Y(t[$])&&(t[$]({trigger:$,direction:T,scrollMin:c,scrollMax:u,range:[c,u]}),a.push($))}),L.singleFunction){var z=L.singleFunction,H=L.direction;Y(t[z])&&t[z]({trigger:z,direction:H,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(z)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function xt(){return X?document.body.scrollTop||document.documentElement.scrollTop:0}function $o(){return X?window.innerHeight||document.documentElement.clientHeight:0}function An(){return Math.round(xt()+$o())}function $n(){if(!X)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function qe(t,e){return Math.round(t/e*100)}var Nn="EventListener";function No(t){return function(e,n,r,i){var o=r||Ot,a=i||!1;if(!X)return o;var s=rt(n),f=rt(e,!0);if(!f.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var m=c?"add"+Nn:"remove"+Nn,d=0;d<f.length;d++){var w=f[d];p[d]=c?a&&a.once?Uo(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[m]?w["on"+s[k]]=c?p[d]:null:w[m](s[k],p[d],a)}return u.bind(null,!c)}(t)}}function rt(t,e){if(se(t))return e?rt(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=Li(t);return e?o.map(function(a){return se(a)?rt(a,!0):a}).flat():o}function Uo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var wt=No("Event");function Or(t,e){return X&&Y(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),Y(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}Or.bind(null,"onerror");Or.bind(null,"onload");var jr=typeof window>"u",Un="hidden";function zo(t){if(jr)return!1;var e=Ro(),n="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),r=function(){return t(!!document[e])},i=function(){return document.addEventListener(n,r)};return i(),function(){return document.removeEventListener(n,r),i}}function Ro(){var t=["webkit","moz","ms","o"];return jr||Un in document?Un:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Lo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Do(t,e){e===void 0&&(e={});var n=function(a,s){var f=this,p=!1;return function(u){p||(a.call(f,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=zo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Lo.map(function(s){return wt(document,s,n)})).concat(wt(window,"load",n)).concat(wt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Mo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,f=t.throttle,p=f===void 0?2e3:f,u=!1,c=!1,m=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(ze(m),v),i&&u&&(u=!1,i(ze(n),v),m=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(ze(m),v))},s)}var k=Do(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,m=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:ze(m,c),idle:u?ze(n,c):0}}}}function ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const zn=5e3;class Zo{constructor(e){q(this,"element");q(this,"isInViewport",!1);q(this,"isAwake",!1);q(this,"isFlushing");q(this,"observer");q(this,"lastEventAt",Date.now());q(this,"registeredView",!1);q(this,"viewCallback");q(this,"activeDurationCallback");q(this,"idleDurationCallback");q(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Mo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:zn}),Ao({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(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*zn:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const Rn="sesamy_session_id";function Ko(){let t=sessionStorage.getItem(Rn);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(Rn,t)),t}let Cr=!1,At,Ln,it;function Wo({clientId:t,enabled:e=!0,endpoint:n=di}){if(At=t,Ln=e,it=n,!Ln)return;xo();const r=new Zo({element:document.body,viewCallback:()=>{re.page()},activeDurationCallback:(i,o,a)=>{re.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{re.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{re.track("scroll",{scroll:i.scrollMax})}});Jo(document.body,()=>{r.flush()}),Xo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(Q.AUTHENTICATED,async i=>{const o=i;await re.identify(o.detail.sub)}),window.addEventListener(Q.LOGOUT,async()=>{await re.track("logout",{}),Xt.flush(),await re.reset()})}function xr(t){return JSON.stringify(t.map(e=>({...e,clientId:At,requestId:Math.random().toString(36).slice(2,9),sessionId:Ko(),timestamp:new Date().toISOString(),version:Mt,event:e.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:ar,userAgent:navigator.userAgent,clientId:At}})))}const Xt=To(async t=>{if(t.length>0){const e=xr(t);Cr?navigator.sendBeacon(it,e):(await fetch(it,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function bt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(it,xr([n]))}else Xt.push(t)}const re=Po({app:ar,version:Mt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;bt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Fo(t,e){re.track(t,e)}function Ho(){return Cr=!0,Xt.flush()}const Ar=new Map;function Jo(t,e){Ar.set(t,e)}window.addEventListener("beforeunload",()=>{Ar.forEach((t,e)=>{t.bind(e)()}),Ho()});const $r=new Map;function Xo(t,e){$r.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&$r.forEach((t,e)=>{t.bind(e)()})});const Nr="sesamySignedURLs";function Ur(){const t=sessionStorage.getItem(Nr);return t?JSON.parse(t):[]}function Vo(t){const e=Ur();e.push(t),sessionStorage.setItem(Nr,JSON.stringify(e))}function Yo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:f,getProfile:p,updateProfile:u,getTags:c,deleteTag:m,setTag:d,getUserMetadata:w,listUserMetadata:k,setUserMetadata:v,deleteUserMetadata:_,getTally:S,getTallies:y,pushTally:l,deleteTally:b,getProduct:T,getPaymentIssues:O,autoOnboardProduct:C,openHostedAccountPage:L}=Oi(t),z={auth:{getUser:p,isAuthenticated:Lt,loginWithRedirect:Dt,logout:pi,setToken:nr},profile:{get:p,update:u,openHostedAccountPage:L},analytics:{track:Fo},tags:{list:c,set:d,delete:m},entitlements:{get:e,list:n,access:r,signedLinks:Ur},contracts:{get:o,list:a},bills:{get:s,list:f},userMetadata:{get:w,list:k,set:v,delete:_},tallies:{get:S,list:y,push:l,delete:b},subscriptions:{list:i},products:{get:T,autoOnboard:C},getVersion:Go,getPaymentIssues:O,clearCache:te};return t.namespace&&(window[t.namespace]=z),z}function Go(){return Mt}function Bo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){nr(e,n?parseInt(n,10):void 0);const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Dn="sesamy-refresh",Mn="force-refetch-entitlements";function qo(){const t=new URLSearchParams(window.location.search),e=t.get(Mn),n=t.get(Dn);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Mn),t.delete(Dn),r.search=t.toString(),te(),window.history.replaceState(null,"",r)}}function Qo(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Vo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const Zn="sesamy-user";async function ea(){const e=new URLSearchParams(window.location.search).get(Zn);if(!e)return;const n=await fi();(n==null?void 0:n.email)!==e&&Dt();const r=new URL(window.location.href);r.searchParams.delete(Zn),window.history.replaceState(null,"",r)}const Kn="sesamy-purchase";function ta(){const t=new URLSearchParams(window.location.search),e=t.get(Kn);if(e!==null){const n=new URL(window.location.href);t.delete(Kn),n.search=t.toString(),ue(Q.PURCHASE,{itemSrc:e}),te(),window.history.replaceState(null,"",n)}}const Wn="sesamy-login";async function na(){if(!new URLSearchParams(window.location.search).get(Wn))return;await Lt()||Dt();const r=new URL(window.location.href);r.searchParams.delete(Wn),window.history.replaceState(null,"",r)}async function zr(t){Wo({clientId:t.clientId,...t.analytics}),await hi({clientId:t.clientId,organization:t.organization,...t.auth});const e=Yo({clientId:t.clientId,...t.api});return ue(Q.READY,{}),Bo(),qo(),Qo(),await na(),await ea(),ta(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);zr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=zr;
6
+ `))}}(C.methodName,C.pluginName),Promise.resolve(C.method({payload:z,instance:r,abort:(H=z,$=y,R=C.pluginName,function(K,j){return A({},H,{abort:{reason:K,plugins:j||[$],caller:c,from:R||$}})}),config:bn(C.pluginName,p,o),plugins:p})).then(function(K){var j=V(K)?K:{};return Promise.resolve(A({},z,j))})):z;var H,$,R})}catch(z){return Promise.reject(z)}},Promise.resolve(n))).then(function(O){l[y]=O});l[y]=n}();return T&&T.then?T.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(_,S,y){try{var l=e.exact.length===y+1,b=S.pluginName,T=o[b];return Promise.resolve(_).then(function(O){var C=v[b]?v[b]:{};if(m&&(C=O),yt(C,b))return gt({data:C,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(O);if(yt(O,b))return l&&gt({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:C,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var L=w(v[b],o[b]);return Promise.resolve(T[c]({abort:L.abort,payload:C,instance:r,config:bn(b,p,o),plugins:p})).then(function(z){var H=V(z)?z:{},$=A({},O,H),R=v[b];if(yt(R,b))gt({data:R,method:c,instance:r,pluginName:b,store:s});else{var K=c+":"+b;(K.match(/:/g)||[]).length<2&&!c.match(vn)&&!c.match(wn)&&r.dispatch(A({},m?$:C,{type:K,_:{called:K,from:"submethod"}}))}return Promise.resolve($)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(_){if(!(c.match(Pe)||c.match(/^registerPlugin/)||c.match(wn)||c.match(vn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(f.plugins.includes(c),_._&&_._.originalAction===c)return _;var S=A({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});gr(_,e.exact.length)&&!c.match(/End$/)&&(S=A({},S,{type:_.type+"Aborted"})),s.dispatch(S)}return _})})}catch(v){return Promise.reject(v)}},Pe=/Start$/,vn=/^bootstrap/,wn=/^ready/;function gt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(A({},t.data,{type:n,_:{called:n,from:"abort"}}))}function bn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function kn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function In(t,e){var n=t.replace(Pe,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||Sn(n,e)||n&&Sn(n.plugins,e))}function gr(t,e){var n=t.abort;if(!n)return!1;if(n===!0||se(n))return!0;var r=n.plugins;return Ke(n)&&n.length===e||Ke(r)&&r.length===e}function Ke(t){return Array.isArray(t)}function Sn(t,e){return!(!t||!Ke(t))&&t.includes(e)}function _n(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Bi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=V(t[n])?Object.assign({},t[n]):t[n]),e},{})}function qi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,f=function(l){return s?l:o(c)},p=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(p===x.enablePlugin&&i.dispatch({type:x.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===x.disablePlugin&&setTimeout(function(){return yn(a.meta.rid,{payload:a})},0),p===x.initializeEnd){var m=e(),d=Object.keys(m),w=d.filter(function(l){return u.includes(l)}).map(function(l){return m[l]}),k=[],v=[],_=a.disabled,S=w.map(function(l){var b=l.loaded,T=l.name,O=l.config;return pr(l,function(){return b({config:O})},1e4).then(function(C){return r[T]||(i.dispatch({type:x.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(L){return!jt.includes(L)})}),r[T]=!0),k=k.concat(T),l}).catch(function(C){if(C instanceof Error)throw new Error(C);return v=v.concat(C.name),C})});Promise.all(S).then(function(l){var b={plugins:k,failed:v,disabled:_};setTimeout(function(){d.length===S.length+_.length&&i.dispatch(A({},{type:x.ready},b))},0)})}var y=function(){if(p!==x.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return mr(i,e,t)},0),Promise.resolve(function(l,b,T,O,C){try{var L=Y(b)?b():b,z=l.type,H=z.replace(Pe,"");if(l._&&l._.called)return Promise.resolve(l);var $=T.getState(),R=(I=L,(E=$.plugins)===void 0&&(E={}),(W=l.options)===void 0&&(W={}),Object.keys(I).filter(function(h){var g=W.plugins||{};return Ai(g[h])?g[h]:g.all!==!1&&(!E[h]||E[h].enabled!==!1)}).map(function(h){return I[h]}));z===x.initializeStart&&l.fromEnable&&(R=Object.keys($.plugins).filter(function(h){var g=$.plugins[h];return l.plugins.includes(h)&&!g.initialized}).map(function(h){return L[h]}));var K=R.map(function(h){return h.name}),j=function(h,g,P){var N=In(h).map(function(U){return kn(U,g)});return g.reduce(function(U,D){var J=D.name,Z=In(h,J).map(function(Ne){return kn(Ne,g)}),F=Z[0],M=Z[1],ee=Z[2];return F.length&&(U.beforeNS[J]=F),M.length&&(U.duringNS[J]=M),ee.length&&(U.afterNS[J]=ee),U},{before:N[0],beforeNS:{},during:N[1],duringNS:{},after:N[2],afterNS:{}})}(z,R);return Promise.resolve(mt({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(h){function g(){var U=function(){if(z.match(Pe))return Promise.resolve(mt({action:A({},P,{type:H+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(D){D.meta&&D.meta.hasCallback&&yn(D.meta.rid,{payload:D})})}();return U&&U.then?U.then(function(){return h}):h}if(gr(h,K.length))return h;var P,N=function(){if(z!==H)return Promise.resolve(mt({action:A({},h,{type:H}),data:{exact:j.during,namespaced:j.duringNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(U){P=U});P=h}();return N&&N.then?N.then(g):g()})}catch(h){return Promise.reject(h)}var I,E,W}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(f):f(y))}catch(l){return Promise.reject(l)}}}}}function Qi(t){return function(e){return function(n){return function(r){var i=r.type,o=r.key,a=r.value,s=r.options;if(i===x.setItem||i===x.removeItem){if(r.abort)return n(r);i===x.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var eo=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,n){t[n]=t[n].concat(e)},this.removeMiddleware=function(e,n){var r=t[n].findIndex(function(i){return i===e});r!==-1&&(t[n]=[].concat(t[n].slice(0,r),t[n].slice(r+1)))},this.dynamicMiddlewares=function(e){return function(n){return function(r){return function(i){var o={getState:n.getState,dispatch:function(s){return n.dispatch(s)}},a=t[e].map(function(s){return s(o)});return xe.apply(void 0,a)(r)(i)}}}}};function to(t){return function(e,n){e===void 0&&(e={});var r={};if(n.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(n.type)){var i=En(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},A({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var f=En(n.type,x.initialize),p=t()[f];return p&&f?(r[f]=A({},e[f],{initialized:!0,loaded:!!p.loaded({config:p.config})}),A({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=A({},e[n.name],{loaded:!0}),A({},e,r);switch(n.type){case x.disablePlugin:return A({},e,Pn(n.plugins,!1,e));case x.enablePlugin:return A({},e,Pn(n.plugins,!0,e));default:return e}}}function En(t,e){return t.substring(e.length+1,t.length)}function Pn(t,e,n){return t.reduce(function(r,i){return r[i]=A({},n[i],{enabled:e}),r},n)}function yr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var no={last:{},history:[]};function ro(t,e){t===void 0&&(t=no);var n=e.options,r=e.meta;if(e.type===x.track){var i=yr(A({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return A({},t,{last:i,history:t.history.concat(i)})}return t}var io={actions:[]};function oo(t,e){t===void 0&&(t=io);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===x.identify?[e].concat(t.actions):t.actions.concat(e),A({},t,{actions:r});case"dequeue":return[];default:return t}}var vr=/#.*$/;function ao(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(vr,""):"")}var wr,br,kr,Ir,so=function(t){if(t===void 0&&(t={}),!X)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,f=o.hash,p=o.search,u=function(m){var d=function(){if(X){for(var w,k=document.getElementsByTagName("link"),v=0;w=k[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+m:window.location.href.replace(vr,"")}(p),c={title:n,url:u,path:ao(u),hash:f,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),A({},c,t)},co={last:{},history:[]};function uo(t,e){t===void 0&&(t=co);var n=e.options;if(e.type===x.page){var r=yr(A({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return A({},t,{last:r,history:t.history.concat(r)})}return t}wr=function(){if(!X)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),br=X?document.referrer:null,kr=Di(),Ir=Mi();var Tn={initialized:!1,sessionId:st(),app:null,version:null,debug:!1,offline:!!X&&!navigator.onLine,os:{name:wr},userAgent:X?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Ir,locale:kr,campaign:{},referrer:br};function lo(t,e){t===void 0&&(t=Tn);var n=t.initialized,r=e.campaign;switch(e.type){case x.campaign:return A({},t,{campaign:r});case x.offline:return A({},t,{offline:!0});case x.online:return A({},t,{offline:!1});default:return n?t:A({},Tn,t,{initialized:!0})}}var ho=["plugins","reducers","storage"];function fo(t,e,n){if(X){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function po(t){var e=fo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function Sr(){return be("analytics",[]),function(t){return function(e,n,r){var i=t(e,n,r),o=i.dispatch;return Object.assign(i,{dispatch:function(a){return Ce[je].analytics.push(a.action||a),o(a)}})}}}function On(t){return function(){return xe(xe.apply(null,arguments),Sr())}}function vt(t){return t?dr(t)?t:[t]:[]}function jn(t,e,n){t===void 0&&(t={});var r,i,o=st();return e&&(Re[o]=(r=e,i=function(a){for(var s,f=a||Array.prototype.slice.call(arguments),p=0;p<f.length;p++)if(Y(f[p])){s=f[p];break}return s}(n),function(a){i&&i(a),r(a)})),A({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function mo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(h,g){if(Y(g))return h.middlewares=h.middlewares.concat(g),h;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var P=g.EVENTS?Object.keys(g.EVENTS).map(function(D){return g.EVENTS[D]}):[];h.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(h.methods[g.name]=Object.keys(g.methods).reduce(function(D,J){var Z;return D[J]=(Z=g.methods[J],function(){for(var F=Array.prototype.slice.call(arguments),M=new Array(Z.length),ee=0;ee<F.length;ee++)M[ee]=F[ee];return M[M.length]=b,Z.apply({instance:b},M)}),D},{}),delete g.methods);var N=Object.keys(g).concat(P),U=new Set(h.events.concat(N));if(h.events=Array.from(U),h.pluginsArray=h.pluginsArray.concat(g),h.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return h.plugins[g.name]=g,h.plugins[g.name].loaded||(h.plugins[g.name].loaded=function(){return!0}),h},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:we,setItem:be,removeItem:Ae},o=function(h){return function(g,P,N){return P.getState("user")[g]||(N&&V(N)&&N[g]?N[g]:gn(h)[g]||we(Ct(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(h){return!jt.includes(h)}).sort(),f=new Set(s.concat(et).filter(function(h){return!jt.includes(h)})),p=Array.from(f).sort(),u=function(){return a},c=new eo,m=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Zi(),_=gn(i),S=A({},_,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=st());var y=A({enable:function(h,g){return new Promise(function(P){j.dispatch({type:x.enablePlugin,plugins:vt(h),_:{originalAction:x.enablePlugin}},P,[g])})},disable:function(h,g){return new Promise(function(P){j.dispatch({type:x.disablePlugin,plugins:vt(h),_:{originalAction:x.disablePlugin}},P,[g])})}},r.methods),l=!1,b={identify:function(h,g,P,N){try{var U=se(h)?h:null,D=V(h)?h:g,J=P||{},Z=b.user();be(Ct(oe),U);var F=U||D.userId||o(oe,b,D);return Promise.resolve(new Promise(function(M){j.dispatch(A({type:x.identifyStart,userId:F,traits:D||{},options:J,anonymousId:Z.anonymousId},Z.id&&Z.id!==U&&{previousId:Z.id}),M,[g,P,N])}))}catch(M){return Promise.reject(M)}},track:function(h,g,P,N){try{var U=V(h)?h.event:h;if(!U||!se(U))throw new Error("EventMissing");var D=V(h)?h:g||{},J=V(P)?P:{};return Promise.resolve(new Promise(function(Z){j.dispatch({type:x.trackStart,event:U,properties:D,options:J,userId:o(oe,b,g),anonymousId:o(_e,b,g)},Z,[g,P,N])}))}catch(Z){return Promise.reject(Z)}},page:function(h,g,P){try{var N=V(h)?h:{},U=V(g)?g:{};return Promise.resolve(new Promise(function(D){j.dispatch({type:x.pageStart,properties:so(N),options:U,userId:o(oe,b,N),anonymousId:o(_e,b,N)},D,[h,g,P])}))}catch(D){return Promise.reject(D)}},user:function(h){if(h===oe||h==="id")return o(oe,b);if(h===_e||h==="anonId")return o(_e,b);var g=b.getState("user");return h?un(g,h):g},reset:function(h){return new Promise(function(g){j.dispatch({type:x.resetStart},g,h)})},ready:function(h){return l&&h({plugins:y,instance:b}),b.on(x.ready,function(g){h(g),l=!0})},on:function(h,g){if(!h||!Y(g))return!1;if(h===x.bootstrap)throw new Error(".on disabled for "+h);var P=/Start$|Start:/;if(h==="*"){var N=function(Z){return function(F){return function(M){return M.type.match(P)&&g({payload:M,instance:b,plugins:a}),F(M)}}},U=function(Z){return function(F){return function(M){return M.type.match(P)||g({payload:M,instance:b,plugins:a}),F(M)}}};return m(N,Ye),m(U,Ge),function(){d(N,Ye),d(U,Ge)}}var D=h.match(P)?Ye:Ge,J=function(Z){return function(F){return function(M){return M.type===h&&g({payload:M,instance:b,plugins:a,abort:k}),F(M)}}};return m(J,D),function(){return d(J,D)}},once:function(h,g){if(!h||!Y(g))return!1;if(h===x.bootstrap)throw new Error(".once disabled for "+h);var P=b.on(h,function(N){g({payload:N.payload,instance:b,plugins:a,abort:k}),P()});return P},getState:function(h){var g=j.getState();return h?un(g,h):Object.assign({},g)},dispatch:function(h){var g=se(h)?{type:h}:h;if(et.includes(g.type))throw new Error("reserved action "+g.type);var P=A({},g,{_:A({originalAction:g.type},h._||{})});j.dispatch(P)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(h,g,P){j.dispatch({type:x.setItemStart,key:h,value:g,options:P})},removeItem:function(h,g){j.dispatch({type:x.removeItemStart,key:h,options:g})}},setAnonymousId:function(h,g){b.storage.setItem(ce,h,g)},events:{core:et,plugins:s}},T=r.middlewares.concat([function(h){return function(g){return function(P){return P.meta||(P.meta=jn()),g(P)}}},w(Ye),qi(b,u,{all:p,plugins:s}),Qi(i),Xi(b),Yi(b),w(Ge)]),O={context:lo,user:Vi(i),page:uo,track:ro,plugins:to(u),queue:oo},C=xe,L=xe;if(X&&t.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(C=z({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?Sr():V(typeof arguments[0])?On():On().apply(null,arguments)}}var H,$=function(h){return Object.keys(h).reduce(function(g,P){return ho.includes(P)||(g[P]=h[P]),g},{})}(t),R=r.pluginsArray.reduce(function(h,g){var P=g.name,N=g.config,U=g.loaded,D=r.pluginEnabled[P];return h[P]={enabled:D,initialized:!!D&&!g.initialize,loaded:!!U({config:N}),config:N},h},{}),K={context:$,user:S,plugins:R},j=fr(function(h){for(var g=Object.keys(h),P={},N=0;N<g.length;N++){var U=g[N];typeof h[U]===ae&&(P[U]=h[U])}var D,J=Object.keys(P);try{(function(Z){Object.keys(Z).forEach(function(F){var M=Z[F];if(typeof M(void 0,{type:"@@redux/INIT"})===ie||typeof M(void 0,{type:Fi})===ie)throw new Error("reducer "+F+" "+ie)})})(P)}catch(Z){D=Z}return function(Z,F){if(Z===void 0&&(Z={}),D)throw D;for(var M=!1,ee={},Ne=0;Ne<J.length;Ne++){var Fe=J[Ne],Vt=Z[Fe],lt=(0,P[Fe])(Vt,F);if(typeof lt===ie){var Rr=Hi(Fe,F);throw new Error(Rr)}ee[Fe]=lt,M=M||lt!==Vt}return M?ee:Z}}(A({},O,e)),K,L(C(Ji.apply(void 0,T))));j.dispatch=(H=j.dispatch,function(h,g,P){var N=A({},h,{meta:jn(h.meta,g,vt(P))});return H.apply(null,[N])});var I=Object.keys(a);j.dispatch({type:x.bootstrap,plugins:I,config:$,params:v,user:S,initialUser:n,persistedUser:_});var E=I.filter(function(h){return r.pluginEnabled[h]}),W=I.filter(function(h){return!r.pluginEnabled[h]});return j.dispatch({type:x.registerPlugins,plugins:I,enabled:r.pluginEnabled}),r.pluginsArray.map(function(h,g){var P=h.bootstrap,N=h.config,U=h.name;P&&Y(P)&&P({instance:b,config:N,payload:h}),j.dispatch({type:x.registerPluginType(U),name:U,enabled:r.pluginEnabled[U],plugin:h}),r.pluginsArray.length===g+1&&j.dispatch({type:x.initializeStart,plugins:E,disabled:W})}),po(function(h){j.dispatch({type:h?x.offline:x.online})}),function(h,g,P){setInterval(function(){return mr(h,g,P)},3e3)}(j,u,b),b}var Ye="before",Ge="after",De="cookie",fe=Pr(),_r=ct,go=ct;function Er(t){return fe?ct(t,"",-1):Ae(t)}function Pr(){if(fe!==void 0)return fe;var t="cookiecookie";try{ct(t,t),fe=document.cookie.indexOf(t)!==-1,Er(t)}catch{fe=!1}return fe}function ct(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return fe===!1&&(a?be(t,e):we(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var Me="localStorage",yo=Zt.bind(null,"localStorage");$e("localStorage","getItem",we);$e("localStorage","setItem",be);$e("localStorage","removeItem",Ae);var Ze="sessionStorage",vo=Zt.bind(null,"sessionStorage");$e("sessionStorage","getItem",we);$e("sessionStorage","setItem",be);$e("sessionStorage","removeItem",Ae);function Te(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(V(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var wo=yo(),bo=vo(),ko=Pr();function Tr(t,e){if(t){var n=Kt(e),r=!Jt(n),i=Wt(n)?Te(localStorage.getItem(t)):void 0;if(r&&!Se(i))return i;var o=Ft(n)?Te(_r(t)):void 0;if(r&&o)return o;var a=Ht(n)?Te(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=we(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function Io(t,e,n){if(t&&!Se(e)){var r={},i=Kt(n),o=JSON.stringify(e),a=!Jt(i);return Wt(i)&&(r[Me]=Be(Me,e,Te(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Me]:Ft(i)&&(r[De]=Be(De,e,Te(_r(t))),go(t,o),a)?r[De]:Ht(i)&&(r[Ze]=Be(Ze,e,Te(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ze]:(r[Le]=Be(Le,e,we(t)),be(t,e),a?r[Le]:r)}}function So(t,e){if(t){var n=Kt(e),r=Tr(t,cr),i={};return!Se(r.localStorage)&&Wt(n)&&(localStorage.removeItem(t),i[Me]=r.localStorage),!Se(r.cookie)&&Ft(n)&&(Er(t),i[De]=r.cookie),!Se(r.sessionStorage)&&Ht(n)&&(sessionStorage.removeItem(t),i[Ze]=r.sessionStorage),!Se(r.global)&&ut(n,Le)&&(Ae(t),i[Le]=r.global),i}}function Kt(t){return t?se(t)?t:t.storage:sr}function Wt(t){return wo&&ut(t,Me)}function Ft(t){return ko&&ut(t,De)}function Ht(t){return bo&&ut(t,Ze)}function Jt(t){return t===cr||t==="all"}function ut(t,e){return t===sr||t===e||Jt(t)}function Be(t,e,n){return{location:t,current:e,previous:n}}var _o={setItem:Io,getItem:Tr,removeItem:So};function Eo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Cn(Object(n),!0).forEach(function(r){Eo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Cn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Po(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:_o};return mo(xn(xn({},e),t))}function To(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(f){return r=i.push(f),r>=o&&a(),r},size:function(){return i.length},end:function(f){f&&a(),clearInterval(n)}}}function Oo(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...f){var c;const p=((c=f[2])==null?void 0:c.toString())||"",u=Co(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,f)}})}function jo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Co(t){return["#","?"].forEach(e=>t=jo(t,e)),t}function xo(){Oo(()=>{re.page()})}function Ao(t){if(t===void 0&&(t={}),!X)return Ot;var e=$n(),n=xt(),r=An(),i=qe(r,e),o=qe(n,e),a=[],s=[],f=[],p=r,u=i,c=o,m=Object.keys(t);if(!m.length)return Ot;var d=m.map(function(k){return Number(k)}),w=Wi(function(){var k=$n(),v=function($,R){return R.map(function(K){return K===100?$-5:$*(K/100)})}(k,d),_=xt(),S=An(),y=qe(S,k),l=qe(_,k);if(u=y>u?y:u,c=l<c?l:c,!(a.length>=d.length)){var b=p===S,T="up";b?T="initial":p<=S&&(T="down");var O=v,C=d;(T==="up"||b)&&(O=v.slice().reverse(),C=d.slice().reverse());var L=C.reduce(function($,R,K){var j=O[K];return f.includes(R)&&S<=j&&(f=f.filter(function(I){return I!==R}),$.singleFunction=R),T==="down"&&!a.includes(R)&&S>=j&&R>o?(s.push(R),$.callbacks=$.callbacks.concat(R),$):T==="up"&&!a.includes(R)&&S<=j&&R<=y?($.foundFunc=[R],$):(b&&S>=j&&$.foundFunc.length===0&&($.foundFunc=[R]),!s.includes(R)&&S>=j&&(s.push(R),$.singleFunction?f.push(R):$.singleFunction=R),$)},{foundFunc:[],singleFunction:null,callbacks:[],direction:T});if(p=S,T==="down"&&L.callbacks&&L.callbacks.forEach(function($){Y(t[$])&&(t[$]({trigger:$,direction:T,scrollMin:c,scrollMax:u,range:[c,u]}),a.push($))}),L.singleFunction){var z=L.singleFunction,H=L.direction;Y(t[z])&&t[z]({trigger:z,direction:H,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(z)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function xt(){return X?document.body.scrollTop||document.documentElement.scrollTop:0}function $o(){return X?window.innerHeight||document.documentElement.clientHeight:0}function An(){return Math.round(xt()+$o())}function $n(){if(!X)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function qe(t,e){return Math.round(t/e*100)}var Nn="EventListener";function No(t){return function(e,n,r,i){var o=r||Ot,a=i||!1;if(!X)return o;var s=rt(n),f=rt(e,!0);if(!f.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var m=c?"add"+Nn:"remove"+Nn,d=0;d<f.length;d++){var w=f[d];p[d]=c?a&&a.once?Uo(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[m]?w["on"+s[k]]=c?p[d]:null:w[m](s[k],p[d],a)}return u.bind(null,!c)}(t)}}function rt(t,e){if(se(t))return e?rt(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=Li(t);return e?o.map(function(a){return se(a)?rt(a,!0):a}).flat():o}function Uo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var wt=No("Event");function Or(t,e){return X&&Y(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),Y(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}Or.bind(null,"onerror");Or.bind(null,"onload");var jr=typeof window>"u",Un="hidden";function zo(t){if(jr)return!1;var e=Ro(),n="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),r=function(){return t(!!document[e])},i=function(){return document.addEventListener(n,r)};return i(),function(){return document.removeEventListener(n,r),i}}function Ro(){var t=["webkit","moz","ms","o"];return jr||Un in document?Un:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Lo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Do(t,e){e===void 0&&(e={});var n=function(a,s){var f=this,p=!1;return function(u){p||(a.call(f,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=zo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Lo.map(function(s){return wt(document,s,n)})).concat(wt(window,"load",n)).concat(wt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Mo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,f=t.throttle,p=f===void 0?2e3:f,u=!1,c=!1,m=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(ze(m),v),i&&u&&(u=!1,i(ze(n),v),m=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(ze(m),v))},s)}var k=Do(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,m=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:ze(m,c),idle:u?ze(n,c):0}}}}function ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const zn=5e3;class Zo{constructor(e){q(this,"element");q(this,"isInViewport",!1);q(this,"isAwake",!1);q(this,"isFlushing");q(this,"observer");q(this,"lastEventAt",Date.now());q(this,"registeredView",!1);q(this,"viewCallback");q(this,"activeDurationCallback");q(this,"idleDurationCallback");q(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Mo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:zn}),Ao({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(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*zn:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const Rn="sesamy_session_id";function Ko(){let t=sessionStorage.getItem(Rn);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(Rn,t)),t}let Cr=!1,At,Ln,it;function Wo({clientId:t,enabled:e=!0,endpoint:n=di}){if(At=t,Ln=e,it=n,!Ln)return;xo();const r=new Zo({element:document.body,viewCallback:()=>{re.page()},activeDurationCallback:(i,o,a)=>{re.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{re.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{re.track("scroll",{scroll:i.scrollMax})}});Jo(document.body,()=>{r.flush()}),Xo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(Q.AUTHENTICATED,async i=>{const o=i;await re.identify(o.detail.sub)}),window.addEventListener(Q.LOGOUT,async()=>{await re.track("logout",{}),Xt.flush(),await re.reset()})}function xr(t){return JSON.stringify(t.map(e=>({...e,clientId:At,requestId:Math.random().toString(36).slice(2,9),sessionId:Ko(),timestamp:new Date().toISOString(),version:Mt,event:e.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:ar,userAgent:navigator.userAgent,clientId:At}})))}const Xt=To(async t=>{if(t.length>0){const e=xr(t);Cr?navigator.sendBeacon(it,e):(await fetch(it,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function bt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(it,xr([n]))}else Xt.push(t)}const re=Po({app:ar,version:Mt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;bt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Fo(t,e){re.track(t,e)}function Ho(){return Cr=!0,Xt.flush()}const Ar=new Map;function Jo(t,e){Ar.set(t,e)}window.addEventListener("beforeunload",()=>{Ar.forEach((t,e)=>{t.bind(e)()}),Ho()});const $r=new Map;function Xo(t,e){$r.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&$r.forEach((t,e)=>{t.bind(e)()})});const Nr="sesamySignedURLs";function Ur(){const t=sessionStorage.getItem(Nr);return t?JSON.parse(t):[]}function Vo(t){const e=Ur();e.push(t),sessionStorage.setItem(Nr,JSON.stringify(e))}function Yo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:f,getProfile:p,updateProfile:u,getTags:c,deleteTag:m,setTag:d,getUserMetadata:w,listUserMetadata:k,setUserMetadata:v,deleteUserMetadata:_,getTally:S,getTallies:y,pushTally:l,deleteTally:b,getProduct:T,getPaymentIssues:O,autoOnboardProduct:C,openHostedAccountPage:L}=Oi(t),z={auth:{getUser:p,isAuthenticated:Lt,loginWithRedirect:Dt,logout:pi,setToken:nr},profile:{get:p,update:u,openHostedAccountPage:L},analytics:{track:Fo},tags:{list:c,set:d,delete:m},entitlements:{get:e,list:n,access:r,signedLinks:Ur},contracts:{get:o,list:a},bills:{get:s,list:f},userMetadata:{get:w,list:k,set:v,delete:_},tallies:{get:S,list:y,push:l,delete:b},subscriptions:{list:i},products:{get:T,autoOnboard:C},getVersion:Go,getPaymentIssues:O,clearCache:te};return t.namespace&&(window[t.namespace]=z),z}function Go(){return Mt}function Bo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){nr(e,n?parseInt(n,10):void 0);const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Dn="sesamy-refresh",Mn="force-refetch-entitlements";function qo(){const t=new URLSearchParams(window.location.search),e=t.get(Mn),n=t.get(Dn);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Mn),t.delete(Dn),r.search=t.toString(),te(),window.history.replaceState(null,"",r)}}function Qo(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Vo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const Zn="sesamy-user";async function ea(){const e=new URLSearchParams(window.location.search).get(Zn);if(!e)return;const n=await fi();(n==null?void 0:n.email)!==e&&Dt({email:e});const r=new URL(window.location.href);r.searchParams.delete(Zn),window.history.replaceState(null,"",r)}const Kn="sesamy-purchase";function ta(){const t=new URLSearchParams(window.location.search),e=t.get(Kn);if(e!==null){const n=new URL(window.location.href);t.delete(Kn),n.search=t.toString(),ue(Q.PURCHASE,{itemSrc:e}),te(),window.history.replaceState(null,"",n)}}const Wn="sesamy-login";async function na(){if(!new URLSearchParams(window.location.search).get(Wn))return;await Lt()||Dt();const r=new URL(window.location.href);r.searchParams.delete(Wn),window.history.replaceState(null,"",r)}async function zr(t){Wo({clientId:t.clientId,...t.analytics}),await hi({clientId:t.clientId,organization:t.organization,...t.auth});const e=Yo({clientId:t.clientId,...t.api});return ue(Q.READY,{}),Bo(),qo(),Qo(),await na(),await ea(),ta(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);zr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=zr;
@@ -3,4 +3,4 @@ var sesamyJs=function(ie){"use strict";var na=Object.defineProperty;var ra=(ie,V
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
  `)})(),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)r=e.cache;else{if(n=e.cacheLocation||"memory",!cn(n))throw new Error(`Invalid cache location "${n}"`);r=cn(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Ie:ti,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(a=>`auth0.${a}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const i=e.useCookiesForTransactions?this.cookieStorage:ni;var o;this.scope=Je("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Br(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Gt,this.cacheManager=new Gr(r,r.allKeys?void 0:new oi(r,this.options.clientId),this.nowProvider),this.domainUrl=(o=this.options.domain,/^https?:\/\//.test(o)?o:`https://${o}`),this.tokenIssuer=((a,s)=>a?a.startsWith("https://")?a:`https://${a}/`:`${s}/`)(this.options.issuer,this.domainUrl),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&n==="memory"&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ii)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Yt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${mt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Qr({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:n,organization:r,leeway:this.options.leeway,max_age:(o=this.options.authorizationParams.max_age,typeof o!="string"?o:parseInt(o,10)||void 0),now:i});var o}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(e,n,r){const i=Qt(pt()),o=Qt(pt()),a=pt(),s=(u=>{const c=new Uint8Array(u);return(m=>{const d={"+":"-","/":"_","=":""};return m.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await He().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),f=((u,c,m,d,w,k,v,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),m),{scope:Je(c,m.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:v||u.authorizationParams.redirect_uri,code_challenge:k,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),p=this._authorizeUrl(f);return{nonce:o,code_verifier:a,scope:f.scope,audience:f.audience||"default",redirect_uri:f.redirect_uri,state:i,url:p}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const f=window.screenX+(window.innerWidth-400)/2,p=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${f},top=${p},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((f,p)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(m),window.removeEventListener("message",u,!1),p(new Kr(s.popup)))},1e3),m=setTimeout(()=>{clearInterval(c),p(new Zr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(m),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return p(q.fromPayload(d.data.response));f(d.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(i.state!==o.state)throw new q("state_mismatch","Invalid state");const a=((r=e.authorizationParams)===null||r===void 0?void 0:r.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:a})}async getUser(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.user}async getIdTokenClaims(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.claims}async loginWithRedirect(e={}){var n;const r=un(e),{openUrl:i,fragment:o,appState:a}=r,s=Y(r,["openUrl","fragment","appState"]),f=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,p=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=p,c=Y(p,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),f&&{organization:f}));const m=o?`${u}#${o}`:u;i?await i(m):window.location.assign(m)}async handleRedirectCallback(e=window.location.href){const n=e.split("?").slice(1);if(n.length===0)throw new Error("There are no query params available for parsing.");const{state:r,code:i,error:o,error_description:a}=(c=>{c.indexOf("#")>-1&&(c=c.substring(0,c.indexOf("#")));const m=new URLSearchParams(c);return{state:m.get("state"),code:m.get("code")||void 0,error:m.get("error")||void 0,error_description:m.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new q("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Mr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new q("state_mismatch","Invalid state");const f=s.organization,p=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:p,organization:f}),{appState:s.appState}}async checkSession(e){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(e)}catch{}}async getTokenSilently(e={}){var n;const r=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Je(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=yt[a];return s||(s=o().finally(()=>{delete yt[a],s=null}),yt[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=Y(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>vt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new ft;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const p=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(p)return p}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:f}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:f})}finally{await vt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Je(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Dr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new pe({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId!==null?e.clientId=e.clientId||this.options.clientId:delete e.clientId;const n=e.logoutParams||{},{federated:r}=n,i=Y(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${mt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=un(e),{openUrl:r}=n,i=Y(n,["openUrl"]);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.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 o=this._buildLogoutUrl(i);r?await r(o):r!==!1&&window.location.assign(o)}async _getTokenFromIFrame(e){const n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);const{url:i,state:o,nonce:a,code_verifier:s,redirect_uri:f,scope:p,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new q("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const c=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,m=await((w,k,v=60)=>new Promise((_,S)=>{const y=window.document.createElement("iframe");y.setAttribute("width","0"),y.setAttribute("height","0"),y.style.display="none";const l=()=>{window.document.body.contains(y)&&(window.document.body.removeChild(y),window.removeEventListener("message",b,!1))};let b;const T=setTimeout(()=>{S(new ft),l()},1e3*v);b=function(O){if(O.origin!=k||!O.data||O.data.type!=="authorization_response")return;const A=O.source;A&&A.close(),O.data.response.error?S(q.fromPayload(O.data.response)):_(O.data.response),clearTimeout(T),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(y),y.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==m.state)throw new q("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:m.code,grant_type:"authorization_code",redirect_uri:f,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:p,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new pe({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(n&&n.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new Bt(e.authorizationParams.audience||"default",e.authorizationParams.scope)}const r=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,i=typeof e.timeoutInSeconds=="number"?1e3*e.timeoutInSeconds:null;try{const o=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:r}),i&&{timeout:i}));return Object.assign(Object.assign({},o),{scope:e.authorizationParams.scope,oauthTokenScope:o.scope,audience:e.authorizationParams.audience||"default"})}catch(o){if((o.message.indexOf("Missing Refresh Token")>-1||o.message&&o.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw o}}async _saveEntryInCache(e){const{id_token:n,decodedToken:r}=e,i=Y(e,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:n,decodedToken:r}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(i)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||"default",n=await this.cacheManager.getIdToken(new pe({clientId:this.options.clientId,audience:e,scope:this.scope})),r=this.userCache.get("@@user@@");return n&&n.id_token===(r==null?void 0:r.id_token)?r:(this.userCache.set("@@user@@",n),n)}async _getEntryFromCache({scope:e,audience:n,clientId:r}){const i=await this.cacheManager.get(new pe({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,f=await this._getIdTokenFromCache();return f&&Object.assign(Object.assign({id_token:f.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Vr(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},e),this.worker),a=await this._verifyIdToken(o.id_token,r,i);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:a,scope:e.scope,audience:e.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||a.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:a})}};async function ci(t){const e=new si(t);return await e.checkSession(),e}const wt="sesamy.com",ui="https://logs.sesamy.com/events",bt="sesamyCacheTimestamp";var te=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(te||{});let Q,kt;const It="sesamyAccessToken",St="sesamyExpires";function _t(){const t=localStorage.getItem(St);if(!(t&&parseInt(t,10)<new Date().getTime()))return localStorage.getItem(It)}async function li(t){if(t.enabled!==!1&&(kt=t.organization,Q=await ci({domain:t.endpoint||`token.${wt}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await Q.handleRedirectCallback();const e=await Q.getUser();V(te.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),r.delete("state"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function Et(){if(_t())return!0;if(!Q)throw new Error("Auth0 client not initialized");return Q.isAuthenticated()}async function di(){if(_t())return{sub:"local",name:"Local User"};if(!Q)throw new Error("Auth0 client not initialized");return Q.getUser()}function Pt(t){if(!Q)throw new Error("Auth0 client not initialized");const e={redirect_uri:window.location.href};return t!=null&&t.email&&(e.login_hint=t.email),kt&&(e.organization=kt),Q.loginWithRedirect({authorizationParams:e})}async function ln(t=!0){const e=_t();if(e)return e;try{if(!Q)throw new Error("Auth0 client not initialized");return await Q.getTokenSilently()}catch(n){if(t)throw n;return null}}async function hi(){if(localStorage.removeItem(It),localStorage.removeItem(St),!Q)throw new Error("Auth0 client not initialized");return V(te.LOGOUT,{}),Q.logout({logoutParams:{returnTo:window.location.href}})}function fi(t){const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT token format.");const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}async function dn(t,e){localStorage.setItem(It,t),e&&localStorage.setItem(St,JSON.stringify(e*1e3+new Date().getTime()));const n=fi(t);V(te.AUTHENTICATED,n)}const pi=(t,e)=>e.skipDedupe||e.method!=="GET",mi=(t,e)=>e.method+"@"+t,gi=t=>t.clone(),hn=({skip:t=pi,key:e=mi,resolver:n=gi}={})=>{const r=new Map;return i=>(o,a)=>{if(t(o,a))return i(o,a);const s=e(o,a);if(!r.has(s))r.set(s,[]);else return new Promise((f,p)=>{r.get(s).push([f,p])});try{return i(o,a).then(f=>(r.get(s).forEach(([p])=>p(n(f))),r.delete(s),f)).catch(f=>{throw r.get(s).forEach(([p,u])=>u(f)),r.delete(s),f})}catch(f){return r.delete(s),Promise.reject(f)}}},yi=(t,e)=>t*e,vi=t=>t&&t.ok,fn=({delayTimer:t=500,delayRamp:e=yi,maxAttempts:n=10,until:r=vi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>f=>(p,u)=>{let c=0;if(s&&s(p,u))return f(p,u);const m=(d,w)=>Promise.resolve(r(d,w)).then(k=>k?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(v=>{const _=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:p,options:u})).then((S={})=>{var y,l;v(f((y=S&&S.url)!==null&&y!==void 0?y:p,(l=S&&S.options)!==null&&l!==void 0?l:u))}):v(f(p,u))},_)}).then(m).catch(v=>{if(!o)throw v;return m(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return f(p,u).then(m).catch(d=>{if(!o)throw d;return m(null,d)})},wi="application/json",pn="Content-Type",Se=Symbol(),mn=Symbol();function gn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===pn.toLowerCase()))===null||e===void 0?void 0:e[1]}function yn(t){return/^application\/.*json.*/.test(t)}const ge=function(t,e,n=!1){return Object.entries(e).reduce((r,[i,o])=>{const a=t[i];return Array.isArray(a)&&Array.isArray(o)?r[i]=n?[...a,...o]:o:typeof a=="object"&&typeof o=="object"?r[i]=ge(a,o,n):r[i]=o,r},{...t})},_e={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function bi(t,e=!1){_e.options=e?t:ge(_e.options,t)}function ki(t,e=!1){_e.polyfills=e?t:ge(_e.polyfills,t)}function Ii(t){_e.errorType=t}const Si=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class vn extends Error{}const _i=t=>{const e=Object.create(null);t=t._addons.reduce((y,l)=>l.beforeRequest&&l.beforeRequest(y,t._options,e)||y,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:f}=t,p=new Map(o),u=ge(i.options,r);let c=n;const m=Si(s)((y,l)=>(c=y,i.polyfill("fetch")(y,l)))(n,u),d=new Error,w=m.catch(y=>{throw{[Se]:y}}).then(y=>{if(!y.ok){const l=new vn;if(l.cause=d,l.stack=l.stack+`
5
5
  CAUSE: `+d.stack,l.response=y,l.url=c,y.type==="opaque")throw l;return y.text().then(b=>{var T;if(l.message=b,i.errorType==="json"||((T=y.headers.get("Content-Type"))===null||T===void 0?void 0:T.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=y.status,l})}return y}),k=y=>y.catch(l=>{const b=l.hasOwnProperty(Se),T=b?l[Se]:l,O=(T==null?void 0:T.status)&&p.get(T.status)||p.get(T==null?void 0:T.name)||b&&p.has(Se)&&p.get(Se);if(O)return O(T,t);const A=p.get(mn);if(A)return A(T,t);throw T}),v=y=>l=>k(y?w.then(b=>b&&b[y]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),_={_wretchReq:t,_fetchReq:m,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(y,l){return p.set(y,l),this},badRequest(y){return this.error(400,y)},unauthorized(y){return this.error(401,y)},forbidden(y){return this.error(403,y)},notFound(y){return this.error(404,y)},timeout(y){return this.error(408,y)},internalError(y){return this.error(500,y)},fetchError(y){return this.error(Se,y)}},S=f.reduce((y,l)=>({...y,...typeof l.resolver=="function"?l.resolver(y):l.resolver}),_);return a.reduce((y,l)=>l(y,t),S)},Ei={_url:"",_options:{},_config:_e,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:ge(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const n=this._url.split("?");return{...this,_url:n.length>1?n[0]+t+"?"+n[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:ge(this._options,t)}},headers(t){const e=t?Array.isArray(t)?Object.fromEntries(t):"entries"in t?Object.fromEntries(t.entries()):t:{};return{...this,_options:ge(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[pn]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const n=new Map(this._catchers);return n.set(t,e),{...this,_catchers:n}},catcherFallback(t){return this.catcher(mn,t)},resolve(t,e=!1){return{...this,_resolvers:e?[t]:[...this._resolvers,t]}},defer(t,e=!1){return{...this,_deferred:e?[t]:[...this._deferred,t]}},middlewares(t,e=!1){return{...this,_middlewares:e?t:[...this._middlewares,...t]}},fetch(t=this._options.method,e="",n=null){let r=this.url(e).options({method:t});const i=gn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||yn(i));return r=n?o?r.json(n,i):r.body(n):r,_i(r._deferred.reduce((a,s)=>s(a,a._url,a._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=gn(this._options.headers);return this.content(e||yn(n)&&n||wi).body(JSON.stringify(t))}};function se(t="",e={}){return{...Ei,_url:t,_options:e}}se.default=se,se.options=bi,se.errorType=Ii,se.polyfills=ki,se.WretchError=vn;function ne(){sessionStorage.removeItem(bt),V(te.CLEAR_CACHE,{})}function Pi(t){const e=t.endpoint||`https://api2.${wt}`,n=I=>async(E,W)=>{let h=sessionStorage.getItem(bt);h||(h=Date.now().toString(),sessionStorage.setItem(bt,h));const g={...W,headers:{...W.headers,"Cache-Timestamp":h}};return I(E,g)},r=(I=!0)=>E=>async(W,h)=>{let g=null;if(g=await ln(I),!g){if(I)throw new Error("No access token available");return E(W,h)}const P={...h,headers:{...h.headers,...g?{Authorization:`Bearer ${g}`}:{}}};return E(W,P)},i=I=>(E,W)=>{if(W.headers.Authorization)return I(E,W);const h=localStorage.getItem("__anon_id"),g=btoa(`${h}:`),P={...W,headers:{...W.headers,Authorization:`Basic ${g}`}};return I(E,P)},o=se(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),hn(),fn({delayTimer:1e3,delayRamp:(I,E)=>I*E,maxAttempts:3,until:I=>!!(I&&(I.ok||I.status>=400&&I.status<500)),retryOnNetworkError:!1})]),a=se(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,hn(),fn({delayTimer:1e3,delayRamp:(I,E)=>I*E,maxAttempts:3,until:I=>!!(I&&(I.ok||I.status>=400&&I.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function f(I){const E=await o.get("/entitlements").json();return E==null?void 0:E.find(W=>W.id===I)}async function p(I){return o.get(`/entitlements/${I}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(I){const E=await o.get("/contracts").json();return E==null?void 0:E.find(W=>W.id===I)}async function m(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function w(I){const E=await o.get("/bills").json();return E==null?void 0:E.find(W=>W.id===I)}async function k(I,E){const W=await o.url(`/user-metadata/${I}`).put(E).json();return V(te.USER_ATTRIBUTE_CHANGED,{}),ne(),W}async function v(I){const E=await o.url(`/user-metadata/${I}`).delete().res();return ne(),E.ok}async function _(I){return(await o.url(`/user-metadata/${I}`).get().json())[I]}async function S(){return await o.url("/user-metadata").get().json()}async function y(){return await o.url("/tags").get().json()}async function l(I){const E=await o.url(`/tags/${I}`).delete().res();return ne(),E.ok}async function b(I){const E=await o.url("/tags").post(I).res();return V(te.USER_ATTRIBUTE_CHANGED,{}),ne(),E.ok}async function T(I){return(await a.url("/tallies").get().json())[I]}async function O(){return await a.url("/tallies").get().json()}async function A(I){const E=await a.url(`/tallies/${I}`).delete().res();return ne(),E.ok}async function L(I,E){return await a.url(`/tallies/${I}/push`).post(E).json()}async function z(I){return await o.url(`/products/${I}`).get().json()}async function J(){return await Et()?await o.url("/profile").get().json():null}async function $(I){const E=await o.url("/profile").patch(I).res();return ne(),E.ok}async function R(){return await o.url("/payment-issues").get().json()}async function K(I){const E=await o.url(`/products/${I}/auto-onboard`).post().json();return E.length&&ne(),E}async function j(){const I=await ln(!1),E=new URL(`https://account.${wt}/subscriptions/${t.clientId}`);I&&(E.hash=`#access_token=${I}`),window.location.href=E.toString()}return{getEntitlements:s,getEntitlement:f,getEntitlementAccess:p,getContracts:u,getContract:c,getProfile:J,updateProfile:$,getSubscriptions:m,getBills:d,getBill:w,setUserMetadata:k,deleteUserMetadata:v,getUserMetadata:_,listUserMetadata:S,getTags:y,deleteTag:l,setTag:b,getTally:T,getTallies:O,deleteTally:A,pushTally:L,getProduct:z,getPaymentIssues:R,autoOnboardProduct:K,openHostedAccountPage:j}}const wn="@sesamy/sesamy-js",Tt="1.3.2";function bn(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Xe="undefined",kn="object",Ot=function(){},In="any",Sn="*",ye="__",Ve=typeof process<"u"?process:{};Ve.env&&Ve.env.NODE_ENV;var H=typeof document<"u";Ve.versions!=null&&Ve.versions.node!=null,typeof Deno<"u"&&Deno.core,H&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function _n(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ti=_n.bind(null,"toUpperCase"),Oi=_n.bind(null,"toLowerCase");function ji(t){return En(t)?Ti("null"):typeof t=="object"?$i(t):Object.prototype.toString.call(t).slice(8,-1)}function Ye(t,e){e===void 0&&(e=!0);var n=ji(t);return e?Oi(n):n}function ze(t,e){return typeof e===t}var G=ze.bind(null,"function"),ce=ze.bind(null,"string"),Ee=ze.bind(null,"undefined"),Ci=ze.bind(null,"boolean");ze.bind(null,"symbol");function En(t){return t===null}function xi(t){return Ye(t)==="number"&&!isNaN(t)}function Pn(t){return Ye(t)==="array"}function B(t){if(!Ai(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ai(t){return t&&(typeof t=="object"||t!==null)}function $i(t){return G(t.constructor)?t.constructor.name:null}function Ni(t){return t instanceof Error||ce(t.message)&&t.constructor&&xi(t.constructor.stackTraceLimit)}function Tn(t,e){if(typeof e!="object"||En(e))return!1;if(e instanceof t)return!0;var n=Ye(new t(""));if(Ni(e))for(;e;){if(Ye(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Tn.bind(null,TypeError),Tn.bind(null,SyntaxError);function Ge(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ui(t,e):n}function Ui(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Be(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Be(Ge,"form"),Be(Ge,"button"),Be(Ge,"input"),Be(Ge,"select");function zi(t){return t?Pn(t)?t:[t]:[]}function On(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ri(){if(H){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Li(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Di(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=On(n[1]),a=On(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var f=s.split("[");f.length>1&&(Mi(r,f.map(function(p){return p.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return H&&window.location.search.substring(1)}(t))}function Mi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function qe(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Zi(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var f=new Date;a||(a=f);var p=e-(f-a);return n=this,r=arguments,p<=0?(clearTimeout(o),o=null,a=f,i=t.apply(n,r)):o||(o=setTimeout(s,p)),i}}var Re="global",Pe=ye+"global"+ye,Te=typeof self===kn&&self.self===self&&self||typeof global===kn&&global.global===global&&global||void 0;function ve(t){return Te[Pe][t]}function we(t,e){return Te[Pe][t]=e}function Oe(t){delete Te[Pe][t]}function je(t,e,n){var r;try{if(jt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Te[Pe]||(Te[Pe]={});var Qe={};function jt(t){if(typeof Qe[t]!==Xe)return Qe[t];try{var e=window[t];e.setItem(Xe,Xe),e.removeItem(Xe)}catch{return Qe[t]=!1}return Qe[t]=!0}function C(){return C=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},C.apply(this,arguments)}var ue="function",oe="undefined",Ki="@@redux/"+Math.random().toString(36),jn=function(){return typeof Symbol===ue&&Symbol.observable||"@@observable"}(),et=" != "+ue;function Cn(t,e,n){var r;if(typeof e===ue&&typeof n===oe&&(n=e,e=void 0),typeof n!==oe){if(typeof n!==ue)throw new Error("enhancer"+et);return n(Cn)(t,e)}if(typeof t!==ue)throw new Error("reducer"+et);var i=t,o=e,a=[],s=a,f=!1;function p(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ue)throw new Error("Listener"+et);var w=!0;return p(),s.push(d),function(){if(w){w=!1,p();var k=s.indexOf(d);s.splice(k,1)}}}function m(d){if(!B(d))throw new Error("Act != obj");if(typeof d.type===oe)throw new Error("ActType "+oe);if(f)throw new Error("Dispatch in reducer");try{f=!0,o=i(o,d)}finally{f=!1}for(var w=a=s,k=0;k<w.length;k++)(0,w[k])();return d}return m({type:"@@redux/INIT"}),(r={dispatch:m,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ue)throw new Error("next reducer"+et);i=d,m({type:"@@redux/INIT"})}})[jn]=function(){var d,w=c;return(d={subscribe:function(k){if(typeof k!="object")throw new TypeError("Observer != obj");function v(){k.next&&k.next(u())}return v(),{unsubscribe:w(v)}}})[jn]=function(){return this},d},r}function Wi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+oe}function Ce(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function Fi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,f={getState:a.getState,dispatch:function(p){return s(p)}};return o=[].slice.call(t).map(function(p){return p(f)}),C({},a,{dispatch:s=Ce.apply(void 0,o)(a.dispatch)})}}}var le=ye+"anon_id",be=ye+"user_id",xe=ye+"user_traits",de="userId",Ae="anonymousId",tt=["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"],Ct=["name","EVENTS","config","loaded"],x=tt.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),xn=/^utm_/,An=/^an_prop_/,$n=/^an_trait_/;function Hi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===x.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,f=i.initialUser,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(le,a.anonymousId),p||e(be,a.userId),f.traits&&e(xe,C({},p&&s.traits?s.traits:{},f.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,m=o.an_event,d=u.reduce(function(w,k){if(k.match(xn)||k.match(/^(d|g)clid/)){var v=k.replace(xn,"");w.campaign[v==="campaign"?"name":v]=o[k]}return k.match(An)&&(w.props[k.replace(An,"")]=o[k]),k.match($n)&&(w.traits[k.replace($n,"")]=o[k]),w},{campaign:{},props:{},traits:{}});n.dispatch(C({type:x.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),m&&setTimeout(function(){return t.track(m,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:x.campaign,campaign:d.campaign})}}return r(i)}}}}function Ji(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===x.setItemEnd){if(n.key===le)return C({},e,{anonymousId:n.value});if(n.key===be)return C({},e,{userId:n.value})}switch(n.type){case x.identify:return Object.assign({},e,{userId:n.userId,traits:C({},e.traits,n.traits)});case x.reset:return[be,le,xe].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Nn(t){return{userId:t.getItem(be),anonymousId:t.getItem(le),traits:t.getItem(xe)}}var xt=function(t){return ye+"TEMP"+ye+t};function Xi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var f=s.userId,p=s.traits,u=s.options;if(s.type===x.reset&&([be,xe,le].forEach(function(d){r(d)}),[de,Ae,"traits"].forEach(function(d){Oe(xt(d))})),s.type===x.identify){i(le)||n(le,qe());var c=i(be),m=i(xe)||{};c&&c!==f&&o.dispatch({type:x.userIdChanged,old:{userId:c,traits:m},new:{userId:f,traits:p},options:u}),f&&n(be,f),p&&n(xe,C({},m,p))}return a(s)}}}}var Le={};function Un(t,e){Le[t]&&G(Le[t])&&(Le[t](e),delete Le[t])}function zn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(C({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return zn(t,e,n-10).then(r,i)})})}function Vi(t){return{abort:t}}function Rn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,f=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var p=s.actions.reduce(function(c,m,d){return a[m.plugin].loaded?(c.process.push(m),c.processIndex.push(d)):(c.requeue.push(m),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(p.processIndex&&p.processIndex.length){p.processIndex.forEach(function(c){var m=s.actions[c],d=m.plugin,w=m.payload.type,k=i[d][w];if(k&&G(k)){var v,_=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[de,Ae].reduce(function(T,O){return l.hasOwnProperty(O)&&b[O]&&b[O]!==l[O]&&(T[O]=b[O]),T},l)}(m.payload,f),S=r[_.meta.rid];if(!S&&(v=k({payload:_,config:a[d].config,instance:n,abort:Vi}))&&B(v)&&v.abort)return void(r[_.meta.rid]=!0);if(!S){var y=w+":"+d;t.dispatch(C({},_,{type:y,_:{called:y,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,m){return!~p.processIndex.indexOf(m)});s.actions=u}}}var At=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,f=t.EVENTS;try{var p=i.plugins,u=i.context,c=n.type,m=c.match($e),d=e.exact.map(function(v){return v.pluginName});m&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,_){return function(S,y,l){var b=y.config,T=y.name,O=T+"."+S.type;l&&(O=l.event);var A=S.type.match($e)?function(L,z,J,$,R){return function(K,j){var I=$?$.name:L,E=j&&De(j)?j:J;if($&&(!(E=j&&De(j)?j:[L]).includes(L)||E.length!==1))throw new Error("Method "+z+" can only abort "+L+" plugin. "+JSON.stringify(E)+" input valid");return C({},R,{abort:{reason:K,plugins:E,caller:z,_:I}})}}(T,O,_,l,S):function(L,z){return function(){throw new Error(L.type+" action not cancellable. Remove abort in "+z)}}(S,O);return{payload:Yi(S),instance:v,config:b||{},abort:A}}}(r,d),k=e.exact.reduce(function(v,_){var S=_.pluginName,y=_.methodName,l=!1;return y.match(/^initialize/)||y.match(/^reset/)||(l=!p[S].loaded),u.offline&&y.match(/^(page|track|identify)/)&&(l=!0),v[""+S]=l,v},{});return Promise.resolve(e.exact.reduce(function(v,_,S){try{var y=_.pluginName;return Promise.resolve(v).then(function(l){function b(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(O,A,L){try{return Promise.resolve(O).then(function(z){return A.method&&G(A.method)?(function(K,j){var I=Hn(K);if(I&&I.name===j){var E=Hn(I.method);throw new Error([j+" plugin is calling method "+K,"Plugins cant call self","Use "+I.method+" "+(E?"or "+E.method:"")+" in "+j+" plugin insteadof "+K].join(`
6
- `))}}(A.methodName,A.pluginName),Promise.resolve(A.method({payload:z,instance:r,abort:(J=z,$=y,R=A.pluginName,function(K,j){return C({},J,{abort:{reason:K,plugins:j||[$],caller:c,from:R||$}})}),config:Mn(A.pluginName,p,o),plugins:p})).then(function(K){var j=B(K)?K:{};return Promise.resolve(C({},z,j))})):z;var J,$,R})}catch(z){return Promise.reject(z)}},Promise.resolve(n))).then(function(O){l[y]=O});l[y]=n}();return T&&T.then?T.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(_,S,y){try{var l=e.exact.length===y+1,b=S.pluginName,T=o[b];return Promise.resolve(_).then(function(O){var A=v[b]?v[b]:{};if(m&&(A=O),Nt(A,b))return $t({data:A,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(O);if(Nt(O,b))return l&&$t({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var L=w(v[b],o[b]);return Promise.resolve(T[c]({abort:L.abort,payload:A,instance:r,config:Mn(b,p,o),plugins:p})).then(function(z){var J=B(z)?z:{},$=C({},O,J),R=v[b];if(Nt(R,b))$t({data:R,method:c,instance:r,pluginName:b,store:s});else{var K=c+":"+b;(K.match(/:/g)||[]).length<2&&!c.match(Ln)&&!c.match(Dn)&&r.dispatch(C({},m?$:A,{type:K,_:{called:K,from:"submethod"}}))}return Promise.resolve($)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(_){if(!(c.match($e)||c.match(/^registerPlugin/)||c.match(Dn)||c.match(Ln)||c.match(/^params/)||c.match(/^userIdChanged/))){if(f.plugins.includes(c),_._&&_._.originalAction===c)return _;var S=C({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});Wn(_,e.exact.length)&&!c.match(/End$/)&&(S=C({},S,{type:_.type+"Aborted"})),s.dispatch(S)}return _})})}catch(v){return Promise.reject(v)}},$e=/Start$/,Ln=/^bootstrap/,Dn=/^ready/;function $t(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(C({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Mn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Zn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function Kn(t,e){var n=t.replace($e,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function Nt(t,e){var n=t.abort;return!!n&&(n===!0||Fn(n,e)||n&&Fn(n.plugins,e))}function Wn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ce(n))return!0;var r=n.plugins;return De(n)&&n.length===e||De(r)&&r.length===e}function De(t){return Array.isArray(t)}function Fn(t,e){return!(!t||!De(t))&&t.includes(e)}function Hn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Yi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=B(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Gi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,f=function(l){return s?l:o(c)},p=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(p===x.enablePlugin&&i.dispatch({type:x.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===x.disablePlugin&&setTimeout(function(){return Un(a.meta.rid,{payload:a})},0),p===x.initializeEnd){var m=e(),d=Object.keys(m),w=d.filter(function(l){return u.includes(l)}).map(function(l){return m[l]}),k=[],v=[],_=a.disabled,S=w.map(function(l){var b=l.loaded,T=l.name,O=l.config;return zn(l,function(){return b({config:O})},1e4).then(function(A){return r[T]||(i.dispatch({type:x.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(L){return!Ct.includes(L)})}),r[T]=!0),k=k.concat(T),l}).catch(function(A){if(A instanceof Error)throw new Error(A);return v=v.concat(A.name),A})});Promise.all(S).then(function(l){var b={plugins:k,failed:v,disabled:_};setTimeout(function(){d.length===S.length+_.length&&i.dispatch(C({},{type:x.ready},b))},0)})}var y=function(){if(p!==x.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return Rn(i,e,t)},0),Promise.resolve(function(l,b,T,O,A){try{var L=G(b)?b():b,z=l.type,J=z.replace($e,"");if(l._&&l._.called)return Promise.resolve(l);var $=T.getState(),R=(I=L,(E=$.plugins)===void 0&&(E={}),(W=l.options)===void 0&&(W={}),Object.keys(I).filter(function(h){var g=W.plugins||{};return Ci(g[h])?g[h]:g.all!==!1&&(!E[h]||E[h].enabled!==!1)}).map(function(h){return I[h]}));z===x.initializeStart&&l.fromEnable&&(R=Object.keys($.plugins).filter(function(h){var g=$.plugins[h];return l.plugins.includes(h)&&!g.initialized}).map(function(h){return L[h]}));var K=R.map(function(h){return h.name}),j=function(h,g,P){var N=Kn(h).map(function(U){return Zn(U,g)});return g.reduce(function(U,D){var X=D.name,Z=Kn(h,X).map(function(Fe){return Zn(Fe,g)}),F=Z[0],M=Z[1],re=Z[2];return F.length&&(U.beforeNS[X]=F),M.length&&(U.duringNS[X]=M),re.length&&(U.afterNS[X]=re),U},{before:N[0],beforeNS:{},during:N[1],duringNS:{},after:N[2],afterNS:{}})}(z,R);return Promise.resolve(At({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(h){function g(){var U=function(){if(z.match($e))return Promise.resolve(At({action:C({},P,{type:J+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(D){D.meta&&D.meta.hasCallback&&Un(D.meta.rid,{payload:D})})}();return U&&U.then?U.then(function(){return h}):h}if(Wn(h,K.length))return h;var P,N=function(){if(z!==J)return Promise.resolve(At({action:C({},h,{type:J}),data:{exact:j.during,namespaced:j.duringNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(U){P=U});P=h}();return N&&N.then?N.then(g):g()})}catch(h){return Promise.reject(h)}var I,E,W}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(f):f(y))}catch(l){return Promise.reject(l)}}}}}function Bi(t){return function(e){return function(n){return function(r){var i=r.type,o=r.key,a=r.value,s=r.options;if(i===x.setItem||i===x.removeItem){if(r.abort)return n(r);i===x.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var qi=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,n){t[n]=t[n].concat(e)},this.removeMiddleware=function(e,n){var r=t[n].findIndex(function(i){return i===e});r!==-1&&(t[n]=[].concat(t[n].slice(0,r),t[n].slice(r+1)))},this.dynamicMiddlewares=function(e){return function(n){return function(r){return function(i){var o={getState:n.getState,dispatch:function(s){return n.dispatch(s)}},a=t[e].map(function(s){return s(o)});return Ce.apply(void 0,a)(r)(i)}}}}};function Qi(t){return function(e,n){e===void 0&&(e={});var r={};if(n.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(n.type)){var i=Jn(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},C({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var f=Jn(n.type,x.initialize),p=t()[f];return p&&f?(r[f]=C({},e[f],{initialized:!0,loaded:!!p.loaded({config:p.config})}),C({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=C({},e[n.name],{loaded:!0}),C({},e,r);switch(n.type){case x.disablePlugin:return C({},e,Xn(n.plugins,!1,e));case x.enablePlugin:return C({},e,Xn(n.plugins,!0,e));default:return e}}}function Jn(t,e){return t.substring(e.length+1,t.length)}function Xn(t,e,n){return t.reduce(function(r,i){return r[i]=C({},n[i],{enabled:e}),r},n)}function Vn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var eo={last:{},history:[]};function to(t,e){t===void 0&&(t=eo);var n=e.options,r=e.meta;if(e.type===x.track){var i=Vn(C({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return C({},t,{last:i,history:t.history.concat(i)})}return t}var no={actions:[]};function ro(t,e){t===void 0&&(t=no);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===x.identify?[e].concat(t.actions):t.actions.concat(e),C({},t,{actions:r});case"dequeue":return[];default:return t}}var Yn=/#.*$/;function io(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Yn,""):"")}var Gn,Bn,qn,Qn,oo=function(t){if(t===void 0&&(t={}),!H)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,f=o.hash,p=o.search,u=function(m){var d=function(){if(H){for(var w,k=document.getElementsByTagName("link"),v=0;w=k[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+m:window.location.href.replace(Yn,"")}(p),c={title:n,url:u,path:io(u),hash:f,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),C({},c,t)},ao={last:{},history:[]};function so(t,e){t===void 0&&(t=ao);var n=e.options;if(e.type===x.page){var r=Vn(C({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return C({},t,{last:r,history:t.history.concat(r)})}return t}Gn=function(){if(!H)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),Bn=H?document.referrer:null,qn=Ri(),Qn=Li();var er={initialized:!1,sessionId:qe(),app:null,version:null,debug:!1,offline:!!H&&!navigator.onLine,os:{name:Gn},userAgent:H?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Qn,locale:qn,campaign:{},referrer:Bn};function co(t,e){t===void 0&&(t=er);var n=t.initialized,r=e.campaign;switch(e.type){case x.campaign:return C({},t,{campaign:r});case x.offline:return C({},t,{offline:!0});case x.online:return C({},t,{offline:!1});default:return n?t:C({},er,t,{initialized:!0})}}var uo=["plugins","reducers","storage"];function lo(t,e,n){if(H){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function ho(t){var e=lo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function tr(){return we("analytics",[]),function(t){return function(e,n,r){var i=t(e,n,r),o=i.dispatch;return Object.assign(i,{dispatch:function(a){return Te[Pe].analytics.push(a.action||a),o(a)}})}}}function nr(t){return function(){return Ce(Ce.apply(null,arguments),tr())}}function Ut(t){return t?Pn(t)?t:[t]:[]}function rr(t,e,n){t===void 0&&(t={});var r,i,o=qe();return e&&(Le[o]=(r=e,i=function(a){for(var s,f=a||Array.prototype.slice.call(arguments),p=0;p<f.length;p++)if(G(f[p])){s=f[p];break}return s}(n),function(a){i&&i(a),r(a)})),C({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function fo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(h,g){if(G(g))return h.middlewares=h.middlewares.concat(g),h;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var P=g.EVENTS?Object.keys(g.EVENTS).map(function(D){return g.EVENTS[D]}):[];h.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(h.methods[g.name]=Object.keys(g.methods).reduce(function(D,X){var Z;return D[X]=(Z=g.methods[X],function(){for(var F=Array.prototype.slice.call(arguments),M=new Array(Z.length),re=0;re<F.length;re++)M[re]=F[re];return M[M.length]=b,Z.apply({instance:b},M)}),D},{}),delete g.methods);var N=Object.keys(g).concat(P),U=new Set(h.events.concat(N));if(h.events=Array.from(U),h.pluginsArray=h.pluginsArray.concat(g),h.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return h.plugins[g.name]=g,h.plugins[g.name].loaded||(h.plugins[g.name].loaded=function(){return!0}),h},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ve,setItem:we,removeItem:Oe},o=function(h){return function(g,P,N){return P.getState("user")[g]||(N&&B(N)&&N[g]?N[g]:Nn(h)[g]||ve(xt(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(h){return!Ct.includes(h)}).sort(),f=new Set(s.concat(tt).filter(function(h){return!Ct.includes(h)})),p=Array.from(f).sort(),u=function(){return a},c=new qi,m=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Di(),_=Nn(i),S=C({},_,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=qe());var y=C({enable:function(h,g){return new Promise(function(P){j.dispatch({type:x.enablePlugin,plugins:Ut(h),_:{originalAction:x.enablePlugin}},P,[g])})},disable:function(h,g){return new Promise(function(P){j.dispatch({type:x.disablePlugin,plugins:Ut(h),_:{originalAction:x.disablePlugin}},P,[g])})}},r.methods),l=!1,b={identify:function(h,g,P,N){try{var U=ce(h)?h:null,D=B(h)?h:g,X=P||{},Z=b.user();we(xt(de),U);var F=U||D.userId||o(de,b,D);return Promise.resolve(new Promise(function(M){j.dispatch(C({type:x.identifyStart,userId:F,traits:D||{},options:X,anonymousId:Z.anonymousId},Z.id&&Z.id!==U&&{previousId:Z.id}),M,[g,P,N])}))}catch(M){return Promise.reject(M)}},track:function(h,g,P,N){try{var U=B(h)?h.event:h;if(!U||!ce(U))throw new Error("EventMissing");var D=B(h)?h:g||{},X=B(P)?P:{};return Promise.resolve(new Promise(function(Z){j.dispatch({type:x.trackStart,event:U,properties:D,options:X,userId:o(de,b,g),anonymousId:o(Ae,b,g)},Z,[g,P,N])}))}catch(Z){return Promise.reject(Z)}},page:function(h,g,P){try{var N=B(h)?h:{},U=B(g)?g:{};return Promise.resolve(new Promise(function(D){j.dispatch({type:x.pageStart,properties:oo(N),options:U,userId:o(de,b,N),anonymousId:o(Ae,b,N)},D,[h,g,P])}))}catch(D){return Promise.reject(D)}},user:function(h){if(h===de||h==="id")return o(de,b);if(h===Ae||h==="anonId")return o(Ae,b);var g=b.getState("user");return h?bn(g,h):g},reset:function(h){return new Promise(function(g){j.dispatch({type:x.resetStart},g,h)})},ready:function(h){return l&&h({plugins:y,instance:b}),b.on(x.ready,function(g){h(g),l=!0})},on:function(h,g){if(!h||!G(g))return!1;if(h===x.bootstrap)throw new Error(".on disabled for "+h);var P=/Start$|Start:/;if(h==="*"){var N=function(Z){return function(F){return function(M){return M.type.match(P)&&g({payload:M,instance:b,plugins:a}),F(M)}}},U=function(Z){return function(F){return function(M){return M.type.match(P)||g({payload:M,instance:b,plugins:a}),F(M)}}};return m(N,nt),m(U,rt),function(){d(N,nt),d(U,rt)}}var D=h.match(P)?nt:rt,X=function(Z){return function(F){return function(M){return M.type===h&&g({payload:M,instance:b,plugins:a,abort:k}),F(M)}}};return m(X,D),function(){return d(X,D)}},once:function(h,g){if(!h||!G(g))return!1;if(h===x.bootstrap)throw new Error(".once disabled for "+h);var P=b.on(h,function(N){g({payload:N.payload,instance:b,plugins:a,abort:k}),P()});return P},getState:function(h){var g=j.getState();return h?bn(g,h):Object.assign({},g)},dispatch:function(h){var g=ce(h)?{type:h}:h;if(tt.includes(g.type))throw new Error("reserved action "+g.type);var P=C({},g,{_:C({originalAction:g.type},h._||{})});j.dispatch(P)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(h,g,P){j.dispatch({type:x.setItemStart,key:h,value:g,options:P})},removeItem:function(h,g){j.dispatch({type:x.removeItemStart,key:h,options:g})}},setAnonymousId:function(h,g){b.storage.setItem(le,h,g)},events:{core:tt,plugins:s}},T=r.middlewares.concat([function(h){return function(g){return function(P){return P.meta||(P.meta=rr()),g(P)}}},w(nt),Gi(b,u,{all:p,plugins:s}),Bi(i),Hi(b),Xi(b),w(rt)]),O={context:co,user:Ji(i),page:so,track:to,plugins:Qi(u),queue:ro},A=Ce,L=Ce;if(H&&t.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(A=z({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?tr():B(typeof arguments[0])?nr():nr().apply(null,arguments)}}var J,$=function(h){return Object.keys(h).reduce(function(g,P){return uo.includes(P)||(g[P]=h[P]),g},{})}(t),R=r.pluginsArray.reduce(function(h,g){var P=g.name,N=g.config,U=g.loaded,D=r.pluginEnabled[P];return h[P]={enabled:D,initialized:!!D&&!g.initialize,loaded:!!U({config:N}),config:N},h},{}),K={context:$,user:S,plugins:R},j=Cn(function(h){for(var g=Object.keys(h),P={},N=0;N<g.length;N++){var U=g[N];typeof h[U]===ue&&(P[U]=h[U])}var D,X=Object.keys(P);try{(function(Z){Object.keys(Z).forEach(function(F){var M=Z[F];if(typeof M(void 0,{type:"@@redux/INIT"})===oe||typeof M(void 0,{type:Ki})===oe)throw new Error("reducer "+F+" "+oe)})})(P)}catch(Z){D=Z}return function(Z,F){if(Z===void 0&&(Z={}),D)throw D;for(var M=!1,re={},Fe=0;Fe<X.length;Fe++){var lt=X[Fe],xr=Z[lt],Jt=(0,P[lt])(xr,F);if(typeof Jt===oe){var ta=Wi(lt,F);throw new Error(ta)}re[lt]=Jt,M=M||Jt!==xr}return M?re:Z}}(C({},O,e)),K,L(A(Fi.apply(void 0,T))));j.dispatch=(J=j.dispatch,function(h,g,P){var N=C({},h,{meta:rr(h.meta,g,Ut(P))});return J.apply(null,[N])});var I=Object.keys(a);j.dispatch({type:x.bootstrap,plugins:I,config:$,params:v,user:S,initialUser:n,persistedUser:_});var E=I.filter(function(h){return r.pluginEnabled[h]}),W=I.filter(function(h){return!r.pluginEnabled[h]});return j.dispatch({type:x.registerPlugins,plugins:I,enabled:r.pluginEnabled}),r.pluginsArray.map(function(h,g){var P=h.bootstrap,N=h.config,U=h.name;P&&G(P)&&P({instance:b,config:N,payload:h}),j.dispatch({type:x.registerPluginType(U),name:U,enabled:r.pluginEnabled[U],plugin:h}),r.pluginsArray.length===g+1&&j.dispatch({type:x.initializeStart,plugins:E,disabled:W})}),ho(function(h){j.dispatch({type:h?x.offline:x.online})}),function(h,g,P){setInterval(function(){return Rn(h,g,P)},3e3)}(j,u,b),b}var nt="before",rt="after",Me="cookie",ke=ar(),ir=it,po=it;function or(t){return ke?it(t,"",-1):Oe(t)}function ar(){if(ke!==void 0)return ke;var t="cookiecookie";try{it(t,t),ke=document.cookie.indexOf(t)!==-1,or(t)}catch{ke=!1}return ke}function it(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ke===!1&&(a?we(t,e):ve(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var Ze="localStorage",mo=jt.bind(null,"localStorage");je("localStorage","getItem",ve),je("localStorage","setItem",we),je("localStorage","removeItem",Oe);var Ke="sessionStorage",go=jt.bind(null,"sessionStorage");je("sessionStorage","getItem",ve),je("sessionStorage","setItem",we),je("sessionStorage","removeItem",Oe);function Ne(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(B(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var yo=mo(),vo=go(),wo=ar();function sr(t,e){if(t){var n=zt(e),r=!Mt(n),i=Rt(n)?Ne(localStorage.getItem(t)):void 0;if(r&&!Ee(i))return i;var o=Lt(n)?Ne(ir(t)):void 0;if(r&&o)return o;var a=Dt(n)?Ne(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ve(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function bo(t,e,n){if(t&&!Ee(e)){var r={},i=zt(n),o=JSON.stringify(e),a=!Mt(i);return Rt(i)&&(r[Ze]=at(Ze,e,Ne(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ze]:Lt(i)&&(r[Me]=at(Me,e,Ne(ir(t))),po(t,o),a)?r[Me]:Dt(i)&&(r[Ke]=at(Ke,e,Ne(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ke]:(r[Re]=at(Re,e,ve(t)),we(t,e),a?r[Re]:r)}}function ko(t,e){if(t){var n=zt(e),r=sr(t,Sn),i={};return!Ee(r.localStorage)&&Rt(n)&&(localStorage.removeItem(t),i[Ze]=r.localStorage),!Ee(r.cookie)&&Lt(n)&&(or(t),i[Me]=r.cookie),!Ee(r.sessionStorage)&&Dt(n)&&(sessionStorage.removeItem(t),i[Ke]=r.sessionStorage),!Ee(r.global)&&ot(n,Re)&&(Oe(t),i[Re]=r.global),i}}function zt(t){return t?ce(t)?t:t.storage:In}function Rt(t){return yo&&ot(t,Ze)}function Lt(t){return wo&&ot(t,Me)}function Dt(t){return vo&&ot(t,Ke)}function Mt(t){return t===Sn||t==="all"}function ot(t,e){return t===In||t===e||Mt(t)}function at(t,e,n){return{location:t,current:e,previous:n}}var Io={setItem:bo,getItem:sr,removeItem:ko};function So(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ur(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cr(Object(n),!0).forEach(function(r){So(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cr(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _o(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Io};return fo(ur(ur({},e),t))}function Eo(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(f){return r=i.push(f),r>=o&&a(),r},size:function(){return i.length},end:function(f){f&&a(),clearInterval(n)}}}function Po(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...f){var c;const p=((c=f[2])==null?void 0:c.toString())||"",u=Oo(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,f)}})}function To(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Oo(t){return["#","?"].forEach(e=>t=To(t,e)),t}function jo(){Po(()=>{ae.page()})}function Co(t){if(t===void 0&&(t={}),!H)return Ot;var e=dr(),n=Zt(),r=lr(),i=st(r,e),o=st(n,e),a=[],s=[],f=[],p=r,u=i,c=o,m=Object.keys(t);if(!m.length)return Ot;var d=m.map(function(k){return Number(k)}),w=Zi(function(){var k=dr(),v=function($,R){return R.map(function(K){return K===100?$-5:$*(K/100)})}(k,d),_=Zt(),S=lr(),y=st(S,k),l=st(_,k);if(u=y>u?y:u,c=l<c?l:c,!(a.length>=d.length)){var b=p===S,T="up";b?T="initial":p<=S&&(T="down");var O=v,A=d;(T==="up"||b)&&(O=v.slice().reverse(),A=d.slice().reverse());var L=A.reduce(function($,R,K){var j=O[K];return f.includes(R)&&S<=j&&(f=f.filter(function(I){return I!==R}),$.singleFunction=R),T==="down"&&!a.includes(R)&&S>=j&&R>o?(s.push(R),$.callbacks=$.callbacks.concat(R),$):T==="up"&&!a.includes(R)&&S<=j&&R<=y?($.foundFunc=[R],$):(b&&S>=j&&$.foundFunc.length===0&&($.foundFunc=[R]),!s.includes(R)&&S>=j&&(s.push(R),$.singleFunction?f.push(R):$.singleFunction=R),$)},{foundFunc:[],singleFunction:null,callbacks:[],direction:T});if(p=S,T==="down"&&L.callbacks&&L.callbacks.forEach(function($){G(t[$])&&(t[$]({trigger:$,direction:T,scrollMin:c,scrollMax:u,range:[c,u]}),a.push($))}),L.singleFunction){var z=L.singleFunction,J=L.direction;G(t[z])&&t[z]({trigger:z,direction:J,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(z)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function Zt(){return H?document.body.scrollTop||document.documentElement.scrollTop:0}function xo(){return H?window.innerHeight||document.documentElement.clientHeight:0}function lr(){return Math.round(Zt()+xo())}function dr(){if(!H)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function st(t,e){return Math.round(t/e*100)}var hr="EventListener";function Ao(t){return function(e,n,r,i){var o=r||Ot,a=i||!1;if(!H)return o;var s=ct(n),f=ct(e,!0);if(!f.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var m=c?"add"+hr:"remove"+hr,d=0;d<f.length;d++){var w=f[d];p[d]=c?a&&a.once?$o(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[m]?w["on"+s[k]]=c?p[d]:null:w[m](s[k],p[d],a)}return u.bind(null,!c)}(t)}}function ct(t,e){if(ce(t))return e?ct(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=zi(t);return e?o.map(function(a){return ce(a)?ct(a,!0):a}).flat():o}function $o(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var Kt=Ao("Event");function fr(t,e){return H&&G(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),G(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}fr.bind(null,"onerror"),fr.bind(null,"onload");var pr=typeof window>"u",mr="hidden";function No(t){if(pr)return!1;var e=Uo(),n="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),r=function(){return t(!!document[e])},i=function(){return document.addEventListener(n,r)};return i(),function(){return document.removeEventListener(n,r),i}}function Uo(){var t=["webkit","moz","ms","o"];return pr||mr in document?mr:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var zo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Ro(t,e){e===void 0&&(e={});var n=function(a,s){var f=this,p=!1;return function(u){p||(a.call(f,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=No(function(s){s||n({type:"tabVisible"})});return r=[a].concat(zo.map(function(s){return Kt(document,s,n)})).concat(Kt(window,"load",n)).concat(Kt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Lo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,f=t.throttle,p=f===void 0?2e3:f,u=!1,c=!1,m=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(We(m),v),i&&u&&(u=!1,i(We(n),v),m=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(We(m),v))},s)}var k=Ro(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,m=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:We(m,c),idle:u?We(n,c):0}}}}function We(t,e){return e?0:Math.round((new Date-t)/1e3)}const gr=5e3;class Do{constructor(e){ee(this,"element");ee(this,"isInViewport",!1);ee(this,"isAwake",!1);ee(this,"isFlushing");ee(this,"observer");ee(this,"lastEventAt",Date.now());ee(this,"registeredView",!1);ee(this,"viewCallback");ee(this,"activeDurationCallback");ee(this,"idleDurationCallback");ee(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Lo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:gr}),Co({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(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*gr:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const yr="sesamy_session_id";function Mo(){let t=sessionStorage.getItem(yr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(yr,t)),t}let vr=!1,Wt,wr,ut;function Zo({clientId:t,enabled:e=!0,endpoint:n=ui}){if(Wt=t,wr=e,ut=n,!wr)return;jo();const r=new Do({element:document.body,viewCallback:()=>{ae.page()},activeDurationCallback:(i,o,a)=>{ae.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ae.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ae.track("scroll",{scroll:i.scrollMax})}});Fo(document.body,()=>{r.flush()}),Ho(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(te.AUTHENTICATED,async i=>{const o=i;await ae.identify(o.detail.sub)}),window.addEventListener(te.LOGOUT,async()=>{await ae.track("logout",{}),Ft.flush(),await ae.reset()})}function br(t){return JSON.stringify(t.map(e=>({...e,clientId:Wt,requestId:Math.random().toString(36).slice(2,9),sessionId:Mo(),timestamp:new Date().toISOString(),version:Tt,event:e.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:wn,userAgent:navigator.userAgent,clientId:Wt}})))}const Ft=Eo(async t=>{if(t.length>0){const e=br(t);vr?navigator.sendBeacon(ut,e):(await fetch(ut,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Ht(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(ut,br([n]))}else Ft.push(t)}const ae=_o({app:wn,version:Tt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Ht({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Ht({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Ht({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Ko(t,e){ae.track(t,e)}function Wo(){return vr=!0,Ft.flush()}const kr=new Map;function Fo(t,e){kr.set(t,e)}window.addEventListener("beforeunload",()=>{kr.forEach((t,e)=>{t.bind(e)()}),Wo()});const Ir=new Map;function Ho(t,e){Ir.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&Ir.forEach((t,e)=>{t.bind(e)()})});const Sr="sesamySignedURLs";function _r(){const t=sessionStorage.getItem(Sr);return t?JSON.parse(t):[]}function Jo(t){const e=_r();e.push(t),sessionStorage.setItem(Sr,JSON.stringify(e))}function Xo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:f,getProfile:p,updateProfile:u,getTags:c,deleteTag:m,setTag:d,getUserMetadata:w,listUserMetadata:k,setUserMetadata:v,deleteUserMetadata:_,getTally:S,getTallies:y,pushTally:l,deleteTally:b,getProduct:T,getPaymentIssues:O,autoOnboardProduct:A,openHostedAccountPage:L}=Pi(t),z={auth:{getUser:p,isAuthenticated:Et,loginWithRedirect:Pt,logout:hi,setToken:dn},profile:{get:p,update:u,openHostedAccountPage:L},analytics:{track:Ko},tags:{list:c,set:d,delete:m},entitlements:{get:e,list:n,access:r,signedLinks:_r},contracts:{get:o,list:a},bills:{get:s,list:f},userMetadata:{get:w,list:k,set:v,delete:_},tallies:{get:S,list:y,push:l,delete:b},subscriptions:{list:i},products:{get:T,autoOnboard:A},getVersion:Vo,getPaymentIssues:O,clearCache:ne};return t.namespace&&(window[t.namespace]=z),z}function Vo(){return Tt}function Yo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){dn(e,n?parseInt(n,10):void 0);const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Er="sesamy-refresh",Pr="force-refetch-entitlements";function Go(){const t=new URLSearchParams(window.location.search),e=t.get(Pr),n=t.get(Er);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Pr),t.delete(Er),r.search=t.toString(),ne(),window.history.replaceState(null,"",r)}}function Bo(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Jo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const Tr="sesamy-user";async function qo(){const e=new URLSearchParams(window.location.search).get(Tr);if(!e)return;const n=await di();(n==null?void 0:n.email)!==e&&Pt();const r=new URL(window.location.href);r.searchParams.delete(Tr),window.history.replaceState(null,"",r)}const Or="sesamy-purchase";function Qo(){const t=new URLSearchParams(window.location.search),e=t.get(Or);if(e!==null){const n=new URL(window.location.href);t.delete(Or),n.search=t.toString(),V(te.PURCHASE,{itemSrc:e}),ne(),window.history.replaceState(null,"",n)}}const jr="sesamy-login";async function ea(){if(!new URLSearchParams(window.location.search).get(jr))return;await Et()||Pt();const r=new URL(window.location.href);r.searchParams.delete(jr),window.history.replaceState(null,"",r)}async function Cr(t){Zo({clientId:t.clientId,...t.analytics}),await li({clientId:t.clientId,organization:t.organization,...t.auth});const e=Xo({clientId:t.clientId,...t.api});return V(te.READY,{}),Yo(),Go(),Bo(),await ea(),await qo(),Qo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Cr(e)}catch(e){console.error("Failed to parse config",e)}}return ie.init=Cr,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"}),ie}({});
6
+ `))}}(A.methodName,A.pluginName),Promise.resolve(A.method({payload:z,instance:r,abort:(J=z,$=y,R=A.pluginName,function(K,j){return C({},J,{abort:{reason:K,plugins:j||[$],caller:c,from:R||$}})}),config:Mn(A.pluginName,p,o),plugins:p})).then(function(K){var j=B(K)?K:{};return Promise.resolve(C({},z,j))})):z;var J,$,R})}catch(z){return Promise.reject(z)}},Promise.resolve(n))).then(function(O){l[y]=O});l[y]=n}();return T&&T.then?T.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(_,S,y){try{var l=e.exact.length===y+1,b=S.pluginName,T=o[b];return Promise.resolve(_).then(function(O){var A=v[b]?v[b]:{};if(m&&(A=O),Nt(A,b))return $t({data:A,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(O);if(Nt(O,b))return l&&$t({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var L=w(v[b],o[b]);return Promise.resolve(T[c]({abort:L.abort,payload:A,instance:r,config:Mn(b,p,o),plugins:p})).then(function(z){var J=B(z)?z:{},$=C({},O,J),R=v[b];if(Nt(R,b))$t({data:R,method:c,instance:r,pluginName:b,store:s});else{var K=c+":"+b;(K.match(/:/g)||[]).length<2&&!c.match(Ln)&&!c.match(Dn)&&r.dispatch(C({},m?$:A,{type:K,_:{called:K,from:"submethod"}}))}return Promise.resolve($)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(_){if(!(c.match($e)||c.match(/^registerPlugin/)||c.match(Dn)||c.match(Ln)||c.match(/^params/)||c.match(/^userIdChanged/))){if(f.plugins.includes(c),_._&&_._.originalAction===c)return _;var S=C({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});Wn(_,e.exact.length)&&!c.match(/End$/)&&(S=C({},S,{type:_.type+"Aborted"})),s.dispatch(S)}return _})})}catch(v){return Promise.reject(v)}},$e=/Start$/,Ln=/^bootstrap/,Dn=/^ready/;function $t(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(C({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Mn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Zn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function Kn(t,e){var n=t.replace($e,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function Nt(t,e){var n=t.abort;return!!n&&(n===!0||Fn(n,e)||n&&Fn(n.plugins,e))}function Wn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ce(n))return!0;var r=n.plugins;return De(n)&&n.length===e||De(r)&&r.length===e}function De(t){return Array.isArray(t)}function Fn(t,e){return!(!t||!De(t))&&t.includes(e)}function Hn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Yi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=B(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Gi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,f=function(l){return s?l:o(c)},p=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(p===x.enablePlugin&&i.dispatch({type:x.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===x.disablePlugin&&setTimeout(function(){return Un(a.meta.rid,{payload:a})},0),p===x.initializeEnd){var m=e(),d=Object.keys(m),w=d.filter(function(l){return u.includes(l)}).map(function(l){return m[l]}),k=[],v=[],_=a.disabled,S=w.map(function(l){var b=l.loaded,T=l.name,O=l.config;return zn(l,function(){return b({config:O})},1e4).then(function(A){return r[T]||(i.dispatch({type:x.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(L){return!Ct.includes(L)})}),r[T]=!0),k=k.concat(T),l}).catch(function(A){if(A instanceof Error)throw new Error(A);return v=v.concat(A.name),A})});Promise.all(S).then(function(l){var b={plugins:k,failed:v,disabled:_};setTimeout(function(){d.length===S.length+_.length&&i.dispatch(C({},{type:x.ready},b))},0)})}var y=function(){if(p!==x.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return Rn(i,e,t)},0),Promise.resolve(function(l,b,T,O,A){try{var L=G(b)?b():b,z=l.type,J=z.replace($e,"");if(l._&&l._.called)return Promise.resolve(l);var $=T.getState(),R=(I=L,(E=$.plugins)===void 0&&(E={}),(W=l.options)===void 0&&(W={}),Object.keys(I).filter(function(h){var g=W.plugins||{};return Ci(g[h])?g[h]:g.all!==!1&&(!E[h]||E[h].enabled!==!1)}).map(function(h){return I[h]}));z===x.initializeStart&&l.fromEnable&&(R=Object.keys($.plugins).filter(function(h){var g=$.plugins[h];return l.plugins.includes(h)&&!g.initialized}).map(function(h){return L[h]}));var K=R.map(function(h){return h.name}),j=function(h,g,P){var N=Kn(h).map(function(U){return Zn(U,g)});return g.reduce(function(U,D){var X=D.name,Z=Kn(h,X).map(function(Fe){return Zn(Fe,g)}),F=Z[0],M=Z[1],re=Z[2];return F.length&&(U.beforeNS[X]=F),M.length&&(U.duringNS[X]=M),re.length&&(U.afterNS[X]=re),U},{before:N[0],beforeNS:{},during:N[1],duringNS:{},after:N[2],afterNS:{}})}(z,R);return Promise.resolve(At({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(h){function g(){var U=function(){if(z.match($e))return Promise.resolve(At({action:C({},P,{type:J+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(D){D.meta&&D.meta.hasCallback&&Un(D.meta.rid,{payload:D})})}();return U&&U.then?U.then(function(){return h}):h}if(Wn(h,K.length))return h;var P,N=function(){if(z!==J)return Promise.resolve(At({action:C({},h,{type:J}),data:{exact:j.during,namespaced:j.duringNS},state:$,allPlugins:L,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(U){P=U});P=h}();return N&&N.then?N.then(g):g()})}catch(h){return Promise.reject(h)}var I,E,W}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(f):f(y))}catch(l){return Promise.reject(l)}}}}}function Bi(t){return function(e){return function(n){return function(r){var i=r.type,o=r.key,a=r.value,s=r.options;if(i===x.setItem||i===x.removeItem){if(r.abort)return n(r);i===x.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var qi=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,n){t[n]=t[n].concat(e)},this.removeMiddleware=function(e,n){var r=t[n].findIndex(function(i){return i===e});r!==-1&&(t[n]=[].concat(t[n].slice(0,r),t[n].slice(r+1)))},this.dynamicMiddlewares=function(e){return function(n){return function(r){return function(i){var o={getState:n.getState,dispatch:function(s){return n.dispatch(s)}},a=t[e].map(function(s){return s(o)});return Ce.apply(void 0,a)(r)(i)}}}}};function Qi(t){return function(e,n){e===void 0&&(e={});var r={};if(n.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(n.type)){var i=Jn(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},C({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var f=Jn(n.type,x.initialize),p=t()[f];return p&&f?(r[f]=C({},e[f],{initialized:!0,loaded:!!p.loaded({config:p.config})}),C({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=C({},e[n.name],{loaded:!0}),C({},e,r);switch(n.type){case x.disablePlugin:return C({},e,Xn(n.plugins,!1,e));case x.enablePlugin:return C({},e,Xn(n.plugins,!0,e));default:return e}}}function Jn(t,e){return t.substring(e.length+1,t.length)}function Xn(t,e,n){return t.reduce(function(r,i){return r[i]=C({},n[i],{enabled:e}),r},n)}function Vn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var eo={last:{},history:[]};function to(t,e){t===void 0&&(t=eo);var n=e.options,r=e.meta;if(e.type===x.track){var i=Vn(C({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return C({},t,{last:i,history:t.history.concat(i)})}return t}var no={actions:[]};function ro(t,e){t===void 0&&(t=no);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===x.identify?[e].concat(t.actions):t.actions.concat(e),C({},t,{actions:r});case"dequeue":return[];default:return t}}var Yn=/#.*$/;function io(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Yn,""):"")}var Gn,Bn,qn,Qn,oo=function(t){if(t===void 0&&(t={}),!H)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,f=o.hash,p=o.search,u=function(m){var d=function(){if(H){for(var w,k=document.getElementsByTagName("link"),v=0;w=k[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+m:window.location.href.replace(Yn,"")}(p),c={title:n,url:u,path:io(u),hash:f,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),C({},c,t)},ao={last:{},history:[]};function so(t,e){t===void 0&&(t=ao);var n=e.options;if(e.type===x.page){var r=Vn(C({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return C({},t,{last:r,history:t.history.concat(r)})}return t}Gn=function(){if(!H)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),Bn=H?document.referrer:null,qn=Ri(),Qn=Li();var er={initialized:!1,sessionId:qe(),app:null,version:null,debug:!1,offline:!!H&&!navigator.onLine,os:{name:Gn},userAgent:H?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Qn,locale:qn,campaign:{},referrer:Bn};function co(t,e){t===void 0&&(t=er);var n=t.initialized,r=e.campaign;switch(e.type){case x.campaign:return C({},t,{campaign:r});case x.offline:return C({},t,{offline:!0});case x.online:return C({},t,{offline:!1});default:return n?t:C({},er,t,{initialized:!0})}}var uo=["plugins","reducers","storage"];function lo(t,e,n){if(H){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function ho(t){var e=lo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function tr(){return we("analytics",[]),function(t){return function(e,n,r){var i=t(e,n,r),o=i.dispatch;return Object.assign(i,{dispatch:function(a){return Te[Pe].analytics.push(a.action||a),o(a)}})}}}function nr(t){return function(){return Ce(Ce.apply(null,arguments),tr())}}function Ut(t){return t?Pn(t)?t:[t]:[]}function rr(t,e,n){t===void 0&&(t={});var r,i,o=qe();return e&&(Le[o]=(r=e,i=function(a){for(var s,f=a||Array.prototype.slice.call(arguments),p=0;p<f.length;p++)if(G(f[p])){s=f[p];break}return s}(n),function(a){i&&i(a),r(a)})),C({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function fo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(h,g){if(G(g))return h.middlewares=h.middlewares.concat(g),h;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var P=g.EVENTS?Object.keys(g.EVENTS).map(function(D){return g.EVENTS[D]}):[];h.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(h.methods[g.name]=Object.keys(g.methods).reduce(function(D,X){var Z;return D[X]=(Z=g.methods[X],function(){for(var F=Array.prototype.slice.call(arguments),M=new Array(Z.length),re=0;re<F.length;re++)M[re]=F[re];return M[M.length]=b,Z.apply({instance:b},M)}),D},{}),delete g.methods);var N=Object.keys(g).concat(P),U=new Set(h.events.concat(N));if(h.events=Array.from(U),h.pluginsArray=h.pluginsArray.concat(g),h.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return h.plugins[g.name]=g,h.plugins[g.name].loaded||(h.plugins[g.name].loaded=function(){return!0}),h},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ve,setItem:we,removeItem:Oe},o=function(h){return function(g,P,N){return P.getState("user")[g]||(N&&B(N)&&N[g]?N[g]:Nn(h)[g]||ve(xt(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(h){return!Ct.includes(h)}).sort(),f=new Set(s.concat(tt).filter(function(h){return!Ct.includes(h)})),p=Array.from(f).sort(),u=function(){return a},c=new qi,m=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Di(),_=Nn(i),S=C({},_,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=qe());var y=C({enable:function(h,g){return new Promise(function(P){j.dispatch({type:x.enablePlugin,plugins:Ut(h),_:{originalAction:x.enablePlugin}},P,[g])})},disable:function(h,g){return new Promise(function(P){j.dispatch({type:x.disablePlugin,plugins:Ut(h),_:{originalAction:x.disablePlugin}},P,[g])})}},r.methods),l=!1,b={identify:function(h,g,P,N){try{var U=ce(h)?h:null,D=B(h)?h:g,X=P||{},Z=b.user();we(xt(de),U);var F=U||D.userId||o(de,b,D);return Promise.resolve(new Promise(function(M){j.dispatch(C({type:x.identifyStart,userId:F,traits:D||{},options:X,anonymousId:Z.anonymousId},Z.id&&Z.id!==U&&{previousId:Z.id}),M,[g,P,N])}))}catch(M){return Promise.reject(M)}},track:function(h,g,P,N){try{var U=B(h)?h.event:h;if(!U||!ce(U))throw new Error("EventMissing");var D=B(h)?h:g||{},X=B(P)?P:{};return Promise.resolve(new Promise(function(Z){j.dispatch({type:x.trackStart,event:U,properties:D,options:X,userId:o(de,b,g),anonymousId:o(Ae,b,g)},Z,[g,P,N])}))}catch(Z){return Promise.reject(Z)}},page:function(h,g,P){try{var N=B(h)?h:{},U=B(g)?g:{};return Promise.resolve(new Promise(function(D){j.dispatch({type:x.pageStart,properties:oo(N),options:U,userId:o(de,b,N),anonymousId:o(Ae,b,N)},D,[h,g,P])}))}catch(D){return Promise.reject(D)}},user:function(h){if(h===de||h==="id")return o(de,b);if(h===Ae||h==="anonId")return o(Ae,b);var g=b.getState("user");return h?bn(g,h):g},reset:function(h){return new Promise(function(g){j.dispatch({type:x.resetStart},g,h)})},ready:function(h){return l&&h({plugins:y,instance:b}),b.on(x.ready,function(g){h(g),l=!0})},on:function(h,g){if(!h||!G(g))return!1;if(h===x.bootstrap)throw new Error(".on disabled for "+h);var P=/Start$|Start:/;if(h==="*"){var N=function(Z){return function(F){return function(M){return M.type.match(P)&&g({payload:M,instance:b,plugins:a}),F(M)}}},U=function(Z){return function(F){return function(M){return M.type.match(P)||g({payload:M,instance:b,plugins:a}),F(M)}}};return m(N,nt),m(U,rt),function(){d(N,nt),d(U,rt)}}var D=h.match(P)?nt:rt,X=function(Z){return function(F){return function(M){return M.type===h&&g({payload:M,instance:b,plugins:a,abort:k}),F(M)}}};return m(X,D),function(){return d(X,D)}},once:function(h,g){if(!h||!G(g))return!1;if(h===x.bootstrap)throw new Error(".once disabled for "+h);var P=b.on(h,function(N){g({payload:N.payload,instance:b,plugins:a,abort:k}),P()});return P},getState:function(h){var g=j.getState();return h?bn(g,h):Object.assign({},g)},dispatch:function(h){var g=ce(h)?{type:h}:h;if(tt.includes(g.type))throw new Error("reserved action "+g.type);var P=C({},g,{_:C({originalAction:g.type},h._||{})});j.dispatch(P)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(h,g,P){j.dispatch({type:x.setItemStart,key:h,value:g,options:P})},removeItem:function(h,g){j.dispatch({type:x.removeItemStart,key:h,options:g})}},setAnonymousId:function(h,g){b.storage.setItem(le,h,g)},events:{core:tt,plugins:s}},T=r.middlewares.concat([function(h){return function(g){return function(P){return P.meta||(P.meta=rr()),g(P)}}},w(nt),Gi(b,u,{all:p,plugins:s}),Bi(i),Hi(b),Xi(b),w(rt)]),O={context:co,user:Ji(i),page:so,track:to,plugins:Qi(u),queue:ro},A=Ce,L=Ce;if(H&&t.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(A=z({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?tr():B(typeof arguments[0])?nr():nr().apply(null,arguments)}}var J,$=function(h){return Object.keys(h).reduce(function(g,P){return uo.includes(P)||(g[P]=h[P]),g},{})}(t),R=r.pluginsArray.reduce(function(h,g){var P=g.name,N=g.config,U=g.loaded,D=r.pluginEnabled[P];return h[P]={enabled:D,initialized:!!D&&!g.initialize,loaded:!!U({config:N}),config:N},h},{}),K={context:$,user:S,plugins:R},j=Cn(function(h){for(var g=Object.keys(h),P={},N=0;N<g.length;N++){var U=g[N];typeof h[U]===ue&&(P[U]=h[U])}var D,X=Object.keys(P);try{(function(Z){Object.keys(Z).forEach(function(F){var M=Z[F];if(typeof M(void 0,{type:"@@redux/INIT"})===oe||typeof M(void 0,{type:Ki})===oe)throw new Error("reducer "+F+" "+oe)})})(P)}catch(Z){D=Z}return function(Z,F){if(Z===void 0&&(Z={}),D)throw D;for(var M=!1,re={},Fe=0;Fe<X.length;Fe++){var lt=X[Fe],xr=Z[lt],Jt=(0,P[lt])(xr,F);if(typeof Jt===oe){var ta=Wi(lt,F);throw new Error(ta)}re[lt]=Jt,M=M||Jt!==xr}return M?re:Z}}(C({},O,e)),K,L(A(Fi.apply(void 0,T))));j.dispatch=(J=j.dispatch,function(h,g,P){var N=C({},h,{meta:rr(h.meta,g,Ut(P))});return J.apply(null,[N])});var I=Object.keys(a);j.dispatch({type:x.bootstrap,plugins:I,config:$,params:v,user:S,initialUser:n,persistedUser:_});var E=I.filter(function(h){return r.pluginEnabled[h]}),W=I.filter(function(h){return!r.pluginEnabled[h]});return j.dispatch({type:x.registerPlugins,plugins:I,enabled:r.pluginEnabled}),r.pluginsArray.map(function(h,g){var P=h.bootstrap,N=h.config,U=h.name;P&&G(P)&&P({instance:b,config:N,payload:h}),j.dispatch({type:x.registerPluginType(U),name:U,enabled:r.pluginEnabled[U],plugin:h}),r.pluginsArray.length===g+1&&j.dispatch({type:x.initializeStart,plugins:E,disabled:W})}),ho(function(h){j.dispatch({type:h?x.offline:x.online})}),function(h,g,P){setInterval(function(){return Rn(h,g,P)},3e3)}(j,u,b),b}var nt="before",rt="after",Me="cookie",ke=ar(),ir=it,po=it;function or(t){return ke?it(t,"",-1):Oe(t)}function ar(){if(ke!==void 0)return ke;var t="cookiecookie";try{it(t,t),ke=document.cookie.indexOf(t)!==-1,or(t)}catch{ke=!1}return ke}function it(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ke===!1&&(a?we(t,e):ve(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var Ze="localStorage",mo=jt.bind(null,"localStorage");je("localStorage","getItem",ve),je("localStorage","setItem",we),je("localStorage","removeItem",Oe);var Ke="sessionStorage",go=jt.bind(null,"sessionStorage");je("sessionStorage","getItem",ve),je("sessionStorage","setItem",we),je("sessionStorage","removeItem",Oe);function Ne(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(B(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var yo=mo(),vo=go(),wo=ar();function sr(t,e){if(t){var n=zt(e),r=!Mt(n),i=Rt(n)?Ne(localStorage.getItem(t)):void 0;if(r&&!Ee(i))return i;var o=Lt(n)?Ne(ir(t)):void 0;if(r&&o)return o;var a=Dt(n)?Ne(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ve(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function bo(t,e,n){if(t&&!Ee(e)){var r={},i=zt(n),o=JSON.stringify(e),a=!Mt(i);return Rt(i)&&(r[Ze]=at(Ze,e,Ne(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ze]:Lt(i)&&(r[Me]=at(Me,e,Ne(ir(t))),po(t,o),a)?r[Me]:Dt(i)&&(r[Ke]=at(Ke,e,Ne(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ke]:(r[Re]=at(Re,e,ve(t)),we(t,e),a?r[Re]:r)}}function ko(t,e){if(t){var n=zt(e),r=sr(t,Sn),i={};return!Ee(r.localStorage)&&Rt(n)&&(localStorage.removeItem(t),i[Ze]=r.localStorage),!Ee(r.cookie)&&Lt(n)&&(or(t),i[Me]=r.cookie),!Ee(r.sessionStorage)&&Dt(n)&&(sessionStorage.removeItem(t),i[Ke]=r.sessionStorage),!Ee(r.global)&&ot(n,Re)&&(Oe(t),i[Re]=r.global),i}}function zt(t){return t?ce(t)?t:t.storage:In}function Rt(t){return yo&&ot(t,Ze)}function Lt(t){return wo&&ot(t,Me)}function Dt(t){return vo&&ot(t,Ke)}function Mt(t){return t===Sn||t==="all"}function ot(t,e){return t===In||t===e||Mt(t)}function at(t,e,n){return{location:t,current:e,previous:n}}var Io={setItem:bo,getItem:sr,removeItem:ko};function So(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ur(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cr(Object(n),!0).forEach(function(r){So(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cr(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _o(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Io};return fo(ur(ur({},e),t))}function Eo(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(f){return r=i.push(f),r>=o&&a(),r},size:function(){return i.length},end:function(f){f&&a(),clearInterval(n)}}}function Po(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...f){var c;const p=((c=f[2])==null?void 0:c.toString())||"",u=Oo(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,f)}})}function To(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Oo(t){return["#","?"].forEach(e=>t=To(t,e)),t}function jo(){Po(()=>{ae.page()})}function Co(t){if(t===void 0&&(t={}),!H)return Ot;var e=dr(),n=Zt(),r=lr(),i=st(r,e),o=st(n,e),a=[],s=[],f=[],p=r,u=i,c=o,m=Object.keys(t);if(!m.length)return Ot;var d=m.map(function(k){return Number(k)}),w=Zi(function(){var k=dr(),v=function($,R){return R.map(function(K){return K===100?$-5:$*(K/100)})}(k,d),_=Zt(),S=lr(),y=st(S,k),l=st(_,k);if(u=y>u?y:u,c=l<c?l:c,!(a.length>=d.length)){var b=p===S,T="up";b?T="initial":p<=S&&(T="down");var O=v,A=d;(T==="up"||b)&&(O=v.slice().reverse(),A=d.slice().reverse());var L=A.reduce(function($,R,K){var j=O[K];return f.includes(R)&&S<=j&&(f=f.filter(function(I){return I!==R}),$.singleFunction=R),T==="down"&&!a.includes(R)&&S>=j&&R>o?(s.push(R),$.callbacks=$.callbacks.concat(R),$):T==="up"&&!a.includes(R)&&S<=j&&R<=y?($.foundFunc=[R],$):(b&&S>=j&&$.foundFunc.length===0&&($.foundFunc=[R]),!s.includes(R)&&S>=j&&(s.push(R),$.singleFunction?f.push(R):$.singleFunction=R),$)},{foundFunc:[],singleFunction:null,callbacks:[],direction:T});if(p=S,T==="down"&&L.callbacks&&L.callbacks.forEach(function($){G(t[$])&&(t[$]({trigger:$,direction:T,scrollMin:c,scrollMax:u,range:[c,u]}),a.push($))}),L.singleFunction){var z=L.singleFunction,J=L.direction;G(t[z])&&t[z]({trigger:z,direction:J,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(z)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function Zt(){return H?document.body.scrollTop||document.documentElement.scrollTop:0}function xo(){return H?window.innerHeight||document.documentElement.clientHeight:0}function lr(){return Math.round(Zt()+xo())}function dr(){if(!H)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function st(t,e){return Math.round(t/e*100)}var hr="EventListener";function Ao(t){return function(e,n,r,i){var o=r||Ot,a=i||!1;if(!H)return o;var s=ct(n),f=ct(e,!0);if(!f.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var m=c?"add"+hr:"remove"+hr,d=0;d<f.length;d++){var w=f[d];p[d]=c?a&&a.once?$o(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[m]?w["on"+s[k]]=c?p[d]:null:w[m](s[k],p[d],a)}return u.bind(null,!c)}(t)}}function ct(t,e){if(ce(t))return e?ct(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=zi(t);return e?o.map(function(a){return ce(a)?ct(a,!0):a}).flat():o}function $o(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var Kt=Ao("Event");function fr(t,e){return H&&G(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),G(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}fr.bind(null,"onerror"),fr.bind(null,"onload");var pr=typeof window>"u",mr="hidden";function No(t){if(pr)return!1;var e=Uo(),n="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),r=function(){return t(!!document[e])},i=function(){return document.addEventListener(n,r)};return i(),function(){return document.removeEventListener(n,r),i}}function Uo(){var t=["webkit","moz","ms","o"];return pr||mr in document?mr:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var zo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Ro(t,e){e===void 0&&(e={});var n=function(a,s){var f=this,p=!1;return function(u){p||(a.call(f,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=No(function(s){s||n({type:"tabVisible"})});return r=[a].concat(zo.map(function(s){return Kt(document,s,n)})).concat(Kt(window,"load",n)).concat(Kt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Lo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,f=t.throttle,p=f===void 0?2e3:f,u=!1,c=!1,m=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(We(m),v),i&&u&&(u=!1,i(We(n),v),m=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(We(m),v))},s)}var k=Ro(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,m=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:We(m,c),idle:u?We(n,c):0}}}}function We(t,e){return e?0:Math.round((new Date-t)/1e3)}const gr=5e3;class Do{constructor(e){ee(this,"element");ee(this,"isInViewport",!1);ee(this,"isAwake",!1);ee(this,"isFlushing");ee(this,"observer");ee(this,"lastEventAt",Date.now());ee(this,"registeredView",!1);ee(this,"viewCallback");ee(this,"activeDurationCallback");ee(this,"idleDurationCallback");ee(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Lo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:gr}),Co({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(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*gr:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const yr="sesamy_session_id";function Mo(){let t=sessionStorage.getItem(yr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(yr,t)),t}let vr=!1,Wt,wr,ut;function Zo({clientId:t,enabled:e=!0,endpoint:n=ui}){if(Wt=t,wr=e,ut=n,!wr)return;jo();const r=new Do({element:document.body,viewCallback:()=>{ae.page()},activeDurationCallback:(i,o,a)=>{ae.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ae.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ae.track("scroll",{scroll:i.scrollMax})}});Fo(document.body,()=>{r.flush()}),Ho(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(te.AUTHENTICATED,async i=>{const o=i;await ae.identify(o.detail.sub)}),window.addEventListener(te.LOGOUT,async()=>{await ae.track("logout",{}),Ft.flush(),await ae.reset()})}function br(t){return JSON.stringify(t.map(e=>({...e,clientId:Wt,requestId:Math.random().toString(36).slice(2,9),sessionId:Mo(),timestamp:new Date().toISOString(),version:Tt,event:e.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:wn,userAgent:navigator.userAgent,clientId:Wt}})))}const Ft=Eo(async t=>{if(t.length>0){const e=br(t);vr?navigator.sendBeacon(ut,e):(await fetch(ut,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Ht(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(ut,br([n]))}else Ft.push(t)}const ae=_o({app:wn,version:Tt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Ht({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Ht({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Ht({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Ko(t,e){ae.track(t,e)}function Wo(){return vr=!0,Ft.flush()}const kr=new Map;function Fo(t,e){kr.set(t,e)}window.addEventListener("beforeunload",()=>{kr.forEach((t,e)=>{t.bind(e)()}),Wo()});const Ir=new Map;function Ho(t,e){Ir.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&Ir.forEach((t,e)=>{t.bind(e)()})});const Sr="sesamySignedURLs";function _r(){const t=sessionStorage.getItem(Sr);return t?JSON.parse(t):[]}function Jo(t){const e=_r();e.push(t),sessionStorage.setItem(Sr,JSON.stringify(e))}function Xo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:f,getProfile:p,updateProfile:u,getTags:c,deleteTag:m,setTag:d,getUserMetadata:w,listUserMetadata:k,setUserMetadata:v,deleteUserMetadata:_,getTally:S,getTallies:y,pushTally:l,deleteTally:b,getProduct:T,getPaymentIssues:O,autoOnboardProduct:A,openHostedAccountPage:L}=Pi(t),z={auth:{getUser:p,isAuthenticated:Et,loginWithRedirect:Pt,logout:hi,setToken:dn},profile:{get:p,update:u,openHostedAccountPage:L},analytics:{track:Ko},tags:{list:c,set:d,delete:m},entitlements:{get:e,list:n,access:r,signedLinks:_r},contracts:{get:o,list:a},bills:{get:s,list:f},userMetadata:{get:w,list:k,set:v,delete:_},tallies:{get:S,list:y,push:l,delete:b},subscriptions:{list:i},products:{get:T,autoOnboard:A},getVersion:Vo,getPaymentIssues:O,clearCache:ne};return t.namespace&&(window[t.namespace]=z),z}function Vo(){return Tt}function Yo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){dn(e,n?parseInt(n,10):void 0);const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Er="sesamy-refresh",Pr="force-refetch-entitlements";function Go(){const t=new URLSearchParams(window.location.search),e=t.get(Pr),n=t.get(Er);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Pr),t.delete(Er),r.search=t.toString(),ne(),window.history.replaceState(null,"",r)}}function Bo(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Jo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const Tr="sesamy-user";async function qo(){const e=new URLSearchParams(window.location.search).get(Tr);if(!e)return;const n=await di();(n==null?void 0:n.email)!==e&&Pt({email:e});const r=new URL(window.location.href);r.searchParams.delete(Tr),window.history.replaceState(null,"",r)}const Or="sesamy-purchase";function Qo(){const t=new URLSearchParams(window.location.search),e=t.get(Or);if(e!==null){const n=new URL(window.location.href);t.delete(Or),n.search=t.toString(),V(te.PURCHASE,{itemSrc:e}),ne(),window.history.replaceState(null,"",n)}}const jr="sesamy-login";async function ea(){if(!new URLSearchParams(window.location.search).get(jr))return;await Et()||Pt();const r=new URL(window.location.href);r.searchParams.delete(jr),window.history.replaceState(null,"",r)}async function Cr(t){Zo({clientId:t.clientId,...t.analytics}),await li({clientId:t.clientId,organization:t.organization,...t.auth});const e=Xo({clientId:t.clientId,...t.api});return V(te.READY,{}),Yo(),Go(),Bo(),await ea(),await qo(),Qo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Cr(e)}catch(e){console.error("Failed to parse config",e)}}return ie.init=Cr,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"}),ie}({});
@@ -3392,7 +3392,7 @@ async function Qo() {
3392
3392
  if (!e)
3393
3393
  return;
3394
3394
  const n = await hi();
3395
- (n == null ? void 0 : n.email) !== e && Dt();
3395
+ (n == null ? void 0 : n.email) !== e && Dt({ email: e });
3396
3396
  const r = new URL(window.location.href);
3397
3397
  r.searchParams.delete(Zn), window.history.replaceState(null, "", r);
3398
3398
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "registry": "https://registry.npmjs.org/",
7
7
  "tag": "latest"
8
8
  },
9
- "version": "1.10.3",
9
+ "version": "1.10.4",
10
10
  "main": "dist/sesamy-js.cjs",
11
11
  "module": "dist/sesamy-js.mjs",
12
12
  "types": "dist/sesamy-js.d.ts",