@sesamy/sesamy-js 1.6.1 → 1.7.0

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 CHANGED
@@ -16,23 +16,45 @@ The following events are tracked:
16
16
 
17
17
  The following methods are available on the `sesamy` object:
18
18
 
19
- - init - Initializes the sesamy-js library
19
+ - init: Initializes the sesamy-js library
20
20
  - auth
21
21
  - getUser: fetches the user's profile
22
22
  - isAuthenticated: checks if the user is authenticated
23
23
  - loginWithRedirect: redirects the user to the login page
24
24
  - logout: logs the user out
25
+ - setToken: stores a token in session storage
25
26
  - entitlements
26
- - get: fetches a single entitlement by id
27
- - list - fetches the user's entitlements
27
+ - get: gets a single entitlement by id
28
+ - list: lists the user's entitlements
29
+ - access: fetches the user's access url for an entitlement
28
30
  - profile
29
31
  - get: fetches the user's profile
30
32
  - update: updates the user's profile
31
33
  - tags
32
34
  - get: fetches the user's tags
33
35
  - set: sets a tag for the user
34
- - push: pushes a tag to a tag list
36
+ - delete: deletes a tag for the user
37
+ - userMetadata
38
+ - get: get the user's metadata by id
39
+ - list: list all the user's metadata
40
+ - set: sets the user's metadata
41
+ - delete: deletes the user's metadata by id
42
+ - tallies
43
+ - get: get a tally for a user by id
44
+ - list: list all tallies for a user
45
+ - push: push an item to a tally
46
+ - delete: delete a tally by id
47
+ - bills
48
+ - get: get a bill by id
49
+ - list: lists all the user's bills
50
+ - contracts
51
+ - get: get a contract by id
52
+ - list: lists all the user's contracts
53
+ - product
54
+ - get: get a product by sku
55
+ - autoOnboard: trigger the auto-onboarding process for a product by sku
35
56
  - getVersion: returns the version of the sesamy-js library
57
+ - clearCache: clears the cache for the sesamy-js library
36
58
 
37
59
  ## Events
38
60
 
@@ -40,6 +62,8 @@ The following events are emitted by the sesamy-js library:
40
62
 
41
63
  - `sesamyJsReady` - Emitted when the `sesamy-js` library is ready to be used
42
64
  - `sesamyJsAuthenticated` - Emitted when the user is authenticated
65
+ - `sesamyJsClearCache` - Emitted when the cache is cleared
66
+ - `sesamyJsLogout` - Emitted when the user logs out
43
67
 
44
68
  ## Usage
45
69
 
