@sesamy/sesamy-js 1.10.1 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/sesamy-js.cjs +5 -5
- package/dist/sesamy-js.d.ts +4 -2
- package/dist/sesamy-js.iife.js +5 -5
- package/dist/sesamy-js.mjs +974 -967
- package/package.json +1 -1
package/dist/sesamy-js.iife.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var sesamyJs=function(ie){"use strict";var Qo=Object.defineProperty;var ea=(ie,X,V)=>X in ie?Qo(ie,X,{enumerable:!0,configurable:!0,writable:!0,value:V}):ie[X]=V;var ee=(ie,X,V)=>(ea(ie,typeof X!="symbol"?X+"":X,V),V);function X(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function V(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}typeof SuppressedError=="function"&&SuppressedError;var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ht(t,e){return t(e={exports:{}},e.exports),e.exports}var fe=ht(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function r(){var i=this;this.locked=new Map,this.addToLocked=function(o,a){var s=i.locked.get(o);s===void 0?a===void 0?i.locked.set(o,[]):i.locked.set(o,[a]):a!==void 0&&(s.unshift(a),i.locked.set(o,s))},this.isLocked=function(o){return i.locked.has(o)},this.lock=function(o){return new Promise(function(a,s){i.isLocked(o)?i.addToLocked(o,a):(i.addToLocked(o),a())})},this.unlock=function(o){var a=i.locked.get(o);if(a!==void 0&&a.length!==0){var s=a.pop();i.locked.set(o,a),s!==void 0&&setTimeout(s,0)}else i.locked.delete(o)}}return r.getInstance=function(){return r.instance===void 0&&(r.instance=new r),r.instance},r}();e.default=function(){return n.getInstance()}});dt(fe);var Nr=dt(ht(function(t,e){var n=he&&he.__awaiter||function(u,c,p,d){return new(p||(p=Promise))(function(w,I){function v(y){try{S(d.next(y))}catch(l){I(l)}}function _(y){try{S(d.throw(y))}catch(l){I(l)}}function S(y){y.done?w(y.value):new p(function(l){l(y.value)}).then(v,_)}S((d=d.apply(u,c||[])).next())})},r=he&&he.__generator||function(u,c){var p,d,w,I,v={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return I={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(I[Symbol.iterator]=function(){return this}),I;function _(S){return function(y){return function(l){if(p)throw new TypeError("Generator is already executing.");for(;v;)try{if(p=1,d&&(w=2&l[0]?d.return:l[0]?d.throw||((w=d.return)&&w.call(d),0):d.next)&&!(w=w.call(d,l[1])).done)return w;switch(d=0,w&&(l=[2&l[0],w.value]),l[0]){case 0:case 1:w=l;break;case 4:return v.label++,{value:l[1],done:!1};case 5:v.label++,d=l[1],l=[0];continue;case 7:l=v.ops.pop(),v.trys.pop();continue;default:if(w=v.trys,!((w=w.length>0&&w[w.length-1])||l[0]!==6&&l[0]!==2)){v=0;continue}if(l[0]===3&&(!w||l[1]>w[0]&&l[1]<w[3])){v.label=l[1];break}if(l[0]===6&&v.label<w[1]){v.label=w[1],w=l;break}if(w&&v.label<w[2]){v.label=w[2],v.ops.push(l);break}w[2]&&v.ops.pop(),v.trys.pop();continue}l=c.call(u,v)}catch(k){l=[6,k],d=0}finally{p=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([S,y])}}},i=he;Object.defineProperty(e,"__esModule",{value:!0});var o="browser-tabs-lock-key",a={key:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},getItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},clear:function(){return n(i,void 0,void 0,function(){return r(this,function(u){return[2,window.localStorage.clear()]})})},removeItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},setItem:function(u,c){return n(i,void 0,void 0,function(){return r(this,function(p){throw new Error("Unsupported")})})},keySync:function(u){return window.localStorage.key(u)},getItemSync:function(u){return window.localStorage.getItem(u)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(u){return window.localStorage.removeItem(u)},setItemSync:function(u,c){return window.localStorage.setItem(u,c)}};function s(u){return new Promise(function(c){return setTimeout(c,u)})}function h(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",p="",d=0;d<u;d++)p+=c[Math.floor(Math.random()*c.length)];return p}var f=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+h(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=c,u.waiters===void 0&&(u.waiters=[])}return u.prototype.acquireLock=function(c,p){return p===void 0&&(p=5e3),n(this,void 0,void 0,function(){var d,w,I,v,_,S,y;return r(this,function(l){switch(l.label){case 0:d=Date.now()+h(4),w=Date.now()+p,I=o+"-"+c,v=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<w?[4,s(30)]:[3,8];case 2:return l.sent(),v.getItemSync(I)!==null?[3,5]:(_=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),v.setItemSync(I,JSON.stringify({id:this.id,iat:d,timeoutKey:_,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(S=v.getItemSync(I))!==null&&(y=JSON.parse(S)).id===this.id&&y.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(I,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(w)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+h(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,p){return n(this,void 0,void 0,function(){var d=this;return r(this,function(w){return setTimeout(function(){return n(d,void 0,void 0,function(){var I,v,_;return r(this,function(S){switch(S.label){case 0:return[4,fe.default().lock(p)];case 1:return S.sent(),this.acquiredIatSet.has(p)?(I=this.storageHandler===void 0?a:this.storageHandler,(v=I.getItemSync(c))===null?(fe.default().unlock(p),[2]):((_=JSON.parse(v)).timeRefreshed=Date.now(),I.setItemSync(c,JSON.stringify(_)),fe.default().unlock(p),this.refreshLockWhileAcquired(c,p),[2])):(fe.default().unlock(p),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(p){switch(p.label){case 0:return[4,new Promise(function(d){var w=!1,I=Date.now(),v=!1;function _(){if(v||(window.removeEventListener("storage",_),u.removeFromWaiting(_),clearTimeout(S),v=!0),!w){w=!0;var y=50-(Date.now()-I);y>0?setTimeout(d,y):d(null)}}window.addEventListener("storage",_),u.addToWaiting(_);var S=setTimeout(_,Math.max(0,c-Date.now()))})];case 1:return p.sent(),[2]}})})},u.addToWaiting=function(c){this.removeFromWaiting(c),u.waiters!==void 0&&u.waiters.push(c)},u.removeFromWaiting=function(c){u.waiters!==void 0&&(u.waiters=u.waiters.filter(function(p){return p!==c}))},u.notifyWaiters=function(){u.waiters!==void 0&&u.waiters.slice().forEach(function(c){return c()})},u.prototype.releaseLock=function(c){return n(this,void 0,void 0,function(){return r(this,function(p){switch(p.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,p.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var p,d,w,I;return r(this,function(v){switch(v.label){case 0:return p=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=p.getItemSync(d))===null?[2]:(I=JSON.parse(w)).id!==this.id?[3,2]:[4,fe.default().lock(I.iat)];case 1:v.sent(),this.acquiredIatSet.delete(I.iat),p.removeItemSync(d),fe.default().unlock(I.iat),u.notifyWaiters(),v.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var p=Date.now()-5e3,d=c,w=[],I=0;;){var v=d.keySync(I);if(v===null)break;w.push(v),I++}for(var _=!1,S=0;S<w.length;S++){var y=w[S];if(y.includes(o)){var l=d.getItemSync(y);if(l!==null){var k=JSON.parse(l);(k.timeRefreshed===void 0&&k.timeAcquired<p||k.timeRefreshed!==void 0&&k.timeRefreshed<p)&&(d.removeItemSync(y),_=!0)}}}_&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=f}));const Ur={timeoutInSeconds:60},Ft={name:"auth0-spa-js",version:"2.1.3"},Jt=()=>Date.now();let q=class Wt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,Wt.prototype)}static fromPayload({error:e,error_description:n}){return new Wt(e,n)}},zr=class Or extends q{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Or.prototype)}},ft=class jr extends q{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,jr.prototype)}},Rr=class Cr extends ft{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Cr.prototype)}},Dr=class xr extends q{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,xr.prototype)}},Lr=class Ar extends q{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Ar.prototype)}},Xt=class $r extends q{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Vt(e,["default"])}', scope: '${Vt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,$r.prototype)}};function Vt(t,e=[]){return t&&!e.includes(t)?t:""}const Fe=()=>window.crypto,pt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Fe().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Yt=t=>btoa(t),mt=t=>{var{clientId:e}=t,n=V(t,["clientId"]);return new URLSearchParams((r=>Object.keys(r).filter(i=>r[i]!==void 0).reduce((i,o)=>Object.assign(Object.assign({},i),{[o]:r[o]}),{}))(Object.assign({client_id:e},n))).toString()},Gt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Mr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Zr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Mr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Kr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},h=o,new Promise(function(f,u){const c=new MessageChannel;c.port1.onmessage=function(p){p.data.error?u(new Error(p.data.error)):f(p.data),c.port1.close()},h.postMessage(s,[c.port2])});var s,h},Wr=async(t,e,n,r,i,o,a=1e4)=>i?Kr(t,e,n,r,a,i,o):Zr(t,r,a);async function Hr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,h=V(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const f=s?mt(h):JSON.stringify(h);return await async function(u,c,p,d,w,I,v){let _,S=null;for(let x=0;x<3;x++)try{_=await Wr(u,p,d,w,I,v,c),S=null;break}catch(z){S=z}if(S)throw S;const y=_.json,{error:l,error_description:k}=y,P=V(y,["error","error_description"]),{ok:O}=_;if(!O){const x=k||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Lr(l,x,P.mfa_token):l==="missing_refresh_token"?new Xt(p,d):new q(l||"request_error",x)}return P}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:f,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Ft))}},e,s)}const Je=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let pe=class Ht{constructor(e,n="@@auth0spajs@@",r){this.prefix=n,this.suffix=r,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(e){const[n,r,i,o]=e.split("::");return new Ht({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new Ht({scope:n,audience:r,clientId:i})}},Fr=class{set(e,n){localStorage.setItem(e,JSON.stringify(n))}get(e){const n=window.localStorage.getItem(e);if(n)try{return JSON.parse(n)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith("@@auth0spajs@@"))}},Bt=class{constructor(){this.enclosedCache=function(){let e={};return{set(n,r){e[n]=r},get(n){const r=e[n];if(r)return r},remove(n){delete e[n]},allKeys:()=>Object.keys(e)}}()}},Jr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Jt}async setIdToken(e,n,r){var i;const o=this.getIdTokenCacheKey(e);await this.cache.set(o,{id_token:n,decodedToken:r}),await((i=this.keyManifest)===null||i===void 0?void 0:i.add(o))}async getIdToken(e){const n=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!n&&e.scope&&e.audience){const r=await this.get(e);return!r||!r.id_token||!r.decodedToken?void 0:{id_token:r.id_token,decodedToken:r.decodedToken}}if(n)return{id_token:n.id_token,decodedToken:n.decodedToken}}async get(e,n=0){var r;let i=await this.cache.get(e.toKey());if(!i){const s=await this.getCacheKeys();if(!s)return;const h=this.matchExistingCacheKey(e,s);h&&(i=await this.cache.get(h))}if(!i)return;const o=await this.nowProvider(),a=Math.floor(o/1e3);return i.expiresAt-n<a?i.body.refresh_token?(i.body={refresh_token:i.body.refresh_token},await this.cache.set(e.toKey(),i),i.body):(await this.cache.remove(e.toKey()),void await((r=this.keyManifest)===null||r===void 0?void 0:r.remove(e.toKey()))):i.body}async set(e){var n;const r=new pe({clientId:e.client_id,scope:e.scope,audience:e.audience}),i=await this.wrapCacheEntry(e);await this.cache.set(r.toKey(),i),await((n=this.keyManifest)===null||n===void 0?void 0:n.add(r.toKey()))}async clear(e){var n;const r=await this.getCacheKeys();r&&(await r.filter(i=>!e||i.includes(e)).reduce(async(i,o)=>{await i,await this.cache.remove(o)},Promise.resolve()),await((n=this.keyManifest)===null||n===void 0?void 0:n.clear()))}async wrapCacheEntry(e){const n=await this.nowProvider();return{body:e,expiresAt:Math.floor(n/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?(e=await this.keyManifest.get())===null||e===void 0?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new pe({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=pe.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],h=o.scope&&s.reduce((f,u)=>f&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&h})[0]}},Xr=class{constructor(e,n,r){this.storage=e,this.clientId=n,this.cookieDomain=r,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}};const Ue=t=>typeof t=="number",Vr=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"],Yr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,h,f]=a;if(a.length!==3||!s||!h||!f)throw new Error("ID token could not be decoded");const u=JSON.parse(Gt(h)),c={__raw:o},p={};return Object.keys(u).forEach(d=>{c[d]=u[d],Vr.includes(d)||(p[d]=u[d])}),{encoded:{header:s,payload:h,signature:f},header:JSON.parse(Gt(s)),claims:c,user:p}})(t.id_token);if(!e.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(e.claims.iss!==t.iss)throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);if(!e.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if(e.header.alg!=="RS256")throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!e.claims.aud||typeof e.claims.aud!="string"&&!Array.isArray(e.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(e.claims.aud)){if(!e.claims.aud.includes(t.aud))throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);if(e.claims.aud.length>1){if(!e.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(e.claims.azp!==t.aud)throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`)}}else if(e.claims.aud!==t.aud)throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);if(t.nonce){if(!e.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(e.claims.nonce!==t.nonce)throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`)}if(t.max_age&&!Ue(e.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(e.claims.exp==null||!Ue(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Ue(e.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=t.leeway||60,r=new Date(t.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(e.claims.exp+n),r>i)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(e.claims.nbf!=null&&Ue(e.claims.nbf)){const o=new Date(0);if(o.setUTCSeconds(e.claims.nbf-n),r<o)throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${o}`)}if(e.claims.auth_time!=null&&Ue(e.claims.auth_time)){const o=new Date(0);if(o.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+n),r>o)throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${o}`)}if(t.organization){const o=t.organization.trim();if(o.startsWith("org_")){const a=o;if(!e.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(a!==e.claims.org_id)throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`)}else{const a=o.toLowerCase();if(!e.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(a!==e.claims.org_name)throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`)}}return e};var me=ht(function(t,e){var n=he&&he.__assign||function(){return n=Object.assign||function(h){for(var f,u=1,c=arguments.length;u<c;u++)for(var p in f=arguments[u])Object.prototype.hasOwnProperty.call(f,p)&&(h[p]=f[p]);return h},n.apply(this,arguments)};function r(h,f){if(!f)return"";var u="; "+h;return f===!0?u:u+"="+f}function i(h,f,u){return encodeURIComponent(h).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(f).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*c.expires),c.expires=p}return r("Expires",c.expires?c.expires.toUTCString():"")+r("Domain",c.domain)+r("Path",c.path)+r("Secure",c.secure)+r("SameSite",c.sameSite)}(u)}function o(h){for(var f={},u=h?h.split("; "):[],c=/(%[\dA-F]{2})+/gi,p=0;p<u.length;p++){var d=u[p].split("="),w=d.slice(1).join("=");w.charAt(0)==='"'&&(w=w.slice(1,-1));try{f[d[0].replace(c,decodeURIComponent)]=w.replace(c,decodeURIComponent)}catch{}}return f}function a(){return o(document.cookie)}function s(h,f,u){document.cookie=i(h,f,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(h){return a()[h]},e.set=s,e.remove=function(h,f){s(h,"",n(n({},f),{expires:-1}))}});dt(me),me.encode,me.parse,me.getAll;var Gr=me.get,qt=me.set,Qt=me.remove;const Ie={get(t){const e=Gr(t);if(e!==void 0)return JSON.parse(e)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0,sameSite:"none"}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),qt(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Qt(t,n)}},Br={get(t){return Ie.get(t)||Ie.get(`_legacy_${t}`)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),qt(`_legacy_${t}`,JSON.stringify(e),r),Ie.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Qt(t,n),Ie.remove(t,e),Ie.remove(`_legacy_${t}`,e)}},qr={get(t){if(typeof sessionStorage>"u")return;const e=sessionStorage.getItem(t);return e!=null?JSON.parse(e):void 0},save(t,e){sessionStorage.setItem(t,JSON.stringify(e))},remove(t){sessionStorage.removeItem(t)}};function Qr(t,e,n){var r=e===void 0?null:e,i=function(h,f){var u=atob(h);if(f){for(var c=new Uint8Array(u.length),p=0,d=u.length;p<d;++p)c[p]=u.charCodeAt(p);return String.fromCharCode.apply(null,new Uint16Array(c.buffer))}return u}(t,n!==void 0&&n),o=i.indexOf(`
|
|
2
|
-
`,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var
|
|
1
|
+
var sesamyJs=function(ie){"use strict";var Qo=Object.defineProperty;var ea=(ie,V,Y)=>V in ie?Qo(ie,V,{enumerable:!0,configurable:!0,writable:!0,value:Y}):ie[V]=Y;var ee=(ie,V,Y)=>(ea(ie,typeof V!="symbol"?V+"":V,Y),Y);function V(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function Y(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}typeof SuppressedError=="function"&&SuppressedError;var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ht(t,e){return t(e={exports:{}},e.exports),e.exports}var fe=ht(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function r(){var i=this;this.locked=new Map,this.addToLocked=function(o,a){var s=i.locked.get(o);s===void 0?a===void 0?i.locked.set(o,[]):i.locked.set(o,[a]):a!==void 0&&(s.unshift(a),i.locked.set(o,s))},this.isLocked=function(o){return i.locked.has(o)},this.lock=function(o){return new Promise(function(a,s){i.isLocked(o)?i.addToLocked(o,a):(i.addToLocked(o),a())})},this.unlock=function(o){var a=i.locked.get(o);if(a!==void 0&&a.length!==0){var s=a.pop();i.locked.set(o,a),s!==void 0&&setTimeout(s,0)}else i.locked.delete(o)}}return r.getInstance=function(){return r.instance===void 0&&(r.instance=new r),r.instance},r}();e.default=function(){return n.getInstance()}});dt(fe);var zr=dt(ht(function(t,e){var n=he&&he.__awaiter||function(u,c,m,d){return new(m||(m=Promise))(function(w,k){function v(y){try{S(d.next(y))}catch(l){k(l)}}function _(y){try{S(d.throw(y))}catch(l){k(l)}}function S(y){y.done?w(y.value):new m(function(l){l(y.value)}).then(v,_)}S((d=d.apply(u,c||[])).next())})},r=he&&he.__generator||function(u,c){var m,d,w,k,v={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return k={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(k[Symbol.iterator]=function(){return this}),k;function _(S){return function(y){return function(l){if(m)throw new TypeError("Generator is already executing.");for(;v;)try{if(m=1,d&&(w=2&l[0]?d.return:l[0]?d.throw||((w=d.return)&&w.call(d),0):d.next)&&!(w=w.call(d,l[1])).done)return w;switch(d=0,w&&(l=[2&l[0],w.value]),l[0]){case 0:case 1:w=l;break;case 4:return v.label++,{value:l[1],done:!1};case 5:v.label++,d=l[1],l=[0];continue;case 7:l=v.ops.pop(),v.trys.pop();continue;default:if(w=v.trys,!((w=w.length>0&&w[w.length-1])||l[0]!==6&&l[0]!==2)){v=0;continue}if(l[0]===3&&(!w||l[1]>w[0]&&l[1]<w[3])){v.label=l[1];break}if(l[0]===6&&v.label<w[1]){v.label=w[1],w=l;break}if(w&&v.label<w[2]){v.label=w[2],v.ops.push(l);break}w[2]&&v.ops.pop(),v.trys.pop();continue}l=c.call(u,v)}catch(b){l=[6,b],d=0}finally{m=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([S,y])}}},i=he;Object.defineProperty(e,"__esModule",{value:!0});var o="browser-tabs-lock-key",a={key:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},getItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},clear:function(){return n(i,void 0,void 0,function(){return r(this,function(u){return[2,window.localStorage.clear()]})})},removeItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},setItem:function(u,c){return n(i,void 0,void 0,function(){return r(this,function(m){throw new Error("Unsupported")})})},keySync:function(u){return window.localStorage.key(u)},getItemSync:function(u){return window.localStorage.getItem(u)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(u){return window.localStorage.removeItem(u)},setItemSync:function(u,c){return window.localStorage.setItem(u,c)}};function s(u){return new Promise(function(c){return setTimeout(c,u)})}function f(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",m="",d=0;d<u;d++)m+=c[Math.floor(Math.random()*c.length)];return m}var p=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+f(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=c,u.waiters===void 0&&(u.waiters=[])}return u.prototype.acquireLock=function(c,m){return m===void 0&&(m=5e3),n(this,void 0,void 0,function(){var d,w,k,v,_,S,y;return r(this,function(l){switch(l.label){case 0:d=Date.now()+f(4),w=Date.now()+m,k=o+"-"+c,v=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<w?[4,s(30)]:[3,8];case 2:return l.sent(),v.getItemSync(k)!==null?[3,5]:(_=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),v.setItemSync(k,JSON.stringify({id:this.id,iat:d,timeoutKey:_,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(S=v.getItemSync(k))!==null&&(y=JSON.parse(S)).id===this.id&&y.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(k,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(w)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+f(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,m){return n(this,void 0,void 0,function(){var d=this;return r(this,function(w){return setTimeout(function(){return n(d,void 0,void 0,function(){var k,v,_;return r(this,function(S){switch(S.label){case 0:return[4,fe.default().lock(m)];case 1:return S.sent(),this.acquiredIatSet.has(m)?(k=this.storageHandler===void 0?a:this.storageHandler,(v=k.getItemSync(c))===null?(fe.default().unlock(m),[2]):((_=JSON.parse(v)).timeRefreshed=Date.now(),k.setItemSync(c,JSON.stringify(_)),fe.default().unlock(m),this.refreshLockWhileAcquired(c,m),[2])):(fe.default().unlock(m),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(m){switch(m.label){case 0:return[4,new Promise(function(d){var w=!1,k=Date.now(),v=!1;function _(){if(v||(window.removeEventListener("storage",_),u.removeFromWaiting(_),clearTimeout(S),v=!0),!w){w=!0;var y=50-(Date.now()-k);y>0?setTimeout(d,y):d(null)}}window.addEventListener("storage",_),u.addToWaiting(_);var S=setTimeout(_,Math.max(0,c-Date.now()))})];case 1:return m.sent(),[2]}})})},u.addToWaiting=function(c){this.removeFromWaiting(c),u.waiters!==void 0&&u.waiters.push(c)},u.removeFromWaiting=function(c){u.waiters!==void 0&&(u.waiters=u.waiters.filter(function(m){return m!==c}))},u.notifyWaiters=function(){u.waiters!==void 0&&u.waiters.slice().forEach(function(c){return c()})},u.prototype.releaseLock=function(c){return n(this,void 0,void 0,function(){return r(this,function(m){switch(m.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,m.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var m,d,w,k;return r(this,function(v){switch(v.label){case 0:return m=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=m.getItemSync(d))===null?[2]:(k=JSON.parse(w)).id!==this.id?[3,2]:[4,fe.default().lock(k.iat)];case 1:v.sent(),this.acquiredIatSet.delete(k.iat),m.removeItemSync(d),fe.default().unlock(k.iat),u.notifyWaiters(),v.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var m=Date.now()-5e3,d=c,w=[],k=0;;){var v=d.keySync(k);if(v===null)break;w.push(v),k++}for(var _=!1,S=0;S<w.length;S++){var y=w[S];if(y.includes(o)){var l=d.getItemSync(y);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<m||b.timeRefreshed!==void 0&&b.timeRefreshed<m)&&(d.removeItemSync(y),_=!0)}}}_&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=p}));const Rr={timeoutInSeconds:60},Jt={name:"auth0-spa-js",version:"2.1.3"},Xt=()=>Date.now();let q=class Ht extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,Ht.prototype)}static fromPayload({error:e,error_description:n}){return new Ht(e,n)}},Dr=class Cr extends q{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Cr.prototype)}},ft=class xr extends q{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,xr.prototype)}},Lr=class Ar extends ft{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Ar.prototype)}},Mr=class $r extends q{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,$r.prototype)}},Zr=class Nr extends q{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Nr.prototype)}},Vt=class Ur extends q{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Yt(e,["default"])}', scope: '${Yt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,Ur.prototype)}};function Yt(t,e=[]){return t&&!e.includes(t)?t:""}const Fe=()=>window.crypto,pt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Fe().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Gt=t=>btoa(t),mt=t=>{var{clientId:e}=t,n=Y(t,["clientId"]);return new URLSearchParams((r=>Object.keys(r).filter(i=>r[i]!==void 0).reduce((i,o)=>Object.assign(Object.assign({},i),{[o]:r[o]}),{}))(Object.assign({client_id:e},n))).toString()},Bt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Kr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Wr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Kr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Hr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},f=o,new Promise(function(p,u){const c=new MessageChannel;c.port1.onmessage=function(m){m.data.error?u(new Error(m.data.error)):p(m.data),c.port1.close()},f.postMessage(s,[c.port2])});var s,f},Fr=async(t,e,n,r,i,o,a=1e4)=>i?Hr(t,e,n,r,a,i,o):Wr(t,r,a);async function Jr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,f=Y(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const p=s?mt(f):JSON.stringify(f);return await async function(u,c,m,d,w,k,v){let _,S=null;for(let A=0;A<3;A++)try{_=await Fr(u,m,d,w,k,v,c),S=null;break}catch(D){S=D}if(S)throw S;const y=_.json,{error:l,error_description:b}=y,T=Y(y,["error","error_description"]),{ok:O}=_;if(!O){const A=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Zr(l,A,T.mfa_token):l==="missing_refresh_token"?new Vt(m,d):new q(l||"request_error",A)}return T}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:p,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Jt))}},e,s)}const Je=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let pe=class Ft{constructor(e,n="@@auth0spajs@@",r){this.prefix=n,this.suffix=r,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(e){const[n,r,i,o]=e.split("::");return new Ft({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new Ft({scope:n,audience:r,clientId:i})}},Xr=class{set(e,n){localStorage.setItem(e,JSON.stringify(n))}get(e){const n=window.localStorage.getItem(e);if(n)try{return JSON.parse(n)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith("@@auth0spajs@@"))}},qt=class{constructor(){this.enclosedCache=function(){let e={};return{set(n,r){e[n]=r},get(n){const r=e[n];if(r)return r},remove(n){delete e[n]},allKeys:()=>Object.keys(e)}}()}},Vr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Xt}async setIdToken(e,n,r){var i;const o=this.getIdTokenCacheKey(e);await this.cache.set(o,{id_token:n,decodedToken:r}),await((i=this.keyManifest)===null||i===void 0?void 0:i.add(o))}async getIdToken(e){const n=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!n&&e.scope&&e.audience){const r=await this.get(e);return!r||!r.id_token||!r.decodedToken?void 0:{id_token:r.id_token,decodedToken:r.decodedToken}}if(n)return{id_token:n.id_token,decodedToken:n.decodedToken}}async get(e,n=0){var r;let i=await this.cache.get(e.toKey());if(!i){const s=await this.getCacheKeys();if(!s)return;const f=this.matchExistingCacheKey(e,s);f&&(i=await this.cache.get(f))}if(!i)return;const o=await this.nowProvider(),a=Math.floor(o/1e3);return i.expiresAt-n<a?i.body.refresh_token?(i.body={refresh_token:i.body.refresh_token},await this.cache.set(e.toKey(),i),i.body):(await this.cache.remove(e.toKey()),void await((r=this.keyManifest)===null||r===void 0?void 0:r.remove(e.toKey()))):i.body}async set(e){var n;const r=new pe({clientId:e.client_id,scope:e.scope,audience:e.audience}),i=await this.wrapCacheEntry(e);await this.cache.set(r.toKey(),i),await((n=this.keyManifest)===null||n===void 0?void 0:n.add(r.toKey()))}async clear(e){var n;const r=await this.getCacheKeys();r&&(await r.filter(i=>!e||i.includes(e)).reduce(async(i,o)=>{await i,await this.cache.remove(o)},Promise.resolve()),await((n=this.keyManifest)===null||n===void 0?void 0:n.clear()))}async wrapCacheEntry(e){const n=await this.nowProvider();return{body:e,expiresAt:Math.floor(n/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?(e=await this.keyManifest.get())===null||e===void 0?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new pe({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=pe.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],f=o.scope&&s.reduce((p,u)=>p&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&f})[0]}},Yr=class{constructor(e,n,r){this.storage=e,this.clientId=n,this.cookieDomain=r,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}};const Ue=t=>typeof t=="number",Gr=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"],Br=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,f,p]=a;if(a.length!==3||!s||!f||!p)throw new Error("ID token could not be decoded");const u=JSON.parse(Bt(f)),c={__raw:o},m={};return Object.keys(u).forEach(d=>{c[d]=u[d],Gr.includes(d)||(m[d]=u[d])}),{encoded:{header:s,payload:f,signature:p},header:JSON.parse(Bt(s)),claims:c,user:m}})(t.id_token);if(!e.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(e.claims.iss!==t.iss)throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);if(!e.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if(e.header.alg!=="RS256")throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!e.claims.aud||typeof e.claims.aud!="string"&&!Array.isArray(e.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(e.claims.aud)){if(!e.claims.aud.includes(t.aud))throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);if(e.claims.aud.length>1){if(!e.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(e.claims.azp!==t.aud)throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`)}}else if(e.claims.aud!==t.aud)throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);if(t.nonce){if(!e.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(e.claims.nonce!==t.nonce)throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`)}if(t.max_age&&!Ue(e.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(e.claims.exp==null||!Ue(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Ue(e.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=t.leeway||60,r=new Date(t.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(e.claims.exp+n),r>i)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(e.claims.nbf!=null&&Ue(e.claims.nbf)){const o=new Date(0);if(o.setUTCSeconds(e.claims.nbf-n),r<o)throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${o}`)}if(e.claims.auth_time!=null&&Ue(e.claims.auth_time)){const o=new Date(0);if(o.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+n),r>o)throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${o}`)}if(t.organization){const o=t.organization.trim();if(o.startsWith("org_")){const a=o;if(!e.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(a!==e.claims.org_id)throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`)}else{const a=o.toLowerCase();if(!e.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(a!==e.claims.org_name)throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`)}}return e};var me=ht(function(t,e){var n=he&&he.__assign||function(){return n=Object.assign||function(f){for(var p,u=1,c=arguments.length;u<c;u++)for(var m in p=arguments[u])Object.prototype.hasOwnProperty.call(p,m)&&(f[m]=p[m]);return f},n.apply(this,arguments)};function r(f,p){if(!p)return"";var u="; "+f;return p===!0?u:u+"="+p}function i(f,p,u){return encodeURIComponent(f).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(p).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var m=new Date;m.setMilliseconds(m.getMilliseconds()+864e5*c.expires),c.expires=m}return r("Expires",c.expires?c.expires.toUTCString():"")+r("Domain",c.domain)+r("Path",c.path)+r("Secure",c.secure)+r("SameSite",c.sameSite)}(u)}function o(f){for(var p={},u=f?f.split("; "):[],c=/(%[\dA-F]{2})+/gi,m=0;m<u.length;m++){var d=u[m].split("="),w=d.slice(1).join("=");w.charAt(0)==='"'&&(w=w.slice(1,-1));try{p[d[0].replace(c,decodeURIComponent)]=w.replace(c,decodeURIComponent)}catch{}}return p}function a(){return o(document.cookie)}function s(f,p,u){document.cookie=i(f,p,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(f){return a()[f]},e.set=s,e.remove=function(f,p){s(f,"",n(n({},p),{expires:-1}))}});dt(me),me.encode,me.parse,me.getAll;var qr=me.get,Qt=me.set,en=me.remove;const Ie={get(t){const e=qr(t);if(e!==void 0)return JSON.parse(e)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0,sameSite:"none"}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Qt(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),en(t,n)}},Qr={get(t){return Ie.get(t)||Ie.get(`_legacy_${t}`)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Qt(`_legacy_${t}`,JSON.stringify(e),r),Ie.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),en(t,n),Ie.remove(t,e),Ie.remove(`_legacy_${t}`,e)}},ei={get(t){if(typeof sessionStorage>"u")return;const e=sessionStorage.getItem(t);return e!=null?JSON.parse(e):void 0},save(t,e){sessionStorage.setItem(t,JSON.stringify(e))},remove(t){sessionStorage.removeItem(t)}};function ti(t,e,n){var r=e===void 0?null:e,i=function(f,p){var u=atob(f);if(p){for(var c=new Uint8Array(u.length),m=0,d=u.length;m<d;++m)c[m]=u.charCodeAt(m);return String.fromCharCode.apply(null,new Uint16Array(c.buffer))}return u}(t,n!==void 0&&n),o=i.indexOf(`
|
|
2
|
+
`,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var tn,nn,rn,gt,ni=(tn="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",nn=null,rn=!1,function(t){return gt=gt||ti(tn,nn,rn),new Worker(gt,t)});const yt={};let ri=class{constructor(e,n){this.cache=e,this.clientId=n,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){var n;const r=new Set(((n=await this.cache.get(this.manifestKey))===null||n===void 0?void 0:n.keys)||[]);r.add(e),await this.cache.set(this.manifestKey,{keys:[...r]})}async remove(e){const n=await this.cache.get(this.manifestKey);if(n){const r=new Set(n.keys);return r.delete(e),r.size>0?await this.cache.set(this.manifestKey,{keys:[...r]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`@@auth0spajs@@::${e}`}};const ii={memory:()=>new qt().enclosedCache,localstorage:()=>new Xr},on=t=>ii[t],an=t=>{const{openUrl:e,onRedirect:n}=t,r=Y(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},vt=new zr;let oi=class{constructor(e){let n,r;if(this.userCache=new qt().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await vt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<"u"&&(()=>{if(!Fe())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Fe().subtle===void 0)throw new Error(`
|
|
3
3
|
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
4
|
-
`)})(),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",!rn(n))throw new Error(`Invalid cache location "${n}"`);r=rn(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Ie:Br,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:qr;var o;this.scope=Je("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Xr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Jt,this.cacheManager=new Jr(r,r.allKeys?void 0:new ti(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 ei)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Ft)));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 Yr({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=Yt(pt()),o=Yt(pt()),a=pt(),s=(u=>{const c=new Uint8Array(u);return(p=>{const d={"+":"-","/":"_","=":""};return p.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Fe().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,p,d,w,I,v,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),p),{scope:Je(c,p.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:v||u.authorizationParams.redirect_uri,code_challenge:I,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),f=this._authorizeUrl(h);return{nonce:o,code_verifier:a,scope:h.scope,audience:h.audience||"default",redirect_uri:h.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const h=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${h},top=${f},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((h,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(p),window.removeEventListener("message",u,!1),f(new Dr(s.popup)))},1e3),p=setTimeout(()=>{clearInterval(c),f(new Rr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(p),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(q.fromPayload(d.data.response));h(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=on(e),{openUrl:i,fragment:o,appState:a}=r,s=V(r,["openUrl","fragment","appState"]),h=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=V(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),h&&{organization:h}));const p=o?`${u}#${o}`:u;i?await i(p):window.location.assign(p)}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 p=new URLSearchParams(c);return{state:p.get("state"),code:p.get("code")||void 0,error:p.get("error")||void 0,error_description:p.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 zr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new q("state_mismatch","Invalid state");const h=s.organization,f=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:f,organization:h}),{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=V(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 f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:h}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:h})}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({},Ur),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=V(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${mt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=on(e),{openUrl:r}=n,i=V(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:h,scope:f,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,p=await((w,I,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",k,!1))};let k;const P=setTimeout(()=>{S(new ft),l()},1e3*v);k=function(O){if(O.origin!=I||!O.data||O.data.type!=="authorization_response")return;const x=O.source;x&&x.close(),O.data.response.error?S(q.fromPayload(O.data.response)):_(O.data.response),clearTimeout(P),window.removeEventListener("message",k,!1),setTimeout(l,2e3)},window.addEventListener("message",k,!1),window.document.body.appendChild(y),y.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==p.state)throw new q("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:p.code,grant_type:"authorization_code",redirect_uri:h,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,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 Xt(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=V(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,h=await this._getIdTokenFromCache();return h&&Object.assign(Object.assign({id_token:h.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Hr(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 ii(t){const e=new ri(t);return await e.checkSession(),e}const an="sesamy.com",oi="https://logs.sesamy.com/events",wt="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;const bt="sesamyAccessToken",kt="sesamyExpires";function It(){const t=localStorage.getItem(kt);if(!(t&&parseInt(t,10)<new Date().getTime()))return localStorage.getItem(bt)}async function ai(t){if(t.enabled!==!1&&(Q=await ii({domain:t.endpoint||`token.${an}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await Q.handleRedirectCallback();const e=await Q.getUser();X(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 si(){if(It())return!0;if(!Q)throw new Error("Auth0 client not initialized");return Q.isAuthenticated()}async function ci(){if(It())return{sub:"local",name:"Local User"};if(!Q)throw new Error("Auth0 client not initialized");return Q.getUser()}function sn(){if(!Q)throw new Error("Auth0 client not initialized");return Q.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function ui(t=!0){const e=It();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 li(){if(localStorage.removeItem(bt),localStorage.removeItem(kt),!Q)throw new Error("Auth0 client not initialized");return X(te.LOGOUT,{}),Q.logout({logoutParams:{returnTo:window.location.href}})}function di(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 cn(t,e){localStorage.setItem(bt,t),e&&localStorage.setItem(kt,JSON.stringify(e*1e3+new Date().getTime()));const n=di(t);X(te.AUTHENTICATED,n)}const hi=(t,e)=>e.skipDedupe||e.method!=="GET",fi=(t,e)=>e.method+"@"+t,pi=t=>t.clone(),un=({skip:t=hi,key:e=fi,resolver:n=pi}={})=>{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((h,f)=>{r.get(s).push([h,f])});try{return i(o,a).then(h=>(r.get(s).forEach(([f])=>f(n(h))),r.delete(s),h)).catch(h=>{throw r.get(s).forEach(([f,u])=>u(h)),r.delete(s),h})}catch(h){return r.delete(s),Promise.reject(h)}}},mi=(t,e)=>t*e,gi=t=>t&&t.ok,ln=({delayTimer:t=500,delayRamp:e=mi,maxAttempts:n=10,until:r=gi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>h=>(f,u)=>{let c=0;if(s&&s(f,u))return h(f,u);const p=(d,w)=>Promise.resolve(r(d,w)).then(I=>I?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:f,options:u})).then((S={})=>{var y,l;v(h((y=S&&S.url)!==null&&y!==void 0?y:f,(l=S&&S.options)!==null&&l!==void 0?l:u))}):v(h(f,u))},_)}).then(p).catch(v=>{if(!o)throw v;return p(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return h(f,u).then(p).catch(d=>{if(!o)throw d;return p(null,d)})},yi="application/json",dn="Content-Type",Se=Symbol(),hn=Symbol();function fn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===dn.toLowerCase()))===null||e===void 0?void 0:e[1]}function pn(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 vi(t,e=!1){_e.options=e?t:ge(_e.options,t)}function wi(t,e=!1){_e.polyfills=e?t:ge(_e.polyfills,t)}function bi(t){_e.errorType=t}const ki=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class mn extends Error{}const Ii=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:h}=t,f=new Map(o),u=ge(i.options,r);let c=n;const p=ki(s)((y,l)=>(c=y,i.polyfill("fetch")(y,l)))(n,u),d=new Error,w=p.catch(y=>{throw{[Se]:y}}).then(y=>{if(!y.ok){const l=new mn;if(l.cause=d,l.stack=l.stack+`
|
|
5
|
-
CAUSE: `+d.stack,l.response=y,l.url=c,y.type==="opaque")throw l;return y.text().then(k=>{var P;if(l.message=k,i.errorType==="json"||((P=y.headers.get("Content-Type"))===null||P===void 0?void 0:P.split(";")[0])==="application/json")try{l.json=JSON.parse(k)}catch{}throw l.text=k,l.status=y.status,l})}return y}),I=y=>y.catch(l=>{const k=l.hasOwnProperty(Se),P=k?l[Se]:l,O=(P==null?void 0:P.status)&&f.get(P.status)||f.get(P==null?void 0:P.name)||k&&f.has(Se)&&f.get(Se);if(O)return O(P,t);const x=f.get(hn);if(x)return x(P,t);throw P}),v=y=>l=>I(y?w.then(k=>k&&k[y]()).then(k=>l?l(k):k):w.then(k=>l?l(k):k)),_={_wretchReq:t,_fetchReq:p,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(y,l){return f.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=h.reduce((y,l)=>({...y,...typeof l.resolver=="function"?l.resolver(y):l.resolver}),_);return a.reduce((y,l)=>l(y,t),S)},Si={_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({[dn]: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(hn,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=fn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||pn(i));return r=n?o?r.json(n,i):r.body(n):r,Ii(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=fn(this._options.headers);return this.content(e||pn(n)&&n||yi).body(JSON.stringify(t))}};function se(t="",e={}){return{...Si,_url:t,_options:e}}se.default=se,se.options=vi,se.errorType=bi,se.polyfills=wi,se.WretchError=mn;function ne(){sessionStorage.removeItem(wt),X(te.CLEAR_CACHE,{})}function _i(t){const e=t.endpoint||`https://api2.${an}`,n=b=>async(E,U)=>{let Y=sessionStorage.getItem(wt);Y||(Y=Date.now().toString(),sessionStorage.setItem(wt,Y));const m={...U,headers:{...U.headers,"Cache-Timestamp":Y}};return b(E,m)},r=(b=!0)=>E=>async(U,Y)=>{let m=null;if(m=await ui(b),!m){if(b)throw new Error("No access token available");return E(U,Y)}const g={...Y,headers:{...Y.headers,...m?{Authorization:`Bearer ${m}`}:{}}};return E(U,g)},i=b=>(E,U)=>{if(U.headers.Authorization)return b(E,U);const Y=localStorage.getItem("__anon_id"),m=btoa(`${Y}:`),g={...U,headers:{...U.headers,Authorization:`Basic ${m}`}};return b(E,g)},o=se(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),un(),ln({delayTimer:1e3,delayRamp:(b,E)=>b*E,maxAttempts:3,until:b=>!!(b&&(b.ok||b.status>=400&&b.status<500)),retryOnNetworkError:!1})]),a=se(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,un(),ln({delayTimer:1e3,delayRamp:(b,E)=>b*E,maxAttempts:3,until:b=>!!(b&&(b.ok||b.status>=400&&b.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(b){const E=await o.get("/entitlements").json();return E==null?void 0:E.find(U=>U.id===b)}async function f(b){return o.get(`/entitlements/${b}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(b){const E=await o.get("/contracts").json();return E==null?void 0:E.find(U=>U.id===b)}async function p(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function w(b){const E=await o.get("/bills").json();return E==null?void 0:E.find(U=>U.id===b)}async function I(b,E){const U=await o.url(`/user-metadata/${b}`).put(E).json();return X(te.USER_ATTRIBUTE_CHANGED,{}),ne(),U}async function v(b){const E=await o.url(`/user-metadata/${b}`).delete().res();return ne(),E.ok}async function _(b){return(await o.url(`/user-metadata/${b}`).get().json())[b]}async function S(){return await o.url("/user-metadata").get().json()}async function y(){return await o.url("/tags").get().json()}async function l(b){const E=await o.url(`/tags/${b}`).delete().res();return ne(),E.ok}async function k(b){const E=await o.url("/tags").post(b).res();return X(te.USER_ATTRIBUTE_CHANGED,{}),ne(),E.ok}async function P(b){return(await a.url("/tallies").get().json())[b]}async function O(){return await a.url("/tallies").get().json()}async function x(b){const E=await a.url(`/tallies/${b}`).delete().res();return ne(),E.ok}async function z(b,E){return await a.url(`/tallies/${b}/push`).post(E).json()}async function L(b){return await o.url(`/products/${b}`).get().json()}async function F(){return await o.url("/profile").get().json()}async function A(b){const E=await o.url("/profile").patch(b).res();return ne(),E.ok}async function R(){return await o.url("/payment-issues").get().json()}async function K(b){const E=await o.url(`/products/${b}/auto-onboard`).post().json();return E.length&&ne(),E}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:f,getContracts:u,getContract:c,getProfile:F,updateProfile:A,getSubscriptions:p,getBills:d,getBill:w,setUserMetadata:I,deleteUserMetadata:v,getUserMetadata:_,listUserMetadata:S,getTags:y,deleteTag:l,setTag:k,getTally:P,getTallies:O,deleteTally:x,pushTally:z,getProduct:L,getPaymentIssues:R,autoOnboardProduct:K}}const gn="@sesamy/sesamy-js",St="1.3.2";function yn(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",vn="object",_t=function(){},wn="any",bn="*",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 kn(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ei=kn.bind(null,"toUpperCase"),Pi=kn.bind(null,"toLowerCase");function Ti(t){return In(t)?Ei("null"):typeof t=="object"?xi(t):Object.prototype.toString.call(t).slice(8,-1)}function Ye(t,e){e===void 0&&(e=!0);var n=Ti(t);return e?Pi(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"),Oi=ze.bind(null,"boolean");ze.bind(null,"symbol");function In(t){return t===null}function ji(t){return Ye(t)==="number"&&!isNaN(t)}function Sn(t){return Ye(t)==="array"}function B(t){if(!Ci(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ci(t){return t&&(typeof t=="object"||t!==null)}function xi(t){return G(t.constructor)?t.constructor.name:null}function Ai(t){return t instanceof Error||ce(t.message)&&t.constructor&&ji(t.constructor.stackTraceLimit)}function _n(t,e){if(typeof e!="object"||In(e))return!1;if(e instanceof t)return!0;var n=Ye(new t(""));if(Ai(e))for(;e;){if(Ye(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}_n.bind(null,TypeError),_n.bind(null,SyntaxError);function Ge(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?$i(t,e):n}function $i(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 Ni(t){return t?Sn(t)?t:[t]:[]}function En(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ui(){if(H){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function zi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ri(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=En(n[1]),a=En(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 h=s.split("[");h.length>1&&(Di(r,h.map(function(f){return f.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 Di(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 Li(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 h=new Date;a||(a=h);var f=e-(h-a);return n=this,r=arguments,f<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,f)),i}}var Re="global",Pe=ye+"global"+ye,Te=typeof self===vn&&self.self===self&&self||typeof global===vn&&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(Et(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Te[Pe]||(Te[Pe]={});var Qe={};function Et(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 j(){return j=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},j.apply(this,arguments)}var ue="function",oe="undefined",Mi="@@redux/"+Math.random().toString(36),Pn=function(){return typeof Symbol===ue&&Symbol.observable||"@@observable"}(),et=" != "+ue;function Tn(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(Tn)(t,e)}if(typeof t!==ue)throw new Error("reducer"+et);var i=t,o=e,a=[],s=a,h=!1;function f(){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 f(),s.push(d),function(){if(w){w=!1,f();var I=s.indexOf(d);s.splice(I,1)}}}function p(d){if(!B(d))throw new Error("Act != obj");if(typeof d.type===oe)throw new Error("ActType "+oe);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var w=a=s,I=0;I<w.length;I++)(0,w[I])();return d}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ue)throw new Error("next reducer"+et);i=d,p({type:"@@redux/INIT"})}})[Pn]=function(){var d,w=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function v(){I.next&&I.next(u())}return v(),{unsubscribe:w(v)}}})[Pn]=function(){return this},d},r}function Zi(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 Ki(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,h={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(h)}),j({},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"],Pt=["name","EVENTS","config","loaded"],C=tt.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),On=/^utm_/,jn=/^an_prop_/,Cn=/^an_trait_/;function Wi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===C.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(le,a.anonymousId),f||e(be,a.userId),h.traits&&e(xe,j({},f&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,p=o.an_event,d=u.reduce(function(w,I){if(I.match(On)||I.match(/^(d|g)clid/)){var v=I.replace(On,"");w.campaign[v==="campaign"?"name":v]=o[I]}return I.match(jn)&&(w.props[I.replace(jn,"")]=o[I]),I.match(Cn)&&(w.traits[I.replace(Cn,"")]=o[I]),w},{campaign:{},props:{},traits:{}});n.dispatch(j({type:C.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),p&&setTimeout(function(){return t.track(p,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:C.campaign,campaign:d.campaign})}}return r(i)}}}}function Hi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===C.setItemEnd){if(n.key===le)return j({},e,{anonymousId:n.value});if(n.key===be)return j({},e,{userId:n.value})}switch(n.type){case C.identify:return Object.assign({},e,{userId:n.userId,traits:j({},e.traits,n.traits)});case C.reset:return[be,le,xe].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function xn(t){return{userId:t.getItem(be),anonymousId:t.getItem(le),traits:t.getItem(xe)}}var Tt=function(t){return ye+"TEMP"+ye+t};function Fi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var h=s.userId,f=s.traits,u=s.options;if(s.type===C.reset&&([be,xe,le].forEach(function(d){r(d)}),[de,Ae,"traits"].forEach(function(d){Oe(Tt(d))})),s.type===C.identify){i(le)||n(le,qe());var c=i(be),p=i(xe)||{};c&&c!==h&&o.dispatch({type:C.userIdChanged,old:{userId:c,traits:p},new:{userId:h,traits:f},options:u}),h&&n(be,h),f&&n(xe,j({},p,f))}return a(s)}}}}var De={};function An(t,e){De[t]&&G(De[t])&&(De[t](e),delete De[t])}function $n(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(j({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return $n(t,e,n-10).then(r,i)})})}function Ji(t){return{abort:t}}function Nn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,h=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,p,d){return a[p.plugin].loaded?(c.process.push(p),c.processIndex.push(d)):(c.requeue.push(p),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var p=s.actions[c],d=p.plugin,w=p.payload.type,I=i[d][w];if(I&&G(I)){var v,_=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[de,Ae].reduce(function(P,O){return l.hasOwnProperty(O)&&k[O]&&k[O]!==l[O]&&(P[O]=k[O]),P},l)}(p.payload,h),S=r[_.meta.rid];if(!S&&(v=I({payload:_,config:a[d].config,instance:n,abort:Ji}))&&B(v)&&v.abort)return void(r[_.meta.rid]=!0);if(!S){var y=w+":"+d;t.dispatch(j({},_,{type:y,_:{called:y,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,p){return!~f.processIndex.indexOf(p)});s.actions=u}}}var Ot=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,p=c.match($e),d=e.exact.map(function(v){return v.pluginName});p&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,_){return function(S,y,l){var k=y.config,P=y.name,O=P+"."+S.type;l&&(O=l.event);var x=S.type.match($e)?function(z,L,F,A,R){return function(K,b){var E=A?A.name:z,U=b&&Le(b)?b:F;if(A&&(!(U=b&&Le(b)?b:[z]).includes(z)||U.length!==1))throw new Error("Method "+L+" can only abort "+z+" plugin. "+JSON.stringify(U)+" input valid");return j({},R,{abort:{reason:K,plugins:U,caller:L,_:E}})}}(P,O,_,l,S):function(z,L){return function(){throw new Error(z.type+" action not cancellable. Remove abort in "+L)}}(S,O);return{payload:Xi(S),instance:v,config:k||{},abort:x}}}(r,d),I=e.exact.reduce(function(v,_){var S=_.pluginName,y=_.methodName,l=!1;return y.match(/^initialize/)||y.match(/^reset/)||(l=!f[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 k(){return Promise.resolve(l)}var P=function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(O,x,z){try{return Promise.resolve(O).then(function(L){return x.method&&G(x.method)?(function(K,b){var E=Kn(K);if(E&&E.name===b){var U=Kn(E.method);throw new Error([b+" plugin is calling method "+K,"Plugins cant call self","Use "+E.method+" "+(U?"or "+U.method:"")+" in "+b+" plugin insteadof "+K].join(`
|
|
6
|
-
`))}}(x.methodName,x.pluginName),Promise.resolve(x.method({payload:L,instance:r,abort:(F=L,A=y,R=x.pluginName,function(K,b){return j({},F,{abort:{reason:K,plugins:b||[A],caller:c,from:R||A}})}),config:Rn(x.pluginName,f,o),plugins:f})).then(function(K){var b=B(K)?K:{};return Promise.resolve(j({},L,b))})):L;var F,A,R})}catch(L){return Promise.reject(L)}},Promise.resolve(n))).then(function(O){l[y]=O});l[y]=n}();return P&&P.then?P.then(k):k()})}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,k=S.pluginName,P=o[k];return Promise.resolve(_).then(function(O){var x=v[k]?v[k]:{};if(p&&(x=O),Ct(x,k))return jt({data:x,method:c,instance:r,pluginName:k,store:s}),Promise.resolve(O);if(Ct(O,k))return l&&jt({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(I.hasOwnProperty(k)&&I[k]===!0)return s.dispatch({type:"queue",plugin:k,payload:x,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var z=w(v[k],o[k]);return Promise.resolve(P[c]({abort:z.abort,payload:x,instance:r,config:Rn(k,f,o),plugins:f})).then(function(L){var F=B(L)?L:{},A=j({},O,F),R=v[k];if(Ct(R,k))jt({data:R,method:c,instance:r,pluginName:k,store:s});else{var K=c+":"+k;(K.match(/:/g)||[]).length<2&&!c.match(Un)&&!c.match(zn)&&r.dispatch(j({},p?A:x,{type:K,_:{called:K,from:"submethod"}}))}return Promise.resolve(A)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(_){if(!(c.match($e)||c.match(/^registerPlugin/)||c.match(zn)||c.match(Un)||c.match(/^params/)||c.match(/^userIdChanged/))){if(h.plugins.includes(c),_._&&_._.originalAction===c)return _;var S=j({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});Mn(_,e.exact.length)&&!c.match(/End$/)&&(S=j({},S,{type:_.type+"Aborted"})),s.dispatch(S)}return _})})}catch(v){return Promise.reject(v)}},$e=/Start$/,Un=/^bootstrap/,zn=/^ready/;function jt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(j({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Rn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Dn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function Ln(t,e){var n=t.replace($e,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function Ct(t,e){var n=t.abort;return!!n&&(n===!0||Zn(n,e)||n&&Zn(n.plugins,e))}function Mn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ce(n))return!0;var r=n.plugins;return Le(n)&&n.length===e||Le(r)&&r.length===e}function Le(t){return Array.isArray(t)}function Zn(t,e){return!(!t||!Le(t))&&t.includes(e)}function Kn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Xi(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 Vi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,h=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===C.enablePlugin&&i.dispatch({type:C.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===C.disablePlugin&&setTimeout(function(){return An(a.meta.rid,{payload:a})},0),f===C.initializeEnd){var p=e(),d=Object.keys(p),w=d.filter(function(l){return u.includes(l)}).map(function(l){return p[l]}),I=[],v=[],_=a.disabled,S=w.map(function(l){var k=l.loaded,P=l.name,O=l.config;return $n(l,function(){return k({config:O})},1e4).then(function(x){return r[P]||(i.dispatch({type:C.pluginReadyType(P),name:P,events:Object.keys(l).filter(function(z){return!Pt.includes(z)})}),r[P]=!0),I=I.concat(P),l}).catch(function(x){if(x instanceof Error)throw new Error(x);return v=v.concat(x.name),x})});Promise.all(S).then(function(l){var k={plugins:I,failed:v,disabled:_};setTimeout(function(){d.length===S.length+_.length&&i.dispatch(j({},{type:C.ready},k))},0)})}var y=function(){if(f!==C.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Nn(i,e,t)},0),Promise.resolve(function(l,k,P,O,x){try{var z=G(k)?k():k,L=l.type,F=L.replace($e,"");if(l._&&l._.called)return Promise.resolve(l);var A=P.getState(),R=(E=z,(U=A.plugins)===void 0&&(U={}),(Y=l.options)===void 0&&(Y={}),Object.keys(E).filter(function(m){var g=Y.plugins||{};return Oi(g[m])?g[m]:g.all!==!1&&(!U[m]||U[m].enabled!==!1)}).map(function(m){return E[m]}));L===C.initializeStart&&l.fromEnable&&(R=Object.keys(A.plugins).filter(function(m){var g=A.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return z[m]}));var K=R.map(function(m){return m.name}),b=function(m,g,T){var $=Ln(m).map(function(N){return Dn(N,g)});return g.reduce(function(N,D){var J=D.name,Z=Ln(m,J).map(function(He){return Dn(He,g)}),W=Z[0],M=Z[1],re=Z[2];return W.length&&(N.beforeNS[J]=W),M.length&&(N.duringNS[J]=M),re.length&&(N.afterNS[J]=re),N},{before:$[0],beforeNS:{},during:$[1],duringNS:{},after:$[2],afterNS:{}})}(L,R);return Promise.resolve(Ot({action:l,data:{exact:b.before,namespaced:b.beforeNS},state:A,allPlugins:z,allMatches:b,instance:P,store:O,EVENTS:x})).then(function(m){function g(){var N=function(){if(L.match($e))return Promise.resolve(Ot({action:j({},T,{type:F+"End"}),data:{exact:b.after,namespaced:b.afterNS},state:A,allPlugins:z,allMatches:b,instance:P,store:O,EVENTS:x})).then(function(D){D.meta&&D.meta.hasCallback&&An(D.meta.rid,{payload:D})})}();return N&&N.then?N.then(function(){return m}):m}if(Mn(m,K.length))return m;var T,$=function(){if(L!==F)return Promise.resolve(Ot({action:j({},m,{type:F}),data:{exact:b.during,namespaced:b.duringNS},state:A,allPlugins:z,allMatches:b,instance:P,store:O,EVENTS:x})).then(function(N){T=N});T=m}();return $&&$.then?$.then(g):g()})}catch(m){return Promise.reject(m)}var E,U,Y}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(h):h(y))}catch(l){return Promise.reject(l)}}}}}function Yi(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===C.setItem||i===C.removeItem){if(r.abort)return n(r);i===C.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var Gi=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 Bi(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=Wn(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},j({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var h=Wn(n.type,C.initialize),f=t()[h];return f&&h?(r[h]=j({},e[h],{initialized:!0,loaded:!!f.loaded({config:f.config})}),j({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=j({},e[n.name],{loaded:!0}),j({},e,r);switch(n.type){case C.disablePlugin:return j({},e,Hn(n.plugins,!1,e));case C.enablePlugin:return j({},e,Hn(n.plugins,!0,e));default:return e}}}function Wn(t,e){return t.substring(e.length+1,t.length)}function Hn(t,e,n){return t.reduce(function(r,i){return r[i]=j({},n[i],{enabled:e}),r},n)}function Fn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var qi={last:{},history:[]};function Qi(t,e){t===void 0&&(t=qi);var n=e.options,r=e.meta;if(e.type===C.track){var i=Fn(j({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return j({},t,{last:i,history:t.history.concat(i)})}return t}var eo={actions:[]};function to(t,e){t===void 0&&(t=eo);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===C.identify?[e].concat(t.actions):t.actions.concat(e),j({},t,{actions:r});case"dequeue":return[];default:return t}}var Jn=/#.*$/;function no(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Jn,""):"")}var Xn,Vn,Yn,Gn,ro=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,h=o.hash,f=o.search,u=function(p){var d=function(){if(H){for(var w,I=document.getElementsByTagName("link"),v=0;w=I[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+p:window.location.href.replace(Jn,"")}(f),c={title:n,url:u,path:no(u),hash:h,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),j({},c,t)},io={last:{},history:[]};function oo(t,e){t===void 0&&(t=io);var n=e.options;if(e.type===C.page){var r=Fn(j({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return j({},t,{last:r,history:t.history.concat(r)})}return t}Xn=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"}(),Vn=H?document.referrer:null,Yn=Ui(),Gn=zi();var Bn={initialized:!1,sessionId:qe(),app:null,version:null,debug:!1,offline:!!H&&!navigator.onLine,os:{name:Xn},userAgent:H?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Gn,locale:Yn,campaign:{},referrer:Vn};function ao(t,e){t===void 0&&(t=Bn);var n=t.initialized,r=e.campaign;switch(e.type){case C.campaign:return j({},t,{campaign:r});case C.offline:return j({},t,{offline:!0});case C.online:return j({},t,{offline:!1});default:return n?t:j({},Bn,t,{initialized:!0})}}var so=["plugins","reducers","storage"];function co(t,e,n){if(H){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function uo(t){var e=co.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function qn(){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 Qn(t){return function(){return Ce(Ce.apply(null,arguments),qn())}}function xt(t){return t?Sn(t)?t:[t]:[]}function er(t,e,n){t===void 0&&(t={});var r,i,o=qe();return e&&(De[o]=(r=e,i=function(a){for(var s,h=a||Array.prototype.slice.call(arguments),f=0;f<h.length;f++)if(G(h[f])){s=h[f];break}return s}(n),function(a){i&&i(a),r(a)})),j({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function lo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,g){if(G(g))return m.middlewares=m.middlewares.concat(g),m;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var T=g.EVENTS?Object.keys(g.EVENTS).map(function(D){return g.EVENTS[D]}):[];m.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(m.methods[g.name]=Object.keys(g.methods).reduce(function(D,J){var Z;return D[J]=(Z=g.methods[J],function(){for(var W=Array.prototype.slice.call(arguments),M=new Array(Z.length),re=0;re<W.length;re++)M[re]=W[re];return M[M.length]=k,Z.apply({instance:k},M)}),D},{}),delete g.methods);var $=Object.keys(g).concat(T),N=new Set(m.events.concat($));if(m.events=Array.from(N),m.pluginsArray=m.pluginsArray.concat(g),m.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return m.plugins[g.name]=g,m.plugins[g.name].loaded||(m.plugins[g.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ve,setItem:we,removeItem:Oe},o=function(m){return function(g,T,$){return T.getState("user")[g]||($&&B($)&&$[g]?$[g]:xn(m)[g]||ve(Tt(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!Pt.includes(m)}).sort(),h=new Set(s.concat(tt).filter(function(m){return!Pt.includes(m)})),f=Array.from(h).sort(),u=function(){return a},c=new Gi,p=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},v=Ri(),_=xn(i),S=j({},_,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=qe());var y=j({enable:function(m,g){return new Promise(function(T){b.dispatch({type:C.enablePlugin,plugins:xt(m),_:{originalAction:C.enablePlugin}},T,[g])})},disable:function(m,g){return new Promise(function(T){b.dispatch({type:C.disablePlugin,plugins:xt(m),_:{originalAction:C.disablePlugin}},T,[g])})}},r.methods),l=!1,k={identify:function(m,g,T,$){try{var N=ce(m)?m:null,D=B(m)?m:g,J=T||{},Z=k.user();we(Tt(de),N);var W=N||D.userId||o(de,k,D);return Promise.resolve(new Promise(function(M){b.dispatch(j({type:C.identifyStart,userId:W,traits:D||{},options:J,anonymousId:Z.anonymousId},Z.id&&Z.id!==N&&{previousId:Z.id}),M,[g,T,$])}))}catch(M){return Promise.reject(M)}},track:function(m,g,T,$){try{var N=B(m)?m.event:m;if(!N||!ce(N))throw new Error("EventMissing");var D=B(m)?m:g||{},J=B(T)?T:{};return Promise.resolve(new Promise(function(Z){b.dispatch({type:C.trackStart,event:N,properties:D,options:J,userId:o(de,k,g),anonymousId:o(Ae,k,g)},Z,[g,T,$])}))}catch(Z){return Promise.reject(Z)}},page:function(m,g,T){try{var $=B(m)?m:{},N=B(g)?g:{};return Promise.resolve(new Promise(function(D){b.dispatch({type:C.pageStart,properties:ro($),options:N,userId:o(de,k,$),anonymousId:o(Ae,k,$)},D,[m,g,T])}))}catch(D){return Promise.reject(D)}},user:function(m){if(m===de||m==="id")return o(de,k);if(m===Ae||m==="anonId")return o(Ae,k);var g=k.getState("user");return m?yn(g,m):g},reset:function(m){return new Promise(function(g){b.dispatch({type:C.resetStart},g,m)})},ready:function(m){return l&&m({plugins:y,instance:k}),k.on(C.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!G(g))return!1;if(m===C.bootstrap)throw new Error(".on disabled for "+m);var T=/Start$|Start:/;if(m==="*"){var $=function(Z){return function(W){return function(M){return M.type.match(T)&&g({payload:M,instance:k,plugins:a}),W(M)}}},N=function(Z){return function(W){return function(M){return M.type.match(T)||g({payload:M,instance:k,plugins:a}),W(M)}}};return p($,nt),p(N,rt),function(){d($,nt),d(N,rt)}}var D=m.match(T)?nt:rt,J=function(Z){return function(W){return function(M){return M.type===m&&g({payload:M,instance:k,plugins:a,abort:I}),W(M)}}};return p(J,D),function(){return d(J,D)}},once:function(m,g){if(!m||!G(g))return!1;if(m===C.bootstrap)throw new Error(".once disabled for "+m);var T=k.on(m,function($){g({payload:$.payload,instance:k,plugins:a,abort:I}),T()});return T},getState:function(m){var g=b.getState();return m?yn(g,m):Object.assign({},g)},dispatch:function(m){var g=ce(m)?{type:m}:m;if(tt.includes(g.type))throw new Error("reserved action "+g.type);var T=j({},g,{_:j({originalAction:g.type},m._||{})});b.dispatch(T)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(m,g,T){b.dispatch({type:C.setItemStart,key:m,value:g,options:T})},removeItem:function(m,g){b.dispatch({type:C.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){k.storage.setItem(le,m,g)},events:{core:tt,plugins:s}},P=r.middlewares.concat([function(m){return function(g){return function(T){return T.meta||(T.meta=er()),g(T)}}},w(nt),Vi(k,u,{all:f,plugins:s}),Yi(i),Wi(k),Fi(k),w(rt)]),O={context:ao,user:Hi(i),page:oo,track:Qi,plugins:Bi(u),queue:to},x=Ce,z=Ce;if(H&&t.debug){var L=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;L&&(x=L({trace:!0,traceLimit:25})),z=function(){return arguments.length===0?qn():B(typeof arguments[0])?Qn():Qn().apply(null,arguments)}}var F,A=function(m){return Object.keys(m).reduce(function(g,T){return so.includes(T)||(g[T]=m[T]),g},{})}(t),R=r.pluginsArray.reduce(function(m,g){var T=g.name,$=g.config,N=g.loaded,D=r.pluginEnabled[T];return m[T]={enabled:D,initialized:!!D&&!g.initialize,loaded:!!N({config:$}),config:$},m},{}),K={context:A,user:S,plugins:R},b=Tn(function(m){for(var g=Object.keys(m),T={},$=0;$<g.length;$++){var N=g[$];typeof m[N]===ue&&(T[N]=m[N])}var D,J=Object.keys(T);try{(function(Z){Object.keys(Z).forEach(function(W){var M=Z[W];if(typeof M(void 0,{type:"@@redux/INIT"})===oe||typeof M(void 0,{type:Mi})===oe)throw new Error("reducer "+W+" "+oe)})})(T)}catch(Z){D=Z}return function(Z,W){if(Z===void 0&&(Z={}),D)throw D;for(var M=!1,re={},He=0;He<J.length;He++){var lt=J[He],Tr=Z[lt],Kt=(0,T[lt])(Tr,W);if(typeof Kt===oe){var qo=Zi(lt,W);throw new Error(qo)}re[lt]=Kt,M=M||Kt!==Tr}return M?re:Z}}(j({},O,e)),K,z(x(Ki.apply(void 0,P))));b.dispatch=(F=b.dispatch,function(m,g,T){var $=j({},m,{meta:er(m.meta,g,xt(T))});return F.apply(null,[$])});var E=Object.keys(a);b.dispatch({type:C.bootstrap,plugins:E,config:A,params:v,user:S,initialUser:n,persistedUser:_});var U=E.filter(function(m){return r.pluginEnabled[m]}),Y=E.filter(function(m){return!r.pluginEnabled[m]});return b.dispatch({type:C.registerPlugins,plugins:E,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var T=m.bootstrap,$=m.config,N=m.name;T&&G(T)&&T({instance:k,config:$,payload:m}),b.dispatch({type:C.registerPluginType(N),name:N,enabled:r.pluginEnabled[N],plugin:m}),r.pluginsArray.length===g+1&&b.dispatch({type:C.initializeStart,plugins:U,disabled:Y})}),uo(function(m){b.dispatch({type:m?C.offline:C.online})}),function(m,g,T){setInterval(function(){return Nn(m,g,T)},3e3)}(b,u,k),k}var nt="before",rt="after",Me="cookie",ke=rr(),tr=it,ho=it;function nr(t){return ke?it(t,"",-1):Oe(t)}function rr(){if(ke!==void 0)return ke;var t="cookiecookie";try{it(t,t),ke=document.cookie.indexOf(t)!==-1,nr(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",fo=Et.bind(null,"localStorage");je("localStorage","getItem",ve),je("localStorage","setItem",we),je("localStorage","removeItem",Oe);var Ke="sessionStorage",po=Et.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 mo=fo(),go=po(),yo=rr();function ir(t,e){if(t){var n=At(e),r=!zt(n),i=$t(n)?Ne(localStorage.getItem(t)):void 0;if(r&&!Ee(i))return i;var o=Nt(n)?Ne(tr(t)):void 0;if(r&&o)return o;var a=Ut(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 vo(t,e,n){if(t&&!Ee(e)){var r={},i=At(n),o=JSON.stringify(e),a=!zt(i);return $t(i)&&(r[Ze]=at(Ze,e,Ne(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ze]:Nt(i)&&(r[Me]=at(Me,e,Ne(tr(t))),ho(t,o),a)?r[Me]:Ut(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 wo(t,e){if(t){var n=At(e),r=ir(t,bn),i={};return!Ee(r.localStorage)&&$t(n)&&(localStorage.removeItem(t),i[Ze]=r.localStorage),!Ee(r.cookie)&&Nt(n)&&(nr(t),i[Me]=r.cookie),!Ee(r.sessionStorage)&&Ut(n)&&(sessionStorage.removeItem(t),i[Ke]=r.sessionStorage),!Ee(r.global)&&ot(n,Re)&&(Oe(t),i[Re]=r.global),i}}function At(t){return t?ce(t)?t:t.storage:wn}function $t(t){return mo&&ot(t,Ze)}function Nt(t){return yo&&ot(t,Me)}function Ut(t){return go&&ot(t,Ke)}function zt(t){return t===bn||t==="all"}function ot(t,e){return t===wn||t===e||zt(t)}function at(t,e,n){return{location:t,current:e,previous:n}}var bo={setItem:vo,getItem:ir,removeItem:wo};function ko(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function or(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 ar(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?or(Object(n),!0).forEach(function(r){ko(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):or(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Io(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:bo};return lo(ar(ar({},e),t))}function So(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(h){return r=i.push(h),r>=o&&a(),r},size:function(){return i.length},end:function(h){h&&a(),clearInterval(n)}}}function _o(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(...h){var c;const f=((c=h[2])==null?void 0:c.toString())||"",u=Po(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,h)}})}function Eo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Po(t){return["#","?"].forEach(e=>t=Eo(t,e)),t}function To(){_o(()=>{ae.page()})}function Oo(t){if(t===void 0&&(t={}),!H)return _t;var e=cr(),n=Rt(),r=sr(),i=st(r,e),o=st(n,e),a=[],s=[],h=[],f=r,u=i,c=o,p=Object.keys(t);if(!p.length)return _t;var d=p.map(function(I){return Number(I)}),w=Li(function(){var I=cr(),v=function(A,R){return R.map(function(K){return K===100?A-5:A*(K/100)})}(I,d),_=Rt(),S=sr(),y=st(S,I),l=st(_,I);if(u=y>u?y:u,c=l<c?l:c,!(a.length>=d.length)){var k=f===S,P="up";k?P="initial":f<=S&&(P="down");var O=v,x=d;(P==="up"||k)&&(O=v.slice().reverse(),x=d.slice().reverse());var z=x.reduce(function(A,R,K){var b=O[K];return h.includes(R)&&S<=b&&(h=h.filter(function(E){return E!==R}),A.singleFunction=R),P==="down"&&!a.includes(R)&&S>=b&&R>o?(s.push(R),A.callbacks=A.callbacks.concat(R),A):P==="up"&&!a.includes(R)&&S<=b&&R<=y?(A.foundFunc=[R],A):(k&&S>=b&&A.foundFunc.length===0&&(A.foundFunc=[R]),!s.includes(R)&&S>=b&&(s.push(R),A.singleFunction?h.push(R):A.singleFunction=R),A)},{foundFunc:[],singleFunction:null,callbacks:[],direction:P});if(f=S,P==="down"&&z.callbacks&&z.callbacks.forEach(function(A){G(t[A])&&(t[A]({trigger:A,direction:P,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(A))}),z.singleFunction){var L=z.singleFunction,F=z.direction;G(t[L])&&t[L]({trigger:L,direction:F,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(L)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function Rt(){return H?document.body.scrollTop||document.documentElement.scrollTop:0}function jo(){return H?window.innerHeight||document.documentElement.clientHeight:0}function sr(){return Math.round(Rt()+jo())}function cr(){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 ur="EventListener";function Co(t){return function(e,n,r,i){var o=r||_t,a=i||!1;if(!H)return o;var s=ct(n),h=ct(e,!0);if(!h.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var p=c?"add"+ur:"remove"+ur,d=0;d<h.length;d++){var w=h[d];f[d]=c?a&&a.once?xo(o):o:f[d]||o;for(var I=0;I<s.length;I++)w[p]?w["on"+s[I]]=c?f[d]:null:w[p](s[I],f[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=Ni(t);return e?o.map(function(a){return ce(a)?ct(a,!0):a}).flat():o}function xo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var Dt=Co("Event");function lr(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}lr.bind(null,"onerror"),lr.bind(null,"onload");var dr=typeof window>"u",hr="hidden";function Ao(t){if(dr)return!1;var e=$o(),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 $o(){var t=["webkit","moz","ms","o"];return dr||hr in document?hr:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var No=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Uo(t,e){e===void 0&&(e={});var n=function(a,s){var h=this,f=!1;return function(u){f||(a.call(h,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=Ao(function(s){s||n({type:"tabVisible"})});return r=[a].concat(No.map(function(s){return Dt(document,s,n)})).concat(Dt(window,"load",n)).concat(Dt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function zo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,h=t.throttle,f=h===void 0?2e3:h,u=!1,c=!1,p=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(We(p),v),i&&u&&(u=!1,i(We(n),v),p=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(We(p),v))},s)}var I=Uo(w,{throttle:f});return{disable:function(){c=!0,u=!1,d();var v=I();return function(){return c=!1,p=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:We(p,c),idle:u?We(n,c):0}}}}function We(t,e){return e?0:Math.round((new Date-t)/1e3)}const fr=5e3;class Ro{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),zo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:fr}),Oo({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*fr: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 pr="sesamy_session_id";function Do(){let t=sessionStorage.getItem(pr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(pr,t)),t}let mr=!1,Lt,gr,ut;function Lo({clientId:t,enabled:e=!0,endpoint:n=oi}){if(Lt=t,gr=e,ut=n,!gr)return;To();const r=new Ro({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})}});Ko(document.body,()=>{r.flush()}),Wo(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",{}),Mt.flush(),await ae.reset()})}function yr(t){return JSON.stringify(t.map(e=>({...e,clientId:Lt,requestId:Math.random().toString(36).slice(2,9),sessionId:Do(),timestamp:new Date().toISOString(),version:St,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:gn,userAgent:navigator.userAgent,clientId:Lt}})))}const Mt=So(async t=>{if(t.length>0){const e=yr(t);mr?navigator.sendBeacon(ut,e):(await fetch(ut,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Zt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(ut,yr([n]))}else Mt.push(t)}const ae=Io({app:gn,version:St,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Zt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Zt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Zt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Mo(t,e){ae.track(t,e)}function Zo(){return mr=!0,Mt.flush()}const vr=new Map;function Ko(t,e){vr.set(t,e)}window.addEventListener("beforeunload",()=>{vr.forEach((t,e)=>{t.bind(e)()}),Zo()});const wr=new Map;function Wo(t,e){wr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&wr.forEach((t,e)=>{t.bind(e)()})});const br="sesamySignedURLs";function kr(){const t=sessionStorage.getItem(br);return t?JSON.parse(t):[]}function Ho(t){const e=kr();e.push(t),sessionStorage.setItem(br,JSON.stringify(e))}function Fo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:h,getProfile:f,updateProfile:u,getTags:c,deleteTag:p,setTag:d,getUserMetadata:w,listUserMetadata:I,setUserMetadata:v,deleteUserMetadata:_,getTally:S,getTallies:y,pushTally:l,deleteTally:k,getProduct:P,getPaymentIssues:O,autoOnboardProduct:x}=_i(t),z={auth:{getUser:f,isAuthenticated:si,loginWithRedirect:sn,logout:li,setToken:cn},profile:{get:f,update:u},analytics:{track:Mo},tags:{list:c,set:d,delete:p},entitlements:{get:e,list:n,access:r,signedLinks:kr},contracts:{get:o,list:a},bills:{get:s,list:h},userMetadata:{get:w,list:I,set:v,delete:_},tallies:{get:S,list:y,push:l,delete:k},subscriptions:{list:i},products:{get:P,autoOnboard:x},getVersion:Jo,getPaymentIssues:O,clearCache:ne};return t.namespace&&(window[t.namespace]=z),z}function Jo(){return St}function Xo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){cn(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 Ir="sesamy-refresh",Sr="force-refetch-entitlements";function Vo(){const t=new URLSearchParams(window.location.search),e=t.get(Sr),n=t.get(Ir);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Sr),t.delete(Ir),r.search=t.toString(),ne(),window.history.replaceState(null,"",r)}}function Yo(){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;Ho({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 _r="sesamy-user";async function Go(){const e=new URLSearchParams(window.location.search).get(_r);if(!e)return;const n=await ci();(n==null?void 0:n.email)!==e&&sn();const r=new URL(window.location.href);r.searchParams.delete(_r),window.history.replaceState(null,"",r)}const Er="sesamy-purchase";function Bo(){const t=new URLSearchParams(window.location.search),e=t.get(Er);if(e!==null){const n=new URL(window.location.href);t.delete(Er),n.search=t.toString(),X(te.PURCHASE,{itemSrc:e}),ne(),window.history.replaceState(null,"",n)}}async function Pr(t){Lo({clientId:t.clientId,...t.analytics}),await ai({clientId:t.clientId,...t.auth});const e=Fo(t.api||{});return X(te.READY,{}),Xo(),Vo(),Yo(),await Go(),Bo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Pr(e)}catch(e){console.error("Failed to parse config",e)}}return ie.init=Pr,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"}),ie}({});
|
|
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",!on(n))throw new Error(`Invalid cache location "${n}"`);r=on(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Ie:Qr,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:ei;var o;this.scope=Je("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Yr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Xt,this.cacheManager=new Vr(r,r.allKeys?void 0:new ri(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 ni)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Jt)));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 Br({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(pt()),o=Gt(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 Fe().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 Mr(s.popup)))},1e3),m=setTimeout(()=>{clearInterval(c),p(new Lr(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=an(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 Dr(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({},Rr),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=an(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 Vt(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 Jr(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 ai(t){const e=new oi(t);return await e.checkSession(),e}const wt="sesamy.com",si="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;const kt="sesamyAccessToken",It="sesamyExpires";function St(){const t=localStorage.getItem(It);if(!(t&&parseInt(t,10)<new Date().getTime()))return localStorage.getItem(kt)}async function ci(t){if(t.enabled!==!1&&(Q=await ai({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 sn(){if(St())return!0;if(!Q)throw new Error("Auth0 client not initialized");return Q.isAuthenticated()}async function ui(){if(St())return{sub:"local",name:"Local User"};if(!Q)throw new Error("Auth0 client not initialized");return Q.getUser()}function cn(){if(!Q)throw new Error("Auth0 client not initialized");return Q.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function un(t=!0){const e=St();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 li(){if(localStorage.removeItem(kt),localStorage.removeItem(It),!Q)throw new Error("Auth0 client not initialized");return V(te.LOGOUT,{}),Q.logout({logoutParams:{returnTo:window.location.href}})}function di(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 ln(t,e){localStorage.setItem(kt,t),e&&localStorage.setItem(It,JSON.stringify(e*1e3+new Date().getTime()));const n=di(t);V(te.AUTHENTICATED,n)}const hi=(t,e)=>e.skipDedupe||e.method!=="GET",fi=(t,e)=>e.method+"@"+t,pi=t=>t.clone(),dn=({skip:t=hi,key:e=fi,resolver:n=pi}={})=>{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)}}},mi=(t,e)=>t*e,gi=t=>t&&t.ok,hn=({delayTimer:t=500,delayRamp:e=mi,maxAttempts:n=10,until:r=gi,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)})},yi="application/json",fn="Content-Type",Se=Symbol(),pn=Symbol();function mn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===fn.toLowerCase()))===null||e===void 0?void 0:e[1]}function gn(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 vi(t,e=!1){_e.options=e?t:ge(_e.options,t)}function wi(t,e=!1){_e.polyfills=e?t:ge(_e.polyfills,t)}function bi(t){_e.errorType=t}const ki=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class yn extends Error{}const Ii=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=ki(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 yn;if(l.cause=d,l.stack=l.stack+`
|
|
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(pn);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)},Si={_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({[fn]: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(pn,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=mn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||gn(i));return r=n?o?r.json(n,i):r.body(n):r,Ii(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=mn(this._options.headers);return this.content(e||gn(n)&&n||yi).body(JSON.stringify(t))}};function se(t="",e={}){return{...Si,_url:t,_options:e}}se.default=se,se.options=vi,se.errorType=bi,se.polyfills=wi,se.WretchError=yn;function ne(){sessionStorage.removeItem(bt),V(te.CLEAR_CACHE,{})}function _i(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 un(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(),dn(),hn({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,dn(),hn({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 D(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 sn()?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 un(!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:D,getProduct:z,getPaymentIssues:R,autoOnboardProduct:K,openHostedAccountPage:j}}const vn="@sesamy/sesamy-js",_t="1.3.2";function wn(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",bn="object",Et=function(){},kn="any",In="*",ye="__",Ve=typeof process<"u"?process:{};Ve.env&&Ve.env.NODE_ENV;var F=typeof document<"u";Ve.versions!=null&&Ve.versions.node!=null,typeof Deno<"u"&&Deno.core,F&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Sn(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ei=Sn.bind(null,"toUpperCase"),Pi=Sn.bind(null,"toLowerCase");function Ti(t){return _n(t)?Ei("null"):typeof t=="object"?xi(t):Object.prototype.toString.call(t).slice(8,-1)}function Ye(t,e){e===void 0&&(e=!0);var n=Ti(t);return e?Pi(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"),Oi=ze.bind(null,"boolean");ze.bind(null,"symbol");function _n(t){return t===null}function ji(t){return Ye(t)==="number"&&!isNaN(t)}function En(t){return Ye(t)==="array"}function B(t){if(!Ci(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ci(t){return t&&(typeof t=="object"||t!==null)}function xi(t){return G(t.constructor)?t.constructor.name:null}function Ai(t){return t instanceof Error||ce(t.message)&&t.constructor&&ji(t.constructor.stackTraceLimit)}function Pn(t,e){if(typeof e!="object"||_n(e))return!1;if(e instanceof t)return!0;var n=Ye(new t(""));if(Ai(e))for(;e;){if(Ye(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Pn.bind(null,TypeError),Pn.bind(null,SyntaxError);function Ge(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?$i(t,e):n}function $i(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 Ni(t){return t?En(t)?t:[t]:[]}function Tn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ui(){if(F){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function zi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ri(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=Tn(n[1]),a=Tn(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&&(Di(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 F&&window.location.search.substring(1)}(t))}function Di(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 Li(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===bn&&self.self===self&&self||typeof global===bn&&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(Pt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Te[Pe]||(Te[Pe]={});var Qe={};function Pt(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",Mi="@@redux/"+Math.random().toString(36),On=function(){return typeof Symbol===ue&&Symbol.observable||"@@observable"}(),et=" != "+ue;function jn(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(jn)(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"})}})[On]=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)}}})[On]=function(){return this},d},r}function Zi(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 Ki(){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"],Tt=["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}}),Cn=/^utm_/,xn=/^an_prop_/,An=/^an_trait_/;function Wi(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(Cn)||k.match(/^(d|g)clid/)){var v=k.replace(Cn,"");w.campaign[v==="campaign"?"name":v]=o[k]}return k.match(xn)&&(w.props[k.replace(xn,"")]=o[k]),k.match(An)&&(w.traits[k.replace(An,"")]=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 Hi(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 $n(t){return{userId:t.getItem(be),anonymousId:t.getItem(le),traits:t.getItem(xe)}}var Ot=function(t){return ye+"TEMP"+ye+t};function Fi(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(Ot(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 De={};function Nn(t,e){De[t]&&G(De[t])&&(De[t](e),delete De[t])}function Un(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 Un(t,e,n-10).then(r,i)})})}function Ji(t){return{abort:t}}function zn(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:Ji}))&&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 jt=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(D,z,J,$,R){return function(K,j){var I=$?$.name:D,E=j&&Le(j)?j:J;if($&&(!(E=j&&Le(j)?j:[D]).includes(D)||E.length!==1))throw new Error("Method "+z+" can only abort "+D+" plugin. "+JSON.stringify(E)+" input valid");return C({},R,{abort:{reason:K,plugins:E,caller:z,_:I}})}}(T,O,_,l,S):function(D,z){return function(){throw new Error(D.type+" action not cancellable. Remove abort in "+z)}}(S,O);return{payload:Xi(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,D){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:Ln(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),xt(A,b))return Ct({data:A,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(O);if(xt(O,b))return l&&Ct({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 D=w(v[b],o[b]);return Promise.resolve(T[c]({abort:D.abort,payload:A,instance:r,config:Ln(b,p,o),plugins:p})).then(function(z){var J=B(z)?z:{},$=C({},O,J),R=v[b];if(xt(R,b))Ct({data:R,method:c,instance:r,pluginName:b,store:s});else{var K=c+":"+b;(K.match(/:/g)||[]).length<2&&!c.match(Rn)&&!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(Rn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(f.plugins.includes(c),_._&&_._.originalAction===c)return _;var S=C({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});Kn(_,e.exact.length)&&!c.match(/End$/)&&(S=C({},S,{type:_.type+"Aborted"})),s.dispatch(S)}return _})})}catch(v){return Promise.reject(v)}},$e=/Start$/,Rn=/^bootstrap/,Dn=/^ready/;function Ct(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(C({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Ln(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Mn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function Zn(t,e){var n=t.replace($e,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function xt(t,e){var n=t.abort;return!!n&&(n===!0||Wn(n,e)||n&&Wn(n.plugins,e))}function Kn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ce(n))return!0;var r=n.plugins;return Le(n)&&n.length===e||Le(r)&&r.length===e}function Le(t){return Array.isArray(t)}function Wn(t,e){return!(!t||!Le(t))&&t.includes(e)}function Hn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Xi(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 Vi(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 Nn(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 Un(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(D){return!Tt.includes(D)})}),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 zn(i,e,t)},0),Promise.resolve(function(l,b,T,O,A){try{var D=G(b)?b():b,z=l.type,J=z.replace($e,"");if(l._&&l._.called)return Promise.resolve(l);var $=T.getState(),R=(I=D,(E=$.plugins)===void 0&&(E={}),(W=l.options)===void 0&&(W={}),Object.keys(I).filter(function(h){var g=W.plugins||{};return Oi(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 D[h]}));var K=R.map(function(h){return h.name}),j=function(h,g,P){var N=Zn(h).map(function(U){return Mn(U,g)});return g.reduce(function(U,L){var X=L.name,Z=Zn(h,X).map(function(He){return Mn(He,g)}),H=Z[0],M=Z[1],re=Z[2];return H.length&&(U.beforeNS[X]=H),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(jt({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:$,allPlugins:D,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(h){function g(){var U=function(){if(z.match($e))return Promise.resolve(jt({action:C({},P,{type:J+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:$,allPlugins:D,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(L){L.meta&&L.meta.hasCallback&&Nn(L.meta.rid,{payload:L})})}();return U&&U.then?U.then(function(){return h}):h}if(Kn(h,K.length))return h;var P,N=function(){if(z!==J)return Promise.resolve(jt({action:C({},h,{type:J}),data:{exact:j.during,namespaced:j.duringNS},state:$,allPlugins:D,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 Yi(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 Gi=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 Bi(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=Fn(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=Fn(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,Jn(n.plugins,!1,e));case x.enablePlugin:return C({},e,Jn(n.plugins,!0,e));default:return e}}}function Fn(t,e){return t.substring(e.length+1,t.length)}function Jn(t,e,n){return t.reduce(function(r,i){return r[i]=C({},n[i],{enabled:e}),r},n)}function Xn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var qi={last:{},history:[]};function Qi(t,e){t===void 0&&(t=qi);var n=e.options,r=e.meta;if(e.type===x.track){var i=Xn(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 eo={actions:[]};function to(t,e){t===void 0&&(t=eo);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 Vn=/#.*$/;function no(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Vn,""):"")}var Yn,Gn,Bn,qn,ro=function(t){if(t===void 0&&(t={}),!F)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(F){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(Vn,"")}(p),c={title:n,url:u,path:no(u),hash:f,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),C({},c,t)},io={last:{},history:[]};function oo(t,e){t===void 0&&(t=io);var n=e.options;if(e.type===x.page){var r=Xn(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}Yn=function(){if(!F)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"}(),Gn=F?document.referrer:null,Bn=Ui(),qn=zi();var Qn={initialized:!1,sessionId:qe(),app:null,version:null,debug:!1,offline:!!F&&!navigator.onLine,os:{name:Yn},userAgent:F?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:qn,locale:Bn,campaign:{},referrer:Gn};function ao(t,e){t===void 0&&(t=Qn);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({},Qn,t,{initialized:!0})}}var so=["plugins","reducers","storage"];function co(t,e,n){if(F){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function uo(t){var e=co.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function er(){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 tr(t){return function(){return Ce(Ce.apply(null,arguments),er())}}function At(t){return t?En(t)?t:[t]:[]}function nr(t,e,n){t===void 0&&(t={});var r,i,o=qe();return e&&(De[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 lo(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(L){return g.EVENTS[L]}):[];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(L,X){var Z;return L[X]=(Z=g.methods[X],function(){for(var H=Array.prototype.slice.call(arguments),M=new Array(Z.length),re=0;re<H.length;re++)M[re]=H[re];return M[M.length]=b,Z.apply({instance:b},M)}),L},{}),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]:$n(h)[g]||ve(Ot(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(h){return!Tt.includes(h)}).sort(),f=new Set(s.concat(tt).filter(function(h){return!Tt.includes(h)})),p=Array.from(f).sort(),u=function(){return a},c=new Gi,m=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Ri(),_=$n(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:At(h),_:{originalAction:x.enablePlugin}},P,[g])})},disable:function(h,g){return new Promise(function(P){j.dispatch({type:x.disablePlugin,plugins:At(h),_:{originalAction:x.disablePlugin}},P,[g])})}},r.methods),l=!1,b={identify:function(h,g,P,N){try{var U=ce(h)?h:null,L=B(h)?h:g,X=P||{},Z=b.user();we(Ot(de),U);var H=U||L.userId||o(de,b,L);return Promise.resolve(new Promise(function(M){j.dispatch(C({type:x.identifyStart,userId:H,traits:L||{},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 L=B(h)?h:g||{},X=B(P)?P:{};return Promise.resolve(new Promise(function(Z){j.dispatch({type:x.trackStart,event:U,properties:L,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(L){j.dispatch({type:x.pageStart,properties:ro(N),options:U,userId:o(de,b,N),anonymousId:o(Ae,b,N)},L,[h,g,P])}))}catch(L){return Promise.reject(L)}},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?wn(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(H){return function(M){return M.type.match(P)&&g({payload:M,instance:b,plugins:a}),H(M)}}},U=function(Z){return function(H){return function(M){return M.type.match(P)||g({payload:M,instance:b,plugins:a}),H(M)}}};return m(N,nt),m(U,rt),function(){d(N,nt),d(U,rt)}}var L=h.match(P)?nt:rt,X=function(Z){return function(H){return function(M){return M.type===h&&g({payload:M,instance:b,plugins:a,abort:k}),H(M)}}};return m(X,L),function(){return d(X,L)}},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?wn(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=nr()),g(P)}}},w(nt),Vi(b,u,{all:p,plugins:s}),Yi(i),Wi(b),Fi(b),w(rt)]),O={context:ao,user:Hi(i),page:oo,track:Qi,plugins:Bi(u),queue:to},A=Ce,D=Ce;if(F&&t.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(A=z({trace:!0,traceLimit:25})),D=function(){return arguments.length===0?er():B(typeof arguments[0])?tr():tr().apply(null,arguments)}}var J,$=function(h){return Object.keys(h).reduce(function(g,P){return so.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,L=r.pluginEnabled[P];return h[P]={enabled:L,initialized:!!L&&!g.initialize,loaded:!!U({config:N}),config:N},h},{}),K={context:$,user:S,plugins:R},j=jn(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 L,X=Object.keys(P);try{(function(Z){Object.keys(Z).forEach(function(H){var M=Z[H];if(typeof M(void 0,{type:"@@redux/INIT"})===oe||typeof M(void 0,{type:Mi})===oe)throw new Error("reducer "+H+" "+oe)})})(P)}catch(Z){L=Z}return function(Z,H){if(Z===void 0&&(Z={}),L)throw L;for(var M=!1,re={},He=0;He<X.length;He++){var lt=X[He],jr=Z[lt],Wt=(0,P[lt])(jr,H);if(typeof Wt===oe){var qo=Zi(lt,H);throw new Error(qo)}re[lt]=Wt,M=M||Wt!==jr}return M?re:Z}}(C({},O,e)),K,D(A(Ki.apply(void 0,T))));j.dispatch=(J=j.dispatch,function(h,g,P){var N=C({},h,{meta:nr(h.meta,g,At(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})}),uo(function(h){j.dispatch({type:h?x.offline:x.online})}),function(h,g,P){setInterval(function(){return zn(h,g,P)},3e3)}(j,u,b),b}var nt="before",rt="after",Me="cookie",ke=or(),rr=it,ho=it;function ir(t){return ke?it(t,"",-1):Oe(t)}function or(){if(ke!==void 0)return ke;var t="cookiecookie";try{it(t,t),ke=document.cookie.indexOf(t)!==-1,ir(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",fo=Pt.bind(null,"localStorage");je("localStorage","getItem",ve),je("localStorage","setItem",we),je("localStorage","removeItem",Oe);var Ke="sessionStorage",po=Pt.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 mo=fo(),go=po(),yo=or();function ar(t,e){if(t){var n=$t(e),r=!Rt(n),i=Nt(n)?Ne(localStorage.getItem(t)):void 0;if(r&&!Ee(i))return i;var o=Ut(n)?Ne(rr(t)):void 0;if(r&&o)return o;var a=zt(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 vo(t,e,n){if(t&&!Ee(e)){var r={},i=$t(n),o=JSON.stringify(e),a=!Rt(i);return Nt(i)&&(r[Ze]=at(Ze,e,Ne(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ze]:Ut(i)&&(r[Me]=at(Me,e,Ne(rr(t))),ho(t,o),a)?r[Me]:zt(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 wo(t,e){if(t){var n=$t(e),r=ar(t,In),i={};return!Ee(r.localStorage)&&Nt(n)&&(localStorage.removeItem(t),i[Ze]=r.localStorage),!Ee(r.cookie)&&Ut(n)&&(ir(t),i[Me]=r.cookie),!Ee(r.sessionStorage)&&zt(n)&&(sessionStorage.removeItem(t),i[Ke]=r.sessionStorage),!Ee(r.global)&&ot(n,Re)&&(Oe(t),i[Re]=r.global),i}}function $t(t){return t?ce(t)?t:t.storage:kn}function Nt(t){return mo&&ot(t,Ze)}function Ut(t){return yo&&ot(t,Me)}function zt(t){return go&&ot(t,Ke)}function Rt(t){return t===In||t==="all"}function ot(t,e){return t===kn||t===e||Rt(t)}function at(t,e,n){return{location:t,current:e,previous:n}}var bo={setItem:vo,getItem:ar,removeItem:wo};function ko(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sr(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 cr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sr(Object(n),!0).forEach(function(r){ko(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sr(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Io(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:bo};return lo(cr(cr({},e),t))}function So(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 _o(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=Po(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,f)}})}function Eo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Po(t){return["#","?"].forEach(e=>t=Eo(t,e)),t}function To(){_o(()=>{ae.page()})}function Oo(t){if(t===void 0&&(t={}),!F)return Et;var e=lr(),n=Dt(),r=ur(),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 Et;var d=m.map(function(k){return Number(k)}),w=Li(function(){var k=lr(),v=function($,R){return R.map(function(K){return K===100?$-5:$*(K/100)})}(k,d),_=Dt(),S=ur(),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 D=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"&&D.callbacks&&D.callbacks.forEach(function($){G(t[$])&&(t[$]({trigger:$,direction:T,scrollMin:c,scrollMax:u,range:[c,u]}),a.push($))}),D.singleFunction){var z=D.singleFunction,J=D.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 Dt(){return F?document.body.scrollTop||document.documentElement.scrollTop:0}function jo(){return F?window.innerHeight||document.documentElement.clientHeight:0}function ur(){return Math.round(Dt()+jo())}function lr(){if(!F)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 dr="EventListener";function Co(t){return function(e,n,r,i){var o=r||Et,a=i||!1;if(!F)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"+dr:"remove"+dr,d=0;d<f.length;d++){var w=f[d];p[d]=c?a&&a.once?xo(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=Ni(t);return e?o.map(function(a){return ce(a)?ct(a,!0):a}).flat():o}function xo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var Lt=Co("Event");function hr(t,e){return F&&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}hr.bind(null,"onerror"),hr.bind(null,"onload");var fr=typeof window>"u",pr="hidden";function Ao(t){if(fr)return!1;var e=$o(),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 $o(){var t=["webkit","moz","ms","o"];return fr||pr in document?pr:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var No=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Uo(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=Ao(function(s){s||n({type:"tabVisible"})});return r=[a].concat(No.map(function(s){return Lt(document,s,n)})).concat(Lt(window,"load",n)).concat(Lt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function zo(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=Uo(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 mr=5e3;class Ro{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),zo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:mr}),Oo({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*mr: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 gr="sesamy_session_id";function Do(){let t=sessionStorage.getItem(gr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(gr,t)),t}let yr=!1,Mt,vr,ut;function Lo({clientId:t,enabled:e=!0,endpoint:n=si}){if(Mt=t,vr=e,ut=n,!vr)return;To();const r=new Ro({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})}});Ko(document.body,()=>{r.flush()}),Wo(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",{}),Zt.flush(),await ae.reset()})}function wr(t){return JSON.stringify(t.map(e=>({...e,clientId:Mt,requestId:Math.random().toString(36).slice(2,9),sessionId:Do(),timestamp:new Date().toISOString(),version:_t,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:vn,userAgent:navigator.userAgent,clientId:Mt}})))}const Zt=So(async t=>{if(t.length>0){const e=wr(t);yr?navigator.sendBeacon(ut,e):(await fetch(ut,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Kt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(ut,wr([n]))}else Zt.push(t)}const ae=Io({app:vn,version:_t,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Kt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Kt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Kt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Mo(t,e){ae.track(t,e)}function Zo(){return yr=!0,Zt.flush()}const br=new Map;function Ko(t,e){br.set(t,e)}window.addEventListener("beforeunload",()=>{br.forEach((t,e)=>{t.bind(e)()}),Zo()});const kr=new Map;function Wo(t,e){kr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&kr.forEach((t,e)=>{t.bind(e)()})});const Ir="sesamySignedURLs";function Sr(){const t=sessionStorage.getItem(Ir);return t?JSON.parse(t):[]}function Ho(t){const e=Sr();e.push(t),sessionStorage.setItem(Ir,JSON.stringify(e))}function Fo(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:D}=_i(t),z={auth:{getUser:p,isAuthenticated:sn,loginWithRedirect:cn,logout:li,setToken:ln},profile:{get:p,update:u,openHostedAccountPage:D},analytics:{track:Mo},tags:{list:c,set:d,delete:m},entitlements:{get:e,list:n,access:r,signedLinks:Sr},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:Jo,getPaymentIssues:O,clearCache:ne};return t.namespace&&(window[t.namespace]=z),z}function Jo(){return _t}function Xo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){ln(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 _r="sesamy-refresh",Er="force-refetch-entitlements";function Vo(){const t=new URLSearchParams(window.location.search),e=t.get(Er),n=t.get(_r);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Er),t.delete(_r),r.search=t.toString(),ne(),window.history.replaceState(null,"",r)}}function Yo(){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;Ho({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 Pr="sesamy-user";async function Go(){const e=new URLSearchParams(window.location.search).get(Pr);if(!e)return;const n=await ui();(n==null?void 0:n.email)!==e&&cn();const r=new URL(window.location.href);r.searchParams.delete(Pr),window.history.replaceState(null,"",r)}const Tr="sesamy-purchase";function Bo(){const t=new URLSearchParams(window.location.search),e=t.get(Tr);if(e!==null){const n=new URL(window.location.href);t.delete(Tr),n.search=t.toString(),V(te.PURCHASE,{itemSrc:e}),ne(),window.history.replaceState(null,"",n)}}async function Or(t){Lo({clientId:t.clientId,...t.analytics}),await ci({clientId:t.clientId,...t.auth});const e=Fo({clientId:t.clientId,...t.api});return V(te.READY,{}),Xo(),Vo(),Yo(),await Go(),Bo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Or(e)}catch(e){console.error("Failed to parse config",e)}}return ie.init=Or,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"}),ie}({});
|