@sesamy/sesamy-js 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ (function(G){typeof define=="function"&&define.amd?define(G):G()})(function(){"use strict";var Gi=Object.defineProperty;var Bi=(G,te,K)=>te in G?Gi(G,te,{enumerable:!0,configurable:!0,writable:!0,value:K}):G[te]=K;var q=(G,te,K)=>(Bi(G,typeof te!="symbol"?te+"":te,K),K);var G=(t=>(t.READY="sesamyReady",t))(G||{});async function te(){const t=new CustomEvent(G.READY,{detail:{},bubbles:!0,composed:!0});dispatchEvent(t)}function K(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}typeof SuppressedError=="function"&&SuppressedError;var se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ot(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()}});ot(ce);var tr=ot(at(function(t,e){var n=se&&se.__awaiter||function(u,c,d,h){return new(d||(d=Promise))(function(v,w){function y(I){try{_(h.next(I))}catch(g){w(g)}}function k(I){try{_(h.throw(I))}catch(g){w(g)}}function _(I){I.done?v(I.value):new d(function(g){g(I.value)}).then(y,k)}_((h=h.apply(u,c||[])).next())})},r=se&&se.__generator||function(u,c){var d,h,v,w,y={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return w={next:k(0),throw:k(1),return:k(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function k(_){return function(I){return function(g){if(d)throw new TypeError("Generator is already executing.");for(;y;)try{if(d=1,h&&(v=2&g[0]?h.return:g[0]?h.throw||((v=h.return)&&v.call(h),0):h.next)&&!(v=v.call(h,g[1])).done)return v;switch(h=0,v&&(g=[2&g[0],v.value]),g[0]){case 0:case 1:v=g;break;case 4:return y.label++,{value:g[1],done:!1};case 5:y.label++,h=g[1],g=[0];continue;case 7:g=y.ops.pop(),y.trys.pop();continue;default:if(v=y.trys,!((v=v.length>0&&v[v.length-1])||g[0]!==6&&g[0]!==2)){y=0;continue}if(g[0]===3&&(!v||g[1]>v[0]&&g[1]<v[3])){y.label=g[1];break}if(g[0]===6&&y.label<v[1]){y.label=v[1],v=g;break}if(v&&y.label<v[2]){y.label=v[2],y.ops.push(g);break}v[2]&&y.ops.pop(),y.trys.pop();continue}g=c.call(u,y)}catch(b){g=[6,b],h=0}finally{d=v=0}if(5&g[0])throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}([_,I])}}},i=se;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(d){throw new Error("Unsupported")})})},keySync:function(u){return window.localStorage.key(u)},getItemSync:function(u){return window.localStorage.getItem(u)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(u){return window.localStorage.removeItem(u)},setItemSync:function(u,c){return window.localStorage.setItem(u,c)}};function s(u){return new Promise(function(c){return setTimeout(c,u)})}function f(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",d="",h=0;h<u;h++)d+=c[Math.floor(Math.random()*c.length)];return d}var m=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+f(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=c,u.waiters===void 0&&(u.waiters=[])}return u.prototype.acquireLock=function(c,d){return d===void 0&&(d=5e3),n(this,void 0,void 0,function(){var h,v,w,y,k,_,I;return r(this,function(g){switch(g.label){case 0:h=Date.now()+f(4),v=Date.now()+d,w=o+"-"+c,y=this.storageHandler===void 0?a:this.storageHandler,g.label=1;case 1:return Date.now()<v?[4,s(30)]:[3,8];case 2:return g.sent(),y.getItemSync(w)!==null?[3,5]:(k=this.id+"-"+c+"-"+h,[4,s(Math.floor(25*Math.random()))]);case 3:return g.sent(),y.setItemSync(w,JSON.stringify({id:this.id,iat:h,timeoutKey:k,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return g.sent(),(_=y.getItemSync(w))!==null&&(I=JSON.parse(_)).id===this.id&&I.iat===h?(this.acquiredIatSet.add(h),this.refreshLockWhileAcquired(w,h),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(v)];case 6:g.sent(),g.label=7;case 7:return h=Date.now()+f(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,d){return n(this,void 0,void 0,function(){var h=this;return r(this,function(v){return setTimeout(function(){return n(h,void 0,void 0,function(){var w,y,k;return r(this,function(_){switch(_.label){case 0:return[4,ce.default().lock(d)];case 1:return _.sent(),this.acquiredIatSet.has(d)?(w=this.storageHandler===void 0?a:this.storageHandler,(y=w.getItemSync(c))===null?(ce.default().unlock(d),[2]):((k=JSON.parse(y)).timeRefreshed=Date.now(),w.setItemSync(c,JSON.stringify(k)),ce.default().unlock(d),this.refreshLockWhileAcquired(c,d),[2])):(ce.default().unlock(d),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(d){switch(d.label){case 0:return[4,new Promise(function(h){var v=!1,w=Date.now(),y=!1;function k(){if(y||(window.removeEventListener("storage",k),u.removeFromWaiting(k),clearTimeout(_),y=!0),!v){v=!0;var I=50-(Date.now()-w);I>0?setTimeout(h,I):h(null)}}window.addEventListener("storage",k),u.addToWaiting(k);var _=setTimeout(k,Math.max(0,c-Date.now()))})];case 1:return d.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(d){return d!==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(d){switch(d.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,d.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var d,h,v,w;return r(this,function(y){switch(y.label){case 0:return d=this.storageHandler===void 0?a:this.storageHandler,h=o+"-"+c,(v=d.getItemSync(h))===null?[2]:(w=JSON.parse(v)).id!==this.id?[3,2]:[4,ce.default().lock(w.iat)];case 1:y.sent(),this.acquiredIatSet.delete(w.iat),d.removeItemSync(h),ce.default().unlock(w.iat),u.notifyWaiters(),y.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var d=Date.now()-5e3,h=c,v=[],w=0;;){var y=h.keySync(w);if(y===null)break;v.push(y),w++}for(var k=!1,_=0;_<v.length;_++){var I=v[_];if(I.includes(o)){var g=h.getItemSync(I);if(g!==null){var b=JSON.parse(g);(b.timeRefreshed===void 0&&b.timeAcquired<d||b.timeRefreshed!==void 0&&b.timeRefreshed<d)&&(h.removeItemSync(I),k=!0)}}}k&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=m}));const nr={timeoutInSeconds:60},jt={name:"auth0-spa-js",version:"2.1.3"},Tt=()=>Date.now();let V=class Et extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,Et.prototype)}static fromPayload({error:e,error_description:n}){return new Et(e,n)}},rr=class Yn extends V{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Yn.prototype)}},st=class Gn extends V{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Gn.prototype)}},ir=class Bn extends st{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Bn.prototype)}},or=class qn extends V{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,qn.prototype)}},ar=class Qn extends V{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Qn.prototype)}},Ct=class er extends V{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${$t(e,["default"])}', scope: '${$t(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,er.prototype)}};function $t(t,e=[]){return t&&!e.includes(t)?t:""}const Ue=()=>window.crypto,ct=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Ue().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},zt=t=>btoa(t),ut=t=>{var{clientId:e}=t,n=K(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()},Nt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),sr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},cr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([sr(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},f=o,new Promise(function(m,u){const c=new MessageChannel;c.port1.onmessage=function(d){d.data.error?u(new Error(d.data.error)):m(d.data),c.port1.close()},f.postMessage(s,[c.port2])});var s,f},lr=async(t,e,n,r,i,o,a=1e4)=>i?ur(t,e,n,r,a,i,o):cr(t,r,a);async function dr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,f=K(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const m=s?ut(f):JSON.stringify(f);return await async function(u,c,d,h,v,w,y){let k,_=null;for(let x=0;x<3;x++)try{k=await lr(u,d,h,v,w,y,c),_=null;break}catch(A){_=A}if(_)throw _;const I=k.json,{error:g,error_description:b}=I,L=K(I,["error","error_description"]),{ok:C}=k;if(!C){const x=b||`HTTP error. Unable to fetch ${u}`;throw g==="mfa_required"?new ar(g,x,L.mfa_token):g==="missing_refresh_token"?new Ct(d,h):new V(g||"request_error",x)}return L}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:m,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||jt))}},e,s)}const Ze=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let ue=class xt{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 xt({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new xt({scope:n,audience:r,clientId:i})}},hr=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@@"))}},Lt=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)}}()}},fr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Tt}async setIdToken(e,n,r){var i;const o=this.getIdTokenCacheKey(e);await this.cache.set(o,{id_token:n,decodedToken:r}),await((i=this.keyManifest)===null||i===void 0?void 0:i.add(o))}async getIdToken(e){const n=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!n&&e.scope&&e.audience){const r=await this.get(e);return!r||!r.id_token||!r.decodedToken?void 0:{id_token:r.id_token,decodedToken:r.decodedToken}}if(n)return{id_token:n.id_token,decodedToken:n.decodedToken}}async get(e,n=0){var r;let i=await this.cache.get(e.toKey());if(!i){const s=await this.getCacheKeys();if(!s)return;const f=this.matchExistingCacheKey(e,s);f&&(i=await this.cache.get(f))}if(!i)return;const o=await this.nowProvider(),a=Math.floor(o/1e3);return i.expiresAt-n<a?i.body.refresh_token?(i.body={refresh_token:i.body.refresh_token},await this.cache.set(e.toKey(),i),i.body):(await this.cache.remove(e.toKey()),void await((r=this.keyManifest)===null||r===void 0?void 0:r.remove(e.toKey()))):i.body}async set(e){var n;const r=new ue({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 ue({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=ue.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],f=o.scope&&s.reduce((m,u)=>m&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&f})[0]}},pr=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 Ee=t=>typeof t=="number",mr=["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"],gr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,f,m]=a;if(a.length!==3||!s||!f||!m)throw new Error("ID token could not be decoded");const u=JSON.parse(Nt(f)),c={__raw:o},d={};return Object.keys(u).forEach(h=>{c[h]=u[h],mr.includes(h)||(d[h]=u[h])}),{encoded:{header:s,payload:f,signature:m},header:JSON.parse(Nt(s)),claims:c,user:d}})(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&&!Ee(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||!Ee(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Ee(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&&Ee(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&&Ee(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 le=at(function(t,e){var n=se&&se.__assign||function(){return n=Object.assign||function(f){for(var m,u=1,c=arguments.length;u<c;u++)for(var d in m=arguments[u])Object.prototype.hasOwnProperty.call(m,d)&&(f[d]=m[d]);return f},n.apply(this,arguments)};function r(f,m){if(!m)return"";var u="; "+f;return m===!0?u:u+"="+m}function i(f,m,u){return encodeURIComponent(f).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(m).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 d=new Date;d.setMilliseconds(d.getMilliseconds()+864e5*c.expires),c.expires=d}return r("Expires",c.expires?c.expires.toUTCString():"")+r("Domain",c.domain)+r("Path",c.path)+r("Secure",c.secure)+r("SameSite",c.sameSite)}(u)}function o(f){for(var m={},u=f?f.split("; "):[],c=/(%[\dA-F]{2})+/gi,d=0;d<u.length;d++){var h=u[d].split("="),v=h.slice(1).join("=");v.charAt(0)==='"'&&(v=v.slice(1,-1));try{m[h[0].replace(c,decodeURIComponent)]=v.replace(c,decodeURIComponent)}catch{}}return m}function a(){return o(document.cookie)}function s(f,m,u){document.cookie=i(f,m,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(f){return a()[f]},e.set=s,e.remove=function(f,m){s(f,"",n(n({},m),{expires:-1}))}});ot(le),le.encode,le.parse,le.getAll;var vr=le.get,Dt=le.set,At=le.remove;const ge={get(t){const e=vr(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),Dt(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),At(t,n)}},yr={get(t){return ge.get(t)||ge.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),Dt(`_legacy_${t}`,JSON.stringify(e),r),ge.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),At(t,n),ge.remove(t,e),ge.remove(`_legacy_${t}`,e)}},wr={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 br(t,e,n){var r=e===void 0?null:e,i=function(f,m){var u=atob(f);if(m){for(var c=new Uint8Array(u.length),d=0,h=u.length;d<h;++d)c[d]=u.charCodeAt(d);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 Ut,Zt,Rt,lt,kr=(Ut="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Zt=null,Rt=!1,function(t){return lt=lt||br(Ut,Zt,Rt),new Worker(lt,t)});const dt={};let Ir=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 Sr={memory:()=>new Lt().enclosedCache,localstorage:()=>new hr},Wt=t=>Sr[t],Kt=t=>{const{openUrl:e,onRedirect:n}=t,r=K(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},ht=new tr;let _r=class{constructor(e){let n,r;if(this.userCache=new Lt().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await ht.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(!Ue())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Ue().subtle===void 0)throw new Error(`
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",!Wt(n))throw new Error(`Invalid cache location "${n}"`);r=Wt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?ge:yr,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:wr;var o;this.scope=Ze("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new pr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Tt,this.cacheManager=new fr(r,r.allKeys?void 0:new Ir(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 kr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||jt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${ut(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return gr({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=zt(ct()),o=zt(ct()),a=ct(),s=(u=>{const c=new Uint8Array(u);return(d=>{const h={"+":"-","/":"_","=":""};return d.replace(/[+/=]/g,v=>h[v])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Ue().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),f=((u,c,d,h,v,w,y,k)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),d),{scope:Ze(c,d.scope),response_type:"code",response_mode:k||"query",state:h,nonce:v,redirect_uri:y||u.authorizationParams.redirect_uri,code_challenge:w,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),m=this._authorizeUrl(f);return{nonce:o,code_verifier:a,scope:f.scope,audience:f.audience||"default",redirect_uri:f.redirect_uri,state:i,url:m}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const f=window.screenX+(window.innerWidth-400)/2,m=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${f},top=${m},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((f,m)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(d),window.removeEventListener("message",u,!1),m(new or(s.popup)))},1e3),d=setTimeout(()=>{clearInterval(c),m(new ir(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(h){if(h.data&&h.data.type==="authorization_response"){if(clearTimeout(d),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),h.data.response.error)return m(V.fromPayload(h.data.response));f(h.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 V("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=Kt(e),{openUrl:i,fragment:o,appState:a}=r,s=K(r,["openUrl","fragment","appState"]),f=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,m=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=m,c=K(m,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),f&&{organization:f}));const d=o?`${u}#${o}`:u;i?await i(d):window.location.assign(d)}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 d=new URLSearchParams(c);return{state:d.get("state"),code:d.get("code")||void 0,error:d.get("error")||void 0,error_description:d.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new V("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new rr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new V("state_mismatch","Invalid state");const f=s.organization,m=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:m,organization:f}),{appState:s.appState}}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(e={}){var n;const r=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ze(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=dt[a];return s||(s=o().finally(()=>{delete dt[a],s=null}),dt[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=K(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})(()=>ht.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new st;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const m=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(m)return m}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:f}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:f})}finally{await ht.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:Ze(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},nr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new ue({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=K(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${ut(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Kt(e),{openUrl:r}=n,i=K(n,["openUrl"]);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const o=this._buildLogoutUrl(i);r?await r(o):r!==!1&&window.location.assign(o)}async _getTokenFromIFrame(e){const n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);const{url:i,state:o,nonce:a,code_verifier:s,redirect_uri:f,scope:m,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new V("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,d=await((v,w,y=60)=>new Promise((k,_)=>{const I=window.document.createElement("iframe");I.setAttribute("width","0"),I.setAttribute("height","0"),I.style.display="none";const g=()=>{window.document.body.contains(I)&&(window.document.body.removeChild(I),window.removeEventListener("message",b,!1))};let b;const L=setTimeout(()=>{_(new st),g()},1e3*y);b=function(C){if(C.origin!=w||!C.data||C.data.type!=="authorization_response")return;const x=C.source;x&&x.close(),C.data.response.error?_(V.fromPayload(C.data.response)):k(C.data.response),clearTimeout(L),window.removeEventListener("message",b,!1),setTimeout(g,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(I),I.setAttribute("src",v)}))(i,this.domainUrl,c);if(o!==d.state)throw new V("state_mismatch","Invalid state");const h=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:d.code,grant_type:"authorization_code",redirect_uri:f,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},h),{scope:m,oauthTokenScope:h.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 ue({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 Ct(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=K(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 ue({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 ue({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,f=await this._getIdTokenFromCache();return f&&Object.assign(Object.assign({id_token:f.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await dr(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 Or(t){const e=new _r(t);return await e.checkSession(),e}const Pr="sesamy.com",Er="https://logs.sesamy.com/events";let Q;async function xr({clientId:t}){if(Q=await Or({domain:`token.${Pr}`,clientId:t,cacheLocation:"localstorage"}),window.location.search.includes("code="))try{await Q.handleRedirectCallback(),window.history.replaceState({},document.title,"/")}catch{}}async function jr(){if(!Q)throw new Error("Auth0 client not initialized");return Q.isAuthenticated()}async function Tr(){if(!Q)throw new Error("Auth0 client not initialized");return Q.getUser()}function Cr(){if(!Q)throw new Error("Auth0 client not initialized");return Q.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}function $r(){if(!Q)throw new Error("Auth0 client not initialized");return Q.logout({logoutParams:{returnTo:window.location.href}})}function zr(t="sesamy"){window[t]={getUser:Tr,isAuthenticated:jr,loginWithRedirect:Cr,logout:$r}}function Mt(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 Re="undefined",Xt="object",Nr=function(){},Vt="any",Ft="*",de="__",We=typeof process<"u"?process:{};We.env&&We.env.NODE_ENV;var F=typeof document<"u";We.versions!=null&&We.versions.node!=null,typeof Deno<"u"&&Deno.core,F&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Jt(t,e){return e.charAt(0)[t]()+e.slice(1)}var Lr=Jt.bind(null,"toUpperCase"),Dr=Jt.bind(null,"toLowerCase");function Ar(t){return Ht(t)?Lr("null"):typeof t=="object"?Wr(t):Object.prototype.toString.call(t).slice(8,-1)}function Ke(t,e){e===void 0&&(e=!0);var n=Ar(t);return e?Dr(n):n}function xe(t,e){return typeof e===t}var B=xe.bind(null,"function"),re=xe.bind(null,"string"),ve=xe.bind(null,"undefined"),Ur=xe.bind(null,"boolean");xe.bind(null,"symbol");function Ht(t){return t===null}function Zr(t){return Ke(t)==="number"&&!isNaN(t)}function Yt(t){return Ke(t)==="array"}function J(t){if(!Rr(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Rr(t){return t&&(typeof t=="object"||t!==null)}function Wr(t){return B(t.constructor)?t.constructor.name:null}function Kr(t){return t instanceof Error||re(t.message)&&t.constructor&&Zr(t.constructor.stackTraceLimit)}function Gt(t,e){if(typeof e!="object"||Ht(e))return!1;if(e instanceof t)return!0;var n=Ke(new t(""));if(Kr(e))for(;e;){if(Ke(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Gt.bind(null,TypeError),Gt.bind(null,SyntaxError);function Me(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Mr(t,e):n}function Mr(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Xe(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Xe(Me,"form"),Xe(Me,"button"),Xe(Me,"input"),Xe(Me,"select");function Xr(t){return t?Yt(t)?t:[t]:[]}function Bt(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Vr(){if(F){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Fr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Jr(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=Bt(n[1]),a=Bt(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var f=s.split("[");f.length>1&&(Hr(r,f.map(function(m){return m.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return F&&window.location.search.substring(1)}(t))}function Hr(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 Ve(){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}var je="global",ye=de+"global"+de,we=typeof self===Xt&&self.self===self&&self||typeof global===Xt&&global.global===global&&global||void 0;function he(t){return we[ye][t]}function fe(t,e){return we[ye][t]=e}function be(t){delete we[ye][t]}function ke(t,e,n){var r;try{if(ft(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}we[ye]||(we[ye]={});var Fe={};function ft(t){if(typeof Fe[t]!==Re)return Fe[t];try{var e=window[t];e.setItem(Re,Re),e.removeItem(Re)}catch{return Fe[t]=!1}return Fe[t]=!0}function O(){return O=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},O.apply(this,arguments)}var ie="function",ne="undefined",Yr="@@redux/"+Math.random().toString(36),qt=function(){return typeof Symbol===ie&&Symbol.observable||"@@observable"}(),Je=" != "+ie;function Qt(t,e,n){var r;if(typeof e===ie&&typeof n===ne&&(n=e,e=void 0),typeof n!==ne){if(typeof n!==ie)throw new Error("enhancer"+Je);return n(Qt)(t,e)}if(typeof t!==ie)throw new Error("reducer"+Je);var i=t,o=e,a=[],s=a,f=!1;function m(){s===a&&(s=a.slice())}function u(){return o}function c(h){if(typeof h!==ie)throw new Error("Listener"+Je);var v=!0;return m(),s.push(h),function(){if(v){v=!1,m();var w=s.indexOf(h);s.splice(w,1)}}}function d(h){if(!J(h))throw new Error("Act != obj");if(typeof h.type===ne)throw new Error("ActType "+ne);if(f)throw new Error("Dispatch in reducer");try{f=!0,o=i(o,h)}finally{f=!1}for(var v=a=s,w=0;w<v.length;w++)(0,v[w])();return h}return d({type:"@@redux/INIT"}),(r={dispatch:d,subscribe:c,getState:u,replaceReducer:function(h){if(typeof h!==ie)throw new Error("next reducer"+Je);i=h,d({type:"@@redux/INIT"})}})[qt]=function(){var h,v=c;return(h={subscribe:function(w){if(typeof w!="object")throw new TypeError("Observer != obj");function y(){w.next&&w.next(u())}return y(),{unsubscribe:v(y)}}})[qt]=function(){return this},h},r}function Gr(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ne}function Ie(){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 Br(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,f={getState:a.getState,dispatch:function(m){return s(m)}};return o=[].slice.call(t).map(function(m){return m(f)}),O({},a,{dispatch:s=Ie.apply(void 0,o)(a.dispatch)})}}}var oe=de+"anon_id",pe=de+"user_id",Se=de+"user_traits",ae="userId",_e="anonymousId",He=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],pt=["name","EVENTS","config","loaded"],P=He.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),en=/^utm_/,tn=/^an_prop_/,nn=/^an_trait_/;function qr(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===P.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,f=i.initialUser,m=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(oe,a.anonymousId),m||e(pe,a.userId),f.traits&&e(Se,O({},m&&s.traits?s.traits:{},f.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,d=o.an_event,h=u.reduce(function(v,w){if(w.match(en)||w.match(/^(d|g)clid/)){var y=w.replace(en,"");v.campaign[y==="campaign"?"name":y]=o[w]}return w.match(tn)&&(v.props[w.replace(tn,"")]=o[w]),w.match(nn)&&(v.traits[w.replace(nn,"")]=o[w]),v},{campaign:{},props:{},traits:{}});n.dispatch(O({type:P.params,raw:o},h,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,h.traits)},0),d&&setTimeout(function(){return t.track(d,h.props)},0),Object.keys(h.campaign).length&&n.dispatch({type:P.campaign,campaign:h.campaign})}}return r(i)}}}}function Qr(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===P.setItemEnd){if(n.key===oe)return O({},e,{anonymousId:n.value});if(n.key===pe)return O({},e,{userId:n.value})}switch(n.type){case P.identify:return Object.assign({},e,{userId:n.userId,traits:O({},e.traits,n.traits)});case P.reset:return[pe,oe,Se].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function rn(t){return{userId:t.getItem(pe),anonymousId:t.getItem(oe),traits:t.getItem(Se)}}var mt=function(t){return de+"TEMP"+de+t};function ei(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var f=s.userId,m=s.traits,u=s.options;if(s.type===P.reset&&([pe,Se,oe].forEach(function(h){r(h)}),[ae,_e,"traits"].forEach(function(h){be(mt(h))})),s.type===P.identify){i(oe)||n(oe,Ve());var c=i(pe),d=i(Se)||{};c&&c!==f&&o.dispatch({type:P.userIdChanged,old:{userId:c,traits:d},new:{userId:f,traits:m},options:u}),f&&n(pe,f),m&&n(Se,O({},d,m))}return a(s)}}}}var Te={};function on(t,e){Te[t]&&B(Te[t])&&(Te[t](e),delete Te[t])}function an(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(O({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return an(t,e,n-10).then(r,i)})})}function sn(t,e,n){var r=e(),i=t.getState(),o=i.plugins,a=i.queue,s=i.user;if(!i.context.offline&&a&&a.actions&&a.actions.length){var f=a.actions.reduce(function(u,c,d){return o[c.plugin].loaded?(u.process.push(c),u.processIndex.push(d)):(u.requeue.push(c),u.requeueIndex.push(d)),u},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(u){var c=a.actions[u],d=c.plugin,h=c.payload.type,v=r[d][h];if(v&&B(v)){var w=function(k,_){return k===void 0&&(k={}),_===void 0&&(_={}),[ae,_e].reduce(function(I,g){return k.hasOwnProperty(g)&&_[g]&&_[g]!==k[g]&&(I[g]=_[g]),I},k)}(c.payload,s);v({payload:w,config:o[d].config,instance:n});var y=h+":"+d;t.dispatch(O({},w,{type:y,_:{called:y,from:"queueDrain"}}))}});var m=a.actions.filter(function(u,c){return!~f.processIndex.indexOf(c)});a.actions=m}}}var gt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,f=t.EVENTS;try{var m=i.plugins,u=i.context,c=n.type,d=c.match(Oe),h=e.exact.map(function(y){return y.pluginName});d&&(h=a.during.map(function(y){return y.pluginName}));var v=function(y,k){return function(_,I,g){var b=I.config,L=I.name,C=L+"."+_.type;g&&(C=g.event);var x=_.type.match(Oe)?function(A,D,H,U,Y){return function(R,E){var M=U?U.name:A,X=E&&Ce(E)?E:H;if(U&&(!(X=E&&Ce(E)?E:[A]).includes(A)||X.length!==1))throw new Error("Method "+D+" can only abort "+A+" plugin. "+JSON.stringify(X)+" input valid");return O({},Y,{abort:{reason:R,plugins:X,caller:D,_:M}})}}(L,C,k,g,_):function(A,D){return function(){throw new Error(A.type+" action not cancellable. Remove abort in "+D)}}(_,C);return{payload:ti(_),instance:y,config:b||{},abort:x}}}(r,h),w=e.exact.reduce(function(y,k){var _=k.pluginName,I=k.methodName,g=!1;return I.match(/^initialize/)||I.match(/^reset/)||(g=!m[_].loaded),u.offline&&I.match(/^(page|track|identify)/)&&(g=!0),y[""+_]=g,y},{});return Promise.resolve(e.exact.reduce(function(y,k,_){try{var I=k.pluginName;return Promise.resolve(y).then(function(g){function b(){return Promise.resolve(g)}var L=function(){if(e.namespaced&&e.namespaced[I])return Promise.resolve(e.namespaced[I].reduce(function(C,x,A){try{return Promise.resolve(C).then(function(D){return x.method&&B(x.method)?(function(R,E){var M=mn(R);if(M&&M.name===E){var X=mn(M.method);throw new Error([E+" plugin is calling method "+R,"Plugins cant call self","Use "+M.method+" "+(X?"or "+X.method:"")+" in "+E+" plugin insteadof "+R].join(`
5
+ `))}}(x.methodName,x.pluginName),Promise.resolve(x.method({payload:D,instance:r,abort:(H=D,U=I,Y=x.pluginName,function(R,E){return O({},H,{abort:{reason:R,plugins:E||[U],caller:c,from:Y||U}})}),config:ln(x.pluginName,m,o),plugins:m})).then(function(R){var E=J(R)?R:{};return Promise.resolve(O({},D,E))})):D;var H,U,Y})}catch(D){return Promise.reject(D)}},Promise.resolve(n))).then(function(C){g[I]=C});g[I]=n}();return L&&L.then?L.then(b):b()})}catch(g){return Promise.reject(g)}},Promise.resolve({}))).then(function(y){return Promise.resolve(e.exact.reduce(function(k,_,I){try{var g=e.exact.length===I+1,b=_.pluginName,L=o[b];return Promise.resolve(k).then(function(C){var x=y[b]?y[b]:{};if(d&&(x=C),yt(x,b))return vt({data:x,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(C);if(yt(C,b))return g&&vt({data:C,method:c,instance:r,store:s}),Promise.resolve(C);if(w.hasOwnProperty(b)&&w[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:x,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(C);var A=v(y[b],o[b]);return Promise.resolve(L[c]({abort:A.abort,payload:x,instance:r,config:ln(b,m,o),plugins:m})).then(function(D){var H=J(D)?D:{},U=O({},C,H),Y=y[b];if(yt(Y,b))vt({data:Y,method:c,instance:r,pluginName:b,store:s});else{var R=c+":"+b;(R.match(/:/g)||[]).length<2&&!c.match(cn)&&!c.match(un)&&r.dispatch(O({},d?U:x,{type:R,_:{called:R,from:"submethod"}}))}return Promise.resolve(U)})})}catch(C){return Promise.reject(C)}},Promise.resolve(n))).then(function(k){if(!(c.match(Oe)||c.match(/^registerPlugin/)||c.match(un)||c.match(cn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(f.plugins.includes(c),k._&&k._.originalAction===c)return k;var _=O({},k,{_:{originalAction:k.type,called:k.type,from:"engineEnd"}});fn(k,e.exact.length)&&!c.match(/End$/)&&(_=O({},_,{type:k.type+"Aborted"})),s.dispatch(_)}return k})})}catch(y){return Promise.reject(y)}},Oe=/Start$/,cn=/^bootstrap/,un=/^ready/;function vt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(O({},t.data,{type:n,_:{called:n,from:"abort"}}))}function ln(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function dn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function hn(t,e){var n=t.replace(Oe,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||pn(n,e)||n&&pn(n.plugins,e))}function fn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||re(n))return!0;var r=n.plugins;return Ce(n)&&n.length===e||Ce(r)&&r.length===e}function Ce(t){return Array.isArray(t)}function pn(t,e){return!(!t||!Ce(t))&&t.includes(e)}function mn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function ti(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=J(t[n])?Object.assign({},t[n]):t[n]),e},{})}function ni(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,f=function(g){return s?g:o(c)},m=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(m===P.enablePlugin&&i.dispatch({type:P.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),m===P.disablePlugin&&setTimeout(function(){return on(a.meta.rid,{payload:a})},0),m===P.initializeEnd){var d=e(),h=Object.keys(d),v=h.filter(function(g){return u.includes(g)}).map(function(g){return d[g]}),w=[],y=[],k=a.disabled,_=v.map(function(g){var b=g.loaded,L=g.name,C=g.config;return an(g,function(){return b({config:C})},1e4).then(function(x){return r[L]||(i.dispatch({type:P.pluginReadyType(L),name:L,events:Object.keys(g).filter(function(A){return!pt.includes(A)})}),r[L]=!0),w=w.concat(L),g}).catch(function(x){if(x instanceof Error)throw new Error(x);return y=y.concat(x.name),x})});Promise.all(_).then(function(g){var b={plugins:w,failed:y,disabled:k};setTimeout(function(){h.length===_.length+k.length&&i.dispatch(O({},{type:P.ready},b))},0)})}var I=function(){if(m!==P.bootstrap)return/^ready:([^:]*)$/.test(m)&&setTimeout(function(){return sn(i,e,t)},0),Promise.resolve(function(g,b,L,C,x){try{var A=B(b)?b():b,D=g.type,H=D.replace(Oe,"");if(g._&&g._.called)return Promise.resolve(g);var U=L.getState(),Y=(M=A,(X=U.plugins)===void 0&&(X={}),(De=g.options)===void 0&&(De={}),Object.keys(M).filter(function(l){var p=De.plugins||{};return Ur(p[l])?p[l]:p.all!==!1&&(!X[l]||X[l].enabled!==!1)}).map(function(l){return M[l]}));D===P.initializeStart&&g.fromEnable&&(Y=Object.keys(U.plugins).filter(function(l){var p=U.plugins[l];return g.plugins.includes(l)&&!p.initialized}).map(function(l){return A[l]}));var R=Y.map(function(l){return l.name}),E=function(l,p,S){var j=hn(l).map(function(T){return dn(T,p)});return p.reduce(function(T,$){var W=$.name,N=hn(l,W).map(function(Ae){return dn(Ae,p)}),Z=N[0],z=N[1],ee=N[2];return Z.length&&(T.beforeNS[W]=Z),z.length&&(T.duringNS[W]=z),ee.length&&(T.afterNS[W]=ee),T},{before:j[0],beforeNS:{},during:j[1],duringNS:{},after:j[2],afterNS:{}})}(D,Y);return Promise.resolve(gt({action:g,data:{exact:E.before,namespaced:E.beforeNS},state:U,allPlugins:A,allMatches:E,instance:L,store:C,EVENTS:x})).then(function(l){function p(){var T=function(){if(D.match(Oe))return Promise.resolve(gt({action:O({},S,{type:H+"End"}),data:{exact:E.after,namespaced:E.afterNS},state:U,allPlugins:A,allMatches:E,instance:L,store:C,EVENTS:x})).then(function($){$.meta&&$.meta.hasCallback&&on($.meta.rid,{payload:$})})}();return T&&T.then?T.then(function(){return l}):l}if(fn(l,R.length))return l;var S,j=function(){if(D!==H)return Promise.resolve(gt({action:O({},l,{type:H}),data:{exact:E.during,namespaced:E.duringNS},state:U,allPlugins:A,allMatches:E,instance:L,store:C,EVENTS:x})).then(function(T){S=T});S=l}();return j&&j.then?j.then(p):p()})}catch(l){return Promise.reject(l)}var M,X,De}(a,e,t,i,n)).then(function(g){return s=1,o(g)})}();return Promise.resolve(I&&I.then?I.then(f):f(I))}catch(g){return Promise.reject(g)}}}}}function ri(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===P.setItem||i===P.removeItem){if(r.abort)return n(r);i===P.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var ii=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 Ie.apply(void 0,a)(r)(i)}}}}};function oi(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=gn(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},O({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var f=gn(n.type,P.initialize),m=t()[f];return m&&f?(r[f]=O({},e[f],{initialized:!0,loaded:!!m.loaded({config:m.config})}),O({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=O({},e[n.name],{loaded:!0}),O({},e,r);switch(n.type){case P.disablePlugin:return O({},e,vn(n.plugins,!1,e));case P.enablePlugin:return O({},e,vn(n.plugins,!0,e));default:return e}}}function gn(t,e){return t.substring(e.length+1,t.length)}function vn(t,e,n){return t.reduce(function(r,i){return r[i]=O({},n[i],{enabled:e}),r},n)}function yn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var ai={last:{},history:[]};function si(t,e){t===void 0&&(t=ai);var n=e.options,r=e.meta;if(e.type===P.track){var i=yn(O({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return O({},t,{last:i,history:t.history.concat(i)})}return t}var ci={actions:[]};function ui(t,e){t===void 0&&(t=ci);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===P.identify?[e].concat(t.actions):t.actions.concat(e),O({},t,{actions:r});case"dequeue":return[];default:return t}}var wn=/#.*$/;function li(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(wn,""):"")}var bn,kn,In,Sn,di=function(t){if(t===void 0&&(t={}),!F)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,f=o.hash,m=o.search,u=function(d){var h=function(){if(F){for(var v,w=document.getElementsByTagName("link"),y=0;v=w[y];y++)if(v.getAttribute("rel")==="canonical")return v.getAttribute("href")}}();return h?h.match(/\?/)?h:h+d:window.location.href.replace(wn,"")}(m),c={title:n,url:u,path:li(u),hash:f,search:m,width:a,height:s};return r&&r!==""&&(c.referrer=r),O({},c,t)},hi={last:{},history:[]};function fi(t,e){t===void 0&&(t=hi);var n=e.options;if(e.type===P.page){var r=yn(O({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return O({},t,{last:r,history:t.history.concat(r)})}return t}bn=function(){if(!F)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),kn=F?document.referrer:null,In=Vr(),Sn=Fr();var _n={initialized:!1,sessionId:Ve(),app:null,version:null,debug:!1,offline:!!F&&!navigator.onLine,os:{name:bn},userAgent:F?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:Sn,locale:In,campaign:{},referrer:kn};function pi(t,e){t===void 0&&(t=_n);var n=t.initialized,r=e.campaign;switch(e.type){case P.campaign:return O({},t,{campaign:r});case P.offline:return O({},t,{offline:!0});case P.online:return O({},t,{offline:!1});default:return n?t:O({},_n,t,{initialized:!0})}}var mi=["plugins","reducers","storage"];function gi(t,e,n){if(F){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function vi(t){var e=gi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function On(){return fe("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 we[ye].analytics.push(a.action||a),o(a)}})}}}function Pn(t){return function(){return Ie(Ie.apply(null,arguments),On())}}function wt(t){return t?Yt(t)?t:[t]:[]}function En(t,e,n){t===void 0&&(t={});var r,i,o=Ve();return e&&(Te[o]=(r=e,i=function(a){for(var s,f=a||Array.prototype.slice.call(arguments),m=0;m<f.length;m++)if(B(f[m])){s=f[m];break}return s}(n),function(a){i&&i(a),r(a)})),O({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function yi(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(l,p){if(B(p))return l.middlewares=l.middlewares.concat(p),l;if(p.NAMESPACE&&(p.name=p.NAMESPACE),!p.name)throw new Error("https://lytics.dev/errors/1");p.config||(p.config={});var S=p.EVENTS?Object.keys(p.EVENTS).map(function($){return p.EVENTS[$]}):[];l.pluginEnabled[p.name]=!(p.enabled===!1||p.config.enabled===!1),delete p.enabled,p.methods&&(l.methods[p.name]=Object.keys(p.methods).reduce(function($,W){var N;return $[W]=(N=p.methods[W],function(){for(var Z=Array.prototype.slice.call(arguments),z=new Array(N.length),ee=0;ee<Z.length;ee++)z[ee]=Z[ee];return z[z.length]=b,N.apply({instance:b},z)}),$},{}),delete p.methods);var j=Object.keys(p).concat(S),T=new Set(l.events.concat(j));if(l.events=Array.from(T),l.pluginsArray=l.pluginsArray.concat(p),l.plugins[p.name])throw new Error(p.name+"AlreadyLoaded");return l.plugins[p.name]=p,l.plugins[p.name].loaded||(l.plugins[p.name].loaded=function(){return!0}),l},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:he,setItem:fe,removeItem:be},o=function(l){return function(p,S,j){return S.getState("user")[p]||(j&&J(j)&&j[p]?j[p]:rn(l)[p]||he(mt(p))||null)}}(i),a=r.plugins,s=r.events.filter(function(l){return!pt.includes(l)}).sort(),f=new Set(s.concat(He).filter(function(l){return!pt.includes(l)})),m=Array.from(f).sort(),u=function(){return a},c=new ii,d=c.addMiddleware,h=c.removeMiddleware,v=c.dynamicMiddlewares,w=function(){throw new Error("Abort disabled inListener")},y=Jr(),k=rn(i),_=O({},k,n,y.an_uid?{userId:y.an_uid}:{},y.an_aid?{anonymousId:y.an_aid}:{});_.anonymousId||(_.anonymousId=Ve());var I=O({enable:function(l,p){return new Promise(function(S){E.dispatch({type:P.enablePlugin,plugins:wt(l),_:{originalAction:P.enablePlugin}},S,[p])})},disable:function(l,p){return new Promise(function(S){E.dispatch({type:P.disablePlugin,plugins:wt(l),_:{originalAction:P.disablePlugin}},S,[p])})}},r.methods),g=!1,b={identify:function(l,p,S,j){try{var T=re(l)?l:null,$=J(l)?l:p,W=S||{},N=b.user();fe(mt(ae),T);var Z=T||$.userId||o(ae,b,$);return Promise.resolve(new Promise(function(z){E.dispatch(O({type:P.identifyStart,userId:Z,traits:$||{},options:W,anonymousId:N.anonymousId},N.id&&N.id!==T&&{previousId:N.id}),z,[p,S,j])}))}catch(z){return Promise.reject(z)}},track:function(l,p,S,j){try{var T=J(l)?l.event:l;if(!T||!re(T))throw new Error("EventMissing");var $=J(l)?l:p||{},W=J(S)?S:{};return Promise.resolve(new Promise(function(N){E.dispatch({type:P.trackStart,event:T,properties:$,options:W,userId:o(ae,b,p),anonymousId:o(_e,b,p)},N,[p,S,j])}))}catch(N){return Promise.reject(N)}},page:function(l,p,S){try{var j=J(l)?l:{},T=J(p)?p:{};return Promise.resolve(new Promise(function($){E.dispatch({type:P.pageStart,properties:di(j),options:T,userId:o(ae,b,j),anonymousId:o(_e,b,j)},$,[l,p,S])}))}catch($){return Promise.reject($)}},user:function(l){if(l===ae||l==="id")return o(ae,b);if(l===_e||l==="anonId")return o(_e,b);var p=b.getState("user");return l?Mt(p,l):p},reset:function(l){return new Promise(function(p){E.dispatch({type:P.resetStart},p,l)})},ready:function(l){return g&&l({plugins:I,instance:b}),b.on(P.ready,function(p){l(p),g=!0})},on:function(l,p){if(!l||!B(p))return!1;if(l===P.bootstrap)throw new Error(".on disabled for "+l);var S=/Start$|Start:/;if(l==="*"){var j=function(N){return function(Z){return function(z){return z.type.match(S)&&p({payload:z,instance:b,plugins:a}),Z(z)}}},T=function(N){return function(Z){return function(z){return z.type.match(S)||p({payload:z,instance:b,plugins:a}),Z(z)}}};return d(j,Ye),d(T,Ge),function(){h(j,Ye),h(T,Ge)}}var $=l.match(S)?Ye:Ge,W=function(N){return function(Z){return function(z){return z.type===l&&p({payload:z,instance:b,plugins:a,abort:w}),Z(z)}}};return d(W,$),function(){return h(W,$)}},once:function(l,p){if(!l||!B(p))return!1;if(l===P.bootstrap)throw new Error(".once disabled for "+l);var S=b.on(l,function(j){p({payload:j.payload,instance:b,plugins:a,abort:w}),S()});return S},getState:function(l){var p=E.getState();return l?Mt(p,l):Object.assign({},p)},dispatch:function(l){var p=re(l)?{type:l}:l;if(He.includes(p.type))throw new Error("reserved action "+p.type);var S=O({},p,{_:O({originalAction:p.type},l._||{})});E.dispatch(S)},enablePlugin:I.enable,disablePlugin:I.disable,plugins:I,storage:{getItem:i.getItem,setItem:function(l,p,S){E.dispatch({type:P.setItemStart,key:l,value:p,options:S})},removeItem:function(l,p){E.dispatch({type:P.removeItemStart,key:l,options:p})}},setAnonymousId:function(l,p){b.storage.setItem(oe,l,p)},events:{core:He,plugins:s}},L=r.middlewares.concat([function(l){return function(p){return function(S){return S.meta||(S.meta=En()),p(S)}}},v(Ye),ni(b,u,{all:m,plugins:s}),ri(i),qr(b),ei(b),v(Ge)]),C={context:pi,user:Qr(i),page:fi,track:si,plugins:oi(u),queue:ui},x=Ie,A=Ie;if(F&&t.debug){var D=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;D&&(x=D({trace:!0,traceLimit:25})),A=function(){return arguments.length===0?On():J(typeof arguments[0])?Pn():Pn().apply(null,arguments)}}var H,U=function(l){return Object.keys(l).reduce(function(p,S){return mi.includes(S)||(p[S]=l[S]),p},{})}(t),Y=r.pluginsArray.reduce(function(l,p){var S=p.name,j=p.config,T=p.loaded,$=r.pluginEnabled[S];return l[S]={enabled:$,initialized:!!$&&!p.initialize,loaded:!!T({config:j}),config:j},l},{}),R={context:U,user:_,plugins:Y},E=Qt(function(l){for(var p=Object.keys(l),S={},j=0;j<p.length;j++){var T=p[j];typeof l[T]===ie&&(S[T]=l[T])}var $,W=Object.keys(S);try{(function(N){Object.keys(N).forEach(function(Z){var z=N[Z];if(typeof z(void 0,{type:"@@redux/INIT"})===ne||typeof z(void 0,{type:Yr})===ne)throw new Error("reducer "+Z+" "+ne)})})(S)}catch(N){$=N}return function(N,Z){if(N===void 0&&(N={}),$)throw $;for(var z=!1,ee={},Ae=0;Ae<W.length;Ae++){var it=W[Ae],Hn=N[it],Pt=(0,S[it])(Hn,Z);if(typeof Pt===ne){var Yi=Gr(it,Z);throw new Error(Yi)}ee[it]=Pt,z=z||Pt!==Hn}return z?ee:N}}(O({},C,e)),R,A(x(Br.apply(void 0,L))));E.dispatch=(H=E.dispatch,function(l,p,S){var j=O({},l,{meta:En(l.meta,p,wt(S))});return H.apply(null,[j])});var M=Object.keys(a);E.dispatch({type:P.bootstrap,plugins:M,config:U,params:y,user:_,initialUser:n,persistedUser:k});var X=M.filter(function(l){return r.pluginEnabled[l]}),De=M.filter(function(l){return!r.pluginEnabled[l]});return E.dispatch({type:P.registerPlugins,plugins:M,enabled:r.pluginEnabled}),r.pluginsArray.map(function(l,p){var S=l.bootstrap,j=l.config,T=l.name;S&&B(S)&&S({instance:b,config:j,payload:l}),E.dispatch({type:P.registerPluginType(T),name:T,enabled:r.pluginEnabled[T],plugin:l}),r.pluginsArray.length===p+1&&E.dispatch({type:P.initializeStart,plugins:X,disabled:De})}),vi(function(l){E.dispatch({type:l?P.offline:P.online})}),function(l,p,S){setInterval(function(){return sn(l,p,S)},3e3)}(E,u,b),b}var Ye="before",Ge="after",$e="cookie",me=Tn(),xn=Be,wi=Be;function jn(t){return me?Be(t,"",-1):be(t)}function Tn(){if(me!==void 0)return me;var t="cookiecookie";try{Be(t,t),me=document.cookie.indexOf(t)!==-1,jn(t)}catch{me=!1}return me}function Be(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return me===!1&&(a?fe(t,e):he(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var ze="localStorage",bi=ft.bind(null,"localStorage");ke("localStorage","getItem",he),ke("localStorage","setItem",fe),ke("localStorage","removeItem",be);var Ne="sessionStorage",ki=ft.bind(null,"sessionStorage");ke("sessionStorage","getItem",he),ke("sessionStorage","setItem",fe),ke("sessionStorage","removeItem",be);function Pe(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(J(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var Ii=bi(),Si=ki(),_i=Tn();function Cn(t,e){if(t){var n=bt(e),r=!_t(n),i=kt(n)?Pe(localStorage.getItem(t)):void 0;if(r&&!ve(i))return i;var o=It(n)?Pe(xn(t)):void 0;if(r&&o)return o;var a=St(n)?Pe(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=he(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function Oi(t,e,n){if(t&&!ve(e)){var r={},i=bt(n),o=JSON.stringify(e),a=!_t(i);return kt(i)&&(r[ze]=Qe(ze,e,Pe(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[ze]:It(i)&&(r[$e]=Qe($e,e,Pe(xn(t))),wi(t,o),a)?r[$e]:St(i)&&(r[Ne]=Qe(Ne,e,Pe(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ne]:(r[je]=Qe(je,e,he(t)),fe(t,e),a?r[je]:r)}}function Pi(t,e){if(t){var n=bt(e),r=Cn(t,Ft),i={};return!ve(r.localStorage)&&kt(n)&&(localStorage.removeItem(t),i[ze]=r.localStorage),!ve(r.cookie)&&It(n)&&(jn(t),i[$e]=r.cookie),!ve(r.sessionStorage)&&St(n)&&(sessionStorage.removeItem(t),i[Ne]=r.sessionStorage),!ve(r.global)&&qe(n,je)&&(be(t),i[je]=r.global),i}}function bt(t){return t?re(t)?t:t.storage:Vt}function kt(t){return Ii&&qe(t,ze)}function It(t){return _i&&qe(t,$e)}function St(t){return Si&&qe(t,Ne)}function _t(t){return t===Ft||t==="all"}function qe(t,e){return t===Vt||t===e||_t(t)}function Qe(t,e,n){return{location:t,current:e,previous:n}}var Ei={setItem:Oi,getItem:Cn,removeItem:Pi};function xi(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $n(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 zn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$n(Object(n),!0).forEach(function(r){xi(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$n(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ji(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Ei};return yi(zn(zn({},e),t))}function Ti(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(f){return r=i.push(f),r>=o&&a(),r},size:function(){return i.length},end:function(f){f&&a(),clearInterval(n)}}}const Nn="@sesamy/sesamy-js",Ln="1.0.1";function Ci(t){if(!(typeof window>"u")){var e=window,n=e.addEventListener,r=e.history,i=e.location,o=i.pathname;n("popstate",function(){return t(i.pathname)}),["push","replace"].map(function(a){var s="".concat(a,"State"),f=r[s];r[s]=function(){var m=arguments,u=zi(arguments[2]);return o!==u&&(o=u,setTimeout(function(){return t(m[2])},0)),f.apply(r,arguments)}})}}function $i(t,e){var n=t.indexOf(e);return n>-1?t.slice(0,n):t}function zi(t){return["#","?"].forEach(function(e){return t=$i(t,e)}),t}function Ni(){Ci(()=>{nt.page()})}var Dn="EventListener";function Li(t){return function(e,n,r,i){var o=r||Nr,a=i||!1;if(!F)return o;var s=et(n),f=et(e,!0);if(!f.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var m=[];return function u(c){c&&(m=[]);for(var d=c?"add"+Dn:"remove"+Dn,h=0;h<f.length;h++){var v=f[h];m[h]=c?a&&a.once?Di(o):o:m[h]||o;for(var w=0;w<s.length;w++)v[d]?v["on"+s[w]]=c?m[h]:null:v[d](s[w],m[h],a)}return u.bind(null,!c)}(t)}}function et(t,e){if(re(t))return e?et(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=Xr(t);return e?o.map(function(a){return re(a)?et(a,!0):a}).flat():o}function Di(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var Ot=Li("Event");function An(t,e){return F&&B(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),B(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}An.bind(null,"onerror"),An.bind(null,"onload");var Un=typeof window>"u",Zn="hidden";function Ai(t){if(Un)return!1;var e=Ui(),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 Ui(){var t=["webkit","moz","ms","o"];return Un||Zn in document?Zn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Zi=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Ri(t,e){e===void 0&&(e={});var n=function(a,s){var f=this,m=!1;return function(u){m||(a.call(f,u),m=!0,setTimeout(function(){return m=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=Ai(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Zi.map(function(s){return Ot(document,s,n)})).concat(Ot(window,"load",n)).concat(Ot(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Wi(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,f=t.throttle,m=f===void 0?2e3:f,u=!1,c=!1,d=new Date,h=function(){return clearTimeout(e)};function v(y){h(),o&&!u&&o(Le(d),y),i&&u&&(u=!1,i(Le(n),y),d=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Le(d),y))},s)}var w=Ri(v,{throttle:m});return{disable:function(){c=!0,u=!1,h();var y=w();return function(){return c=!1,d=new Date,v({type:"load"}),y()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Le(d,c),idle:u?Le(n,c):0}}}}function Le(t,e){return e?0:Math.round((new Date-t)/1e3)}const Rn=5e3;class Ki{constructor(e){q(this,"element");q(this,"isInViewport",!1);q(this,"isAwake",!1);q(this,"isFlushing");q(this,"observer");q(this,"lastEventAt",Date.now());q(this,"registeredView",!1);q(this,"viewCallback");q(this,"activeDurationCallback");q(this,"idleDurationCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Wi({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:Rn})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake,Math.round((Date.now()-this.lastEventAt)/1e3))}handleInViewPort(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1,Math.round((Date.now()-this.lastEventAt)/1e3)),this.isInViewport=e}handleAwake(e,n){this.isAwake=e,this.lastEventAt=e?Date.now()-n*Rn:Date.now(),this.isInViewport&&this.trackAwake(e,n)}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}let Wn=!1,Kn,Mn,tt;function Mi({clientId:t,enabled:e=!0,endpoint:n=Er}){if(Kn=t,Mn=e,tt=n,!Mn)return;Ni();const r=new Ki({element:document.body,viewCallback:()=>{nt.page()},activeDurationCallback:(i,o)=>{nt.track("activeDuration",{duration:i,flushing:o})},idleDurationCallback:(i,o)=>{nt.track("idleDuration",{duration:i,flushing:o})}});Vi(document.body,()=>{r.flush()})}function Xn(t){return JSON.stringify(t.map(e=>({...e,timestamp:new Date().toISOString(),originalTimestamp:new Date().toISOString(),version:Ln,event:e.event||"page",context:{page:{url:window.location.hostname,path:window.location.pathname,title:document.title,search:window.location.search,referrer:document.referrer},locale:navigator.language,library:Nn,userAgent:navigator.userAgent,clientId:Kn}})))}const Vn=Ti(async t=>{if(t.length>0){const e=Xn(t);Wn?navigator.sendBeacon(tt,e):(await fetch(tt,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Fn(t){if(t.properties.flushing){const e={...t};delete e.properties.flushing,navigator.sendBeacon(tt,Xn([e]))}else Vn.push(t)}const nt=ji({app:Nn,version:Ln,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Fn({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Fn({anonymousId:n,userId:r,properties:e,event:i,type:"track"})}}]});function Xi(){return Wn=!0,Vn.flush()}const Jn=new Map;function Vi(t,e){Jn.set(t,e)}window.addEventListener("beforeunload",()=>{Jn.forEach((t,e)=>{t.bind(e)()}),Xi()});async function Fi(t){await xr(t),Mi({clientId:t.clientId,...t.analytics}),zr(t.namespace),te()}const rt=document.getElementById("sesamy-js");if(rt!=null&&rt.textContent)try{const t=JSON.parse(rt.textContent);Fi(t)}catch(t){console.error("Failed to parse config",t)}const Ji="/sesamy.png";class Hi extends HTMLElement{constructor(){super();q(this,"user")}async _handleProfile(){this.user=await window.sesamy.getUser(),this.render()}async connectedCallback(){if(this.setupEventListeners(),!window.sesamy){window.addEventListener(G.READY,()=>this._handleProfile());return}this._handleProfile()}render(){this.innerHTML=`
6
+ <div>
7
+ <a href="https://docs.sesamy.com" target="_blank">
8
+ <img src="${Ji}" class="logo" alt="Vite logo" />
9
+ </a>
10
+ <h1>Sesamy JS</h1>
11
+ <p class="read-the-docs">
12
+ Click on the Sesamy logo to learn more
13
+ </p>
14
+ ${this.user?this.renderUserProfile():this.renderLoginButton()}
15
+ </div>
16
+ `}renderLoginButton(){return'<button part="login-btn" class="login auth-visible" id="login-btn"> Login </button>'}renderUserProfile(){var n,r;return`<div class="user" part="user">
17
+ <a href="/profile" part="user-link">
18
+ ${(n=this.user)!=null&&n.picture?` <img
19
+ class="big"
20
+ part="user-img img-big"
21
+ src=${this.user.picture}
22
+ alt=${this.user.name||"User avatar"}
23
+ />`:'<div part="avatar avatar-big" class="avatar big"> Placeholder </div>'}
24
+ <h2 class="user-name">${((r=this.user)==null?void 0:r.name)||"User Name"}</h2>
25
+ </a>
26
+
27
+ <div class="logout-wrap">
28
+ <a href="#" class="logout-btn" id="logout-btn"> Logout </a>
29
+ </div>
30
+ </div>`}setupEventListeners(){this.addEventListener("click",n=>{const r=n.target,i=r.closest("#logout-btn"),o=r.closest("#login-btn");i&&window.sesamy.logout(),o&&window.sesamy.loginWithRedirect()})}}customElements.define("sesamy-app",Hi)});
package/package.json CHANGED
@@ -2,10 +2,16 @@
2
2
  "name": "@sesamy/sesamy-js",
3
3
  "private": false,
4
4
  "publishConfig": {
5
- "access": "public"
5
+ "access": "public",
6
+ "registry": "https://registry.npmjs.org/",
7
+ "tag": "latest"
6
8
  },
7
- "version": "1.0.0",
9
+ "version": "1.0.2",
8
10
  "type": "module",
11
+ "files": [
12
+ "dist/sesamy-js.es.js",
13
+ "dist/sesamy-js.umd.js"
14
+ ],
9
15
  "exports": {
10
16
  ".": {
11
17
  "import": "./dist/sesamy-js.es.js",
@@ -15,9 +21,10 @@
15
21
  "scripts": {
16
22
  "dev": "vite",
17
23
  "build": "tsc && vite build",
18
- "build:prod": "tsc && vite build --mode production",
24
+ "build:prod": "tsc && vite build --config vite-package.config.js --mode production",
19
25
  "preview": "vite preview",
20
- "type-check": "tsc"
26
+ "type-check": "tsc",
27
+ "semantic-release": "semantic-release"
21
28
  },
22
29
  "release": {
23
30
  "branches": [
@@ -48,6 +55,9 @@
48
55
  ]
49
56
  },
50
57
  "devDependencies": {
58
+ "@semantic-release/changelog": "^6.0.3",
59
+ "@semantic-release/git": "^10.0.1",
60
+ "semantic-release": "^23.0.2",
51
61
  "typescript": "^5.2.2",
52
62
  "vite": "^5.0.8",
53
63
  "vitest": "^1.1.3"
@@ -56,8 +66,8 @@
56
66
  "@analytics/activity-utils": "^0.1.16",
57
67
  "@analytics/router-utils": "^0.1.1",
58
68
  "@analytics/scroll-utils": "^0.1.22",
69
+ "@auth0/auth0-spa-js": "^2.1.3",
59
70
  "analytics": "^0.8.9",
60
- "saturated": "^1.0.0",
61
- "@auth0/auth0-spa-js": "^2.1.3"
71
+ "saturated": "^1.0.0"
62
72
  }
63
73
  }
package/.env DELETED
@@ -1,2 +0,0 @@
1
- VITE_BASE_URL_DOMAIN = "sesamy.dev"
2
- VITE_ANALYTICS_BASE_URL = "https://interactions.sesamy.dev/interactions"
package/.env.production DELETED
@@ -1,2 +0,0 @@
1
- VITE_BASE_URL_DOMAIN = "sesamy.com"
2
- VITE_ANALYTICS_BASE_URL = "https://interactions.sesamy.com/interactions"
@@ -1,22 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- release:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v2
13
- - uses: actions/setup-node@v2
14
- with:
15
- node-version: "18"
16
- registry-url: "https://registry.npmjs.org"
17
- - run: npm ci
18
- - run: npm run build:prod
19
- - run: npx semantic-release
20
- env:
21
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- 20.6.1
package/article.html DELETED
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/png" href="/sesamy.png" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Article</title>
8
- <script type="module" src="/src/main.ts"></script>
9
- </head>
10
- <body>
11
- <h1>Article</h1>
12
- </body>
13
- </html>
package/index.html DELETED
@@ -1,23 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/png" href="/sesamy.png" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Sesamy JS</title>
8
- <script type="application/json" id="sesamy-js">
9
- {
10
- "clientId": "demo",
11
- "analytics": {
12
- "enabled": true
13
- }
14
- }
15
- </script>
16
- </head>
17
- <body>
18
- <div id="app"></div>
19
- <sesamy-app></sesamy-app>
20
- <script type="module" src="/src/main.ts"></script>
21
- <script type="module" src="/src/app.ts"></script>
22
- </body>
23
- </html>
package/public/sesamy.png DELETED
Binary file
package/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:recommended"
5
- ]
6
- }
@@ -1 +0,0 @@
1
- // Will be stuff in here later
package/src/app.ts DELETED
@@ -1,91 +0,0 @@
1
- import { User } from "@auth0/auth0-spa-js";
2
- import "./style.css";
3
- import sesamyLogo from "/sesamy.png";
4
- import { Events } from "./types/Events";
5
-
6
- /**
7
- * This class is only used for rendering the UI and not shipped in the bundle
8
- */
9
-
10
- class SesamyAppComponent extends HTMLElement {
11
- private user: User | undefined;
12
-
13
- constructor() {
14
- super();
15
- }
16
-
17
- async _handleProfile() {
18
- this.user = await window.sesamy.getUser();
19
- this.render();
20
- }
21
-
22
- async connectedCallback() {
23
- this.setupEventListeners();
24
-
25
- if (!window.sesamy) {
26
- window.addEventListener(Events.READY, () => this._handleProfile());
27
- return;
28
- }
29
-
30
- this._handleProfile();
31
- }
32
-
33
- render() {
34
- this.innerHTML = `
35
- <div>
36
- <a href="https://docs.sesamy.com" target="_blank">
37
- <img src="${sesamyLogo}" class="logo" alt="Vite logo" />
38
- </a>
39
- <h1>Sesamy JS</h1>
40
- <p class="read-the-docs">
41
- Click on the Sesamy logo to learn more
42
- </p>
43
- ${this.user ? this.renderUserProfile() : this.renderLoginButton()}
44
- </div>
45
- `;
46
- }
47
-
48
- private renderLoginButton(): string {
49
- return '<button part="login-btn" class="login auth-visible" id="login-btn"> Login </button>';
50
- }
51
-
52
- private renderUserProfile(): string {
53
- return `<div class="user" part="user">
54
- <a href="/profile" part="user-link">
55
- ${
56
- this.user?.picture
57
- ? ` <img
58
- class="big"
59
- part="user-img img-big"
60
- src=${this.user.picture}
61
- alt=${this.user.name || "User avatar"}
62
- />`
63
- : `<div part="avatar avatar-big" class="avatar big"> Placeholder </div>`
64
- }
65
- <h2 class="user-name">${this.user?.name || "User Name"}</h2>
66
- </a>
67
-
68
- <div class="logout-wrap">
69
- <a href="#" class="logout-btn" id="logout-btn"> Logout </a>
70
- </div>
71
- </div>`;
72
- }
73
-
74
- private setupEventListeners() {
75
- this.addEventListener("click", (event) => {
76
- const clickedElement = event.target as Element;
77
- const logoutButton = clickedElement.closest("#logout-btn");
78
- const loginButton = clickedElement.closest("#login-btn");
79
-
80
- if (logoutButton) {
81
- window.sesamy.logout();
82
- }
83
-
84
- if (loginButton) {
85
- window.sesamy.loginWithRedirect();
86
- }
87
- });
88
- }
89
- }
90
-
91
- customElements.define("sesamy-app", SesamyAppComponent);
package/src/constants.ts DELETED
@@ -1,2 +0,0 @@
1
- export const BASE_URL_DOMAIN = import.meta.env.VITE_BASE_URL_DOMAIN;
2
- export const ANALYTICS_BASE_URL = import.meta.env.VITE_ANALYTICS_BASE_URL;
@@ -1,11 +0,0 @@
1
- import { Events } from "../types/Events.js";
2
-
3
- export async function dispatchReadyEvent() {
4
- const event = new CustomEvent(Events.READY, {
5
- detail: {},
6
- bubbles: true,
7
- composed: true,
8
- });
9
-
10
- dispatchEvent(event);
11
- }
@@ -1,30 +0,0 @@
1
- import {
2
- loginWithRedirect,
3
- getUser,
4
- isAuthenticated,
5
- logout,
6
- } from "./services/auth";
7
-
8
- interface SesamyWindow {
9
- sesamy: {
10
- getUser: typeof getUser;
11
- isAuthenticated: typeof isAuthenticated;
12
- loginWithRedirect: typeof loginWithRedirect;
13
- logout: typeof logout;
14
- };
15
- }
16
-
17
- // Extend the global Window type with your SesamyWindow interface
18
- declare global {
19
- interface Window extends SesamyWindow {}
20
- }
21
-
22
- export function registerAPI(namespace = "sesamy") {
23
- // This makes it possible to use a different namespace
24
- (window as any)[namespace] = {
25
- getUser,
26
- isAuthenticated,
27
- loginWithRedirect,
28
- logout,
29
- };
30
- }
package/src/main.ts DELETED
@@ -1,29 +0,0 @@
1
- import { dispatchReadyEvent } from "./events/ready";
2
- import { registerAPI } from "./javascript-api";
3
- import { Config } from "./types/Config";
4
- import { init as initAuth } from "./services/auth";
5
- import { initAnalytics } from "./services/analytics";
6
-
7
- export async function init(config: Config) {
8
- await initAuth(config);
9
-
10
- initAnalytics({
11
- clientId: config.clientId,
12
- // The default client id can be overridden by the config
13
- ...config.analytics,
14
- });
15
-
16
- registerAPI(config.namespace);
17
-
18
- dispatchReadyEvent();
19
- }
20
-
21
- const configElement = document.getElementById("sesamy-js");
22
- if (configElement?.textContent) {
23
- try {
24
- const config = JSON.parse(configElement.textContent);
25
- init(config);
26
- } catch (err) {
27
- console.error("Failed to parse config", err);
28
- }
29
- }