@@ -1,6 +1,6 @@
1
- "use strict";var Er=Object.defineProperty;var Tr=(t,e,n)=>e in t?Er(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>(Tr(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function rt(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function Q(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}var ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function xt(t,e){return t(e={exports:{}},e.exports),e.exports}var se=xt(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()}});jt(se);var Or=jt(xt(function(t,e){var n=ce&&ce.__awaiter||function(u,c,f,d){return new(f||(f=Promise))(function(w,k){function v(g){try{S(d.next(g))}catch(l){k(l)}}function E(g){try{S(d.throw(g))}catch(l){k(l)}}function S(g){g.done?w(g.value):new f(function(l){l(g.value)}).then(v,E)}S((d=d.apply(u,c||[])).next())})},r=ce&&ce.__generator||function(u,c){var f,d,w,k,v={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return k={next:E(0),throw:E(1),return:E(2)},typeof Symbol=="function"&&(k[Symbol.iterator]=function(){return this}),k;function E(S){return function(g){return function(l){if(f)throw new TypeError("Generator is already executing.");for(;v;)try{if(f=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{f=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([S,g])}}},i=ce;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(f){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",f="",d=0;d<u;d++)f+=c[Math.floor(Math.random()*c.length)];return f}var p=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,f){return f===void 0&&(f=5e3),n(this,void 0,void 0,function(){var d,w,k,v,E,S,g;return r(this,function(l){switch(l.label){case 0:d=Date.now()+h(4),w=Date.now()+f,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]:(E=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:E,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(S=v.getItemSync(k))!==null&&(g=JSON.parse(S)).id===this.id&&g.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()+h(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,f){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,E;return r(this,function(S){switch(S.label){case 0:return[4,se.default().lock(f)];case 1:return S.sent(),this.acquiredIatSet.has(f)?(k=this.storageHandler===void 0?a:this.storageHandler,(v=k.getItemSync(c))===null?(se.default().unlock(f),[2]):((E=JSON.parse(v)).timeRefreshed=Date.now(),k.setItemSync(c,JSON.stringify(E)),se.default().unlock(f),this.refreshLockWhileAcquired(c,f),[2])):(se.default().unlock(f),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(f){switch(f.label){case 0:return[4,new Promise(function(d){var w=!1,k=Date.now(),v=!1;function E(){if(v||(window.removeEventListener("storage",E),u.removeFromWaiting(E),clearTimeout(S),v=!0),!w){w=!0;var g=50-(Date.now()-k);g>0?setTimeout(d,g):d(null)}}window.addEventListener("storage",E),u.addToWaiting(E);var S=setTimeout(E,Math.max(0,c-Date.now()))})];case 1:return f.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(f){return f!==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(f){switch(f.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,f.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var f,d,w,k;return r(this,function(v){switch(v.label){case 0:return f=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=f.getItemSync(d))===null?[2]:(k=JSON.parse(w)).id!==this.id?[3,2]:[4,se.default().lock(k.iat)];case 1:v.sent(),this.acquiredIatSet.delete(k.iat),f.removeItemSync(d),se.default().unlock(k.iat),u.notifyWaiters(),v.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var f=Date.now()-5e3,d=c,w=[],k=0;;){var v=d.keySync(k);if(v===null)break;w.push(v),k++}for(var E=!1,S=0;S<w.length;S++){var g=w[S];if(g.includes(o)){var l=d.getItemSync(g);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<f||b.timeRefreshed!==void 0&&b.timeRefreshed<f)&&(d.removeItemSync(g),E=!0)}}}E&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=p}));const Pr={timeoutInSeconds:60},An={name:"auth0-spa-js",version:"2.1.3"},$n=()=>Date.now();let Y=class bt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,bt.prototype)}static fromPayload({error:e,error_description:n}){return new bt(e,n)}},jr=class zn extends Y{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,zn.prototype)}},kt=class Nn extends Y{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Nn.prototype)}},xr=class Dn extends kt{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Dn.prototype)}},Cr=class Un extends Y{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,Un.prototype)}},Ar=class Ln extends Y{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Ln.prototype)}},Rn=class Mn extends Y{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Kt(e,["default"])}', scope: '${Kt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,Mn.prototype)}};function Kt(t,e=[]){return t&&!e.includes(t)?t:""}const Be=()=>window.crypto,lt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Be().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Ft=t=>btoa(t),It=t=>{var{clientId:e}=t,n=Q(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()},Jt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),$r=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([$r(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Nr=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(p,u){const c=new MessageChannel;c.port1.onmessage=function(f){f.data.error?u(new Error(f.data.error)):p(f.data),c.port1.close()},h.postMessage(s,[c.port2])});var s,h},Dr=async(t,e,n,r,i,o,a=1e4)=>i?Nr(t,e,n,r,a,i,o):zr(t,r,a);async function Ur(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,h=Q(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const p=s?It(h):JSON.stringify(h);return await async function(u,c,f,d,w,k,v){let E,S=null;for(let $=0;$<3;$++)try{E=await Dr(u,f,d,w,k,v,c),S=null;break}catch(L){S=L}if(S)throw S;const g=E.json,{error:l,error_description:b}=g,P=Q(g,["error","error_description"]),{ok:j}=E;if(!j){const $=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Ar(l,$,P.mfa_token):l==="missing_refresh_token"?new Rn(f,d):new Y(l||"request_error",$)}return P}(`${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||An))}},e,s)}const Ke=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let le=class St{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 St({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new St({scope:n,audience:r,clientId:i})}},Lr=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@@"))}},Zn=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)}}()}},Rr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||$n}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 le({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 le({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=le.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((p,u)=>p&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&h})[0]}},Mr=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 $e=t=>typeof t=="number",Zr=["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"],Wr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,h,p]=a;if(a.length!==3||!s||!h||!p)throw new Error("ID token could not be decoded");const u=JSON.parse(Jt(h)),c={__raw:o},f={};return Object.keys(u).forEach(d=>{c[d]=u[d],Zr.includes(d)||(f[d]=u[d])}),{encoded:{header:s,payload:h,signature:p},header:JSON.parse(Jt(s)),claims:c,user:f}})(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&&!$e(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||!$e(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!$e(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&&$e(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&&$e(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 de=xt(function(t,e){var n=ce&&ce.__assign||function(){return n=Object.assign||function(h){for(var p,u=1,c=arguments.length;u<c;u++)for(var f in p=arguments[u])Object.prototype.hasOwnProperty.call(p,f)&&(h[f]=p[f]);return h},n.apply(this,arguments)};function r(h,p){if(!p)return"";var u="; "+h;return p===!0?u:u+"="+p}function i(h,p,u){return encodeURIComponent(h).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 f=new Date;f.setMilliseconds(f.getMilliseconds()+864e5*c.expires),c.expires=f}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 p={},u=h?h.split("; "):[],c=/(%[\dA-F]{2})+/gi,f=0;f<u.length;f++){var d=u[f].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(h,p,u){document.cookie=i(h,p,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,p){s(h,"",n(n({},p),{expires:-1}))}});jt(de),de.encode,de.parse,de.getAll;var Kr=de.get,Wn=de.set,Kn=de.remove;const we={get(t){const e=Kr(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),Wn(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Kn(t,n)}},Fr={get(t){return we.get(t)||we.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),Wn(`_legacy_${t}`,JSON.stringify(e),r),we.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Kn(t,n),we.remove(t,e),we.remove(`_legacy_${t}`,e)}},Jr={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 Hr(t,e,n){var r=e===void 0?null:e,i=function(h,p){var u=atob(h);if(p){for(var c=new Uint8Array(u.length),f=0,d=u.length;f<d;++f)c[f]=u.charCodeAt(f);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 Ht,Xt,Vt,dt,Xr=(Ht="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Xt=null,Vt=!1,function(t){return dt=dt||Hr(Ht,Xt,Vt),new Worker(dt,t)});const ht={};let Vr=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 Yr={memory:()=>new Zn().enclosedCache,localstorage:()=>new Lr},Yt=t=>Yr[t],Gt=t=>{const{openUrl:e,onRedirect:n}=t,r=Q(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},ft=new Or;let Gr=class{constructor(e){let n,r;if(this.userCache=new Zn().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await ft.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(!Be())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Be().subtle===void 0)throw new Error(`
1
+ "use strict";var Or=Object.defineProperty;var Pr=(t,e,n)=>e in t?Or(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>(Pr(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function We(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function Q(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}var le=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function At(t,e){return t(e={exports:{}},e.exports),e.exports}var ce=At(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()}});xt(ce);var jr=xt(At(function(t,e){var n=le&&le.__awaiter||function(u,c,f,d){return new(f||(f=Promise))(function(w,k){function v(g){try{S(d.next(g))}catch(l){k(l)}}function E(g){try{S(d.throw(g))}catch(l){k(l)}}function S(g){g.done?w(g.value):new f(function(l){l(g.value)}).then(v,E)}S((d=d.apply(u,c||[])).next())})},r=le&&le.__generator||function(u,c){var f,d,w,k,v={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return k={next:E(0),throw:E(1),return:E(2)},typeof Symbol=="function"&&(k[Symbol.iterator]=function(){return this}),k;function E(S){return function(g){return function(l){if(f)throw new TypeError("Generator is already executing.");for(;v;)try{if(f=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{f=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([S,g])}}},i=le;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(f){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",f="",d=0;d<u;d++)f+=c[Math.floor(Math.random()*c.length)];return f}var p=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,f){return f===void 0&&(f=5e3),n(this,void 0,void 0,function(){var d,w,k,v,E,S,g;return r(this,function(l){switch(l.label){case 0:d=Date.now()+h(4),w=Date.now()+f,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]:(E=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:E,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(S=v.getItemSync(k))!==null&&(g=JSON.parse(S)).id===this.id&&g.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()+h(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,f){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,E;return r(this,function(S){switch(S.label){case 0:return[4,ce.default().lock(f)];case 1:return S.sent(),this.acquiredIatSet.has(f)?(k=this.storageHandler===void 0?a:this.storageHandler,(v=k.getItemSync(c))===null?(ce.default().unlock(f),[2]):((E=JSON.parse(v)).timeRefreshed=Date.now(),k.setItemSync(c,JSON.stringify(E)),ce.default().unlock(f),this.refreshLockWhileAcquired(c,f),[2])):(ce.default().unlock(f),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(f){switch(f.label){case 0:return[4,new Promise(function(d){var w=!1,k=Date.now(),v=!1;function E(){if(v||(window.removeEventListener("storage",E),u.removeFromWaiting(E),clearTimeout(S),v=!0),!w){w=!0;var g=50-(Date.now()-k);g>0?setTimeout(d,g):d(null)}}window.addEventListener("storage",E),u.addToWaiting(E);var S=setTimeout(E,Math.max(0,c-Date.now()))})];case 1:return f.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(f){return f!==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(f){switch(f.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,f.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var f,d,w,k;return r(this,function(v){switch(v.label){case 0:return f=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=f.getItemSync(d))===null?[2]:(k=JSON.parse(w)).id!==this.id?[3,2]:[4,ce.default().lock(k.iat)];case 1:v.sent(),this.acquiredIatSet.delete(k.iat),f.removeItemSync(d),ce.default().unlock(k.iat),u.notifyWaiters(),v.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var f=Date.now()-5e3,d=c,w=[],k=0;;){var v=d.keySync(k);if(v===null)break;w.push(v),k++}for(var E=!1,S=0;S<w.length;S++){var g=w[S];if(g.includes(o)){var l=d.getItemSync(g);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<f||b.timeRefreshed!==void 0&&b.timeRefreshed<f)&&(d.removeItemSync(g),E=!0)}}}E&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=p}));const Cr={timeoutInSeconds:60},zn={name:"auth0-spa-js",version:"2.1.3"},Nn=()=>Date.now();let Y=class kt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,kt.prototype)}static fromPayload({error:e,error_description:n}){return new kt(e,n)}},xr=class Dn extends Y{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Dn.prototype)}},It=class Un extends Y{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Un.prototype)}},Ar=class Ln extends It{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Ln.prototype)}},$r=class Rn extends Y{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,Rn.prototype)}},zr=class Mn extends Y{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Mn.prototype)}},Zn=class Wn extends Y{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Ht(e,["default"])}', scope: '${Ht(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,Wn.prototype)}};function Ht(t,e=[]){return t&&!e.includes(t)?t:""}const Qe=()=>window.crypto,dt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Qe().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Jt=t=>btoa(t),St=t=>{var{clientId:e}=t,n=Q(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()},Xt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Nr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Dr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Nr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Ur=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(p,u){const c=new MessageChannel;c.port1.onmessage=function(f){f.data.error?u(new Error(f.data.error)):p(f.data),c.port1.close()},h.postMessage(s,[c.port2])});var s,h},Lr=async(t,e,n,r,i,o,a=1e4)=>i?Ur(t,e,n,r,a,i,o):Dr(t,r,a);async function Rr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,h=Q(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const p=s?St(h):JSON.stringify(h);return await async function(u,c,f,d,w,k,v){let E,S=null;for(let $=0;$<3;$++)try{E=await Lr(u,f,d,w,k,v,c),S=null;break}catch(L){S=L}if(S)throw S;const g=E.json,{error:l,error_description:b}=g,P=Q(g,["error","error_description"]),{ok:j}=E;if(!j){const $=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new zr(l,$,P.mfa_token):l==="missing_refresh_token"?new Zn(f,d):new Y(l||"request_error",$)}return P}(`${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||zn))}},e,s)}const He=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let he=class _t{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 _t({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new _t({scope:n,audience:r,clientId:i})}},Mr=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@@"))}},Kn=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)}}()}},Zr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Nn}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 he({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 he({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=he.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((p,u)=>p&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&h})[0]}},Wr=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 ze=t=>typeof t=="number",Kr=["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"],Fr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,h,p]=a;if(a.length!==3||!s||!h||!p)throw new Error("ID token could not be decoded");const u=JSON.parse(Xt(h)),c={__raw:o},f={};return Object.keys(u).forEach(d=>{c[d]=u[d],Kr.includes(d)||(f[d]=u[d])}),{encoded:{header:s,payload:h,signature:p},header:JSON.parse(Xt(s)),claims:c,user:f}})(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&&!ze(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||!ze(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!ze(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&&ze(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&&ze(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 fe=At(function(t,e){var n=le&&le.__assign||function(){return n=Object.assign||function(h){for(var p,u=1,c=arguments.length;u<c;u++)for(var f in p=arguments[u])Object.prototype.hasOwnProperty.call(p,f)&&(h[f]=p[f]);return h},n.apply(this,arguments)};function r(h,p){if(!p)return"";var u="; "+h;return p===!0?u:u+"="+p}function i(h,p,u){return encodeURIComponent(h).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 f=new Date;f.setMilliseconds(f.getMilliseconds()+864e5*c.expires),c.expires=f}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 p={},u=h?h.split("; "):[],c=/(%[\dA-F]{2})+/gi,f=0;f<u.length;f++){var d=u[f].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(h,p,u){document.cookie=i(h,p,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,p){s(h,"",n(n({},p),{expires:-1}))}});xt(fe),fe.encode,fe.parse,fe.getAll;var Hr=fe.get,Fn=fe.set,Hn=fe.remove;const be={get(t){const e=Hr(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),Fn(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Hn(t,n)}},Jr={get(t){return be.get(t)||be.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),Fn(`_legacy_${t}`,JSON.stringify(e),r),be.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Hn(t,n),be.remove(t,e),be.remove(`_legacy_${t}`,e)}},Xr={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 Vr(t,e,n){var r=e===void 0?null:e,i=function(h,p){var u=atob(h);if(p){for(var c=new Uint8Array(u.length),f=0,d=u.length;f<d;++f)c[f]=u.charCodeAt(f);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 Vt,Yt,Gt,ht,Yr=(Vt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Yt=null,Gt=!1,function(t){return ht=ht||Vr(Vt,Yt,Gt),new Worker(ht,t)});const ft={};let Gr=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 Br={memory:()=>new Kn().enclosedCache,localstorage:()=>new Mr},Bt=t=>Br[t],qt=t=>{const{openUrl:e,onRedirect:n}=t,r=Q(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},pt=new jr;let qr=class{constructor(e){let n,r;if(this.userCache=new Kn().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await pt.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(!Qe())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Qe().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",!Yt(n))throw new Error(`Invalid cache location "${n}"`);r=Yt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?we:Fr,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:Jr;var o;this.scope=Ke("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Mr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||$n,this.cacheManager=new Rr(r,r.allKeys?void 0:new Vr(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 Xr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||An)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${It(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Wr({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=Ft(lt()),o=Ft(lt()),a=lt(),s=(u=>{const c=new Uint8Array(u);return(f=>{const d={"+":"-","/":"_","=":""};return f.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Be().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,f,d,w,k,v,E)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),f),{scope:Ke(c,f.scope),response_type:"code",response_mode:E||"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(h);return{nonce:o,code_verifier:a,scope:h.scope,audience:h.audience||"default",redirect_uri:h.redirect_uri,state:i,url:p}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const h=window.screenX+(window.innerWidth-400)/2,p=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${h},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((h,p)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(f),window.removeEventListener("message",u,!1),p(new Cr(s.popup)))},1e3),f=setTimeout(()=>{clearInterval(c),p(new xr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(f),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return p(Y.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 Y("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=Gt(e),{openUrl:i,fragment:o,appState:a}=r,s=Q(r,["openUrl","fragment","appState"]),h=((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=Q(p,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),h&&{organization:h}));const f=o?`${u}#${o}`:u;i?await i(f):window.location.assign(f)}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 f=new URLSearchParams(c);return{state:f.get("state"),code:f.get("code")||void 0,error:f.get("error")||void 0,error_description:f.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new Y("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new jr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new Y("state_mismatch","Invalid state");const h=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: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:Ke(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=ht[a];return s||(s=o().finally(()=>{delete ht[a],s=null}),ht[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=Q(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})(()=>ft.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new kt;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:h}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:h})}finally{await ft.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:Ke(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Pr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new le({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=Q(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${It(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Gt(e),{openUrl:r}=n,i=Q(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:p,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new Y("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,f=await((w,k,v=60)=>new Promise((E,S)=>{const g=window.document.createElement("iframe");g.setAttribute("width","0"),g.setAttribute("height","0"),g.style.display="none";const l=()=>{window.document.body.contains(g)&&(window.document.body.removeChild(g),window.removeEventListener("message",b,!1))};let b;const P=setTimeout(()=>{S(new kt),l()},1e3*v);b=function(j){if(j.origin!=k||!j.data||j.data.type!=="authorization_response")return;const $=j.source;$&&$.close(),j.data.response.error?S(Y.fromPayload(j.data.response)):E(j.data.response),clearTimeout(P),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(g),g.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==f.state)throw new Y("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:f.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: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 le({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 Rn(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=Q(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 le({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 le({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 Ur(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 Br(t){const e=new Gr(t);return await e.checkSession(),e}const Fn="sesamy.com",qr="https://logs.sesamy.com/events";var pe=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.SOFT_PAYWALL="sesamyJsSoftPaywall",t))(pe||{});let G;const Ct="sesamyAccessToken",At="sesamyExpires";function $t(){const t=localStorage.getItem(At);if(!(!t||parseInt(t,10)<new Date().getTime()))return localStorage.getItem(Ct)}async function Qr(t){if(t.enabled!==!1&&(G=await Br({domain:t.endpoint||`token.${Fn}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await G.handleRedirectCallback();const e=await G.getUser();rt(pe.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 ei(){if($t())return!0;if(!G)throw new Error("Auth0 client not initialized");return G.isAuthenticated()}async function ti(){if($t())return{sub:"local",name:"Local User"};if(!G)throw new Error("Auth0 client not initialized");return G.getUser()}function ni(){if(!G)throw new Error("Auth0 client not initialized");return G.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function ri(t=!0){const e=$t();if(e)return e;try{if(!G)throw new Error("Auth0 client not initialized");return await G.getTokenSilently()}catch(n){if(t)throw n;return null}}async function ii(){if(localStorage.removeItem(Ct),localStorage.removeItem(At),!G)throw new Error("Auth0 client not initialized");return rt(pe.LOGOUT,{}),G.logout({logoutParams:{returnTo:window.location.href}})}function oi(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 Jn(t,e){localStorage.setItem(Ct,t),localStorage.setItem(At,JSON.stringify(e*1e3+new Date().getTime()));const n=oi(t);rt(pe.AUTHENTICATED,n)}const ai=(t,e)=>e.skipDedupe||e.method!=="GET",si=(t,e)=>e.method+"@"+t,ci=t=>t.clone(),Bt=({skip:t=ai,key:e=si,resolver:n=ci}={})=>{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,p)=>{r.get(s).push([h,p])});try{return i(o,a).then(h=>(r.get(s).forEach(([p])=>p(n(h))),r.delete(s),h)).catch(h=>{throw r.get(s).forEach(([p,u])=>u(h)),r.delete(s),h})}catch(h){return r.delete(s),Promise.reject(h)}}},ui=(t,e)=>t*e,li=t=>t&&t.ok,qt=({delayTimer:t=500,delayRamp:e=ui,maxAttempts:n=10,until:r=li,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>h=>(p,u)=>{let c=0;if(s&&s(p,u))return h(p,u);const f=(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=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:p,options:u})).then((S={})=>{var g,l;v(h((g=S&&S.url)!==null&&g!==void 0?g:p,(l=S&&S.options)!==null&&l!==void 0?l:u))}):v(h(p,u))},E)}).then(f).catch(v=>{if(!o)throw v;return f(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return h(p,u).then(f).catch(d=>{if(!o)throw d;return f(null,d)})},di="application/json",Hn="Content-Type",ve=Symbol(),Xn=Symbol();function Qt(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Hn.toLowerCase()))===null||e===void 0?void 0:e[1]}function en(t){return/^application\/.*json.*/.test(t)}const he=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]=he(a,o,n):r[i]=o,r},{...t})},Ee={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 hi(t,e=!1){Ee.options=e?t:he(Ee.options,t)}function fi(t,e=!1){Ee.polyfills=e?t:he(Ee.polyfills,t)}function pi(t){Ee.errorType=t}const mi=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class Vn extends Error{}const gi=t=>{const e=Object.create(null);t=t._addons.reduce((g,l)=>l.beforeRequest&&l.beforeRequest(g,t._options,e)||g,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:h}=t,p=new Map(o),u=he(i.options,r);let c=n;const f=mi(s)((g,l)=>(c=g,i.polyfill("fetch")(g,l)))(n,u),d=new Error,w=f.catch(g=>{throw{[ve]:g}}).then(g=>{if(!g.ok){const l=new Vn;if(l.cause=d,l.stack=l.stack+`
5
- CAUSE: `+d.stack,l.response=g,l.url=c,g.type==="opaque")throw l;return g.text().then(b=>{var P;if(l.message=b,i.errorType==="json"||((P=g.headers.get("Content-Type"))===null||P===void 0?void 0:P.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=g.status,l})}return g}),k=g=>g.catch(l=>{const b=l.hasOwnProperty(ve),P=b?l[ve]:l,j=(P==null?void 0:P.status)&&p.get(P.status)||p.get(P==null?void 0:P.name)||b&&p.has(ve)&&p.get(ve);if(j)return j(P,t);const $=p.get(Xn);if($)return $(P,t);throw P}),v=g=>l=>k(g?w.then(b=>b&&b[g]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),E={_wretchReq:t,_fetchReq:f,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(g,l){return p.set(g,l),this},badRequest(g){return this.error(400,g)},unauthorized(g){return this.error(401,g)},forbidden(g){return this.error(403,g)},notFound(g){return this.error(404,g)},timeout(g){return this.error(408,g)},internalError(g){return this.error(500,g)},fetchError(g){return this.error(ve,g)}},S=h.reduce((g,l)=>({...g,...typeof l.resolver=="function"?l.resolver(g):l.resolver}),E);return a.reduce((g,l)=>l(g,t),S)},yi={_url:"",_options:{},_config:Ee,_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:he(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:he(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:he(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Hn]: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(Xn,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=Qt(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||en(i));return r=n?o?r.json(n,i):r.body(n):r,gi(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=Qt(this._options.headers);return this.content(e||en(n)&&n||di).body(JSON.stringify(t))}};function ae(t="",e={}){return{...yi,_url:t,_options:e}}ae.default=ae;ae.options=hi;ae.errorType=pi;ae.polyfills=fi;ae.WretchError=Vn;function vi(t){const e=t.endpoint||`https://api2.${Fn}`,n=_=>async(I,x)=>{let D=sessionStorage.getItem("sesamyCacheTimestamp");D||(D=Date.now().toString(),sessionStorage.setItem("sesamyCacheTimestamp",D));const T={...x,headers:{...x.headers,"Cache-Timestamp":D}};return _(I,T)},r=(_=!0)=>I=>async(x,D)=>{let T=null;if(T=await ri(_),!T){if(_)throw new Error("No access token available");return I(x,D)}const W={...D,headers:{...D.headers,...T?{Authorization:`Bearer ${T}`}:{}}};return I(x,W)},i=_=>(I,x)=>{if(x.headers.Authorization)return _(I,x);const D=localStorage.getItem("__anon_id"),T=btoa(`${D}:`),W={...x,headers:{...x.headers,Authorization:`Basic ${T}`}};return _(I,W)},o=ae(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),Bt(),qt({delayTimer:1e3,delayRamp:(_,I)=>_*I,maxAttempts:3,until:_=>!!(_&&(_.ok||_.status>=400&&_.status<500)),retryOnNetworkError:!1})]),a=ae(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,Bt(),qt({delayTimer:1e3,delayRamp:(_,I)=>_*I,maxAttempts:3,until:_=>!!(_&&(_.ok||_.status>=400&&_.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(_){const I=await o.get("/entitlements").json();return I==null?void 0:I.find(x=>x.id===_)}async function p(_){return o.get(`/entitlements/${_}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(_){const I=await o.get("/contracts").json();return I==null?void 0:I.find(x=>x.id===_)}async function f(){return o.get("/bills").json()}async function d(_){const I=await o.get("/bills").json();return I==null?void 0:I.find(x=>x.id===_)}async function w(_,I){return await o.url(`/user-metadata/${_}`).put(I).json()}async function k(_){return(await o.url(`/user-metadata/${_}`).delete().res()).ok}async function v(_){return(await o.url(`/user-metadata/${_}`).get().json())[_]}async function E(){return await o.url("/user-metadata").get().json()}async function S(){return await o.url("/tags").get().json()}async function g(_){return(await o.url(`/tags/${_}`).delete().res()).ok}async function l(_){return(await o.url("/tags").post(_).res()).ok}async function b(_){return(await a.url("/tallies").get().json())[_]}async function P(){return await a.url("/tallies").get().json()}async function j(_){return(await a.url(`/tallies/${_}`).delete().res()).ok}async function $(_,I){return await a.url(`/tallies/${_}/push`).post(I).json()}async function L(_){return await o.url(`/products/${_}`).get().json()}async function R(_){return o.url(`/products/${_}/auto-onboard`).post().json()}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:p,getContracts:u,getContract:c,getBills:f,getBill:d,setUserMetadata:w,deleteUserMetadata:k,getUserMetadata:v,listUserMetadata:E,getTags:S,deleteTag:g,setTag:l,getTally:b,getTallies:P,deleteTally:j,pushTally:$,getProduct:L,autoOnboardProduct:R}}const Yn="@sesamy/sesamy-js",zt="1.3.2";function tn(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 Fe="undefined",nn="object",_t=function(){},Gn="any",Bn="*",me="__",Qe=typeof process<"u"?process:{};Qe.env&&Qe.env.NODE_ENV;var J=typeof document<"u";Qe.versions!=null&&Qe.versions.node!=null;typeof Deno<"u"&&Deno.core;J&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function qn(t,e){return e.charAt(0)[t]()+e.slice(1)}var wi=qn.bind(null,"toUpperCase"),bi=qn.bind(null,"toLowerCase");function ki(t){return Qn(t)?wi("null"):typeof t=="object"?Ei(t):Object.prototype.toString.call(t).slice(8,-1)}function et(t,e){e===void 0&&(e=!0);var n=ki(t);return e?bi(n):n}function Ze(t,e){return typeof e===t}var V=Ze.bind(null,"function"),ie=Ze.bind(null,"string"),be=Ze.bind(null,"undefined"),Ii=Ze.bind(null,"boolean");Ze.bind(null,"symbol");function Qn(t){return t===null}function Si(t){return et(t)==="number"&&!isNaN(t)}function er(t){return et(t)==="array"}function X(t){if(!_i(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function _i(t){return t&&(typeof t=="object"||t!==null)}function Ei(t){return V(t.constructor)?t.constructor.name:null}function Ti(t){return t instanceof Error||ie(t.message)&&t.constructor&&Si(t.constructor.stackTraceLimit)}function tr(t,e){if(typeof e!="object"||Qn(e))return!1;if(e instanceof t)return!0;var n=et(new t(""));if(Ti(e))for(;e;){if(et(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}tr.bind(null,TypeError);tr.bind(null,SyntaxError);function it(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Oi(t,e):n}function Oi(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function ot(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}ot(it,"form");ot(it,"button");ot(it,"input");ot(it,"select");function Pi(t){return t?er(t)?t:[t]:[]}function rn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function ji(){if(J){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function xi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ci(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=rn(n[1]),a=rn(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&&(Ai(r,h.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 J&&window.location.search.substring(1)}(t))}function Ai(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 at(){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 $i(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 p=e-(h-a);return n=this,r=arguments,p<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,p)),i}}var De="global",Te=me+"global"+me,Oe=typeof self===nn&&self.self===self&&self||typeof global===nn&&global.global===global&&global||void 0;function ge(t){return Oe[Te][t]}function ye(t,e){return Oe[Te][t]=e}function je(t){delete Oe[Te][t]}function xe(t,e,n){var r;try{if(Nt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Oe[Te]||(Oe[Te]={});var Je={};function Nt(t){if(typeof Je[t]!==Fe)return Je[t];try{var e=window[t];e.setItem(Fe,Fe),e.removeItem(Fe)}catch{return Je[t]=!1}return Je[t]=!0}function A(){return A=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},A.apply(this,arguments)}var re="function",te="undefined",zi="@@redux/"+Math.random().toString(36),on=function(){return typeof Symbol===re&&Symbol.observable||"@@observable"}(),He=" != "+re;function nr(t,e,n){var r;if(typeof e===re&&typeof n===te&&(n=e,e=void 0),typeof n!==te){if(typeof n!==re)throw new Error("enhancer"+He);return n(nr)(t,e)}if(typeof t!==re)throw new Error("reducer"+He);var i=t,o=e,a=[],s=a,h=!1;function p(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==re)throw new Error("Listener"+He);var w=!0;return p(),s.push(d),function(){if(w){w=!1,p();var k=s.indexOf(d);s.splice(k,1)}}}function f(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===te)throw new Error("ActType "+te);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var w=a=s,k=0;k<w.length;k++)(0,w[k])();return d}return f({type:"@@redux/INIT"}),(r={dispatch:f,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==re)throw new Error("next reducer"+He);i=d,f({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 Ni(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+te}function Pe(){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 Di(){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(p){return s(p)}};return o=[].slice.call(t).map(function(p){return p(h)}),A({},a,{dispatch:s=Pe.apply(void 0,o)(a.dispatch)})}}}var oe=me+"anon_id",fe=me+"user_id",Ie=me+"user_traits",ne="userId",ke="anonymousId",qe=["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"],Et=["name","EVENTS","config","loaded"],C=qe.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),an=/^utm_/,sn=/^an_prop_/,cn=/^an_trait_/;function Ui(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,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(oe,a.anonymousId),p||e(fe,a.userId),h.traits&&e(Ie,A({},p&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,f=o.an_event,d=u.reduce(function(w,k){if(k.match(an)||k.match(/^(d|g)clid/)){var v=k.replace(an,"");w.campaign[v==="campaign"?"name":v]=o[k]}return k.match(sn)&&(w.props[k.replace(sn,"")]=o[k]),k.match(cn)&&(w.traits[k.replace(cn,"")]=o[k]),w},{campaign:{},props:{},traits:{}});n.dispatch(A({type:C.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),f&&setTimeout(function(){return t.track(f,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:C.campaign,campaign:d.campaign})}}return r(i)}}}}function Li(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===C.setItemEnd){if(n.key===oe)return A({},e,{anonymousId:n.value});if(n.key===fe)return A({},e,{userId:n.value})}switch(n.type){case C.identify:return Object.assign({},e,{userId:n.userId,traits:A({},e.traits,n.traits)});case C.reset:return[fe,oe,Ie].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function un(t){return{userId:t.getItem(fe),anonymousId:t.getItem(oe),traits:t.getItem(Ie)}}var Tt=function(t){return me+"TEMP"+me+t};function Ri(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,p=s.traits,u=s.options;if(s.type===C.reset&&([fe,Ie,oe].forEach(function(d){r(d)}),[ne,ke,"traits"].forEach(function(d){je(Tt(d))})),s.type===C.identify){i(oe)||n(oe,at());var c=i(fe),f=i(Ie)||{};c&&c!==h&&o.dispatch({type:C.userIdChanged,old:{userId:c,traits:f},new:{userId:h,traits:p},options:u}),h&&n(fe,h),p&&n(Ie,A({},f,p))}return a(s)}}}}var Ne={};function ln(t,e){Ne[t]&&V(Ne[t])&&(Ne[t](e),delete Ne[t])}function rr(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(A({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return rr(t,e,n-10).then(r,i)})})}function Mi(t){return{abort:t}}function ir(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 p=s.actions.reduce(function(c,f,d){return a[f.plugin].loaded?(c.process.push(f),c.processIndex.push(d)):(c.requeue.push(f),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(p.processIndex&&p.processIndex.length){p.processIndex.forEach(function(c){var f=s.actions[c],d=f.plugin,w=f.payload.type,k=i[d][w];if(k&&V(k)){var v,E=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[ne,ke].reduce(function(P,j){return l.hasOwnProperty(j)&&b[j]&&b[j]!==l[j]&&(P[j]=b[j]),P},l)}(f.payload,h),S=r[E.meta.rid];if(!S&&(v=k({payload:E,config:a[d].config,instance:n,abort:Mi}))&&X(v)&&v.abort)return void(r[E.meta.rid]=!0);if(!S){var g=w+":"+d;t.dispatch(A({},E,{type:g,_:{called:g,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,f){return!~p.processIndex.indexOf(f)});s.actions=u}}}var pt=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 p=i.plugins,u=i.context,c=n.type,f=c.match(Se),d=e.exact.map(function(v){return v.pluginName});f&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,E){return function(S,g,l){var b=g.config,P=g.name,j=P+"."+S.type;l&&(j=l.event);var $=S.type.match(Se)?function(L,R,_,I,x){return function(D,T){var W=I?I.name:L,H=T&&Me(T)?T:_;if(I&&(!(H=T&&Me(T)?T:[L]).includes(L)||H.length!==1))throw new Error("Method "+R+" can only abort "+L+" plugin. "+JSON.stringify(H)+" input valid");return A({},x,{abort:{reason:D,plugins:H,caller:R,_:W}})}}(P,j,E,l,S):function(L,R){return function(){throw new Error(L.type+" action not cancellable. Remove abort in "+R)}}(S,j);return{payload:Zi(S),instance:v,config:b||{},abort:$}}}(r,d),k=e.exact.reduce(function(v,E){var S=E.pluginName,g=E.methodName,l=!1;return g.match(/^initialize/)||g.match(/^reset/)||(l=!p[S].loaded),u.offline&&g.match(/^(page|track|identify)/)&&(l=!0),v[""+S]=l,v},{});return Promise.resolve(e.exact.reduce(function(v,E,S){try{var g=E.pluginName;return Promise.resolve(v).then(function(l){function b(){return Promise.resolve(l)}var P=function(){if(e.namespaced&&e.namespaced[g])return Promise.resolve(e.namespaced[g].reduce(function(j,$,L){try{return Promise.resolve(j).then(function(R){return $.method&&V($.method)?(function(D,T){var W=yn(D);if(W&&W.name===T){var H=yn(W.method);throw new Error([T+" plugin is calling method "+D,"Plugins cant call self","Use "+W.method+" "+(H?"or "+H.method:"")+" in "+T+" plugin insteadof "+D].join(`
6
- `))}}($.methodName,$.pluginName),Promise.resolve($.method({payload:R,instance:r,abort:(_=R,I=g,x=$.pluginName,function(D,T){return A({},_,{abort:{reason:D,plugins:T||[I],caller:c,from:x||I}})}),config:fn($.pluginName,p,o),plugins:p})).then(function(D){var T=X(D)?D:{};return Promise.resolve(A({},R,T))})):R;var _,I,x})}catch(R){return Promise.reject(R)}},Promise.resolve(n))).then(function(j){l[g]=j});l[g]=n}();return P&&P.then?P.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(E,S,g){try{var l=e.exact.length===g+1,b=S.pluginName,P=o[b];return Promise.resolve(E).then(function(j){var $=v[b]?v[b]:{};if(f&&($=j),gt($,b))return mt({data:$,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(j);if(gt(j,b))return l&&mt({data:j,method:c,instance:r,store:s}),Promise.resolve(j);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:$,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(j);var L=w(v[b],o[b]);return Promise.resolve(P[c]({abort:L.abort,payload:$,instance:r,config:fn(b,p,o),plugins:p})).then(function(R){var _=X(R)?R:{},I=A({},j,_),x=v[b];if(gt(x,b))mt({data:x,method:c,instance:r,pluginName:b,store:s});else{var D=c+":"+b;(D.match(/:/g)||[]).length<2&&!c.match(dn)&&!c.match(hn)&&r.dispatch(A({},f?I:$,{type:D,_:{called:D,from:"submethod"}}))}return Promise.resolve(I)})})}catch(j){return Promise.reject(j)}},Promise.resolve(n))).then(function(E){if(!(c.match(Se)||c.match(/^registerPlugin/)||c.match(hn)||c.match(dn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(h.plugins.includes(c),E._&&E._.originalAction===c)return E;var S=A({},E,{_:{originalAction:E.type,called:E.type,from:"engineEnd"}});or(E,e.exact.length)&&!c.match(/End$/)&&(S=A({},S,{type:E.type+"Aborted"})),s.dispatch(S)}return E})})}catch(v){return Promise.reject(v)}},Se=/Start$/,dn=/^bootstrap/,hn=/^ready/;function mt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(A({},t.data,{type:n,_:{called:n,from:"abort"}}))}function fn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function pn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function mn(t,e){var n=t.replace(Se,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function gt(t,e){var n=t.abort;return!!n&&(n===!0||gn(n,e)||n&&gn(n.plugins,e))}function or(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ie(n))return!0;var r=n.plugins;return Me(n)&&n.length===e||Me(r)&&r.length===e}function Me(t){return Array.isArray(t)}function gn(t,e){return!(!t||!Me(t))&&t.includes(e)}function yn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Zi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=X(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Wi(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)},p=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(p===C.enablePlugin&&i.dispatch({type:C.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===C.disablePlugin&&setTimeout(function(){return ln(a.meta.rid,{payload:a})},0),p===C.initializeEnd){var f=e(),d=Object.keys(f),w=d.filter(function(l){return u.includes(l)}).map(function(l){return f[l]}),k=[],v=[],E=a.disabled,S=w.map(function(l){var b=l.loaded,P=l.name,j=l.config;return rr(l,function(){return b({config:j})},1e4).then(function($){return r[P]||(i.dispatch({type:C.pluginReadyType(P),name:P,events:Object.keys(l).filter(function(L){return!Et.includes(L)})}),r[P]=!0),k=k.concat(P),l}).catch(function($){if($ instanceof Error)throw new Error($);return v=v.concat($.name),$})});Promise.all(S).then(function(l){var b={plugins:k,failed:v,disabled:E};setTimeout(function(){d.length===S.length+E.length&&i.dispatch(A({},{type:C.ready},b))},0)})}var g=function(){if(p!==C.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return ir(i,e,t)},0),Promise.resolve(function(l,b,P,j,$){try{var L=V(b)?b():b,R=l.type,_=R.replace(Se,"");if(l._&&l._.called)return Promise.resolve(l);var I=P.getState(),x=(W=L,(H=I.plugins)===void 0&&(H={}),(Ce=l.options)===void 0&&(Ce={}),Object.keys(W).filter(function(m){var y=Ce.plugins||{};return Ii(y[m])?y[m]:y.all!==!1&&(!H[m]||H[m].enabled!==!1)}).map(function(m){return W[m]}));R===C.initializeStart&&l.fromEnable&&(x=Object.keys(I.plugins).filter(function(m){var y=I.plugins[m];return l.plugins.includes(m)&&!y.initialized}).map(function(m){return L[m]}));var D=x.map(function(m){return m.name}),T=function(m,y,O){var z=mn(m).map(function(N){return pn(N,y)});return y.reduce(function(N,U){var F=U.name,Z=mn(m,F).map(function(Ae){return pn(Ae,y)}),K=Z[0],M=Z[1],q=Z[2];return K.length&&(N.beforeNS[F]=K),M.length&&(N.duringNS[F]=M),q.length&&(N.afterNS[F]=q),N},{before:z[0],beforeNS:{},during:z[1],duringNS:{},after:z[2],afterNS:{}})}(R,x);return Promise.resolve(pt({action:l,data:{exact:T.before,namespaced:T.beforeNS},state:I,allPlugins:L,allMatches:T,instance:P,store:j,EVENTS:$})).then(function(m){function y(){var N=function(){if(R.match(Se))return Promise.resolve(pt({action:A({},O,{type:_+"End"}),data:{exact:T.after,namespaced:T.afterNS},state:I,allPlugins:L,allMatches:T,instance:P,store:j,EVENTS:$})).then(function(U){U.meta&&U.meta.hasCallback&&ln(U.meta.rid,{payload:U})})}();return N&&N.then?N.then(function(){return m}):m}if(or(m,D.length))return m;var O,z=function(){if(R!==_)return Promise.resolve(pt({action:A({},m,{type:_}),data:{exact:T.during,namespaced:T.duringNS},state:I,allPlugins:L,allMatches:T,instance:P,store:j,EVENTS:$})).then(function(N){O=N});O=m}();return z&&z.then?z.then(y):y()})}catch(m){return Promise.reject(m)}var W,H,Ce}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(g&&g.then?g.then(h):h(g))}catch(l){return Promise.reject(l)}}}}}function Ki(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 Fi=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 Pe.apply(void 0,a)(r)(i)}}}}};function Ji(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=vn(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},A({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var h=vn(n.type,C.initialize),p=t()[h];return p&&h?(r[h]=A({},e[h],{initialized:!0,loaded:!!p.loaded({config:p.config})}),A({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=A({},e[n.name],{loaded:!0}),A({},e,r);switch(n.type){case C.disablePlugin:return A({},e,wn(n.plugins,!1,e));case C.enablePlugin:return A({},e,wn(n.plugins,!0,e));default:return e}}}function vn(t,e){return t.substring(e.length+1,t.length)}function wn(t,e,n){return t.reduce(function(r,i){return r[i]=A({},n[i],{enabled:e}),r},n)}function ar(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Hi={last:{},history:[]};function Xi(t,e){t===void 0&&(t=Hi);var n=e.options,r=e.meta;if(e.type===C.track){var i=ar(A({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return A({},t,{last:i,history:t.history.concat(i)})}return t}var Vi={actions:[]};function Yi(t,e){t===void 0&&(t=Vi);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),A({},t,{actions:r});case"dequeue":return[];default:return t}}var sr=/#.*$/;function Gi(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(sr,""):"")}var cr,ur,lr,dr,Bi=function(t){if(t===void 0&&(t={}),!J)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,p=o.search,u=function(f){var d=function(){if(J){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+f:window.location.href.replace(sr,"")}(p),c={title:n,url:u,path:Gi(u),hash:h,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),A({},c,t)},qi={last:{},history:[]};function Qi(t,e){t===void 0&&(t=qi);var n=e.options;if(e.type===C.page){var r=ar(A({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return A({},t,{last:r,history:t.history.concat(r)})}return t}cr=function(){if(!J)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"}(),ur=J?document.referrer:null,lr=ji(),dr=xi();var bn={initialized:!1,sessionId:at(),app:null,version:null,debug:!1,offline:!!J&&!navigator.onLine,os:{name:cr},userAgent:J?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:dr,locale:lr,campaign:{},referrer:ur};function eo(t,e){t===void 0&&(t=bn);var n=t.initialized,r=e.campaign;switch(e.type){case C.campaign:return A({},t,{campaign:r});case C.offline:return A({},t,{offline:!0});case C.online:return A({},t,{offline:!1});default:return n?t:A({},bn,t,{initialized:!0})}}var to=["plugins","reducers","storage"];function no(t,e,n){if(J){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function ro(t){var e=no.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function hr(){return ye("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 Oe[Te].analytics.push(a.action||a),o(a)}})}}}function kn(t){return function(){return Pe(Pe.apply(null,arguments),hr())}}function yt(t){return t?er(t)?t:[t]:[]}function In(t,e,n){t===void 0&&(t={});var r,i,o=at();return e&&(Ne[o]=(r=e,i=function(a){for(var s,h=a||Array.prototype.slice.call(arguments),p=0;p<h.length;p++)if(V(h[p])){s=h[p];break}return s}(n),function(a){i&&i(a),r(a)})),A({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function io(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,y){if(V(y))return m.middlewares=m.middlewares.concat(y),m;if(y.NAMESPACE&&(y.name=y.NAMESPACE),!y.name)throw new Error("https://lytics.dev/errors/1");y.config||(y.config={});var O=y.EVENTS?Object.keys(y.EVENTS).map(function(U){return y.EVENTS[U]}):[];m.pluginEnabled[y.name]=!(y.enabled===!1||y.config.enabled===!1),delete y.enabled,y.methods&&(m.methods[y.name]=Object.keys(y.methods).reduce(function(U,F){var Z;return U[F]=(Z=y.methods[F],function(){for(var K=Array.prototype.slice.call(arguments),M=new Array(Z.length),q=0;q<K.length;q++)M[q]=K[q];return M[M.length]=b,Z.apply({instance:b},M)}),U},{}),delete y.methods);var z=Object.keys(y).concat(O),N=new Set(m.events.concat(z));if(m.events=Array.from(N),m.pluginsArray=m.pluginsArray.concat(y),m.plugins[y.name])throw new Error(y.name+"AlreadyLoaded");return m.plugins[y.name]=y,m.plugins[y.name].loaded||(m.plugins[y.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ge,setItem:ye,removeItem:je},o=function(m){return function(y,O,z){return O.getState("user")[y]||(z&&X(z)&&z[y]?z[y]:un(m)[y]||ge(Tt(y))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!Et.includes(m)}).sort(),h=new Set(s.concat(qe).filter(function(m){return!Et.includes(m)})),p=Array.from(h).sort(),u=function(){return a},c=new Fi,f=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Ci(),E=un(i),S=A({},E,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=at());var g=A({enable:function(m,y){return new Promise(function(O){T.dispatch({type:C.enablePlugin,plugins:yt(m),_:{originalAction:C.enablePlugin}},O,[y])})},disable:function(m,y){return new Promise(function(O){T.dispatch({type:C.disablePlugin,plugins:yt(m),_:{originalAction:C.disablePlugin}},O,[y])})}},r.methods),l=!1,b={identify:function(m,y,O,z){try{var N=ie(m)?m:null,U=X(m)?m:y,F=O||{},Z=b.user();ye(Tt(ne),N);var K=N||U.userId||o(ne,b,U);return Promise.resolve(new Promise(function(M){T.dispatch(A({type:C.identifyStart,userId:K,traits:U||{},options:F,anonymousId:Z.anonymousId},Z.id&&Z.id!==N&&{previousId:Z.id}),M,[y,O,z])}))}catch(M){return Promise.reject(M)}},track:function(m,y,O,z){try{var N=X(m)?m.event:m;if(!N||!ie(N))throw new Error("EventMissing");var U=X(m)?m:y||{},F=X(O)?O:{};return Promise.resolve(new Promise(function(Z){T.dispatch({type:C.trackStart,event:N,properties:U,options:F,userId:o(ne,b,y),anonymousId:o(ke,b,y)},Z,[y,O,z])}))}catch(Z){return Promise.reject(Z)}},page:function(m,y,O){try{var z=X(m)?m:{},N=X(y)?y:{};return Promise.resolve(new Promise(function(U){T.dispatch({type:C.pageStart,properties:Bi(z),options:N,userId:o(ne,b,z),anonymousId:o(ke,b,z)},U,[m,y,O])}))}catch(U){return Promise.reject(U)}},user:function(m){if(m===ne||m==="id")return o(ne,b);if(m===ke||m==="anonId")return o(ke,b);var y=b.getState("user");return m?tn(y,m):y},reset:function(m){return new Promise(function(y){T.dispatch({type:C.resetStart},y,m)})},ready:function(m){return l&&m({plugins:g,instance:b}),b.on(C.ready,function(y){m(y),l=!0})},on:function(m,y){if(!m||!V(y))return!1;if(m===C.bootstrap)throw new Error(".on disabled for "+m);var O=/Start$|Start:/;if(m==="*"){var z=function(Z){return function(K){return function(M){return M.type.match(O)&&y({payload:M,instance:b,plugins:a}),K(M)}}},N=function(Z){return function(K){return function(M){return M.type.match(O)||y({payload:M,instance:b,plugins:a}),K(M)}}};return f(z,Xe),f(N,Ve),function(){d(z,Xe),d(N,Ve)}}var U=m.match(O)?Xe:Ve,F=function(Z){return function(K){return function(M){return M.type===m&&y({payload:M,instance:b,plugins:a,abort:k}),K(M)}}};return f(F,U),function(){return d(F,U)}},once:function(m,y){if(!m||!V(y))return!1;if(m===C.bootstrap)throw new Error(".once disabled for "+m);var O=b.on(m,function(z){y({payload:z.payload,instance:b,plugins:a,abort:k}),O()});return O},getState:function(m){var y=T.getState();return m?tn(y,m):Object.assign({},y)},dispatch:function(m){var y=ie(m)?{type:m}:m;if(qe.includes(y.type))throw new Error("reserved action "+y.type);var O=A({},y,{_:A({originalAction:y.type},m._||{})});T.dispatch(O)},enablePlugin:g.enable,disablePlugin:g.disable,plugins:g,storage:{getItem:i.getItem,setItem:function(m,y,O){T.dispatch({type:C.setItemStart,key:m,value:y,options:O})},removeItem:function(m,y){T.dispatch({type:C.removeItemStart,key:m,options:y})}},setAnonymousId:function(m,y){b.storage.setItem(oe,m,y)},events:{core:qe,plugins:s}},P=r.middlewares.concat([function(m){return function(y){return function(O){return O.meta||(O.meta=In()),y(O)}}},w(Xe),Wi(b,u,{all:p,plugins:s}),Ki(i),Ui(b),Ri(b),w(Ve)]),j={context:eo,user:Li(i),page:Qi,track:Xi,plugins:Ji(u),queue:Yi},$=Pe,L=Pe;if(J&&t.debug){var R=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;R&&($=R({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?hr():X(typeof arguments[0])?kn():kn().apply(null,arguments)}}var _,I=function(m){return Object.keys(m).reduce(function(y,O){return to.includes(O)||(y[O]=m[O]),y},{})}(t),x=r.pluginsArray.reduce(function(m,y){var O=y.name,z=y.config,N=y.loaded,U=r.pluginEnabled[O];return m[O]={enabled:U,initialized:!!U&&!y.initialize,loaded:!!N({config:z}),config:z},m},{}),D={context:I,user:S,plugins:x},T=nr(function(m){for(var y=Object.keys(m),O={},z=0;z<y.length;z++){var N=y[z];typeof m[N]===re&&(O[N]=m[N])}var U,F=Object.keys(O);try{(function(Z){Object.keys(Z).forEach(function(K){var M=Z[K];if(typeof M(void 0,{type:"@@redux/INIT"})===te||typeof M(void 0,{type:zi})===te)throw new Error("reducer "+K+" "+te)})})(O)}catch(Z){U=Z}return function(Z,K){if(Z===void 0&&(Z={}),U)throw U;for(var M=!1,q={},Ae=0;Ae<F.length;Ae++){var We=F[Ae],Wt=Z[We],ut=(0,O[We])(Wt,K);if(typeof ut===te){var _r=Ni(We,K);throw new Error(_r)}q[We]=ut,M=M||ut!==Wt}return M?q:Z}}(A({},j,e)),D,L($(Di.apply(void 0,P))));T.dispatch=(_=T.dispatch,function(m,y,O){var z=A({},m,{meta:In(m.meta,y,yt(O))});return _.apply(null,[z])});var W=Object.keys(a);T.dispatch({type:C.bootstrap,plugins:W,config:I,params:v,user:S,initialUser:n,persistedUser:E});var H=W.filter(function(m){return r.pluginEnabled[m]}),Ce=W.filter(function(m){return!r.pluginEnabled[m]});return T.dispatch({type:C.registerPlugins,plugins:W,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,y){var O=m.bootstrap,z=m.config,N=m.name;O&&V(O)&&O({instance:b,config:z,payload:m}),T.dispatch({type:C.registerPluginType(N),name:N,enabled:r.pluginEnabled[N],plugin:m}),r.pluginsArray.length===y+1&&T.dispatch({type:C.initializeStart,plugins:H,disabled:Ce})}),ro(function(m){T.dispatch({type:m?C.offline:C.online})}),function(m,y,O){setInterval(function(){return ir(m,y,O)},3e3)}(T,u,b),b}var Xe="before",Ve="after",Ue="cookie",ue=mr(),fr=st,oo=st;function pr(t){return ue?st(t,"",-1):je(t)}function mr(){if(ue!==void 0)return ue;var t="cookiecookie";try{st(t,t),ue=document.cookie.indexOf(t)!==-1,pr(t)}catch{ue=!1}return ue}function st(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ue===!1&&(a?ye(t,e):ge(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 Le="localStorage",ao=Nt.bind(null,"localStorage");xe("localStorage","getItem",ge);xe("localStorage","setItem",ye);xe("localStorage","removeItem",je);var Re="sessionStorage",so=Nt.bind(null,"sessionStorage");xe("sessionStorage","getItem",ge);xe("sessionStorage","setItem",ye);xe("sessionStorage","removeItem",je);function _e(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(X(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var co=ao(),uo=so(),lo=mr();function gr(t,e){if(t){var n=Dt(e),r=!Mt(n),i=Ut(n)?_e(localStorage.getItem(t)):void 0;if(r&&!be(i))return i;var o=Lt(n)?_e(fr(t)):void 0;if(r&&o)return o;var a=Rt(n)?_e(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ge(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function ho(t,e,n){if(t&&!be(e)){var r={},i=Dt(n),o=JSON.stringify(e),a=!Mt(i);return Ut(i)&&(r[Le]=Ye(Le,e,_e(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Le]:Lt(i)&&(r[Ue]=Ye(Ue,e,_e(fr(t))),oo(t,o),a)?r[Ue]:Rt(i)&&(r[Re]=Ye(Re,e,_e(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Re]:(r[De]=Ye(De,e,ge(t)),ye(t,e),a?r[De]:r)}}function fo(t,e){if(t){var n=Dt(e),r=gr(t,Bn),i={};return!be(r.localStorage)&&Ut(n)&&(localStorage.removeItem(t),i[Le]=r.localStorage),!be(r.cookie)&&Lt(n)&&(pr(t),i[Ue]=r.cookie),!be(r.sessionStorage)&&Rt(n)&&(sessionStorage.removeItem(t),i[Re]=r.sessionStorage),!be(r.global)&&ct(n,De)&&(je(t),i[De]=r.global),i}}function Dt(t){return t?ie(t)?t:t.storage:Gn}function Ut(t){return co&&ct(t,Le)}function Lt(t){return lo&&ct(t,Ue)}function Rt(t){return uo&&ct(t,Re)}function Mt(t){return t===Bn||t==="all"}function ct(t,e){return t===Gn||t===e||Mt(t)}function Ye(t,e,n){return{location:t,current:e,previous:n}}var po={setItem:ho,getItem:gr,removeItem:fo};function mo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sn(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 _n(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Sn(Object(n),!0).forEach(function(r){mo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Sn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function go(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:po};return io(_n(_n({},e),t))}function yo(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 vo(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 p=((c=h[2])==null?void 0:c.toString())||"",u=bo(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,h)}})}function wo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function bo(t){return["#","?"].forEach(e=>t=wo(t,e)),t}function ko(){vo(()=>{ee.page()})}function Io(t){if(t===void 0&&(t={}),!J)return _t;var e=Tn(),n=Ot(),r=En(),i=Ge(r,e),o=Ge(n,e),a=[],s=[],h=[],p=r,u=i,c=o,f=Object.keys(t);if(!f.length)return _t;var d=f.map(function(k){return Number(k)}),w=$i(function(){var k=Tn(),v=function(I,x){return x.map(function(D){return D===100?I-5:I*(D/100)})}(k,d),E=Ot(),S=En(),g=Ge(S,k),l=Ge(E,k);if(u=g>u?g:u,c=l<c?l:c,!(a.length>=d.length)){var b=p===S,P="up";b?P="initial":p<=S&&(P="down");var j=v,$=d;(P==="up"||b)&&(j=v.slice().reverse(),$=d.slice().reverse());var L=$.reduce(function(I,x,D){var T=j[D];return h.includes(x)&&S<=T&&(h=h.filter(function(W){return W!==x}),I.singleFunction=x),P==="down"&&!a.includes(x)&&S>=T&&x>o?(s.push(x),I.callbacks=I.callbacks.concat(x),I):P==="up"&&!a.includes(x)&&S<=T&&x<=g?(I.foundFunc=[x],I):(b&&S>=T&&I.foundFunc.length===0&&(I.foundFunc=[x]),!s.includes(x)&&S>=T&&(s.push(x),I.singleFunction?h.push(x):I.singleFunction=x),I)},{foundFunc:[],singleFunction:null,callbacks:[],direction:P});if(p=S,P==="down"&&L.callbacks&&L.callbacks.forEach(function(I){V(t[I])&&(t[I]({trigger:I,direction:P,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(I))}),L.singleFunction){var R=L.singleFunction,_=L.direction;V(t[R])&&t[R]({trigger:R,direction:_,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(R)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function Ot(){return J?document.body.scrollTop||document.documentElement.scrollTop:0}function So(){return J?window.innerHeight||document.documentElement.clientHeight:0}function En(){return Math.round(Ot()+So())}function Tn(){if(!J)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function Ge(t,e){return Math.round(t/e*100)}var On="EventListener";function _o(t){return function(e,n,r,i){var o=r||_t,a=i||!1;if(!J)return o;var s=tt(n),h=tt(e,!0);if(!h.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var f=c?"add"+On:"remove"+On,d=0;d<h.length;d++){var w=h[d];p[d]=c?a&&a.once?Eo(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[f]?w["on"+s[k]]=c?p[d]:null:w[f](s[k],p[d],a)}return u.bind(null,!c)}(t)}}function tt(t,e){if(ie(t))return e?tt(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=Pi(t);return e?o.map(function(a){return ie(a)?tt(a,!0):a}).flat():o}function Eo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var vt=_o("Event");function yr(t,e){return J&&V(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),V(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}yr.bind(null,"onerror");yr.bind(null,"onload");var vr=typeof window>"u",Pn="hidden";function To(t){if(vr)return!1;var e=Oo(),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 Oo(){var t=["webkit","moz","ms","o"];return vr||Pn in document?Pn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Po=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function jo(t,e){e===void 0&&(e={});var n=function(a,s){var h=this,p=!1;return function(u){p||(a.call(h,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=To(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Po.map(function(s){return vt(document,s,n)})).concat(vt(window,"load",n)).concat(vt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function xo(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,p=h===void 0?2e3:h,u=!1,c=!1,f=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(ze(f),v),i&&u&&(u=!1,i(ze(n),v),f=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(ze(f),v))},s)}var k=jo(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,f=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:ze(f,c),idle:u?ze(n,c):0}}}}function ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const jn=5e3;class Co{constructor(e){B(this,"element");B(this,"isInViewport",!1);B(this,"isAwake",!1);B(this,"isFlushing");B(this,"observer");B(this,"lastEventAt",Date.now());B(this,"registeredView",!1);B(this,"viewCallback");B(this,"activeDurationCallback");B(this,"idleDurationCallback");B(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),xo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:jn}),Io({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*jn: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 xn="sesamy_session_id";function Ao(){let t=sessionStorage.getItem(xn);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(xn,t)),t}let wr=!1,Pt,Cn,nt;function $o({clientId:t,enabled:e=!0,endpoint:n=qr}){if(Pt=t,Cn=e,nt=n,!Cn)return;ko();const r=new Co({element:document.body,viewCallback:()=>{ee.page()},activeDurationCallback:(i,o,a)=>{ee.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ee.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ee.track("scroll",{scroll:i.scrollMax})}});Do(document.body,()=>{r.flush()}),Uo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(pe.AUTHENTICATED,async i=>{const o=i;await ee.identify(o.detail.sub)}),window.addEventListener(pe.LOGOUT,async()=>{await ee.track("logout",{}),Zt.flush(),await ee.reset()})}function br(t){return JSON.stringify(t.map(e=>({...e,clientId:Pt,requestId:Math.random().toString(36).slice(2,9),sessionId:Ao(),timestamp:new Date().toISOString(),version:zt,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:Yn,userAgent:navigator.userAgent,clientId:Pt}})))}const Zt=yo(async t=>{if(t.length>0){const e=br(t);wr?navigator.sendBeacon(nt,e):(await fetch(nt,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function wt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(nt,br([n]))}else Zt.push(t)}const ee=go({app:Yn,version:zt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;wt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;wt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;wt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function zo(t,e){ee.track(t,e)}function No(){return wr=!0,Zt.flush()}const kr=new Map;function Do(t,e){kr.set(t,e)}window.addEventListener("beforeunload",()=>{kr.forEach((t,e)=>{t.bind(e)()}),No()});const Ir=new Map;function Uo(t,e){Ir.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&Ir.forEach((t,e)=>{t.bind(e)()})});function Lo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getContract:i,getContracts:o,getBill:a,getBills:s,getTags:h,deleteTag:p,setTag:u,getUserMetadata:c,listUserMetadata:f,setUserMetadata:d,deleteUserMetadata:w,getTally:k,getTallies:v,pushTally:E,deleteTally:S,getProduct:g,autoOnboardProduct:l}=vi(t),b={auth:{getUser:ti,isAuthenticated:ei,loginWithRedirect:ni,logout:ii,setToken:Jn},analytics:{track:zo},tags:{list:h,set:u,delete:p},entitlements:{get:e,list:n,access:r},contracts:{get:i,list:o},bills:{get:a,list:s},userMetadata:{get:c,list:f,set:d,delete:w},tallies:{get:k,list:v,push:E,delete:S},products:{get:g,autoOnboard:l},getVersion:Ro};return t.namespace&&(window[t.namespace]=b),b}function Ro(){return zt}function Mo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e&&n){Jn(e,parseInt(n,10));const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}async function Sr(t){$o({clientId:t.clientId,...t.analytics}),await Qr({clientId:t.clientId,...t.auth});const e=Lo(t.api||{});return rt(pe.READY,{}),Mo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Sr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=Sr;
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",!Bt(n))throw new Error(`Invalid cache location "${n}"`);r=Bt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?be:Jr,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:Xr;var o;this.scope=He("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Wr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Nn,this.cacheManager=new Zr(r,r.allKeys?void 0:new Gr(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 Yr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||zn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${St(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Fr({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=Jt(dt()),o=Jt(dt()),a=dt(),s=(u=>{const c=new Uint8Array(u);return(f=>{const d={"+":"-","/":"_","=":""};return f.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Qe().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,f,d,w,k,v,E)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),f),{scope:He(c,f.scope),response_type:"code",response_mode:E||"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(h);return{nonce:o,code_verifier:a,scope:h.scope,audience:h.audience||"default",redirect_uri:h.redirect_uri,state:i,url:p}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const h=window.screenX+(window.innerWidth-400)/2,p=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${h},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((h,p)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(f),window.removeEventListener("message",u,!1),p(new $r(s.popup)))},1e3),f=setTimeout(()=>{clearInterval(c),p(new Ar(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(f),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return p(Y.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 Y("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=qt(e),{openUrl:i,fragment:o,appState:a}=r,s=Q(r,["openUrl","fragment","appState"]),h=((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=Q(p,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),h&&{organization:h}));const f=o?`${u}#${o}`:u;i?await i(f):window.location.assign(f)}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 f=new URLSearchParams(c);return{state:f.get("state"),code:f.get("code")||void 0,error:f.get("error")||void 0,error_description:f.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new Y("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new xr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new Y("state_mismatch","Invalid state");const h=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: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:He(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=ft[a];return s||(s=o().finally(()=>{delete ft[a],s=null}),ft[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=Q(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>pt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new It;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const p=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(p)return p}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:h}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:h})}finally{await pt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:He(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Cr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new he({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=Q(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${St(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=qt(e),{openUrl:r}=n,i=Q(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:p,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new Y("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,f=await((w,k,v=60)=>new Promise((E,S)=>{const g=window.document.createElement("iframe");g.setAttribute("width","0"),g.setAttribute("height","0"),g.style.display="none";const l=()=>{window.document.body.contains(g)&&(window.document.body.removeChild(g),window.removeEventListener("message",b,!1))};let b;const P=setTimeout(()=>{S(new It),l()},1e3*v);b=function(j){if(j.origin!=k||!j.data||j.data.type!=="authorization_response")return;const $=j.source;$&&$.close(),j.data.response.error?S(Y.fromPayload(j.data.response)):E(j.data.response),clearTimeout(P),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(g),g.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==f.state)throw new Y("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:f.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: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 he({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 Zn(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=Q(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 he({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 he({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 Rr(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 Qr(t){const e=new qr(t);return await e.checkSession(),e}const Jn="sesamy.com",ei="https://logs.sesamy.com/events",Et="sesamyCacheTimestamp";var ae=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t))(ae||{});let G;const $t="sesamyAccessToken",zt="sesamyExpires";function Nt(){const t=localStorage.getItem(zt);if(!(!t||parseInt(t,10)<new Date().getTime()))return localStorage.getItem($t)}async function ti(t){if(t.enabled!==!1&&(G=await Qr({domain:t.endpoint||`token.${Jn}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await G.handleRedirectCallback();const e=await G.getUser();We(ae.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 ni(){if(Nt())return!0;if(!G)throw new Error("Auth0 client not initialized");return G.isAuthenticated()}async function ri(){if(Nt())return{sub:"local",name:"Local User"};if(!G)throw new Error("Auth0 client not initialized");return G.getUser()}function ii(){if(!G)throw new Error("Auth0 client not initialized");return G.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function oi(t=!0){const e=Nt();if(e)return e;try{if(!G)throw new Error("Auth0 client not initialized");return await G.getTokenSilently()}catch(n){if(t)throw n;return null}}async function ai(){if(localStorage.removeItem($t),localStorage.removeItem(zt),!G)throw new Error("Auth0 client not initialized");return We(ae.LOGOUT,{}),G.logout({logoutParams:{returnTo:window.location.href}})}function si(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 Xn(t,e){localStorage.setItem($t,t),localStorage.setItem(zt,JSON.stringify(e*1e3+new Date().getTime()));const n=si(t);We(ae.AUTHENTICATED,n)}const ci=(t,e)=>e.skipDedupe||e.method!=="GET",ui=(t,e)=>e.method+"@"+t,li=t=>t.clone(),Qt=({skip:t=ci,key:e=ui,resolver:n=li}={})=>{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,p)=>{r.get(s).push([h,p])});try{return i(o,a).then(h=>(r.get(s).forEach(([p])=>p(n(h))),r.delete(s),h)).catch(h=>{throw r.get(s).forEach(([p,u])=>u(h)),r.delete(s),h})}catch(h){return r.delete(s),Promise.reject(h)}}},di=(t,e)=>t*e,hi=t=>t&&t.ok,en=({delayTimer:t=500,delayRamp:e=di,maxAttempts:n=10,until:r=hi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>h=>(p,u)=>{let c=0;if(s&&s(p,u))return h(p,u);const f=(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=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:p,options:u})).then((S={})=>{var g,l;v(h((g=S&&S.url)!==null&&g!==void 0?g:p,(l=S&&S.options)!==null&&l!==void 0?l:u))}):v(h(p,u))},E)}).then(f).catch(v=>{if(!o)throw v;return f(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return h(p,u).then(f).catch(d=>{if(!o)throw d;return f(null,d)})},fi="application/json",Vn="Content-Type",we=Symbol(),Yn=Symbol();function tn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Vn.toLowerCase()))===null||e===void 0?void 0:e[1]}function nn(t){return/^application\/.*json.*/.test(t)}const pe=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]=pe(a,o,n):r[i]=o,r},{...t})},Te={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 pi(t,e=!1){Te.options=e?t:pe(Te.options,t)}function mi(t,e=!1){Te.polyfills=e?t:pe(Te.polyfills,t)}function gi(t){Te.errorType=t}const yi=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class Gn extends Error{}const vi=t=>{const e=Object.create(null);t=t._addons.reduce((g,l)=>l.beforeRequest&&l.beforeRequest(g,t._options,e)||g,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:h}=t,p=new Map(o),u=pe(i.options,r);let c=n;const f=yi(s)((g,l)=>(c=g,i.polyfill("fetch")(g,l)))(n,u),d=new Error,w=f.catch(g=>{throw{[we]:g}}).then(g=>{if(!g.ok){const l=new Gn;if(l.cause=d,l.stack=l.stack+`
5
+ CAUSE: `+d.stack,l.response=g,l.url=c,g.type==="opaque")throw l;return g.text().then(b=>{var P;if(l.message=b,i.errorType==="json"||((P=g.headers.get("Content-Type"))===null||P===void 0?void 0:P.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=g.status,l})}return g}),k=g=>g.catch(l=>{const b=l.hasOwnProperty(we),P=b?l[we]:l,j=(P==null?void 0:P.status)&&p.get(P.status)||p.get(P==null?void 0:P.name)||b&&p.has(we)&&p.get(we);if(j)return j(P,t);const $=p.get(Yn);if($)return $(P,t);throw P}),v=g=>l=>k(g?w.then(b=>b&&b[g]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),E={_wretchReq:t,_fetchReq:f,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(g,l){return p.set(g,l),this},badRequest(g){return this.error(400,g)},unauthorized(g){return this.error(401,g)},forbidden(g){return this.error(403,g)},notFound(g){return this.error(404,g)},timeout(g){return this.error(408,g)},internalError(g){return this.error(500,g)},fetchError(g){return this.error(we,g)}},S=h.reduce((g,l)=>({...g,...typeof l.resolver=="function"?l.resolver(g):l.resolver}),E);return a.reduce((g,l)=>l(g,t),S)},wi={_url:"",_options:{},_config:Te,_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:pe(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:pe(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:pe(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Vn]: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(Yn,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=tn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||nn(i));return r=n?o?r.json(n,i):r.body(n):r,vi(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=tn(this._options.headers);return this.content(e||nn(n)&&n||fi).body(JSON.stringify(t))}};function se(t="",e={}){return{...wi,_url:t,_options:e}}se.default=se;se.options=pi;se.errorType=gi;se.polyfills=mi;se.WretchError=Gn;function ue(){sessionStorage.removeItem(Et),We(ae.CLEAR_CACHE,{})}function bi(t){const e=t.endpoint||`https://api2.${Jn}`,n=_=>async(I,C)=>{let D=sessionStorage.getItem(Et);D||(D=Date.now().toString(),sessionStorage.setItem(Et,D));const T={...C,headers:{...C.headers,"Cache-Timestamp":D}};return _(I,T)},r=(_=!0)=>I=>async(C,D)=>{let T=null;if(T=await oi(_),!T){if(_)throw new Error("No access token available");return I(C,D)}const W={...D,headers:{...D.headers,...T?{Authorization:`Bearer ${T}`}:{}}};return I(C,W)},i=_=>(I,C)=>{if(C.headers.Authorization)return _(I,C);const D=localStorage.getItem("__anon_id"),T=btoa(`${D}:`),W={...C,headers:{...C.headers,Authorization:`Basic ${T}`}};return _(I,W)},o=se(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),Qt(),en({delayTimer:1e3,delayRamp:(_,I)=>_*I,maxAttempts:3,until:_=>!!(_&&(_.ok||_.status>=400&&_.status<500)),retryOnNetworkError:!1})]),a=se(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,Qt(),en({delayTimer:1e3,delayRamp:(_,I)=>_*I,maxAttempts:3,until:_=>!!(_&&(_.ok||_.status>=400&&_.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(_){const I=await o.get("/entitlements").json();return I==null?void 0:I.find(C=>C.id===_)}async function p(_){return o.get(`/entitlements/${_}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(_){const I=await o.get("/contracts").json();return I==null?void 0:I.find(C=>C.id===_)}async function f(){return o.get("/bills").json()}async function d(_){const I=await o.get("/bills").json();return I==null?void 0:I.find(C=>C.id===_)}async function w(_,I){const C=await o.url(`/user-metadata/${_}`).put(I).json();return ue(),C}async function k(_){const I=await o.url(`/user-metadata/${_}`).delete().res();return ue(),I.ok}async function v(_){return(await o.url(`/user-metadata/${_}`).get().json())[_]}async function E(){return await o.url("/user-metadata").get().json()}async function S(){return await o.url("/tags").get().json()}async function g(_){const I=await o.url(`/tags/${_}`).delete().res();return ue(),I.ok}async function l(_){const I=await o.url("/tags").post(_).res();return ue(),I.ok}async function b(_){return(await a.url("/tallies").get().json())[_]}async function P(){return await a.url("/tallies").get().json()}async function j(_){const I=await a.url(`/tallies/${_}`).delete().res();return ue(),I.ok}async function $(_,I){return await a.url(`/tallies/${_}/push`).post(I).json()}async function L(_){return await o.url(`/products/${_}`).get().json()}async function R(_){const I=await o.url(`/products/${_}/auto-onboard`).post().json();return I.length&&ue(),I}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:p,getContracts:u,getContract:c,getBills:f,getBill:d,setUserMetadata:w,deleteUserMetadata:k,getUserMetadata:v,listUserMetadata:E,getTags:S,deleteTag:g,setTag:l,getTally:b,getTallies:P,deleteTally:j,pushTally:$,getProduct:L,autoOnboardProduct:R}}const Bn="@sesamy/sesamy-js",Dt="1.3.2";function rn(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Je="undefined",on="object",Tt=function(){},qn="any",Qn="*",ge="__",tt=typeof process<"u"?process:{};tt.env&&tt.env.NODE_ENV;var H=typeof document<"u";tt.versions!=null&&tt.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 er(t,e){return e.charAt(0)[t]()+e.slice(1)}var ki=er.bind(null,"toUpperCase"),Ii=er.bind(null,"toLowerCase");function Si(t){return tr(t)?ki("null"):typeof t=="object"?Oi(t):Object.prototype.toString.call(t).slice(8,-1)}function nt(t,e){e===void 0&&(e=!0);var n=Si(t);return e?Ii(n):n}function Ke(t,e){return typeof e===t}var V=Ke.bind(null,"function"),ie=Ke.bind(null,"string"),ke=Ke.bind(null,"undefined"),_i=Ke.bind(null,"boolean");Ke.bind(null,"symbol");function tr(t){return t===null}function Ei(t){return nt(t)==="number"&&!isNaN(t)}function nr(t){return nt(t)==="array"}function X(t){if(!Ti(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ti(t){return t&&(typeof t=="object"||t!==null)}function Oi(t){return V(t.constructor)?t.constructor.name:null}function Pi(t){return t instanceof Error||ie(t.message)&&t.constructor&&Ei(t.constructor.stackTraceLimit)}function rr(t,e){if(typeof e!="object"||tr(e))return!1;if(e instanceof t)return!0;var n=nt(new t(""));if(Pi(e))for(;e;){if(nt(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}rr.bind(null,TypeError);rr.bind(null,SyntaxError);function ot(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?ji(t,e):n}function ji(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function at(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}at(ot,"form");at(ot,"button");at(ot,"input");at(ot,"select");function Ci(t){return t?nr(t)?t:[t]:[]}function an(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function xi(){if(H){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Ai(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function $i(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=an(n[1]),a=an(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&&(zi(r,h.map(function(p){return p.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return H&&window.location.search.substring(1)}(t))}function zi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function st(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Ni(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 p=e-(h-a);return n=this,r=arguments,p<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,p)),i}}var Ue="global",Oe=ge+"global"+ge,Pe=typeof self===on&&self.self===self&&self||typeof global===on&&global.global===global&&global||void 0;function ye(t){return Pe[Oe][t]}function ve(t,e){return Pe[Oe][t]=e}function Ce(t){delete Pe[Oe][t]}function xe(t,e,n){var r;try{if(Ut(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Pe[Oe]||(Pe[Oe]={});var Xe={};function Ut(t){if(typeof Xe[t]!==Je)return Xe[t];try{var e=window[t];e.setItem(Je,Je),e.removeItem(Je)}catch{return Xe[t]=!1}return Xe[t]=!0}function A(){return A=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},A.apply(this,arguments)}var re="function",te="undefined",Di="@@redux/"+Math.random().toString(36),sn=function(){return typeof Symbol===re&&Symbol.observable||"@@observable"}(),Ve=" != "+re;function ir(t,e,n){var r;if(typeof e===re&&typeof n===te&&(n=e,e=void 0),typeof n!==te){if(typeof n!==re)throw new Error("enhancer"+Ve);return n(ir)(t,e)}if(typeof t!==re)throw new Error("reducer"+Ve);var i=t,o=e,a=[],s=a,h=!1;function p(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==re)throw new Error("Listener"+Ve);var w=!0;return p(),s.push(d),function(){if(w){w=!1,p();var k=s.indexOf(d);s.splice(k,1)}}}function f(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===te)throw new Error("ActType "+te);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var w=a=s,k=0;k<w.length;k++)(0,w[k])();return d}return f({type:"@@redux/INIT"}),(r={dispatch:f,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==re)throw new Error("next reducer"+Ve);i=d,f({type:"@@redux/INIT"})}})[sn]=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)}}})[sn]=function(){return this},d},r}function Ui(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+te}function je(){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 Li(){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(p){return s(p)}};return o=[].slice.call(t).map(function(p){return p(h)}),A({},a,{dispatch:s=je.apply(void 0,o)(a.dispatch)})}}}var oe=ge+"anon_id",me=ge+"user_id",Se=ge+"user_traits",ne="userId",Ie="anonymousId",et=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],Ot=["name","EVENTS","config","loaded"],x=et.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),cn=/^utm_/,un=/^an_prop_/,ln=/^an_trait_/;function Ri(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,h=i.initialUser,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(oe,a.anonymousId),p||e(me,a.userId),h.traits&&e(Se,A({},p&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,f=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(un)&&(w.props[k.replace(un,"")]=o[k]),k.match(ln)&&(w.traits[k.replace(ln,"")]=o[k]),w},{campaign:{},props:{},traits:{}});n.dispatch(A({type:x.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),f&&setTimeout(function(){return t.track(f,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:x.campaign,campaign:d.campaign})}}return r(i)}}}}function Mi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===x.setItemEnd){if(n.key===oe)return A({},e,{anonymousId:n.value});if(n.key===me)return A({},e,{userId:n.value})}switch(n.type){case x.identify:return Object.assign({},e,{userId:n.userId,traits:A({},e.traits,n.traits)});case x.reset:return[me,oe,Se].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function dn(t){return{userId:t.getItem(me),anonymousId:t.getItem(oe),traits:t.getItem(Se)}}var Pt=function(t){return ge+"TEMP"+ge+t};function Zi(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,p=s.traits,u=s.options;if(s.type===x.reset&&([me,Se,oe].forEach(function(d){r(d)}),[ne,Ie,"traits"].forEach(function(d){Ce(Pt(d))})),s.type===x.identify){i(oe)||n(oe,st());var c=i(me),f=i(Se)||{};c&&c!==h&&o.dispatch({type:x.userIdChanged,old:{userId:c,traits:f},new:{userId:h,traits:p},options:u}),h&&n(me,h),p&&n(Se,A({},f,p))}return a(s)}}}}var De={};function hn(t,e){De[t]&&V(De[t])&&(De[t](e),delete De[t])}function or(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(A({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return or(t,e,n-10).then(r,i)})})}function Wi(t){return{abort:t}}function ar(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 p=s.actions.reduce(function(c,f,d){return a[f.plugin].loaded?(c.process.push(f),c.processIndex.push(d)):(c.requeue.push(f),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(p.processIndex&&p.processIndex.length){p.processIndex.forEach(function(c){var f=s.actions[c],d=f.plugin,w=f.payload.type,k=i[d][w];if(k&&V(k)){var v,E=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[ne,Ie].reduce(function(P,j){return l.hasOwnProperty(j)&&b[j]&&b[j]!==l[j]&&(P[j]=b[j]),P},l)}(f.payload,h),S=r[E.meta.rid];if(!S&&(v=k({payload:E,config:a[d].config,instance:n,abort:Wi}))&&X(v)&&v.abort)return void(r[E.meta.rid]=!0);if(!S){var g=w+":"+d;t.dispatch(A({},E,{type:g,_:{called:g,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,f){return!~p.processIndex.indexOf(f)});s.actions=u}}}var mt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var p=i.plugins,u=i.context,c=n.type,f=c.match(_e),d=e.exact.map(function(v){return v.pluginName});f&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,E){return function(S,g,l){var b=g.config,P=g.name,j=P+"."+S.type;l&&(j=l.event);var $=S.type.match(_e)?function(L,R,_,I,C){return function(D,T){var W=I?I.name:L,J=T&&Ze(T)?T:_;if(I&&(!(J=T&&Ze(T)?T:[L]).includes(L)||J.length!==1))throw new Error("Method "+R+" can only abort "+L+" plugin. "+JSON.stringify(J)+" input valid");return A({},C,{abort:{reason:D,plugins:J,caller:R,_:W}})}}(P,j,E,l,S):function(L,R){return function(){throw new Error(L.type+" action not cancellable. Remove abort in "+R)}}(S,j);return{payload:Ki(S),instance:v,config:b||{},abort:$}}}(r,d),k=e.exact.reduce(function(v,E){var S=E.pluginName,g=E.methodName,l=!1;return g.match(/^initialize/)||g.match(/^reset/)||(l=!p[S].loaded),u.offline&&g.match(/^(page|track|identify)/)&&(l=!0),v[""+S]=l,v},{});return Promise.resolve(e.exact.reduce(function(v,E,S){try{var g=E.pluginName;return Promise.resolve(v).then(function(l){function b(){return Promise.resolve(l)}var P=function(){if(e.namespaced&&e.namespaced[g])return Promise.resolve(e.namespaced[g].reduce(function(j,$,L){try{return Promise.resolve(j).then(function(R){return $.method&&V($.method)?(function(D,T){var W=wn(D);if(W&&W.name===T){var J=wn(W.method);throw new Error([T+" plugin is calling method "+D,"Plugins cant call self","Use "+W.method+" "+(J?"or "+J.method:"")+" in "+T+" plugin insteadof "+D].join(`
6
+ `))}}($.methodName,$.pluginName),Promise.resolve($.method({payload:R,instance:r,abort:(_=R,I=g,C=$.pluginName,function(D,T){return A({},_,{abort:{reason:D,plugins:T||[I],caller:c,from:C||I}})}),config:mn($.pluginName,p,o),plugins:p})).then(function(D){var T=X(D)?D:{};return Promise.resolve(A({},R,T))})):R;var _,I,C})}catch(R){return Promise.reject(R)}},Promise.resolve(n))).then(function(j){l[g]=j});l[g]=n}();return P&&P.then?P.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(E,S,g){try{var l=e.exact.length===g+1,b=S.pluginName,P=o[b];return Promise.resolve(E).then(function(j){var $=v[b]?v[b]:{};if(f&&($=j),yt($,b))return gt({data:$,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(j);if(yt(j,b))return l&&gt({data:j,method:c,instance:r,store:s}),Promise.resolve(j);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:$,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(j);var L=w(v[b],o[b]);return Promise.resolve(P[c]({abort:L.abort,payload:$,instance:r,config:mn(b,p,o),plugins:p})).then(function(R){var _=X(R)?R:{},I=A({},j,_),C=v[b];if(yt(C,b))gt({data:C,method:c,instance:r,pluginName:b,store:s});else{var D=c+":"+b;(D.match(/:/g)||[]).length<2&&!c.match(fn)&&!c.match(pn)&&r.dispatch(A({},f?I:$,{type:D,_:{called:D,from:"submethod"}}))}return Promise.resolve(I)})})}catch(j){return Promise.reject(j)}},Promise.resolve(n))).then(function(E){if(!(c.match(_e)||c.match(/^registerPlugin/)||c.match(pn)||c.match(fn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(h.plugins.includes(c),E._&&E._.originalAction===c)return E;var S=A({},E,{_:{originalAction:E.type,called:E.type,from:"engineEnd"}});sr(E,e.exact.length)&&!c.match(/End$/)&&(S=A({},S,{type:E.type+"Aborted"})),s.dispatch(S)}return E})})}catch(v){return Promise.reject(v)}},_e=/Start$/,fn=/^bootstrap/,pn=/^ready/;function gt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(A({},t.data,{type:n,_:{called:n,from:"abort"}}))}function mn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function gn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function yn(t,e){var n=t.replace(_e,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||vn(n,e)||n&&vn(n.plugins,e))}function sr(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ie(n))return!0;var r=n.plugins;return Ze(n)&&n.length===e||Ze(r)&&r.length===e}function Ze(t){return Array.isArray(t)}function vn(t,e){return!(!t||!Ze(t))&&t.includes(e)}function wn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Ki(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=X(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Fi(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)},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 hn(a.meta.rid,{payload:a})},0),p===x.initializeEnd){var f=e(),d=Object.keys(f),w=d.filter(function(l){return u.includes(l)}).map(function(l){return f[l]}),k=[],v=[],E=a.disabled,S=w.map(function(l){var b=l.loaded,P=l.name,j=l.config;return or(l,function(){return b({config:j})},1e4).then(function($){return r[P]||(i.dispatch({type:x.pluginReadyType(P),name:P,events:Object.keys(l).filter(function(L){return!Ot.includes(L)})}),r[P]=!0),k=k.concat(P),l}).catch(function($){if($ instanceof Error)throw new Error($);return v=v.concat($.name),$})});Promise.all(S).then(function(l){var b={plugins:k,failed:v,disabled:E};setTimeout(function(){d.length===S.length+E.length&&i.dispatch(A({},{type:x.ready},b))},0)})}var g=function(){if(p!==x.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return ar(i,e,t)},0),Promise.resolve(function(l,b,P,j,$){try{var L=V(b)?b():b,R=l.type,_=R.replace(_e,"");if(l._&&l._.called)return Promise.resolve(l);var I=P.getState(),C=(W=L,(J=I.plugins)===void 0&&(J={}),(Ae=l.options)===void 0&&(Ae={}),Object.keys(W).filter(function(m){var y=Ae.plugins||{};return _i(y[m])?y[m]:y.all!==!1&&(!J[m]||J[m].enabled!==!1)}).map(function(m){return W[m]}));R===x.initializeStart&&l.fromEnable&&(C=Object.keys(I.plugins).filter(function(m){var y=I.plugins[m];return l.plugins.includes(m)&&!y.initialized}).map(function(m){return L[m]}));var D=C.map(function(m){return m.name}),T=function(m,y,O){var z=yn(m).map(function(N){return gn(N,y)});return y.reduce(function(N,U){var F=U.name,Z=yn(m,F).map(function($e){return gn($e,y)}),K=Z[0],M=Z[1],q=Z[2];return K.length&&(N.beforeNS[F]=K),M.length&&(N.duringNS[F]=M),q.length&&(N.afterNS[F]=q),N},{before:z[0],beforeNS:{},during:z[1],duringNS:{},after:z[2],afterNS:{}})}(R,C);return Promise.resolve(mt({action:l,data:{exact:T.before,namespaced:T.beforeNS},state:I,allPlugins:L,allMatches:T,instance:P,store:j,EVENTS:$})).then(function(m){function y(){var N=function(){if(R.match(_e))return Promise.resolve(mt({action:A({},O,{type:_+"End"}),data:{exact:T.after,namespaced:T.afterNS},state:I,allPlugins:L,allMatches:T,instance:P,store:j,EVENTS:$})).then(function(U){U.meta&&U.meta.hasCallback&&hn(U.meta.rid,{payload:U})})}();return N&&N.then?N.then(function(){return m}):m}if(sr(m,D.length))return m;var O,z=function(){if(R!==_)return Promise.resolve(mt({action:A({},m,{type:_}),data:{exact:T.during,namespaced:T.duringNS},state:I,allPlugins:L,allMatches:T,instance:P,store:j,EVENTS:$})).then(function(N){O=N});O=m}();return z&&z.then?z.then(y):y()})}catch(m){return Promise.reject(m)}var W,J,Ae}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(g&&g.then?g.then(h):h(g))}catch(l){return Promise.reject(l)}}}}}function Hi(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 Ji=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 je.apply(void 0,a)(r)(i)}}}}};function Xi(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=bn(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},A({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var h=bn(n.type,x.initialize),p=t()[h];return p&&h?(r[h]=A({},e[h],{initialized:!0,loaded:!!p.loaded({config:p.config})}),A({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=A({},e[n.name],{loaded:!0}),A({},e,r);switch(n.type){case x.disablePlugin:return A({},e,kn(n.plugins,!1,e));case x.enablePlugin:return A({},e,kn(n.plugins,!0,e));default:return e}}}function bn(t,e){return t.substring(e.length+1,t.length)}function kn(t,e,n){return t.reduce(function(r,i){return r[i]=A({},n[i],{enabled:e}),r},n)}function cr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Vi={last:{},history:[]};function Yi(t,e){t===void 0&&(t=Vi);var n=e.options,r=e.meta;if(e.type===x.track){var i=cr(A({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return A({},t,{last:i,history:t.history.concat(i)})}return t}var Gi={actions:[]};function Bi(t,e){t===void 0&&(t=Gi);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===x.identify?[e].concat(t.actions):t.actions.concat(e),A({},t,{actions:r});case"dequeue":return[];default:return t}}var ur=/#.*$/;function qi(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(ur,""):"")}var lr,dr,hr,fr,Qi=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,p=o.search,u=function(f){var d=function(){if(H){for(var w,k=document.getElementsByTagName("link"),v=0;w=k[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+f:window.location.href.replace(ur,"")}(p),c={title:n,url:u,path:qi(u),hash:h,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),A({},c,t)},eo={last:{},history:[]};function to(t,e){t===void 0&&(t=eo);var n=e.options;if(e.type===x.page){var r=cr(A({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return A({},t,{last:r,history:t.history.concat(r)})}return t}lr=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"}(),dr=H?document.referrer:null,hr=xi(),fr=Ai();var In={initialized:!1,sessionId:st(),app:null,version:null,debug:!1,offline:!!H&&!navigator.onLine,os:{name:lr},userAgent:H?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:fr,locale:hr,campaign:{},referrer:dr};function no(t,e){t===void 0&&(t=In);var n=t.initialized,r=e.campaign;switch(e.type){case x.campaign:return A({},t,{campaign:r});case x.offline:return A({},t,{offline:!0});case x.online:return A({},t,{offline:!1});default:return n?t:A({},In,t,{initialized:!0})}}var ro=["plugins","reducers","storage"];function io(t,e,n){if(H){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function oo(t){var e=io.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function pr(){return ve("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 Pe[Oe].analytics.push(a.action||a),o(a)}})}}}function Sn(t){return function(){return je(je.apply(null,arguments),pr())}}function vt(t){return t?nr(t)?t:[t]:[]}function _n(t,e,n){t===void 0&&(t={});var r,i,o=st();return e&&(De[o]=(r=e,i=function(a){for(var s,h=a||Array.prototype.slice.call(arguments),p=0;p<h.length;p++)if(V(h[p])){s=h[p];break}return s}(n),function(a){i&&i(a),r(a)})),A({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function ao(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,y){if(V(y))return m.middlewares=m.middlewares.concat(y),m;if(y.NAMESPACE&&(y.name=y.NAMESPACE),!y.name)throw new Error("https://lytics.dev/errors/1");y.config||(y.config={});var O=y.EVENTS?Object.keys(y.EVENTS).map(function(U){return y.EVENTS[U]}):[];m.pluginEnabled[y.name]=!(y.enabled===!1||y.config.enabled===!1),delete y.enabled,y.methods&&(m.methods[y.name]=Object.keys(y.methods).reduce(function(U,F){var Z;return U[F]=(Z=y.methods[F],function(){for(var K=Array.prototype.slice.call(arguments),M=new Array(Z.length),q=0;q<K.length;q++)M[q]=K[q];return M[M.length]=b,Z.apply({instance:b},M)}),U},{}),delete y.methods);var z=Object.keys(y).concat(O),N=new Set(m.events.concat(z));if(m.events=Array.from(N),m.pluginsArray=m.pluginsArray.concat(y),m.plugins[y.name])throw new Error(y.name+"AlreadyLoaded");return m.plugins[y.name]=y,m.plugins[y.name].loaded||(m.plugins[y.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ye,setItem:ve,removeItem:Ce},o=function(m){return function(y,O,z){return O.getState("user")[y]||(z&&X(z)&&z[y]?z[y]:dn(m)[y]||ye(Pt(y))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!Ot.includes(m)}).sort(),h=new Set(s.concat(et).filter(function(m){return!Ot.includes(m)})),p=Array.from(h).sort(),u=function(){return a},c=new Ji,f=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=$i(),E=dn(i),S=A({},E,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=st());var g=A({enable:function(m,y){return new Promise(function(O){T.dispatch({type:x.enablePlugin,plugins:vt(m),_:{originalAction:x.enablePlugin}},O,[y])})},disable:function(m,y){return new Promise(function(O){T.dispatch({type:x.disablePlugin,plugins:vt(m),_:{originalAction:x.disablePlugin}},O,[y])})}},r.methods),l=!1,b={identify:function(m,y,O,z){try{var N=ie(m)?m:null,U=X(m)?m:y,F=O||{},Z=b.user();ve(Pt(ne),N);var K=N||U.userId||o(ne,b,U);return Promise.resolve(new Promise(function(M){T.dispatch(A({type:x.identifyStart,userId:K,traits:U||{},options:F,anonymousId:Z.anonymousId},Z.id&&Z.id!==N&&{previousId:Z.id}),M,[y,O,z])}))}catch(M){return Promise.reject(M)}},track:function(m,y,O,z){try{var N=X(m)?m.event:m;if(!N||!ie(N))throw new Error("EventMissing");var U=X(m)?m:y||{},F=X(O)?O:{};return Promise.resolve(new Promise(function(Z){T.dispatch({type:x.trackStart,event:N,properties:U,options:F,userId:o(ne,b,y),anonymousId:o(Ie,b,y)},Z,[y,O,z])}))}catch(Z){return Promise.reject(Z)}},page:function(m,y,O){try{var z=X(m)?m:{},N=X(y)?y:{};return Promise.resolve(new Promise(function(U){T.dispatch({type:x.pageStart,properties:Qi(z),options:N,userId:o(ne,b,z),anonymousId:o(Ie,b,z)},U,[m,y,O])}))}catch(U){return Promise.reject(U)}},user:function(m){if(m===ne||m==="id")return o(ne,b);if(m===Ie||m==="anonId")return o(Ie,b);var y=b.getState("user");return m?rn(y,m):y},reset:function(m){return new Promise(function(y){T.dispatch({type:x.resetStart},y,m)})},ready:function(m){return l&&m({plugins:g,instance:b}),b.on(x.ready,function(y){m(y),l=!0})},on:function(m,y){if(!m||!V(y))return!1;if(m===x.bootstrap)throw new Error(".on disabled for "+m);var O=/Start$|Start:/;if(m==="*"){var z=function(Z){return function(K){return function(M){return M.type.match(O)&&y({payload:M,instance:b,plugins:a}),K(M)}}},N=function(Z){return function(K){return function(M){return M.type.match(O)||y({payload:M,instance:b,plugins:a}),K(M)}}};return f(z,Ye),f(N,Ge),function(){d(z,Ye),d(N,Ge)}}var U=m.match(O)?Ye:Ge,F=function(Z){return function(K){return function(M){return M.type===m&&y({payload:M,instance:b,plugins:a,abort:k}),K(M)}}};return f(F,U),function(){return d(F,U)}},once:function(m,y){if(!m||!V(y))return!1;if(m===x.bootstrap)throw new Error(".once disabled for "+m);var O=b.on(m,function(z){y({payload:z.payload,instance:b,plugins:a,abort:k}),O()});return O},getState:function(m){var y=T.getState();return m?rn(y,m):Object.assign({},y)},dispatch:function(m){var y=ie(m)?{type:m}:m;if(et.includes(y.type))throw new Error("reserved action "+y.type);var O=A({},y,{_:A({originalAction:y.type},m._||{})});T.dispatch(O)},enablePlugin:g.enable,disablePlugin:g.disable,plugins:g,storage:{getItem:i.getItem,setItem:function(m,y,O){T.dispatch({type:x.setItemStart,key:m,value:y,options:O})},removeItem:function(m,y){T.dispatch({type:x.removeItemStart,key:m,options:y})}},setAnonymousId:function(m,y){b.storage.setItem(oe,m,y)},events:{core:et,plugins:s}},P=r.middlewares.concat([function(m){return function(y){return function(O){return O.meta||(O.meta=_n()),y(O)}}},w(Ye),Fi(b,u,{all:p,plugins:s}),Hi(i),Ri(b),Zi(b),w(Ge)]),j={context:no,user:Mi(i),page:to,track:Yi,plugins:Xi(u),queue:Bi},$=je,L=je;if(H&&t.debug){var R=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;R&&($=R({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?pr():X(typeof arguments[0])?Sn():Sn().apply(null,arguments)}}var _,I=function(m){return Object.keys(m).reduce(function(y,O){return ro.includes(O)||(y[O]=m[O]),y},{})}(t),C=r.pluginsArray.reduce(function(m,y){var O=y.name,z=y.config,N=y.loaded,U=r.pluginEnabled[O];return m[O]={enabled:U,initialized:!!U&&!y.initialize,loaded:!!N({config:z}),config:z},m},{}),D={context:I,user:S,plugins:C},T=ir(function(m){for(var y=Object.keys(m),O={},z=0;z<y.length;z++){var N=y[z];typeof m[N]===re&&(O[N]=m[N])}var U,F=Object.keys(O);try{(function(Z){Object.keys(Z).forEach(function(K){var M=Z[K];if(typeof M(void 0,{type:"@@redux/INIT"})===te||typeof M(void 0,{type:Di})===te)throw new Error("reducer "+K+" "+te)})})(O)}catch(Z){U=Z}return function(Z,K){if(Z===void 0&&(Z={}),U)throw U;for(var M=!1,q={},$e=0;$e<F.length;$e++){var Fe=F[$e],Ft=Z[Fe],lt=(0,O[Fe])(Ft,K);if(typeof lt===te){var Tr=Ui(Fe,K);throw new Error(Tr)}q[Fe]=lt,M=M||lt!==Ft}return M?q:Z}}(A({},j,e)),D,L($(Li.apply(void 0,P))));T.dispatch=(_=T.dispatch,function(m,y,O){var z=A({},m,{meta:_n(m.meta,y,vt(O))});return _.apply(null,[z])});var W=Object.keys(a);T.dispatch({type:x.bootstrap,plugins:W,config:I,params:v,user:S,initialUser:n,persistedUser:E});var J=W.filter(function(m){return r.pluginEnabled[m]}),Ae=W.filter(function(m){return!r.pluginEnabled[m]});return T.dispatch({type:x.registerPlugins,plugins:W,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,y){var O=m.bootstrap,z=m.config,N=m.name;O&&V(O)&&O({instance:b,config:z,payload:m}),T.dispatch({type:x.registerPluginType(N),name:N,enabled:r.pluginEnabled[N],plugin:m}),r.pluginsArray.length===y+1&&T.dispatch({type:x.initializeStart,plugins:J,disabled:Ae})}),oo(function(m){T.dispatch({type:m?x.offline:x.online})}),function(m,y,O){setInterval(function(){return ar(m,y,O)},3e3)}(T,u,b),b}var Ye="before",Ge="after",Le="cookie",de=yr(),mr=ct,so=ct;function gr(t){return de?ct(t,"",-1):Ce(t)}function yr(){if(de!==void 0)return de;var t="cookiecookie";try{ct(t,t),de=document.cookie.indexOf(t)!==-1,gr(t)}catch{de=!1}return de}function ct(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return de===!1&&(a?ve(t,e):ye(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 Re="localStorage",co=Ut.bind(null,"localStorage");xe("localStorage","getItem",ye);xe("localStorage","setItem",ve);xe("localStorage","removeItem",Ce);var Me="sessionStorage",uo=Ut.bind(null,"sessionStorage");xe("sessionStorage","getItem",ye);xe("sessionStorage","setItem",ve);xe("sessionStorage","removeItem",Ce);function Ee(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(X(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var lo=co(),ho=uo(),fo=yr();function vr(t,e){if(t){var n=Lt(e),r=!Wt(n),i=Rt(n)?Ee(localStorage.getItem(t)):void 0;if(r&&!ke(i))return i;var o=Mt(n)?Ee(mr(t)):void 0;if(r&&o)return o;var a=Zt(n)?Ee(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ye(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function po(t,e,n){if(t&&!ke(e)){var r={},i=Lt(n),o=JSON.stringify(e),a=!Wt(i);return Rt(i)&&(r[Re]=Be(Re,e,Ee(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Re]:Mt(i)&&(r[Le]=Be(Le,e,Ee(mr(t))),so(t,o),a)?r[Le]:Zt(i)&&(r[Me]=Be(Me,e,Ee(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Me]:(r[Ue]=Be(Ue,e,ye(t)),ve(t,e),a?r[Ue]:r)}}function mo(t,e){if(t){var n=Lt(e),r=vr(t,Qn),i={};return!ke(r.localStorage)&&Rt(n)&&(localStorage.removeItem(t),i[Re]=r.localStorage),!ke(r.cookie)&&Mt(n)&&(gr(t),i[Le]=r.cookie),!ke(r.sessionStorage)&&Zt(n)&&(sessionStorage.removeItem(t),i[Me]=r.sessionStorage),!ke(r.global)&&ut(n,Ue)&&(Ce(t),i[Ue]=r.global),i}}function Lt(t){return t?ie(t)?t:t.storage:qn}function Rt(t){return lo&&ut(t,Re)}function Mt(t){return fo&&ut(t,Le)}function Zt(t){return ho&&ut(t,Me)}function Wt(t){return t===Qn||t==="all"}function ut(t,e){return t===qn||t===e||Wt(t)}function Be(t,e,n){return{location:t,current:e,previous:n}}var go={setItem:po,getItem:vr,removeItem:mo};function yo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function En(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 Tn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?En(Object(n),!0).forEach(function(r){yo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):En(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:go};return ao(Tn(Tn({},e),t))}function wo(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 bo(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 p=((c=h[2])==null?void 0:c.toString())||"",u=Io(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,h)}})}function ko(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Io(t){return["#","?"].forEach(e=>t=ko(t,e)),t}function So(){bo(()=>{ee.page()})}function _o(t){if(t===void 0&&(t={}),!H)return Tt;var e=Pn(),n=jt(),r=On(),i=qe(r,e),o=qe(n,e),a=[],s=[],h=[],p=r,u=i,c=o,f=Object.keys(t);if(!f.length)return Tt;var d=f.map(function(k){return Number(k)}),w=Ni(function(){var k=Pn(),v=function(I,C){return C.map(function(D){return D===100?I-5:I*(D/100)})}(k,d),E=jt(),S=On(),g=qe(S,k),l=qe(E,k);if(u=g>u?g:u,c=l<c?l:c,!(a.length>=d.length)){var b=p===S,P="up";b?P="initial":p<=S&&(P="down");var j=v,$=d;(P==="up"||b)&&(j=v.slice().reverse(),$=d.slice().reverse());var L=$.reduce(function(I,C,D){var T=j[D];return h.includes(C)&&S<=T&&(h=h.filter(function(W){return W!==C}),I.singleFunction=C),P==="down"&&!a.includes(C)&&S>=T&&C>o?(s.push(C),I.callbacks=I.callbacks.concat(C),I):P==="up"&&!a.includes(C)&&S<=T&&C<=g?(I.foundFunc=[C],I):(b&&S>=T&&I.foundFunc.length===0&&(I.foundFunc=[C]),!s.includes(C)&&S>=T&&(s.push(C),I.singleFunction?h.push(C):I.singleFunction=C),I)},{foundFunc:[],singleFunction:null,callbacks:[],direction:P});if(p=S,P==="down"&&L.callbacks&&L.callbacks.forEach(function(I){V(t[I])&&(t[I]({trigger:I,direction:P,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(I))}),L.singleFunction){var R=L.singleFunction,_=L.direction;V(t[R])&&t[R]({trigger:R,direction:_,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(R)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function jt(){return H?document.body.scrollTop||document.documentElement.scrollTop:0}function Eo(){return H?window.innerHeight||document.documentElement.clientHeight:0}function On(){return Math.round(jt()+Eo())}function Pn(){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 qe(t,e){return Math.round(t/e*100)}var jn="EventListener";function To(t){return function(e,n,r,i){var o=r||Tt,a=i||!1;if(!H)return o;var s=rt(n),h=rt(e,!0);if(!h.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var f=c?"add"+jn:"remove"+jn,d=0;d<h.length;d++){var w=h[d];p[d]=c?a&&a.once?Oo(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[f]?w["on"+s[k]]=c?p[d]:null:w[f](s[k],p[d],a)}return u.bind(null,!c)}(t)}}function rt(t,e){if(ie(t))return e?rt(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=Ci(t);return e?o.map(function(a){return ie(a)?rt(a,!0):a}).flat():o}function Oo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var wt=To("Event");function wr(t,e){return H&&V(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),V(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}wr.bind(null,"onerror");wr.bind(null,"onload");var br=typeof window>"u",Cn="hidden";function Po(t){if(br)return!1;var e=jo(),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 jo(){var t=["webkit","moz","ms","o"];return br||Cn in document?Cn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Co=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function xo(t,e){e===void 0&&(e={});var n=function(a,s){var h=this,p=!1;return function(u){p||(a.call(h,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=Po(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Co.map(function(s){return wt(document,s,n)})).concat(wt(window,"load",n)).concat(wt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Ao(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,p=h===void 0?2e3:h,u=!1,c=!1,f=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(Ne(f),v),i&&u&&(u=!1,i(Ne(n),v),f=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Ne(f),v))},s)}var k=xo(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,f=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Ne(f,c),idle:u?Ne(n,c):0}}}}function Ne(t,e){return e?0:Math.round((new Date-t)/1e3)}const xn=5e3;class $o{constructor(e){B(this,"element");B(this,"isInViewport",!1);B(this,"isAwake",!1);B(this,"isFlushing");B(this,"observer");B(this,"lastEventAt",Date.now());B(this,"registeredView",!1);B(this,"viewCallback");B(this,"activeDurationCallback");B(this,"idleDurationCallback");B(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),Ao({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:xn}),_o({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*xn: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 An="sesamy_session_id";function zo(){let t=sessionStorage.getItem(An);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(An,t)),t}let kr=!1,Ct,$n,it;function No({clientId:t,enabled:e=!0,endpoint:n=ei}){if(Ct=t,$n=e,it=n,!$n)return;So();const r=new $o({element:document.body,viewCallback:()=>{ee.page()},activeDurationCallback:(i,o,a)=>{ee.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ee.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ee.track("scroll",{scroll:i.scrollMax})}});Lo(document.body,()=>{r.flush()}),Ro(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(ae.AUTHENTICATED,async i=>{const o=i;await ee.identify(o.detail.sub)}),window.addEventListener(ae.LOGOUT,async()=>{await ee.track("logout",{}),Kt.flush(),await ee.reset()})}function Ir(t){return JSON.stringify(t.map(e=>({...e,clientId:Ct,requestId:Math.random().toString(36).slice(2,9),sessionId:zo(),timestamp:new Date().toISOString(),version:Dt,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:Bn,userAgent:navigator.userAgent,clientId:Ct}})))}const Kt=wo(async t=>{if(t.length>0){const e=Ir(t);kr?navigator.sendBeacon(it,e):(await fetch(it,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function bt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(it,Ir([n]))}else Kt.push(t)}const ee=vo({app:Bn,version:Dt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;bt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Do(t,e){ee.track(t,e)}function Uo(){return kr=!0,Kt.flush()}const Sr=new Map;function Lo(t,e){Sr.set(t,e)}window.addEventListener("beforeunload",()=>{Sr.forEach((t,e)=>{t.bind(e)()}),Uo()});const _r=new Map;function Ro(t,e){_r.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&_r.forEach((t,e)=>{t.bind(e)()})});function Mo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getContract:i,getContracts:o,getBill:a,getBills:s,getTags:h,deleteTag:p,setTag:u,getUserMetadata:c,listUserMetadata:f,setUserMetadata:d,deleteUserMetadata:w,getTally:k,getTallies:v,pushTally:E,deleteTally:S,getProduct:g,autoOnboardProduct:l}=bi(t),b={auth:{getUser:ri,isAuthenticated:ni,loginWithRedirect:ii,logout:ai,setToken:Xn},analytics:{track:Do},tags:{list:h,set:u,delete:p},entitlements:{get:e,list:n,access:r},contracts:{get:i,list:o},bills:{get:a,list:s},userMetadata:{get:c,list:f,set:d,delete:w},tallies:{get:k,list:v,push:E,delete:S},products:{get:g,autoOnboard:l},getVersion:Zo,clearCache:ue};return t.namespace&&(window[t.namespace]=b),b}function Zo(){return Dt}function Wo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e&&n){Xn(e,parseInt(n,10));const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}async function Er(t){No({clientId:t.clientId,...t.analytics}),await ti({clientId:t.clientId,...t.auth});const e=Mo(t.api||{});return We(ae.READY,{}),Wo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Er(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=Er;
@@ -30,6 +30,7 @@ export type Entitlement = {
30
30
  id: string;
31
31
  sku: string;
32
32
  purchaseOptionsId?: string;
33
+ url?: string;
33
34
  cover?: string;
34
35
  title: string;
35
36
  type: string;
@@ -86,6 +87,7 @@ export type Product = {
86
87
  createdAt: string;
87
88
  updatedAt: string;
88
89
  };
90
+ declare function clearCache(): void;
89
91
  export declare function init(config: Config): Promise<{
90
92
  auth: {
91
93
  getUser: typeof getUser;
@@ -140,6 +142,7 @@ export declare function init(config: Config): Promise<{
140
142
  autoOnboard: (sku: string) => Promise<Entitlement[]>;
141
143
  };
142
144
  getVersion: () => string;
145
+ clearCache: typeof clearCache;
143
146
  }>;
144
147
 
145
148
  export {};