@sesamy/sesamy-js 1.4.0 → 1.4.1

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";var br=Object.defineProperty;var kr=(t,e,n)=>e in t?br(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>(kr(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function nt(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 Ot(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Tt(t,e){return t(e={exports:{}},e.exports),e.exports}var ae=Tt(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(ae);var Ir=Ot(Tt(function(t,e){var n=ce&&ce.__awaiter||function(u,c,h,d){return new(h||(h=Promise))(function(w,I){function y(v){try{E(d.next(v))}catch(l){I(l)}}function _(v){try{E(d.throw(v))}catch(l){I(l)}}function E(v){v.done?w(v.value):new h(function(l){l(v.value)}).then(y,_)}E((d=d.apply(u,c||[])).next())})},r=ce&&ce.__generator||function(u,c){var h,d,w,I,y={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return I={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(I[Symbol.iterator]=function(){return this}),I;function _(E){return function(v){return function(l){if(h)throw new TypeError("Generator is already executing.");for(;y;)try{if(h=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 y.label++,{value:l[1],done:!1};case 5:y.label++,d=l[1],l=[0];continue;case 7:l=y.ops.pop(),y.trys.pop();continue;default:if(w=y.trys,!((w=w.length>0&&w[w.length-1])||l[0]!==6&&l[0]!==2)){y=0;continue}if(l[0]===3&&(!w||l[1]>w[0]&&l[1]<w[3])){y.label=l[1];break}if(l[0]===6&&y.label<w[1]){y.label=w[1],w=l;break}if(w&&y.label<w[2]){y.label=w[2],y.ops.push(l);break}w[2]&&y.ops.pop(),y.trys.pop();continue}l=c.call(u,y)}catch(b){l=[6,b],d=0}finally{h=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([E,v])}}},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(h){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 p(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",h="",d=0;d<u;d++)h+=c[Math.floor(Math.random()*c.length)];return h}var f=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+p(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,h){return h===void 0&&(h=5e3),n(this,void 0,void 0,function(){var d,w,I,y,_,E,v;return r(this,function(l){switch(l.label){case 0:d=Date.now()+p(4),w=Date.now()+h,I=o+"-"+c,y=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(),y.getItemSync(I)!==null?[3,5]:(_=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),y.setItemSync(I,JSON.stringify({id:this.id,iat:d,timeoutKey:_,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(E=y.getItemSync(I))!==null&&(v=JSON.parse(E)).id===this.id&&v.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(I,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(w)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+p(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,h){return n(this,void 0,void 0,function(){var d=this;return r(this,function(w){return setTimeout(function(){return n(d,void 0,void 0,function(){var I,y,_;return r(this,function(E){switch(E.label){case 0:return[4,ae.default().lock(h)];case 1:return E.sent(),this.acquiredIatSet.has(h)?(I=this.storageHandler===void 0?a:this.storageHandler,(y=I.getItemSync(c))===null?(ae.default().unlock(h),[2]):((_=JSON.parse(y)).timeRefreshed=Date.now(),I.setItemSync(c,JSON.stringify(_)),ae.default().unlock(h),this.refreshLockWhileAcquired(c,h),[2])):(ae.default().unlock(h),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(h){switch(h.label){case 0:return[4,new Promise(function(d){var w=!1,I=Date.now(),y=!1;function _(){if(y||(window.removeEventListener("storage",_),u.removeFromWaiting(_),clearTimeout(E),y=!0),!w){w=!0;var v=50-(Date.now()-I);v>0?setTimeout(d,v):d(null)}}window.addEventListener("storage",_),u.addToWaiting(_);var E=setTimeout(_,Math.max(0,c-Date.now()))})];case 1:return h.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(h){return h!==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(h){switch(h.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,h.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var h,d,w,I;return r(this,function(y){switch(y.label){case 0:return h=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=h.getItemSync(d))===null?[2]:(I=JSON.parse(w)).id!==this.id?[3,2]:[4,ae.default().lock(I.iat)];case 1:y.sent(),this.acquiredIatSet.delete(I.iat),h.removeItemSync(d),ae.default().unlock(I.iat),u.notifyWaiters(),y.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var h=Date.now()-5e3,d=c,w=[],I=0;;){var y=d.keySync(I);if(y===null)break;w.push(y),I++}for(var _=!1,E=0;E<w.length;E++){var v=w[E];if(v.includes(o)){var l=d.getItemSync(v);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<h||b.timeRefreshed!==void 0&&b.timeRefreshed<h)&&(d.removeItemSync(v),_=!0)}}}_&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=f}));const Sr={timeoutInSeconds:60},Tn={name:"auth0-spa-js",version:"2.1.3"},Pn=()=>Date.now();let H=class wt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,wt.prototype)}static fromPayload({error:e,error_description:n}){return new wt(e,n)}},_r=class jn extends H{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,jn.prototype)}},bt=class xn extends H{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,xn.prototype)}},Er=class Cn extends bt{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Cn.prototype)}},Or=class An extends H{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,An.prototype)}},Tr=class $n extends H{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,$n.prototype)}},zn=class Nn extends H{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Zt(e,["default"])}', scope: '${Zt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,Nn.prototype)}};function Zt(t,e=[]){return t&&!e.includes(t)?t:""}const Ge=()=>window.crypto,ut=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Ge().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Mt=t=>btoa(t),kt=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()},Wt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Pr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},jr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Pr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},xr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},p=o,new Promise(function(f,u){const c=new MessageChannel;c.port1.onmessage=function(h){h.data.error?u(new Error(h.data.error)):f(h.data),c.port1.close()},p.postMessage(s,[c.port2])});var s,p},Cr=async(t,e,n,r,i,o,a=1e4)=>i?xr(t,e,n,r,a,i,o):jr(t,r,a);async function Ar(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,p=Q(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const f=s?kt(p):JSON.stringify(p);return await async function(u,c,h,d,w,I,y){let _,E=null;for(let S=0;S<3;S++)try{_=await Cr(u,h,d,w,I,y,c),E=null;break}catch($){E=$}if(E)throw E;const v=_.json,{error:l,error_description:b}=v,j=Q(v,["error","error_description"]),{ok:k}=_;if(!k){const S=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Tr(l,S,j.mfa_token):l==="missing_refresh_token"?new zn(h,d):new H(l||"request_error",S)}return j}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:f,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Tn))}},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 It{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 It({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new It({scope:n,audience:r,clientId:i})}},$r=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@@"))}},Dn=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||Pn}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 p=this.matchExistingCacheKey(e,s);p&&(i=await this.cache.get(p))}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(" "))||[],p=o.scope&&s.reduce((f,u)=>f&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&p})[0]}},Nr=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",Dr=["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"],Ur=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,p,f]=a;if(a.length!==3||!s||!p||!f)throw new Error("ID token could not be decoded");const u=JSON.parse(Wt(p)),c={__raw:o},h={};return Object.keys(u).forEach(d=>{c[d]=u[d],Dr.includes(d)||(h[d]=u[d])}),{encoded:{header:s,payload:p,signature:f},header:JSON.parse(Wt(s)),claims:c,user:h}})(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=Tt(function(t,e){var n=ce&&ce.__assign||function(){return n=Object.assign||function(p){for(var f,u=1,c=arguments.length;u<c;u++)for(var h in f=arguments[u])Object.prototype.hasOwnProperty.call(f,h)&&(p[h]=f[h]);return p},n.apply(this,arguments)};function r(p,f){if(!f)return"";var u="; "+p;return f===!0?u:u+"="+f}function i(p,f,u){return encodeURIComponent(p).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(f).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*c.expires),c.expires=h}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(p){for(var f={},u=p?p.split("; "):[],c=/(%[\dA-F]{2})+/gi,h=0;h<u.length;h++){var d=u[h].split("="),w=d.slice(1).join("=");w.charAt(0)==='"'&&(w=w.slice(1,-1));try{f[d[0].replace(c,decodeURIComponent)]=w.replace(c,decodeURIComponent)}catch{}}return f}function a(){return o(document.cookie)}function s(p,f,u){document.cookie=i(p,f,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(p){return a()[p]},e.set=s,e.remove=function(p,f){s(p,"",n(n({},f),{expires:-1}))}});Ot(de),de.encode,de.parse,de.getAll;var Lr=de.get,Un=de.set,Ln=de.remove;const we={get(t){const e=Lr(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),Un(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Ln(t,n)}},Rr={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),Un(`_legacy_${t}`,JSON.stringify(e),r),we.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Ln(t,n),we.remove(t,e),we.remove(`_legacy_${t}`,e)}},Zr={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 Mr(t,e,n){var r=e===void 0?null:e,i=function(p,f){var u=atob(p);if(f){for(var c=new Uint8Array(u.length),h=0,d=u.length;h<d;++h)c[h]=u.charCodeAt(h);return String.fromCharCode.apply(null,new Uint16Array(c.buffer))}return u}(t,n!==void 0&&n),o=i.indexOf(`
2
2
  `,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var Kt,Jt,Xt,lt,Wr=(Kt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Jt=null,Xt=!1,function(t){return lt=lt||Mr(Kt,Jt,Xt),new Worker(lt,t)});const dt={};let Kr=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 Jr={memory:()=>new Dn().enclosedCache,localstorage:()=>new $r},Ft=t=>Jr[t],Ht=t=>{const{openUrl:e,onRedirect:n}=t,r=Q(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},ht=new Ir;let Xr=class{constructor(e){let n,r;if(this.userCache=new Dn().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(!Ge())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Ge().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",!Ft(n))throw new Error(`Invalid cache location "${n}"`);r=Ft(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?we:Rr,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:Zr;var o;this.scope=Ke("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Nr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Pn,this.cacheManager=new zr(r,r.allKeys?void 0:new Kr(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 Wr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Tn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${kt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Ur({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=Mt(ut()),o=Mt(ut()),a=ut(),s=(u=>{const c=new Uint8Array(u);return(h=>{const d={"+":"-","/":"_","=":""};return h.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Ge().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),p=((u,c,h,d,w,I,y,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),h),{scope:Ke(c,h.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:y||u.authorizationParams.redirect_uri,code_challenge:I,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(p);return{nonce:o,code_verifier:a,scope:p.scope,audience:p.audience||"default",redirect_uri:p.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const p=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${p},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((p,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(h),window.removeEventListener("message",u,!1),f(new Or(s.popup)))},1e3),h=setTimeout(()=>{clearInterval(c),f(new Er(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(h),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(H.fromPayload(d.data.response));p(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 H("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=Ht(e),{openUrl:i,fragment:o,appState:a}=r,s=Q(r,["openUrl","fragment","appState"]),p=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=Q(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),p&&{organization:p}));const h=o?`${u}#${o}`:u;i?await i(h):window.location.assign(h)}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 h=new URLSearchParams(c);return{state:h.get("state"),code:h.get("code")||void 0,error:h.get("error")||void 0,error_description:h.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new H("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new _r(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new H("state_mismatch","Invalid state");const p=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization:p}),{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=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=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})(()=>ht.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new bt;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:p}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:p})}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:Ke(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Sr),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?${kt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Ht(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:p,scope:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new H("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,h=await((w,I,y=60)=>new Promise((_,E)=>{const v=window.document.createElement("iframe");v.setAttribute("width","0"),v.setAttribute("height","0"),v.style.display="none";const l=()=>{window.document.body.contains(v)&&(window.document.body.removeChild(v),window.removeEventListener("message",b,!1))};let b;const j=setTimeout(()=>{E(new bt),l()},1e3*y);b=function(k){if(k.origin!=I||!k.data||k.data.type!=="authorization_response")return;const S=k.source;S&&S.close(),k.data.response.error?E(H.fromPayload(k.data.response)):_(k.data.response),clearTimeout(j),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(v),v.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==h.state)throw new H("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:h.code,grant_type:"authorization_code",redirect_uri:p,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new 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 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 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,p=await this._getIdTokenFromCache();return p&&Object.assign(Object.assign({id_token:p.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Ar(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 Fr(t){const e=new Xr(t);return await e.checkSession(),e}const Rn="sesamy.com",Hr="https://logs.sesamy.com/events";var pe=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.SOFT_PAYWALL="sesamyJsSoftPaywall",t))(pe||{});let V;const Pt="sesamyAccessToken",jt="sesamyExpiresAt";function xt(){const t=localStorage.getItem(jt);if(!(!t||parseInt(t,10)<new Date().getTime()))return localStorage.getItem(Pt)}async function Vr(t){if(t.enabled!==!1&&(V=await Fr({domain:t.endpoint||`token.${Rn}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await V.handleRedirectCallback();const e=await V.getUser();nt(pe.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function Yr(){if(xt())return!0;if(!V)throw new Error("Auth0 client not initialized");return V.isAuthenticated()}async function Gr(){if(xt())return{sub:"local",name:"Local User"};if(!V)throw new Error("Auth0 client not initialized");return V.getUser()}function Br(){if(!V)throw new Error("Auth0 client not initialized");return V.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function qr(){const t=xt();if(t)return t;if(!V)throw new Error("Auth0 client not initialized");return V.getTokenSilently()}async function Qr(){if(localStorage.removeItem(Pt),localStorage.removeItem(jt),!V)throw new Error("Auth0 client not initialized");return nt(pe.LOGOUT,{}),V.logout({logoutParams:{returnTo:window.location.href}})}function ei(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 Zn(t,e){localStorage.setItem(Pt,t),localStorage.setItem(jt,JSON.stringify(e*1e3+new Date().getTime()));const n=ei(t);nt(pe.AUTHENTICATED,n)}const ti=(t,e)=>e.skipDedupe||e.method!=="GET",ni=(t,e)=>e.method+"@"+t,ri=t=>t.clone(),Vt=({skip:t=ti,key:e=ni,resolver:n=ri}={})=>{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((p,f)=>{r.get(s).push([p,f])});try{return i(o,a).then(p=>(r.get(s).forEach(([f])=>f(n(p))),r.delete(s),p)).catch(p=>{throw r.get(s).forEach(([f,u])=>u(p)),r.delete(s),p})}catch(p){return r.delete(s),Promise.reject(p)}}},ii=(t,e)=>t*e,oi=t=>t&&t.ok,Yt=({delayTimer:t=500,delayRamp:e=ii,maxAttempts:n=10,until:r=oi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>p=>(f,u)=>{let c=0;if(s&&s(f,u))return p(f,u);const h=(d,w)=>Promise.resolve(r(d,w)).then(I=>I?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(y=>{const _=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:f,options:u})).then((E={})=>{var v,l;y(p((v=E&&E.url)!==null&&v!==void 0?v:f,(l=E&&E.options)!==null&&l!==void 0?l:u))}):y(p(f,u))},_)}).then(h).catch(y=>{if(!o)throw y;return h(null,y)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return p(f,u).then(h).catch(d=>{if(!o)throw d;return h(null,d)})},ai="application/json",Mn="Content-Type",ve=Symbol(),Wn=Symbol();function Gt(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Mn.toLowerCase()))===null||e===void 0?void 0:e[1]}function Bt(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 si(t,e=!1){Ee.options=e?t:he(Ee.options,t)}function ci(t,e=!1){Ee.polyfills=e?t:he(Ee.polyfills,t)}function ui(t){Ee.errorType=t}const li=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class Kn extends Error{}const di=t=>{const e=Object.create(null);t=t._addons.reduce((v,l)=>l.beforeRequest&&l.beforeRequest(v,t._options,e)||v,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:p}=t,f=new Map(o),u=he(i.options,r);let c=n;const h=li(s)((v,l)=>(c=v,i.polyfill("fetch")(v,l)))(n,u),d=new Error,w=h.catch(v=>{throw{[ve]:v}}).then(v=>{if(!v.ok){const l=new Kn;if(l.cause=d,l.stack=l.stack+`
5
- CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(b=>{var j;if(l.message=b,i.errorType==="json"||((j=v.headers.get("Content-Type"))===null||j===void 0?void 0:j.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=v.status,l})}return v}),I=v=>v.catch(l=>{const b=l.hasOwnProperty(ve),j=b?l[ve]:l,k=(j==null?void 0:j.status)&&f.get(j.status)||f.get(j==null?void 0:j.name)||b&&f.has(ve)&&f.get(ve);if(k)return k(j,t);const S=f.get(Wn);if(S)return S(j,t);throw j}),y=v=>l=>I(v?w.then(b=>b&&b[v]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),_={_wretchReq:t,_fetchReq:h,_sharedState:e,res:y(null),json:y("json"),blob:y("blob"),formData:y("formData"),arrayBuffer:y("arrayBuffer"),text:y("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(ve,v)}},E=p.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),_);return a.reduce((v,l)=>l(v,t),E)},hi={_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({[Mn]: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(Wn,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=Gt(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||Bt(i));return r=n?o?r.json(n,i):r.body(n):r,di(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=Gt(this._options.headers);return this.content(e||Bt(n)&&n||ai).body(JSON.stringify(t))}};function oe(t="",e={}){return{...hi,_url:t,_options:e}}oe.default=oe;oe.options=si;oe.errorType=ui;oe.polyfills=ci;oe.WretchError=Kn;function fi(t){const e=t.endpoint||`https://api2.${Rn}`,n=(k=!0)=>S=>async($,U)=>{let R=null;if(R=await qr(),!R&&k)throw new Error("No access token available");const L={...U,headers:{...U.headers,...R?{Authorization:`Bearer ${R}`}:{}}};return S($,L)},r=k=>(S,$)=>{const U=localStorage.getItem("__anon_id"),R=btoa(`${U}:`),L={...$,headers:{...$.headers,Authorization:`Basic ${R}`}};return k(S,L)},i=oe(e).headers({"Content-Type":"application/json"}).middlewares([n(),Vt(),Yt({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]),o=oe(e).headers({"Content-Type":"application/json"}).middlewares([n(!1),r,Vt(),Yt({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]);async function a(){return i.get("/entitlements").json()}async function s(k){const S=await i.get("/entitlements").json();return S==null?void 0:S.find($=>$.id===k)}async function p(){return i.get("/contracts").json()}async function f(k){const S=await i.get("/contracts").json();return S==null?void 0:S.find($=>$.id===k)}async function u(){return i.get("/bills").json()}async function c(k){const S=await i.get("/bills").json();return S==null?void 0:S.find($=>$.id===k)}async function h(k,S){return await i.url(`/user-metadata/${k}`).put(S).json()}async function d(k){return(await i.url(`/user-metadata/${k}`).delete().res()).ok}async function w(k){return(await i.url(`/user-metadata/${k}`).get().json())[k]}async function I(){return i.url("/user-metadata").get().json()}async function y(){return await i.url("/tags").get().json()}async function _(k){return(await i.url(`/tags/${k}`).delete().res()).ok}async function E(k){return(await i.url("/tags").post(k).res()).ok}async function v(k){return(await o.url("/tallies").get().json())[k]}async function l(){return await o.url("/tallies").get().json()}async function b(k){return(await o.url(`/tallies/${k}`).delete().res()).ok}async function j(k,S){return await o.url(`/tallies/${k}/push`).post(S).json()}return{getEntitlements:a,getEntitlement:s,getContracts:p,getContract:f,getBills:u,getBill:c,setUserMetadata:h,deleteUserMetadata:d,getUserMetadata:w,listUserMetadata:I,getTags:y,deleteTag:_,setTag:E,getTally:v,getTallies:l,deleteTally:b,pushTally:j}}const Jn="@sesamy/sesamy-js",Ct="1.3.2";function pi(t){const{getEntitlement:e,getEntitlements:n,getContract:r,getContracts:i,getBill:o,getBills:a,getTags:s,deleteTag:p,setTag:f,getUserMetadata:u,listUserMetadata:c,setUserMetadata:h,deleteUserMetadata:d,getTally:w,getTallies:I,pushTally:y,deleteTally:_}=fi(t),E={auth:{getUser:Gr,isAuthenticated:Yr,loginWithRedirect:Br,logout:Qr,setToken:Zn},tags:{list:s,set:f,delete:p},entitlements:{get:e,list:n},contracts:{get:r,list:i},bills:{get:o,list:a},userMetadata:{get:u,list:c,set:h,delete:d},tallies:{get:w,list:I,push:y,delete:_},getVersion:mi};return t.namespace&&(window[t.namespace]=E),E}function mi(){return Ct}function qt(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",Qt="object",gi=function(){},Xn="any",Fn="*",me="__",qe=typeof process<"u"?process:{};qe.env&&qe.env.NODE_ENV;var Y=typeof document<"u";qe.versions!=null&&qe.versions.node!=null;typeof Deno<"u"&&Deno.core;Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Hn(t,e){return e.charAt(0)[t]()+e.slice(1)}var yi=Hn.bind(null,"toUpperCase"),vi=Hn.bind(null,"toLowerCase");function wi(t){return Vn(t)?yi("null"):typeof t=="object"?Si(t):Object.prototype.toString.call(t).slice(8,-1)}function Qe(t,e){e===void 0&&(e=!0);var n=wi(t);return e?vi(n):n}function Me(t,e){return typeof e===t}var G=Me.bind(null,"function"),re=Me.bind(null,"string"),be=Me.bind(null,"undefined"),bi=Me.bind(null,"boolean");Me.bind(null,"symbol");function Vn(t){return t===null}function ki(t){return Qe(t)==="number"&&!isNaN(t)}function Yn(t){return Qe(t)==="array"}function X(t){if(!Ii(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ii(t){return t&&(typeof t=="object"||t!==null)}function Si(t){return G(t.constructor)?t.constructor.name:null}function _i(t){return t instanceof Error||re(t.message)&&t.constructor&&ki(t.constructor.stackTraceLimit)}function Gn(t,e){if(typeof e!="object"||Vn(e))return!1;if(e instanceof t)return!0;var n=Qe(new t(""));if(_i(e))for(;e;){if(Qe(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Gn.bind(null,TypeError);Gn.bind(null,SyntaxError);function rt(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ei(t,e):n}function Ei(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function it(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}it(rt,"form");it(rt,"button");it(rt,"input");it(rt,"select");function Oi(t){return t?Yn(t)?t:[t]:[]}function en(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ti(){if(Y){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Pi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function ji(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=en(n[1]),a=en(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var p=s.split("[");p.length>1&&(xi(r,p.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return Y&&window.location.search.substring(1)}(t))}function xi(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 ot(){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 De="global",Oe=me+"global"+me,Te=typeof self===Qt&&self.self===self&&self||typeof global===Qt&&global.global===global&&global||void 0;function ge(t){return Te[Oe][t]}function ye(t,e){return Te[Oe][t]=e}function je(t){delete Te[Oe][t]}function xe(t,e,n){var r;try{if(At(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Te[Oe]||(Te[Oe]={});var Xe={};function At(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 P(){return P=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},P.apply(this,arguments)}var ne="function",ee="undefined",Ci="@@redux/"+Math.random().toString(36),tn=function(){return typeof Symbol===ne&&Symbol.observable||"@@observable"}(),Fe=" != "+ne;function Bn(t,e,n){var r;if(typeof e===ne&&typeof n===ee&&(n=e,e=void 0),typeof n!==ee){if(typeof n!==ne)throw new Error("enhancer"+Fe);return n(Bn)(t,e)}if(typeof t!==ne)throw new Error("reducer"+Fe);var i=t,o=e,a=[],s=a,p=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ne)throw new Error("Listener"+Fe);var w=!0;return f(),s.push(d),function(){if(w){w=!1,f();var I=s.indexOf(d);s.splice(I,1)}}}function h(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===ee)throw new Error("ActType "+ee);if(p)throw new Error("Dispatch in reducer");try{p=!0,o=i(o,d)}finally{p=!1}for(var w=a=s,I=0;I<w.length;I++)(0,w[I])();return d}return h({type:"@@redux/INIT"}),(r={dispatch:h,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ne)throw new Error("next reducer"+Fe);i=d,h({type:"@@redux/INIT"})}})[tn]=function(){var d,w=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function y(){I.next&&I.next(u())}return y(),{unsubscribe:w(y)}}})[tn]=function(){return this},d},r}function Ai(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ee}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 $i(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,p={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(p)}),P({},a,{dispatch:s=Pe.apply(void 0,o)(a.dispatch)})}}}var ie=me+"anon_id",fe=me+"user_id",Ie=me+"user_traits",te="userId",ke="anonymousId",Be=["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"],St=["name","EVENTS","config","loaded"],T=Be.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),nn=/^utm_/,rn=/^an_prop_/,on=/^an_trait_/;function zi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===T.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,p=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ie,a.anonymousId),f||e(fe,a.userId),p.traits&&e(Ie,P({},f&&s.traits?s.traits:{},p.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,h=o.an_event,d=u.reduce(function(w,I){if(I.match(nn)||I.match(/^(d|g)clid/)){var y=I.replace(nn,"");w.campaign[y==="campaign"?"name":y]=o[I]}return I.match(rn)&&(w.props[I.replace(rn,"")]=o[I]),I.match(on)&&(w.traits[I.replace(on,"")]=o[I]),w},{campaign:{},props:{},traits:{}});n.dispatch(P({type:T.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:T.campaign,campaign:d.campaign})}}return r(i)}}}}function Ni(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===T.setItemEnd){if(n.key===ie)return P({},e,{anonymousId:n.value});if(n.key===fe)return P({},e,{userId:n.value})}switch(n.type){case T.identify:return Object.assign({},e,{userId:n.userId,traits:P({},e.traits,n.traits)});case T.reset:return[fe,ie,Ie].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function an(t){return{userId:t.getItem(fe),anonymousId:t.getItem(ie),traits:t.getItem(Ie)}}var _t=function(t){return me+"TEMP"+me+t};function Di(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var p=s.userId,f=s.traits,u=s.options;if(s.type===T.reset&&([fe,Ie,ie].forEach(function(d){r(d)}),[te,ke,"traits"].forEach(function(d){je(_t(d))})),s.type===T.identify){i(ie)||n(ie,ot());var c=i(fe),h=i(Ie)||{};c&&c!==p&&o.dispatch({type:T.userIdChanged,old:{userId:c,traits:h},new:{userId:p,traits:f},options:u}),p&&n(fe,p),f&&n(Ie,P({},h,f))}return a(s)}}}}var Ne={};function sn(t,e){Ne[t]&&G(Ne[t])&&(Ne[t](e),delete Ne[t])}function qn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(P({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return qn(t,e,n-10).then(r,i)})})}function Ui(t){return{abort:t}}function Qn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,p=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,h,d){return a[h.plugin].loaded?(c.process.push(h),c.processIndex.push(d)):(c.requeue.push(h),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var h=s.actions[c],d=h.plugin,w=h.payload.type,I=i[d][w];if(I&&G(I)){var y,_=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[te,ke].reduce(function(j,k){return l.hasOwnProperty(k)&&b[k]&&b[k]!==l[k]&&(j[k]=b[k]),j},l)}(h.payload,p),E=r[_.meta.rid];if(!E&&(y=I({payload:_,config:a[d].config,instance:n,abort:Ui}))&&X(y)&&y.abort)return void(r[_.meta.rid]=!0);if(!E){var v=w+":"+d;t.dispatch(P({},_,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,h){return!~f.processIndex.indexOf(h)});s.actions=u}}}var ft=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,p=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,h=c.match(Se),d=e.exact.map(function(y){return y.pluginName});h&&(d=a.during.map(function(y){return y.pluginName}));var w=function(y,_){return function(E,v,l){var b=v.config,j=v.name,k=j+"."+E.type;l&&(k=l.event);var S=E.type.match(Se)?function($,U,R,L,F){return function(M,x){var K=L?L.name:$,J=x&&Ze(x)?x:R;if(L&&(!(J=x&&Ze(x)?x:[$]).includes($)||J.length!==1))throw new Error("Method "+U+" can only abort "+$+" plugin. "+JSON.stringify(J)+" input valid");return P({},F,{abort:{reason:M,plugins:J,caller:U,_:K}})}}(j,k,_,l,E):function($,U){return function(){throw new Error($.type+" action not cancellable. Remove abort in "+U)}}(E,k);return{payload:Li(E),instance:y,config:b||{},abort:S}}}(r,d),I=e.exact.reduce(function(y,_){var E=_.pluginName,v=_.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[E].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),y[""+E]=l,y},{});return Promise.resolve(e.exact.reduce(function(y,_,E){try{var v=_.pluginName;return Promise.resolve(y).then(function(l){function b(){return Promise.resolve(l)}var j=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(k,S,$){try{return Promise.resolve(k).then(function(U){return S.method&&G(S.method)?(function(M,x){var K=pn(M);if(K&&K.name===x){var J=pn(K.method);throw new Error([x+" plugin is calling method "+M,"Plugins cant call self","Use "+K.method+" "+(J?"or "+J.method:"")+" in "+x+" plugin insteadof "+M].join(`
6
- `))}}(S.methodName,S.pluginName),Promise.resolve(S.method({payload:U,instance:r,abort:(R=U,L=v,F=S.pluginName,function(M,x){return P({},R,{abort:{reason:M,plugins:x||[L],caller:c,from:F||L}})}),config:ln(S.pluginName,f,o),plugins:f})).then(function(M){var x=X(M)?M:{};return Promise.resolve(P({},U,x))})):U;var R,L,F})}catch(U){return Promise.reject(U)}},Promise.resolve(n))).then(function(k){l[v]=k});l[v]=n}();return j&&j.then?j.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(y){return Promise.resolve(e.exact.reduce(function(_,E,v){try{var l=e.exact.length===v+1,b=E.pluginName,j=o[b];return Promise.resolve(_).then(function(k){var S=y[b]?y[b]:{};if(h&&(S=k),mt(S,b))return pt({data:S,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(k);if(mt(k,b))return l&&pt({data:k,method:c,instance:r,store:s}),Promise.resolve(k);if(I.hasOwnProperty(b)&&I[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:S,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(k);var $=w(y[b],o[b]);return Promise.resolve(j[c]({abort:$.abort,payload:S,instance:r,config:ln(b,f,o),plugins:f})).then(function(U){var R=X(U)?U:{},L=P({},k,R),F=y[b];if(mt(F,b))pt({data:F,method:c,instance:r,pluginName:b,store:s});else{var M=c+":"+b;(M.match(/:/g)||[]).length<2&&!c.match(cn)&&!c.match(un)&&r.dispatch(P({},h?L:S,{type:M,_:{called:M,from:"submethod"}}))}return Promise.resolve(L)})})}catch(k){return Promise.reject(k)}},Promise.resolve(n))).then(function(_){if(!(c.match(Se)||c.match(/^registerPlugin/)||c.match(un)||c.match(cn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(p.plugins.includes(c),_._&&_._.originalAction===c)return _;var E=P({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});er(_,e.exact.length)&&!c.match(/End$/)&&(E=P({},E,{type:_.type+"Aborted"})),s.dispatch(E)}return _})})}catch(y){return Promise.reject(y)}},Se=/Start$/,cn=/^bootstrap/,un=/^ready/;function pt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(P({},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(Se,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function mt(t,e){var n=t.abort;return!!n&&(n===!0||fn(n,e)||n&&fn(n.plugins,e))}function er(t,e){var n=t.abort;if(!n)return!1;if(n===!0||re(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 fn(t,e){return!(!t||!Ze(t))&&t.includes(e)}function pn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Li(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 Ri(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,p=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===T.enablePlugin&&i.dispatch({type:T.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===T.disablePlugin&&setTimeout(function(){return sn(a.meta.rid,{payload:a})},0),f===T.initializeEnd){var h=e(),d=Object.keys(h),w=d.filter(function(l){return u.includes(l)}).map(function(l){return h[l]}),I=[],y=[],_=a.disabled,E=w.map(function(l){var b=l.loaded,j=l.name,k=l.config;return qn(l,function(){return b({config:k})},1e4).then(function(S){return r[j]||(i.dispatch({type:T.pluginReadyType(j),name:j,events:Object.keys(l).filter(function($){return!St.includes($)})}),r[j]=!0),I=I.concat(j),l}).catch(function(S){if(S instanceof Error)throw new Error(S);return y=y.concat(S.name),S})});Promise.all(E).then(function(l){var b={plugins:I,failed:y,disabled:_};setTimeout(function(){d.length===E.length+_.length&&i.dispatch(P({},{type:T.ready},b))},0)})}var v=function(){if(f!==T.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Qn(i,e,t)},0),Promise.resolve(function(l,b,j,k,S){try{var $=G(b)?b():b,U=l.type,R=U.replace(Se,"");if(l._&&l._.called)return Promise.resolve(l);var L=j.getState(),F=(K=$,(J=L.plugins)===void 0&&(J={}),(Ce=l.options)===void 0&&(Ce={}),Object.keys(K).filter(function(m){var g=Ce.plugins||{};return bi(g[m])?g[m]:g.all!==!1&&(!J[m]||J[m].enabled!==!1)}).map(function(m){return K[m]}));U===T.initializeStart&&l.fromEnable&&(F=Object.keys(L.plugins).filter(function(m){var g=L.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return $[m]}));var M=F.map(function(m){return m.name}),x=function(m,g,O){var C=hn(m).map(function(A){return dn(A,g)});return g.reduce(function(A,z){var W=z.name,D=hn(m,W).map(function(Ae){return dn(Ae,g)}),Z=D[0],N=D[1],q=D[2];return Z.length&&(A.beforeNS[W]=Z),N.length&&(A.duringNS[W]=N),q.length&&(A.afterNS[W]=q),A},{before:C[0],beforeNS:{},during:C[1],duringNS:{},after:C[2],afterNS:{}})}(U,F);return Promise.resolve(ft({action:l,data:{exact:x.before,namespaced:x.beforeNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(m){function g(){var A=function(){if(U.match(Se))return Promise.resolve(ft({action:P({},O,{type:R+"End"}),data:{exact:x.after,namespaced:x.afterNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(z){z.meta&&z.meta.hasCallback&&sn(z.meta.rid,{payload:z})})}();return A&&A.then?A.then(function(){return m}):m}if(er(m,M.length))return m;var O,C=function(){if(U!==R)return Promise.resolve(ft({action:P({},m,{type:R}),data:{exact:x.during,namespaced:x.duringNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(A){O=A});O=m}();return C&&C.then?C.then(g):g()})}catch(m){return Promise.reject(m)}var K,J,Ce}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(v&&v.then?v.then(p):p(v))}catch(l){return Promise.reject(l)}}}}}function Zi(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===T.setItem||i===T.removeItem){if(r.abort)return n(r);i===T.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var Mi=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 Wi(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=mn(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},P({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var p=mn(n.type,T.initialize),f=t()[p];return f&&p?(r[p]=P({},e[p],{initialized:!0,loaded:!!f.loaded({config:f.config})}),P({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=P({},e[n.name],{loaded:!0}),P({},e,r);switch(n.type){case T.disablePlugin:return P({},e,gn(n.plugins,!1,e));case T.enablePlugin:return P({},e,gn(n.plugins,!0,e));default:return e}}}function mn(t,e){return t.substring(e.length+1,t.length)}function gn(t,e,n){return t.reduce(function(r,i){return r[i]=P({},n[i],{enabled:e}),r},n)}function tr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Ki={last:{},history:[]};function Ji(t,e){t===void 0&&(t=Ki);var n=e.options,r=e.meta;if(e.type===T.track){var i=tr(P({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return P({},t,{last:i,history:t.history.concat(i)})}return t}var Xi={actions:[]};function Fi(t,e){t===void 0&&(t=Xi);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===T.identify?[e].concat(t.actions):t.actions.concat(e),P({},t,{actions:r});case"dequeue":return[];default:return t}}var nr=/#.*$/;function Hi(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(nr,""):"")}var rr,ir,or,ar,Vi=function(t){if(t===void 0&&(t={}),!Y)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,p=o.hash,f=o.search,u=function(h){var d=function(){if(Y){for(var w,I=document.getElementsByTagName("link"),y=0;w=I[y];y++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+h:window.location.href.replace(nr,"")}(f),c={title:n,url:u,path:Hi(u),hash:p,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),P({},c,t)},Yi={last:{},history:[]};function Gi(t,e){t===void 0&&(t=Yi);var n=e.options;if(e.type===T.page){var r=tr(P({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return P({},t,{last:r,history:t.history.concat(r)})}return t}rr=function(){if(!Y)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"}(),ir=Y?document.referrer:null,or=Ti(),ar=Pi();var yn={initialized:!1,sessionId:ot(),app:null,version:null,debug:!1,offline:!!Y&&!navigator.onLine,os:{name:rr},userAgent:Y?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:ar,locale:or,campaign:{},referrer:ir};function Bi(t,e){t===void 0&&(t=yn);var n=t.initialized,r=e.campaign;switch(e.type){case T.campaign:return P({},t,{campaign:r});case T.offline:return P({},t,{offline:!0});case T.online:return P({},t,{offline:!1});default:return n?t:P({},yn,t,{initialized:!0})}}var qi=["plugins","reducers","storage"];function Qi(t,e,n){if(Y){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function eo(t){var e=Qi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function sr(){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 Te[Oe].analytics.push(a.action||a),o(a)}})}}}function vn(t){return function(){return Pe(Pe.apply(null,arguments),sr())}}function gt(t){return t?Yn(t)?t:[t]:[]}function wn(t,e,n){t===void 0&&(t={});var r,i,o=ot();return e&&(Ne[o]=(r=e,i=function(a){for(var s,p=a||Array.prototype.slice.call(arguments),f=0;f<p.length;f++)if(G(p[f])){s=p[f];break}return s}(n),function(a){i&&i(a),r(a)})),P({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function to(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,g){if(G(g))return m.middlewares=m.middlewares.concat(g),m;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var O=g.EVENTS?Object.keys(g.EVENTS).map(function(z){return g.EVENTS[z]}):[];m.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(m.methods[g.name]=Object.keys(g.methods).reduce(function(z,W){var D;return z[W]=(D=g.methods[W],function(){for(var Z=Array.prototype.slice.call(arguments),N=new Array(D.length),q=0;q<Z.length;q++)N[q]=Z[q];return N[N.length]=b,D.apply({instance:b},N)}),z},{}),delete g.methods);var C=Object.keys(g).concat(O),A=new Set(m.events.concat(C));if(m.events=Array.from(A),m.pluginsArray=m.pluginsArray.concat(g),m.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return m.plugins[g.name]=g,m.plugins[g.name].loaded||(m.plugins[g.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ge,setItem:ye,removeItem:je},o=function(m){return function(g,O,C){return O.getState("user")[g]||(C&&X(C)&&C[g]?C[g]:an(m)[g]||ge(_t(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!St.includes(m)}).sort(),p=new Set(s.concat(Be).filter(function(m){return!St.includes(m)})),f=Array.from(p).sort(),u=function(){return a},c=new Mi,h=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},y=ji(),_=an(i),E=P({},_,n,y.an_uid?{userId:y.an_uid}:{},y.an_aid?{anonymousId:y.an_aid}:{});E.anonymousId||(E.anonymousId=ot());var v=P({enable:function(m,g){return new Promise(function(O){x.dispatch({type:T.enablePlugin,plugins:gt(m),_:{originalAction:T.enablePlugin}},O,[g])})},disable:function(m,g){return new Promise(function(O){x.dispatch({type:T.disablePlugin,plugins:gt(m),_:{originalAction:T.disablePlugin}},O,[g])})}},r.methods),l=!1,b={identify:function(m,g,O,C){try{var A=re(m)?m:null,z=X(m)?m:g,W=O||{},D=b.user();ye(_t(te),A);var Z=A||z.userId||o(te,b,z);return Promise.resolve(new Promise(function(N){x.dispatch(P({type:T.identifyStart,userId:Z,traits:z||{},options:W,anonymousId:D.anonymousId},D.id&&D.id!==A&&{previousId:D.id}),N,[g,O,C])}))}catch(N){return Promise.reject(N)}},track:function(m,g,O,C){try{var A=X(m)?m.event:m;if(!A||!re(A))throw new Error("EventMissing");var z=X(m)?m:g||{},W=X(O)?O:{};return Promise.resolve(new Promise(function(D){x.dispatch({type:T.trackStart,event:A,properties:z,options:W,userId:o(te,b,g),anonymousId:o(ke,b,g)},D,[g,O,C])}))}catch(D){return Promise.reject(D)}},page:function(m,g,O){try{var C=X(m)?m:{},A=X(g)?g:{};return Promise.resolve(new Promise(function(z){x.dispatch({type:T.pageStart,properties:Vi(C),options:A,userId:o(te,b,C),anonymousId:o(ke,b,C)},z,[m,g,O])}))}catch(z){return Promise.reject(z)}},user:function(m){if(m===te||m==="id")return o(te,b);if(m===ke||m==="anonId")return o(ke,b);var g=b.getState("user");return m?qt(g,m):g},reset:function(m){return new Promise(function(g){x.dispatch({type:T.resetStart},g,m)})},ready:function(m){return l&&m({plugins:v,instance:b}),b.on(T.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!G(g))return!1;if(m===T.bootstrap)throw new Error(".on disabled for "+m);var O=/Start$|Start:/;if(m==="*"){var C=function(D){return function(Z){return function(N){return N.type.match(O)&&g({payload:N,instance:b,plugins:a}),Z(N)}}},A=function(D){return function(Z){return function(N){return N.type.match(O)||g({payload:N,instance:b,plugins:a}),Z(N)}}};return h(C,He),h(A,Ve),function(){d(C,He),d(A,Ve)}}var z=m.match(O)?He:Ve,W=function(D){return function(Z){return function(N){return N.type===m&&g({payload:N,instance:b,plugins:a,abort:I}),Z(N)}}};return h(W,z),function(){return d(W,z)}},once:function(m,g){if(!m||!G(g))return!1;if(m===T.bootstrap)throw new Error(".once disabled for "+m);var O=b.on(m,function(C){g({payload:C.payload,instance:b,plugins:a,abort:I}),O()});return O},getState:function(m){var g=x.getState();return m?qt(g,m):Object.assign({},g)},dispatch:function(m){var g=re(m)?{type:m}:m;if(Be.includes(g.type))throw new Error("reserved action "+g.type);var O=P({},g,{_:P({originalAction:g.type},m._||{})});x.dispatch(O)},enablePlugin:v.enable,disablePlugin:v.disable,plugins:v,storage:{getItem:i.getItem,setItem:function(m,g,O){x.dispatch({type:T.setItemStart,key:m,value:g,options:O})},removeItem:function(m,g){x.dispatch({type:T.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){b.storage.setItem(ie,m,g)},events:{core:Be,plugins:s}},j=r.middlewares.concat([function(m){return function(g){return function(O){return O.meta||(O.meta=wn()),g(O)}}},w(He),Ri(b,u,{all:f,plugins:s}),Zi(i),zi(b),Di(b),w(Ve)]),k={context:Bi,user:Ni(i),page:Gi,track:Ji,plugins:Wi(u),queue:Fi},S=Pe,$=Pe;if(Y&&t.debug){var U=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;U&&(S=U({trace:!0,traceLimit:25})),$=function(){return arguments.length===0?sr():X(typeof arguments[0])?vn():vn().apply(null,arguments)}}var R,L=function(m){return Object.keys(m).reduce(function(g,O){return qi.includes(O)||(g[O]=m[O]),g},{})}(t),F=r.pluginsArray.reduce(function(m,g){var O=g.name,C=g.config,A=g.loaded,z=r.pluginEnabled[O];return m[O]={enabled:z,initialized:!!z&&!g.initialize,loaded:!!A({config:C}),config:C},m},{}),M={context:L,user:E,plugins:F},x=Bn(function(m){for(var g=Object.keys(m),O={},C=0;C<g.length;C++){var A=g[C];typeof m[A]===ne&&(O[A]=m[A])}var z,W=Object.keys(O);try{(function(D){Object.keys(D).forEach(function(Z){var N=D[Z];if(typeof N(void 0,{type:"@@redux/INIT"})===ee||typeof N(void 0,{type:Ci})===ee)throw new Error("reducer "+Z+" "+ee)})})(O)}catch(D){z=D}return function(D,Z){if(D===void 0&&(D={}),z)throw z;for(var N=!1,q={},Ae=0;Ae<W.length;Ae++){var We=W[Ae],Rt=D[We],ct=(0,O[We])(Rt,Z);if(typeof ct===ee){var wr=Ai(We,Z);throw new Error(wr)}q[We]=ct,N=N||ct!==Rt}return N?q:D}}(P({},k,e)),M,$(S($i.apply(void 0,j))));x.dispatch=(R=x.dispatch,function(m,g,O){var C=P({},m,{meta:wn(m.meta,g,gt(O))});return R.apply(null,[C])});var K=Object.keys(a);x.dispatch({type:T.bootstrap,plugins:K,config:L,params:y,user:E,initialUser:n,persistedUser:_});var J=K.filter(function(m){return r.pluginEnabled[m]}),Ce=K.filter(function(m){return!r.pluginEnabled[m]});return x.dispatch({type:T.registerPlugins,plugins:K,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var O=m.bootstrap,C=m.config,A=m.name;O&&G(O)&&O({instance:b,config:C,payload:m}),x.dispatch({type:T.registerPluginType(A),name:A,enabled:r.pluginEnabled[A],plugin:m}),r.pluginsArray.length===g+1&&x.dispatch({type:T.initializeStart,plugins:J,disabled:Ce})}),eo(function(m){x.dispatch({type:m?T.offline:T.online})}),function(m,g,O){setInterval(function(){return Qn(m,g,O)},3e3)}(x,u,b),b}var He="before",Ve="after",Ue="cookie",ue=lr(),cr=at,no=at;function ur(t){return ue?at(t,"",-1):je(t)}function lr(){if(ue!==void 0)return ue;var t="cookiecookie";try{at(t,t),ue=document.cookie.indexOf(t)!==-1,ur(t)}catch{ue=!1}return ue}function at(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",ro=At.bind(null,"localStorage");xe("localStorage","getItem",ge);xe("localStorage","setItem",ye);xe("localStorage","removeItem",je);var Re="sessionStorage",io=At.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 oo=ro(),ao=io(),so=lr();function dr(t,e){if(t){var n=$t(e),r=!Ut(n),i=zt(n)?_e(localStorage.getItem(t)):void 0;if(r&&!be(i))return i;var o=Nt(n)?_e(cr(t)):void 0;if(r&&o)return o;var a=Dt(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 co(t,e,n){if(t&&!be(e)){var r={},i=$t(n),o=JSON.stringify(e),a=!Ut(i);return zt(i)&&(r[Le]=Ye(Le,e,_e(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Le]:Nt(i)&&(r[Ue]=Ye(Ue,e,_e(cr(t))),no(t,o),a)?r[Ue]:Dt(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 uo(t,e){if(t){var n=$t(e),r=dr(t,Fn),i={};return!be(r.localStorage)&&zt(n)&&(localStorage.removeItem(t),i[Le]=r.localStorage),!be(r.cookie)&&Nt(n)&&(ur(t),i[Ue]=r.cookie),!be(r.sessionStorage)&&Dt(n)&&(sessionStorage.removeItem(t),i[Re]=r.sessionStorage),!be(r.global)&&st(n,De)&&(je(t),i[De]=r.global),i}}function $t(t){return t?re(t)?t:t.storage:Xn}function zt(t){return oo&&st(t,Le)}function Nt(t){return so&&st(t,Ue)}function Dt(t){return ao&&st(t,Re)}function Ut(t){return t===Fn||t==="all"}function st(t,e){return t===Xn||t===e||Ut(t)}function Ye(t,e,n){return{location:t,current:e,previous:n}}var lo={setItem:co,getItem:dr,removeItem:uo};function ho(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bn(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 kn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bn(Object(n),!0).forEach(function(r){ho(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:lo};return to(kn(kn({},e),t))}function po(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(p){return r=i.push(p),r>=o&&a(),r},size:function(){return i.length},end:function(p){p&&a(),clearInterval(n)}}}function mo(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(...p){var c;const f=((c=p[2])==null?void 0:c.toString())||"",u=yo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,p)}})}function go(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function yo(t){return["#","?"].forEach(e=>t=go(t,e)),t}function vo(){mo(()=>{se.page()})}var In="EventListener";function wo(t){return function(e,n,r,i){var o=r||gi,a=i||!1;if(!Y)return o;var s=et(n),p=et(e,!0);if(!p.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var h=c?"add"+In:"remove"+In,d=0;d<p.length;d++){var w=p[d];f[d]=c?a&&a.once?bo(o):o:f[d]||o;for(var I=0;I<s.length;I++)w[h]?w["on"+s[I]]=c?f[d]:null:w[h](s[I],f[d],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=Oi(t);return e?o.map(function(a){return re(a)?et(a,!0):a}).flat():o}function bo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var yt=wo("Event");function hr(t,e){return Y&&G(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),G(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}hr.bind(null,"onerror");hr.bind(null,"onload");var fr=typeof window>"u",Sn="hidden";function ko(t){if(fr)return!1;var e=Io(),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 Io(){var t=["webkit","moz","ms","o"];return fr||Sn in document?Sn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var So=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function _o(t,e){e===void 0&&(e={});var n=function(a,s){var p=this,f=!1;return function(u){f||(a.call(p,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=ko(function(s){s||n({type:"tabVisible"})});return r=[a].concat(So.map(function(s){return yt(document,s,n)})).concat(yt(window,"load",n)).concat(yt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Eo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,p=t.throttle,f=p===void 0?2e3:p,u=!1,c=!1,h=new Date,d=function(){return clearTimeout(e)};function w(y){d(),o&&!u&&o(ze(h),y),i&&u&&(u=!1,i(ze(n),y),h=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(ze(h),y))},s)}var I=_o(w,{throttle:f});return{disable:function(){c=!0,u=!1,d();var y=I();return function(){return c=!1,h=new Date,w({type:"load"}),y()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:ze(h,c),idle:u?ze(n,c):0}}}}function ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const _n=5e3;class Oo{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");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),Eo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:_n})}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*_n:Date.now(),this.isInViewport&&this.trackAwake(e,n)}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 En="sesamy_session_id";function To(){let t=sessionStorage.getItem(En);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(En,t)),t}let pr=!1,Et,On,tt;function Po({clientId:t,enabled:e=!0,endpoint:n=Hr}){if(Et=t,On=e,tt=n,!On)return;vo();const r=new Oo({element:document.body,viewCallback:()=>{se.page()},activeDurationCallback:(i,o,a)=>{se.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{se.track("idleDuration",{duration:i,durationStart:a,flushing:o})}});xo(document.body,()=>{r.flush()}),Co(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(pe.AUTHENTICATED,async i=>{const o=i;await se.identify(o.detail.sub)}),window.addEventListener(pe.LOGOUT,async()=>{await se.track("logout",{}),Lt.flush(),await se.reset()})}function mr(t){return JSON.stringify(t.map(e=>({...e,clientId:Et,requestId:Math.random().toString(36).slice(2,9),sessionId:To(),timestamp:new Date().toISOString(),version:Ct,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:Jn,userAgent:navigator.userAgent,clientId:Et}})))}const Lt=po(async t=>{if(t.length>0){const e=mr(t);pr?navigator.sendBeacon(tt,e):(await fetch(tt,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function vt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(tt,mr([n]))}else Lt.push(t)}const se=fo({app:Jn,version:Ct,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;vt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;vt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;vt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function jo(){return pr=!0,Lt.flush()}const gr=new Map;function xo(t,e){gr.set(t,e)}window.addEventListener("beforeunload",()=>{gr.forEach((t,e)=>{t.bind(e)()}),jo()});const yr=new Map;function Co(t,e){yr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&yr.forEach((t,e)=>{t.bind(e)()})});function Ao(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e&&n){Zn(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 vr(t){Po({clientId:t.clientId,...t.analytics}),await Vr({clientId:t.clientId,...t.auth});const e=pi(t.api||{});return nt(pe.READY,{}),Ao(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);vr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=vr;
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",!Ft(n))throw new Error(`Invalid cache location "${n}"`);r=Ft(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?we:Rr,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:Zr;var o;this.scope=Ke("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Nr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Pn,this.cacheManager=new zr(r,r.allKeys?void 0:new Kr(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 Wr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Tn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${kt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Ur({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=Mt(ut()),o=Mt(ut()),a=ut(),s=(u=>{const c=new Uint8Array(u);return(h=>{const d={"+":"-","/":"_","=":""};return h.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Ge().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),p=((u,c,h,d,w,I,y,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),h),{scope:Ke(c,h.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:y||u.authorizationParams.redirect_uri,code_challenge:I,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(p);return{nonce:o,code_verifier:a,scope:p.scope,audience:p.audience||"default",redirect_uri:p.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const p=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${p},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((p,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(h),window.removeEventListener("message",u,!1),f(new Or(s.popup)))},1e3),h=setTimeout(()=>{clearInterval(c),f(new Er(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(h),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(H.fromPayload(d.data.response));p(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 H("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=Ht(e),{openUrl:i,fragment:o,appState:a}=r,s=Q(r,["openUrl","fragment","appState"]),p=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=Q(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),p&&{organization:p}));const h=o?`${u}#${o}`:u;i?await i(h):window.location.assign(h)}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 h=new URLSearchParams(c);return{state:h.get("state"),code:h.get("code")||void 0,error:h.get("error")||void 0,error_description:h.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new H("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new _r(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new H("state_mismatch","Invalid state");const p=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization:p}),{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=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=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})(()=>ht.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new bt;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:p}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:p})}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:Ke(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Sr),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?${kt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Ht(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:p,scope:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new H("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,h=await((w,I,y=60)=>new Promise((_,E)=>{const v=window.document.createElement("iframe");v.setAttribute("width","0"),v.setAttribute("height","0"),v.style.display="none";const l=()=>{window.document.body.contains(v)&&(window.document.body.removeChild(v),window.removeEventListener("message",b,!1))};let b;const j=setTimeout(()=>{E(new bt),l()},1e3*y);b=function(k){if(k.origin!=I||!k.data||k.data.type!=="authorization_response")return;const S=k.source;S&&S.close(),k.data.response.error?E(H.fromPayload(k.data.response)):_(k.data.response),clearTimeout(j),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(v),v.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==h.state)throw new H("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:h.code,grant_type:"authorization_code",redirect_uri:p,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new 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 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 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,p=await this._getIdTokenFromCache();return p&&Object.assign(Object.assign({id_token:p.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Ar(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 Fr(t){const e=new Xr(t);return await e.checkSession(),e}const Rn="sesamy.com",Hr="https://logs.sesamy.com/events";var pe=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.SOFT_PAYWALL="sesamyJsSoftPaywall",t))(pe||{});let V;const Pt="sesamyAccessToken",jt="sesamyExpiresAt";function xt(){const t=localStorage.getItem(jt);if(!(!t||parseInt(t,10)<new Date().getTime()))return localStorage.getItem(Pt)}async function Vr(t){if(t.enabled!==!1&&(V=await Fr({domain:t.endpoint||`token.${Rn}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await V.handleRedirectCallback();const e=await V.getUser();nt(pe.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function Yr(){if(xt())return!0;if(!V)throw new Error("Auth0 client not initialized");return V.isAuthenticated()}async function Gr(){if(xt())return{sub:"local",name:"Local User"};if(!V)throw new Error("Auth0 client not initialized");return V.getUser()}function Br(){if(!V)throw new Error("Auth0 client not initialized");return V.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function qr(t=!0){const e=xt();if(e)return e;try{if(!V)throw new Error("Auth0 client not initialized");return await V.getTokenSilently()}catch(n){if(t)throw n;return null}}async function Qr(){if(localStorage.removeItem(Pt),localStorage.removeItem(jt),!V)throw new Error("Auth0 client not initialized");return nt(pe.LOGOUT,{}),V.logout({logoutParams:{returnTo:window.location.href}})}function ei(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 Zn(t,e){localStorage.setItem(Pt,t),localStorage.setItem(jt,JSON.stringify(e*1e3+new Date().getTime()));const n=ei(t);nt(pe.AUTHENTICATED,n)}const ti=(t,e)=>e.skipDedupe||e.method!=="GET",ni=(t,e)=>e.method+"@"+t,ri=t=>t.clone(),Vt=({skip:t=ti,key:e=ni,resolver:n=ri}={})=>{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((p,f)=>{r.get(s).push([p,f])});try{return i(o,a).then(p=>(r.get(s).forEach(([f])=>f(n(p))),r.delete(s),p)).catch(p=>{throw r.get(s).forEach(([f,u])=>u(p)),r.delete(s),p})}catch(p){return r.delete(s),Promise.reject(p)}}},ii=(t,e)=>t*e,oi=t=>t&&t.ok,Yt=({delayTimer:t=500,delayRamp:e=ii,maxAttempts:n=10,until:r=oi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>p=>(f,u)=>{let c=0;if(s&&s(f,u))return p(f,u);const h=(d,w)=>Promise.resolve(r(d,w)).then(I=>I?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(y=>{const _=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:f,options:u})).then((E={})=>{var v,l;y(p((v=E&&E.url)!==null&&v!==void 0?v:f,(l=E&&E.options)!==null&&l!==void 0?l:u))}):y(p(f,u))},_)}).then(h).catch(y=>{if(!o)throw y;return h(null,y)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return p(f,u).then(h).catch(d=>{if(!o)throw d;return h(null,d)})},ai="application/json",Mn="Content-Type",ve=Symbol(),Wn=Symbol();function Gt(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Mn.toLowerCase()))===null||e===void 0?void 0:e[1]}function Bt(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 si(t,e=!1){Ee.options=e?t:he(Ee.options,t)}function ci(t,e=!1){Ee.polyfills=e?t:he(Ee.polyfills,t)}function ui(t){Ee.errorType=t}const li=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class Kn extends Error{}const di=t=>{const e=Object.create(null);t=t._addons.reduce((v,l)=>l.beforeRequest&&l.beforeRequest(v,t._options,e)||v,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:p}=t,f=new Map(o),u=he(i.options,r);let c=n;const h=li(s)((v,l)=>(c=v,i.polyfill("fetch")(v,l)))(n,u),d=new Error,w=h.catch(v=>{throw{[ve]:v}}).then(v=>{if(!v.ok){const l=new Kn;if(l.cause=d,l.stack=l.stack+`
5
+ CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(b=>{var j;if(l.message=b,i.errorType==="json"||((j=v.headers.get("Content-Type"))===null||j===void 0?void 0:j.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=v.status,l})}return v}),I=v=>v.catch(l=>{const b=l.hasOwnProperty(ve),j=b?l[ve]:l,k=(j==null?void 0:j.status)&&f.get(j.status)||f.get(j==null?void 0:j.name)||b&&f.has(ve)&&f.get(ve);if(k)return k(j,t);const S=f.get(Wn);if(S)return S(j,t);throw j}),y=v=>l=>I(v?w.then(b=>b&&b[v]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),_={_wretchReq:t,_fetchReq:h,_sharedState:e,res:y(null),json:y("json"),blob:y("blob"),formData:y("formData"),arrayBuffer:y("arrayBuffer"),text:y("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(ve,v)}},E=p.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),_);return a.reduce((v,l)=>l(v,t),E)},hi={_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({[Mn]: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(Wn,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=Gt(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||Bt(i));return r=n?o?r.json(n,i):r.body(n):r,di(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=Gt(this._options.headers);return this.content(e||Bt(n)&&n||ai).body(JSON.stringify(t))}};function oe(t="",e={}){return{...hi,_url:t,_options:e}}oe.default=oe;oe.options=si;oe.errorType=ui;oe.polyfills=ci;oe.WretchError=Kn;function fi(t){const e=t.endpoint||`https://api2.${Rn}`,n=(k=!0)=>S=>async($,D)=>{let R=null;if(R=await qr(k),!R){if(k)throw new Error("No access token available");return S($,D)}const L={...D,headers:{...D.headers,...R?{Authorization:`Bearer ${R}`}:{}}};return S($,L)},r=k=>(S,$)=>{const D=localStorage.getItem("__anon_id"),R=btoa(`${D}:`),L={...$,headers:{...$.headers,Authorization:`Basic ${R}`}};return k(S,L)},i=oe(e).headers({"Content-Type":"application/json"}).middlewares([n(),Vt(),Yt({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]),o=oe(e).headers({"Content-Type":"application/json"}).middlewares([n(!1),r,Vt(),Yt({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]);async function a(){return i.get("/entitlements").json()}async function s(k){const S=await i.get("/entitlements").json();return S==null?void 0:S.find($=>$.id===k)}async function p(){return i.get("/contracts").json()}async function f(k){const S=await i.get("/contracts").json();return S==null?void 0:S.find($=>$.id===k)}async function u(){return i.get("/bills").json()}async function c(k){const S=await i.get("/bills").json();return S==null?void 0:S.find($=>$.id===k)}async function h(k,S){return await i.url(`/user-metadata/${k}`).put(S).json()}async function d(k){return(await i.url(`/user-metadata/${k}`).delete().res()).ok}async function w(k){return(await i.url(`/user-metadata/${k}`).get().json())[k]}async function I(){return i.url("/user-metadata").get().json()}async function y(){return await i.url("/tags").get().json()}async function _(k){return(await i.url(`/tags/${k}`).delete().res()).ok}async function E(k){return(await i.url("/tags").post(k).res()).ok}async function v(k){return(await o.url("/tallies").get().json())[k]}async function l(){return await o.url("/tallies").get().json()}async function b(k){return(await o.url(`/tallies/${k}`).delete().res()).ok}async function j(k,S){return await o.url(`/tallies/${k}/push`).post(S).json()}return{getEntitlements:a,getEntitlement:s,getContracts:p,getContract:f,getBills:u,getBill:c,setUserMetadata:h,deleteUserMetadata:d,getUserMetadata:w,listUserMetadata:I,getTags:y,deleteTag:_,setTag:E,getTally:v,getTallies:l,deleteTally:b,pushTally:j}}const Jn="@sesamy/sesamy-js",Ct="1.3.2";function pi(t){const{getEntitlement:e,getEntitlements:n,getContract:r,getContracts:i,getBill:o,getBills:a,getTags:s,deleteTag:p,setTag:f,getUserMetadata:u,listUserMetadata:c,setUserMetadata:h,deleteUserMetadata:d,getTally:w,getTallies:I,pushTally:y,deleteTally:_}=fi(t),E={auth:{getUser:Gr,isAuthenticated:Yr,loginWithRedirect:Br,logout:Qr,setToken:Zn},tags:{list:s,set:f,delete:p},entitlements:{get:e,list:n},contracts:{get:r,list:i},bills:{get:o,list:a},userMetadata:{get:u,list:c,set:h,delete:d},tallies:{get:w,list:I,push:y,delete:_},getVersion:mi};return t.namespace&&(window[t.namespace]=E),E}function mi(){return Ct}function qt(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",Qt="object",gi=function(){},Xn="any",Fn="*",me="__",qe=typeof process<"u"?process:{};qe.env&&qe.env.NODE_ENV;var Y=typeof document<"u";qe.versions!=null&&qe.versions.node!=null;typeof Deno<"u"&&Deno.core;Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Hn(t,e){return e.charAt(0)[t]()+e.slice(1)}var yi=Hn.bind(null,"toUpperCase"),vi=Hn.bind(null,"toLowerCase");function wi(t){return Vn(t)?yi("null"):typeof t=="object"?Si(t):Object.prototype.toString.call(t).slice(8,-1)}function Qe(t,e){e===void 0&&(e=!0);var n=wi(t);return e?vi(n):n}function Me(t,e){return typeof e===t}var G=Me.bind(null,"function"),re=Me.bind(null,"string"),be=Me.bind(null,"undefined"),bi=Me.bind(null,"boolean");Me.bind(null,"symbol");function Vn(t){return t===null}function ki(t){return Qe(t)==="number"&&!isNaN(t)}function Yn(t){return Qe(t)==="array"}function X(t){if(!Ii(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ii(t){return t&&(typeof t=="object"||t!==null)}function Si(t){return G(t.constructor)?t.constructor.name:null}function _i(t){return t instanceof Error||re(t.message)&&t.constructor&&ki(t.constructor.stackTraceLimit)}function Gn(t,e){if(typeof e!="object"||Vn(e))return!1;if(e instanceof t)return!0;var n=Qe(new t(""));if(_i(e))for(;e;){if(Qe(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Gn.bind(null,TypeError);Gn.bind(null,SyntaxError);function rt(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ei(t,e):n}function Ei(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function it(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}it(rt,"form");it(rt,"button");it(rt,"input");it(rt,"select");function Oi(t){return t?Yn(t)?t:[t]:[]}function en(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ti(){if(Y){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Pi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function ji(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=en(n[1]),a=en(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var p=s.split("[");p.length>1&&(xi(r,p.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return Y&&window.location.search.substring(1)}(t))}function xi(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 ot(){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 De="global",Oe=me+"global"+me,Te=typeof self===Qt&&self.self===self&&self||typeof global===Qt&&global.global===global&&global||void 0;function ge(t){return Te[Oe][t]}function ye(t,e){return Te[Oe][t]=e}function je(t){delete Te[Oe][t]}function xe(t,e,n){var r;try{if(At(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Te[Oe]||(Te[Oe]={});var Xe={};function At(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 P(){return P=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},P.apply(this,arguments)}var ne="function",ee="undefined",Ci="@@redux/"+Math.random().toString(36),tn=function(){return typeof Symbol===ne&&Symbol.observable||"@@observable"}(),Fe=" != "+ne;function Bn(t,e,n){var r;if(typeof e===ne&&typeof n===ee&&(n=e,e=void 0),typeof n!==ee){if(typeof n!==ne)throw new Error("enhancer"+Fe);return n(Bn)(t,e)}if(typeof t!==ne)throw new Error("reducer"+Fe);var i=t,o=e,a=[],s=a,p=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ne)throw new Error("Listener"+Fe);var w=!0;return f(),s.push(d),function(){if(w){w=!1,f();var I=s.indexOf(d);s.splice(I,1)}}}function h(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===ee)throw new Error("ActType "+ee);if(p)throw new Error("Dispatch in reducer");try{p=!0,o=i(o,d)}finally{p=!1}for(var w=a=s,I=0;I<w.length;I++)(0,w[I])();return d}return h({type:"@@redux/INIT"}),(r={dispatch:h,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ne)throw new Error("next reducer"+Fe);i=d,h({type:"@@redux/INIT"})}})[tn]=function(){var d,w=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function y(){I.next&&I.next(u())}return y(),{unsubscribe:w(y)}}})[tn]=function(){return this},d},r}function Ai(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ee}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 $i(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,p={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(p)}),P({},a,{dispatch:s=Pe.apply(void 0,o)(a.dispatch)})}}}var ie=me+"anon_id",fe=me+"user_id",Ie=me+"user_traits",te="userId",ke="anonymousId",Be=["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"],St=["name","EVENTS","config","loaded"],T=Be.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),nn=/^utm_/,rn=/^an_prop_/,on=/^an_trait_/;function zi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===T.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,p=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ie,a.anonymousId),f||e(fe,a.userId),p.traits&&e(Ie,P({},f&&s.traits?s.traits:{},p.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,h=o.an_event,d=u.reduce(function(w,I){if(I.match(nn)||I.match(/^(d|g)clid/)){var y=I.replace(nn,"");w.campaign[y==="campaign"?"name":y]=o[I]}return I.match(rn)&&(w.props[I.replace(rn,"")]=o[I]),I.match(on)&&(w.traits[I.replace(on,"")]=o[I]),w},{campaign:{},props:{},traits:{}});n.dispatch(P({type:T.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:T.campaign,campaign:d.campaign})}}return r(i)}}}}function Ni(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===T.setItemEnd){if(n.key===ie)return P({},e,{anonymousId:n.value});if(n.key===fe)return P({},e,{userId:n.value})}switch(n.type){case T.identify:return Object.assign({},e,{userId:n.userId,traits:P({},e.traits,n.traits)});case T.reset:return[fe,ie,Ie].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function an(t){return{userId:t.getItem(fe),anonymousId:t.getItem(ie),traits:t.getItem(Ie)}}var _t=function(t){return me+"TEMP"+me+t};function Di(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var p=s.userId,f=s.traits,u=s.options;if(s.type===T.reset&&([fe,Ie,ie].forEach(function(d){r(d)}),[te,ke,"traits"].forEach(function(d){je(_t(d))})),s.type===T.identify){i(ie)||n(ie,ot());var c=i(fe),h=i(Ie)||{};c&&c!==p&&o.dispatch({type:T.userIdChanged,old:{userId:c,traits:h},new:{userId:p,traits:f},options:u}),p&&n(fe,p),f&&n(Ie,P({},h,f))}return a(s)}}}}var Ne={};function sn(t,e){Ne[t]&&G(Ne[t])&&(Ne[t](e),delete Ne[t])}function qn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(P({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return qn(t,e,n-10).then(r,i)})})}function Ui(t){return{abort:t}}function Qn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,p=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,h,d){return a[h.plugin].loaded?(c.process.push(h),c.processIndex.push(d)):(c.requeue.push(h),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var h=s.actions[c],d=h.plugin,w=h.payload.type,I=i[d][w];if(I&&G(I)){var y,_=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[te,ke].reduce(function(j,k){return l.hasOwnProperty(k)&&b[k]&&b[k]!==l[k]&&(j[k]=b[k]),j},l)}(h.payload,p),E=r[_.meta.rid];if(!E&&(y=I({payload:_,config:a[d].config,instance:n,abort:Ui}))&&X(y)&&y.abort)return void(r[_.meta.rid]=!0);if(!E){var v=w+":"+d;t.dispatch(P({},_,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,h){return!~f.processIndex.indexOf(h)});s.actions=u}}}var ft=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,p=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,h=c.match(Se),d=e.exact.map(function(y){return y.pluginName});h&&(d=a.during.map(function(y){return y.pluginName}));var w=function(y,_){return function(E,v,l){var b=v.config,j=v.name,k=j+"."+E.type;l&&(k=l.event);var S=E.type.match(Se)?function($,D,R,L,F){return function(M,x){var K=L?L.name:$,J=x&&Ze(x)?x:R;if(L&&(!(J=x&&Ze(x)?x:[$]).includes($)||J.length!==1))throw new Error("Method "+D+" can only abort "+$+" plugin. "+JSON.stringify(J)+" input valid");return P({},F,{abort:{reason:M,plugins:J,caller:D,_:K}})}}(j,k,_,l,E):function($,D){return function(){throw new Error($.type+" action not cancellable. Remove abort in "+D)}}(E,k);return{payload:Li(E),instance:y,config:b||{},abort:S}}}(r,d),I=e.exact.reduce(function(y,_){var E=_.pluginName,v=_.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[E].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),y[""+E]=l,y},{});return Promise.resolve(e.exact.reduce(function(y,_,E){try{var v=_.pluginName;return Promise.resolve(y).then(function(l){function b(){return Promise.resolve(l)}var j=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(k,S,$){try{return Promise.resolve(k).then(function(D){return S.method&&G(S.method)?(function(M,x){var K=pn(M);if(K&&K.name===x){var J=pn(K.method);throw new Error([x+" plugin is calling method "+M,"Plugins cant call self","Use "+K.method+" "+(J?"or "+J.method:"")+" in "+x+" plugin insteadof "+M].join(`
6
+ `))}}(S.methodName,S.pluginName),Promise.resolve(S.method({payload:D,instance:r,abort:(R=D,L=v,F=S.pluginName,function(M,x){return P({},R,{abort:{reason:M,plugins:x||[L],caller:c,from:F||L}})}),config:ln(S.pluginName,f,o),plugins:f})).then(function(M){var x=X(M)?M:{};return Promise.resolve(P({},D,x))})):D;var R,L,F})}catch(D){return Promise.reject(D)}},Promise.resolve(n))).then(function(k){l[v]=k});l[v]=n}();return j&&j.then?j.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(y){return Promise.resolve(e.exact.reduce(function(_,E,v){try{var l=e.exact.length===v+1,b=E.pluginName,j=o[b];return Promise.resolve(_).then(function(k){var S=y[b]?y[b]:{};if(h&&(S=k),mt(S,b))return pt({data:S,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(k);if(mt(k,b))return l&&pt({data:k,method:c,instance:r,store:s}),Promise.resolve(k);if(I.hasOwnProperty(b)&&I[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:S,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(k);var $=w(y[b],o[b]);return Promise.resolve(j[c]({abort:$.abort,payload:S,instance:r,config:ln(b,f,o),plugins:f})).then(function(D){var R=X(D)?D:{},L=P({},k,R),F=y[b];if(mt(F,b))pt({data:F,method:c,instance:r,pluginName:b,store:s});else{var M=c+":"+b;(M.match(/:/g)||[]).length<2&&!c.match(cn)&&!c.match(un)&&r.dispatch(P({},h?L:S,{type:M,_:{called:M,from:"submethod"}}))}return Promise.resolve(L)})})}catch(k){return Promise.reject(k)}},Promise.resolve(n))).then(function(_){if(!(c.match(Se)||c.match(/^registerPlugin/)||c.match(un)||c.match(cn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(p.plugins.includes(c),_._&&_._.originalAction===c)return _;var E=P({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});er(_,e.exact.length)&&!c.match(/End$/)&&(E=P({},E,{type:_.type+"Aborted"})),s.dispatch(E)}return _})})}catch(y){return Promise.reject(y)}},Se=/Start$/,cn=/^bootstrap/,un=/^ready/;function pt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(P({},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(Se,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function mt(t,e){var n=t.abort;return!!n&&(n===!0||fn(n,e)||n&&fn(n.plugins,e))}function er(t,e){var n=t.abort;if(!n)return!1;if(n===!0||re(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 fn(t,e){return!(!t||!Ze(t))&&t.includes(e)}function pn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Li(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 Ri(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,p=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===T.enablePlugin&&i.dispatch({type:T.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===T.disablePlugin&&setTimeout(function(){return sn(a.meta.rid,{payload:a})},0),f===T.initializeEnd){var h=e(),d=Object.keys(h),w=d.filter(function(l){return u.includes(l)}).map(function(l){return h[l]}),I=[],y=[],_=a.disabled,E=w.map(function(l){var b=l.loaded,j=l.name,k=l.config;return qn(l,function(){return b({config:k})},1e4).then(function(S){return r[j]||(i.dispatch({type:T.pluginReadyType(j),name:j,events:Object.keys(l).filter(function($){return!St.includes($)})}),r[j]=!0),I=I.concat(j),l}).catch(function(S){if(S instanceof Error)throw new Error(S);return y=y.concat(S.name),S})});Promise.all(E).then(function(l){var b={plugins:I,failed:y,disabled:_};setTimeout(function(){d.length===E.length+_.length&&i.dispatch(P({},{type:T.ready},b))},0)})}var v=function(){if(f!==T.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Qn(i,e,t)},0),Promise.resolve(function(l,b,j,k,S){try{var $=G(b)?b():b,D=l.type,R=D.replace(Se,"");if(l._&&l._.called)return Promise.resolve(l);var L=j.getState(),F=(K=$,(J=L.plugins)===void 0&&(J={}),(Ce=l.options)===void 0&&(Ce={}),Object.keys(K).filter(function(m){var g=Ce.plugins||{};return bi(g[m])?g[m]:g.all!==!1&&(!J[m]||J[m].enabled!==!1)}).map(function(m){return K[m]}));D===T.initializeStart&&l.fromEnable&&(F=Object.keys(L.plugins).filter(function(m){var g=L.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return $[m]}));var M=F.map(function(m){return m.name}),x=function(m,g,O){var C=hn(m).map(function(A){return dn(A,g)});return g.reduce(function(A,z){var W=z.name,U=hn(m,W).map(function(Ae){return dn(Ae,g)}),Z=U[0],N=U[1],q=U[2];return Z.length&&(A.beforeNS[W]=Z),N.length&&(A.duringNS[W]=N),q.length&&(A.afterNS[W]=q),A},{before:C[0],beforeNS:{},during:C[1],duringNS:{},after:C[2],afterNS:{}})}(D,F);return Promise.resolve(ft({action:l,data:{exact:x.before,namespaced:x.beforeNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(m){function g(){var A=function(){if(D.match(Se))return Promise.resolve(ft({action:P({},O,{type:R+"End"}),data:{exact:x.after,namespaced:x.afterNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(z){z.meta&&z.meta.hasCallback&&sn(z.meta.rid,{payload:z})})}();return A&&A.then?A.then(function(){return m}):m}if(er(m,M.length))return m;var O,C=function(){if(D!==R)return Promise.resolve(ft({action:P({},m,{type:R}),data:{exact:x.during,namespaced:x.duringNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(A){O=A});O=m}();return C&&C.then?C.then(g):g()})}catch(m){return Promise.reject(m)}var K,J,Ce}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(v&&v.then?v.then(p):p(v))}catch(l){return Promise.reject(l)}}}}}function Zi(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===T.setItem||i===T.removeItem){if(r.abort)return n(r);i===T.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var Mi=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 Wi(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=mn(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},P({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var p=mn(n.type,T.initialize),f=t()[p];return f&&p?(r[p]=P({},e[p],{initialized:!0,loaded:!!f.loaded({config:f.config})}),P({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=P({},e[n.name],{loaded:!0}),P({},e,r);switch(n.type){case T.disablePlugin:return P({},e,gn(n.plugins,!1,e));case T.enablePlugin:return P({},e,gn(n.plugins,!0,e));default:return e}}}function mn(t,e){return t.substring(e.length+1,t.length)}function gn(t,e,n){return t.reduce(function(r,i){return r[i]=P({},n[i],{enabled:e}),r},n)}function tr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Ki={last:{},history:[]};function Ji(t,e){t===void 0&&(t=Ki);var n=e.options,r=e.meta;if(e.type===T.track){var i=tr(P({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return P({},t,{last:i,history:t.history.concat(i)})}return t}var Xi={actions:[]};function Fi(t,e){t===void 0&&(t=Xi);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===T.identify?[e].concat(t.actions):t.actions.concat(e),P({},t,{actions:r});case"dequeue":return[];default:return t}}var nr=/#.*$/;function Hi(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(nr,""):"")}var rr,ir,or,ar,Vi=function(t){if(t===void 0&&(t={}),!Y)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,p=o.hash,f=o.search,u=function(h){var d=function(){if(Y){for(var w,I=document.getElementsByTagName("link"),y=0;w=I[y];y++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+h:window.location.href.replace(nr,"")}(f),c={title:n,url:u,path:Hi(u),hash:p,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),P({},c,t)},Yi={last:{},history:[]};function Gi(t,e){t===void 0&&(t=Yi);var n=e.options;if(e.type===T.page){var r=tr(P({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return P({},t,{last:r,history:t.history.concat(r)})}return t}rr=function(){if(!Y)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"}(),ir=Y?document.referrer:null,or=Ti(),ar=Pi();var yn={initialized:!1,sessionId:ot(),app:null,version:null,debug:!1,offline:!!Y&&!navigator.onLine,os:{name:rr},userAgent:Y?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:ar,locale:or,campaign:{},referrer:ir};function Bi(t,e){t===void 0&&(t=yn);var n=t.initialized,r=e.campaign;switch(e.type){case T.campaign:return P({},t,{campaign:r});case T.offline:return P({},t,{offline:!0});case T.online:return P({},t,{offline:!1});default:return n?t:P({},yn,t,{initialized:!0})}}var qi=["plugins","reducers","storage"];function Qi(t,e,n){if(Y){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function eo(t){var e=Qi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function sr(){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 Te[Oe].analytics.push(a.action||a),o(a)}})}}}function vn(t){return function(){return Pe(Pe.apply(null,arguments),sr())}}function gt(t){return t?Yn(t)?t:[t]:[]}function wn(t,e,n){t===void 0&&(t={});var r,i,o=ot();return e&&(Ne[o]=(r=e,i=function(a){for(var s,p=a||Array.prototype.slice.call(arguments),f=0;f<p.length;f++)if(G(p[f])){s=p[f];break}return s}(n),function(a){i&&i(a),r(a)})),P({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function to(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,g){if(G(g))return m.middlewares=m.middlewares.concat(g),m;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var O=g.EVENTS?Object.keys(g.EVENTS).map(function(z){return g.EVENTS[z]}):[];m.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(m.methods[g.name]=Object.keys(g.methods).reduce(function(z,W){var U;return z[W]=(U=g.methods[W],function(){for(var Z=Array.prototype.slice.call(arguments),N=new Array(U.length),q=0;q<Z.length;q++)N[q]=Z[q];return N[N.length]=b,U.apply({instance:b},N)}),z},{}),delete g.methods);var C=Object.keys(g).concat(O),A=new Set(m.events.concat(C));if(m.events=Array.from(A),m.pluginsArray=m.pluginsArray.concat(g),m.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return m.plugins[g.name]=g,m.plugins[g.name].loaded||(m.plugins[g.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ge,setItem:ye,removeItem:je},o=function(m){return function(g,O,C){return O.getState("user")[g]||(C&&X(C)&&C[g]?C[g]:an(m)[g]||ge(_t(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!St.includes(m)}).sort(),p=new Set(s.concat(Be).filter(function(m){return!St.includes(m)})),f=Array.from(p).sort(),u=function(){return a},c=new Mi,h=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},y=ji(),_=an(i),E=P({},_,n,y.an_uid?{userId:y.an_uid}:{},y.an_aid?{anonymousId:y.an_aid}:{});E.anonymousId||(E.anonymousId=ot());var v=P({enable:function(m,g){return new Promise(function(O){x.dispatch({type:T.enablePlugin,plugins:gt(m),_:{originalAction:T.enablePlugin}},O,[g])})},disable:function(m,g){return new Promise(function(O){x.dispatch({type:T.disablePlugin,plugins:gt(m),_:{originalAction:T.disablePlugin}},O,[g])})}},r.methods),l=!1,b={identify:function(m,g,O,C){try{var A=re(m)?m:null,z=X(m)?m:g,W=O||{},U=b.user();ye(_t(te),A);var Z=A||z.userId||o(te,b,z);return Promise.resolve(new Promise(function(N){x.dispatch(P({type:T.identifyStart,userId:Z,traits:z||{},options:W,anonymousId:U.anonymousId},U.id&&U.id!==A&&{previousId:U.id}),N,[g,O,C])}))}catch(N){return Promise.reject(N)}},track:function(m,g,O,C){try{var A=X(m)?m.event:m;if(!A||!re(A))throw new Error("EventMissing");var z=X(m)?m:g||{},W=X(O)?O:{};return Promise.resolve(new Promise(function(U){x.dispatch({type:T.trackStart,event:A,properties:z,options:W,userId:o(te,b,g),anonymousId:o(ke,b,g)},U,[g,O,C])}))}catch(U){return Promise.reject(U)}},page:function(m,g,O){try{var C=X(m)?m:{},A=X(g)?g:{};return Promise.resolve(new Promise(function(z){x.dispatch({type:T.pageStart,properties:Vi(C),options:A,userId:o(te,b,C),anonymousId:o(ke,b,C)},z,[m,g,O])}))}catch(z){return Promise.reject(z)}},user:function(m){if(m===te||m==="id")return o(te,b);if(m===ke||m==="anonId")return o(ke,b);var g=b.getState("user");return m?qt(g,m):g},reset:function(m){return new Promise(function(g){x.dispatch({type:T.resetStart},g,m)})},ready:function(m){return l&&m({plugins:v,instance:b}),b.on(T.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!G(g))return!1;if(m===T.bootstrap)throw new Error(".on disabled for "+m);var O=/Start$|Start:/;if(m==="*"){var C=function(U){return function(Z){return function(N){return N.type.match(O)&&g({payload:N,instance:b,plugins:a}),Z(N)}}},A=function(U){return function(Z){return function(N){return N.type.match(O)||g({payload:N,instance:b,plugins:a}),Z(N)}}};return h(C,He),h(A,Ve),function(){d(C,He),d(A,Ve)}}var z=m.match(O)?He:Ve,W=function(U){return function(Z){return function(N){return N.type===m&&g({payload:N,instance:b,plugins:a,abort:I}),Z(N)}}};return h(W,z),function(){return d(W,z)}},once:function(m,g){if(!m||!G(g))return!1;if(m===T.bootstrap)throw new Error(".once disabled for "+m);var O=b.on(m,function(C){g({payload:C.payload,instance:b,plugins:a,abort:I}),O()});return O},getState:function(m){var g=x.getState();return m?qt(g,m):Object.assign({},g)},dispatch:function(m){var g=re(m)?{type:m}:m;if(Be.includes(g.type))throw new Error("reserved action "+g.type);var O=P({},g,{_:P({originalAction:g.type},m._||{})});x.dispatch(O)},enablePlugin:v.enable,disablePlugin:v.disable,plugins:v,storage:{getItem:i.getItem,setItem:function(m,g,O){x.dispatch({type:T.setItemStart,key:m,value:g,options:O})},removeItem:function(m,g){x.dispatch({type:T.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){b.storage.setItem(ie,m,g)},events:{core:Be,plugins:s}},j=r.middlewares.concat([function(m){return function(g){return function(O){return O.meta||(O.meta=wn()),g(O)}}},w(He),Ri(b,u,{all:f,plugins:s}),Zi(i),zi(b),Di(b),w(Ve)]),k={context:Bi,user:Ni(i),page:Gi,track:Ji,plugins:Wi(u),queue:Fi},S=Pe,$=Pe;if(Y&&t.debug){var D=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;D&&(S=D({trace:!0,traceLimit:25})),$=function(){return arguments.length===0?sr():X(typeof arguments[0])?vn():vn().apply(null,arguments)}}var R,L=function(m){return Object.keys(m).reduce(function(g,O){return qi.includes(O)||(g[O]=m[O]),g},{})}(t),F=r.pluginsArray.reduce(function(m,g){var O=g.name,C=g.config,A=g.loaded,z=r.pluginEnabled[O];return m[O]={enabled:z,initialized:!!z&&!g.initialize,loaded:!!A({config:C}),config:C},m},{}),M={context:L,user:E,plugins:F},x=Bn(function(m){for(var g=Object.keys(m),O={},C=0;C<g.length;C++){var A=g[C];typeof m[A]===ne&&(O[A]=m[A])}var z,W=Object.keys(O);try{(function(U){Object.keys(U).forEach(function(Z){var N=U[Z];if(typeof N(void 0,{type:"@@redux/INIT"})===ee||typeof N(void 0,{type:Ci})===ee)throw new Error("reducer "+Z+" "+ee)})})(O)}catch(U){z=U}return function(U,Z){if(U===void 0&&(U={}),z)throw z;for(var N=!1,q={},Ae=0;Ae<W.length;Ae++){var We=W[Ae],Rt=U[We],ct=(0,O[We])(Rt,Z);if(typeof ct===ee){var wr=Ai(We,Z);throw new Error(wr)}q[We]=ct,N=N||ct!==Rt}return N?q:U}}(P({},k,e)),M,$(S($i.apply(void 0,j))));x.dispatch=(R=x.dispatch,function(m,g,O){var C=P({},m,{meta:wn(m.meta,g,gt(O))});return R.apply(null,[C])});var K=Object.keys(a);x.dispatch({type:T.bootstrap,plugins:K,config:L,params:y,user:E,initialUser:n,persistedUser:_});var J=K.filter(function(m){return r.pluginEnabled[m]}),Ce=K.filter(function(m){return!r.pluginEnabled[m]});return x.dispatch({type:T.registerPlugins,plugins:K,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var O=m.bootstrap,C=m.config,A=m.name;O&&G(O)&&O({instance:b,config:C,payload:m}),x.dispatch({type:T.registerPluginType(A),name:A,enabled:r.pluginEnabled[A],plugin:m}),r.pluginsArray.length===g+1&&x.dispatch({type:T.initializeStart,plugins:J,disabled:Ce})}),eo(function(m){x.dispatch({type:m?T.offline:T.online})}),function(m,g,O){setInterval(function(){return Qn(m,g,O)},3e3)}(x,u,b),b}var He="before",Ve="after",Ue="cookie",ue=lr(),cr=at,no=at;function ur(t){return ue?at(t,"",-1):je(t)}function lr(){if(ue!==void 0)return ue;var t="cookiecookie";try{at(t,t),ue=document.cookie.indexOf(t)!==-1,ur(t)}catch{ue=!1}return ue}function at(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",ro=At.bind(null,"localStorage");xe("localStorage","getItem",ge);xe("localStorage","setItem",ye);xe("localStorage","removeItem",je);var Re="sessionStorage",io=At.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 oo=ro(),ao=io(),so=lr();function dr(t,e){if(t){var n=$t(e),r=!Ut(n),i=zt(n)?_e(localStorage.getItem(t)):void 0;if(r&&!be(i))return i;var o=Nt(n)?_e(cr(t)):void 0;if(r&&o)return o;var a=Dt(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 co(t,e,n){if(t&&!be(e)){var r={},i=$t(n),o=JSON.stringify(e),a=!Ut(i);return zt(i)&&(r[Le]=Ye(Le,e,_e(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Le]:Nt(i)&&(r[Ue]=Ye(Ue,e,_e(cr(t))),no(t,o),a)?r[Ue]:Dt(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 uo(t,e){if(t){var n=$t(e),r=dr(t,Fn),i={};return!be(r.localStorage)&&zt(n)&&(localStorage.removeItem(t),i[Le]=r.localStorage),!be(r.cookie)&&Nt(n)&&(ur(t),i[Ue]=r.cookie),!be(r.sessionStorage)&&Dt(n)&&(sessionStorage.removeItem(t),i[Re]=r.sessionStorage),!be(r.global)&&st(n,De)&&(je(t),i[De]=r.global),i}}function $t(t){return t?re(t)?t:t.storage:Xn}function zt(t){return oo&&st(t,Le)}function Nt(t){return so&&st(t,Ue)}function Dt(t){return ao&&st(t,Re)}function Ut(t){return t===Fn||t==="all"}function st(t,e){return t===Xn||t===e||Ut(t)}function Ye(t,e,n){return{location:t,current:e,previous:n}}var lo={setItem:co,getItem:dr,removeItem:uo};function ho(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bn(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 kn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bn(Object(n),!0).forEach(function(r){ho(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:lo};return to(kn(kn({},e),t))}function po(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(p){return r=i.push(p),r>=o&&a(),r},size:function(){return i.length},end:function(p){p&&a(),clearInterval(n)}}}function mo(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(...p){var c;const f=((c=p[2])==null?void 0:c.toString())||"",u=yo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,p)}})}function go(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function yo(t){return["#","?"].forEach(e=>t=go(t,e)),t}function vo(){mo(()=>{se.page()})}var In="EventListener";function wo(t){return function(e,n,r,i){var o=r||gi,a=i||!1;if(!Y)return o;var s=et(n),p=et(e,!0);if(!p.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var h=c?"add"+In:"remove"+In,d=0;d<p.length;d++){var w=p[d];f[d]=c?a&&a.once?bo(o):o:f[d]||o;for(var I=0;I<s.length;I++)w[h]?w["on"+s[I]]=c?f[d]:null:w[h](s[I],f[d],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=Oi(t);return e?o.map(function(a){return re(a)?et(a,!0):a}).flat():o}function bo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var yt=wo("Event");function hr(t,e){return Y&&G(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),G(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}hr.bind(null,"onerror");hr.bind(null,"onload");var fr=typeof window>"u",Sn="hidden";function ko(t){if(fr)return!1;var e=Io(),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 Io(){var t=["webkit","moz","ms","o"];return fr||Sn in document?Sn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var So=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function _o(t,e){e===void 0&&(e={});var n=function(a,s){var p=this,f=!1;return function(u){f||(a.call(p,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=ko(function(s){s||n({type:"tabVisible"})});return r=[a].concat(So.map(function(s){return yt(document,s,n)})).concat(yt(window,"load",n)).concat(yt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Eo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,p=t.throttle,f=p===void 0?2e3:p,u=!1,c=!1,h=new Date,d=function(){return clearTimeout(e)};function w(y){d(),o&&!u&&o(ze(h),y),i&&u&&(u=!1,i(ze(n),y),h=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(ze(h),y))},s)}var I=_o(w,{throttle:f});return{disable:function(){c=!0,u=!1,d();var y=I();return function(){return c=!1,h=new Date,w({type:"load"}),y()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:ze(h,c),idle:u?ze(n,c):0}}}}function ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const _n=5e3;class Oo{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");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),Eo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:_n})}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*_n:Date.now(),this.isInViewport&&this.trackAwake(e,n)}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 En="sesamy_session_id";function To(){let t=sessionStorage.getItem(En);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(En,t)),t}let pr=!1,Et,On,tt;function Po({clientId:t,enabled:e=!0,endpoint:n=Hr}){if(Et=t,On=e,tt=n,!On)return;vo();const r=new Oo({element:document.body,viewCallback:()=>{se.page()},activeDurationCallback:(i,o,a)=>{se.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{se.track("idleDuration",{duration:i,durationStart:a,flushing:o})}});xo(document.body,()=>{r.flush()}),Co(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(pe.AUTHENTICATED,async i=>{const o=i;await se.identify(o.detail.sub)}),window.addEventListener(pe.LOGOUT,async()=>{await se.track("logout",{}),Lt.flush(),await se.reset()})}function mr(t){return JSON.stringify(t.map(e=>({...e,clientId:Et,requestId:Math.random().toString(36).slice(2,9),sessionId:To(),timestamp:new Date().toISOString(),version:Ct,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:Jn,userAgent:navigator.userAgent,clientId:Et}})))}const Lt=po(async t=>{if(t.length>0){const e=mr(t);pr?navigator.sendBeacon(tt,e):(await fetch(tt,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function vt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(tt,mr([n]))}else Lt.push(t)}const se=fo({app:Jn,version:Ct,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;vt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;vt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;vt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function jo(){return pr=!0,Lt.flush()}const gr=new Map;function xo(t,e){gr.set(t,e)}window.addEventListener("beforeunload",()=>{gr.forEach((t,e)=>{t.bind(e)()}),jo()});const yr=new Map;function Co(t,e){yr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&yr.forEach((t,e)=>{t.bind(e)()})});function Ao(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e&&n){Zn(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 vr(t){Po({clientId:t.clientId,...t.analytics}),await Vr({clientId:t.clientId,...t.auth});const e=pi(t.api||{});return nt(pe.READY,{}),Ao(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);vr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=vr;
@@ -1,6 +1,6 @@
1
1
  var sesamyJs=function(te){"use strict";var Ao=Object.defineProperty;var $o=(te,B,K)=>B in te?Ao(te,B,{enumerable:!0,configurable:!0,writable:!0,value:K}):te[B]=K;var Q=(te,B,K)=>($o(te,typeof B!="symbol"?B+"":B,K),K);function B(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}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 ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ut(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function lt(t,e){return t(e={exports:{}},e.exports),e.exports}var ue=lt(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()}});ut(ue);var br=ut(lt(function(t,e){var n=ce&&ce.__awaiter||function(u,c,h,d){return new(h||(h=Promise))(function(w,I){function y(v){try{E(d.next(v))}catch(l){I(l)}}function _(v){try{E(d.throw(v))}catch(l){I(l)}}function E(v){v.done?w(v.value):new h(function(l){l(v.value)}).then(y,_)}E((d=d.apply(u,c||[])).next())})},r=ce&&ce.__generator||function(u,c){var h,d,w,I,y={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return I={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(I[Symbol.iterator]=function(){return this}),I;function _(E){return function(v){return function(l){if(h)throw new TypeError("Generator is already executing.");for(;y;)try{if(h=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 y.label++,{value:l[1],done:!1};case 5:y.label++,d=l[1],l=[0];continue;case 7:l=y.ops.pop(),y.trys.pop();continue;default:if(w=y.trys,!((w=w.length>0&&w[w.length-1])||l[0]!==6&&l[0]!==2)){y=0;continue}if(l[0]===3&&(!w||l[1]>w[0]&&l[1]<w[3])){y.label=l[1];break}if(l[0]===6&&y.label<w[1]){y.label=w[1],w=l;break}if(w&&y.label<w[2]){y.label=w[2],y.ops.push(l);break}w[2]&&y.ops.pop(),y.trys.pop();continue}l=c.call(u,y)}catch(b){l=[6,b],d=0}finally{h=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([E,v])}}},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(h){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 p(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",h="",d=0;d<u;d++)h+=c[Math.floor(Math.random()*c.length)];return h}var f=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+p(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,h){return h===void 0&&(h=5e3),n(this,void 0,void 0,function(){var d,w,I,y,_,E,v;return r(this,function(l){switch(l.label){case 0:d=Date.now()+p(4),w=Date.now()+h,I=o+"-"+c,y=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(),y.getItemSync(I)!==null?[3,5]:(_=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),y.setItemSync(I,JSON.stringify({id:this.id,iat:d,timeoutKey:_,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(E=y.getItemSync(I))!==null&&(v=JSON.parse(E)).id===this.id&&v.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(I,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(w)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+p(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,h){return n(this,void 0,void 0,function(){var d=this;return r(this,function(w){return setTimeout(function(){return n(d,void 0,void 0,function(){var I,y,_;return r(this,function(E){switch(E.label){case 0:return[4,ue.default().lock(h)];case 1:return E.sent(),this.acquiredIatSet.has(h)?(I=this.storageHandler===void 0?a:this.storageHandler,(y=I.getItemSync(c))===null?(ue.default().unlock(h),[2]):((_=JSON.parse(y)).timeRefreshed=Date.now(),I.setItemSync(c,JSON.stringify(_)),ue.default().unlock(h),this.refreshLockWhileAcquired(c,h),[2])):(ue.default().unlock(h),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(h){switch(h.label){case 0:return[4,new Promise(function(d){var w=!1,I=Date.now(),y=!1;function _(){if(y||(window.removeEventListener("storage",_),u.removeFromWaiting(_),clearTimeout(E),y=!0),!w){w=!0;var v=50-(Date.now()-I);v>0?setTimeout(d,v):d(null)}}window.addEventListener("storage",_),u.addToWaiting(_);var E=setTimeout(_,Math.max(0,c-Date.now()))})];case 1:return h.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(h){return h!==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(h){switch(h.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,h.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var h,d,w,I;return r(this,function(y){switch(y.label){case 0:return h=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=h.getItemSync(d))===null?[2]:(I=JSON.parse(w)).id!==this.id?[3,2]:[4,ue.default().lock(I.iat)];case 1:y.sent(),this.acquiredIatSet.delete(I.iat),h.removeItemSync(d),ue.default().unlock(I.iat),u.notifyWaiters(),y.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var h=Date.now()-5e3,d=c,w=[],I=0;;){var y=d.keySync(I);if(y===null)break;w.push(y),I++}for(var _=!1,E=0;E<w.length;E++){var v=w[E];if(v.includes(o)){var l=d.getItemSync(v);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<h||b.timeRefreshed!==void 0&&b.timeRefreshed<h)&&(d.removeItemSync(v),_=!0)}}}_&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=f}));const kr={timeoutInSeconds:60},Zt={name:"auth0-spa-js",version:"2.1.3"},Mt=()=>Date.now();let H=class Lt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,Lt.prototype)}static fromPayload({error:e,error_description:n}){return new Lt(e,n)}},Ir=class pr extends H{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,pr.prototype)}},dt=class mr extends H{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,mr.prototype)}},Sr=class gr extends dt{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,gr.prototype)}},_r=class yr extends H{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,yr.prototype)}},Er=class vr extends H{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,vr.prototype)}},Wt=class wr extends H{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,wr.prototype)}};function Kt(t,e=[]){return t&&!e.includes(t)?t:""}const Je=()=>window.crypto,ht=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Je().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Jt=t=>btoa(t),ft=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()},Xt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Or=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Tr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Or(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Pr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},p=o,new Promise(function(f,u){const c=new MessageChannel;c.port1.onmessage=function(h){h.data.error?u(new Error(h.data.error)):f(h.data),c.port1.close()},p.postMessage(s,[c.port2])});var s,p},jr=async(t,e,n,r,i,o,a=1e4)=>i?Pr(t,e,n,r,a,i,o):Tr(t,r,a);async function xr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,p=K(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const f=s?ft(p):JSON.stringify(p);return await async function(u,c,h,d,w,I,y){let _,E=null;for(let S=0;S<3;S++)try{_=await jr(u,h,d,w,I,y,c),E=null;break}catch($){E=$}if(E)throw E;const v=_.json,{error:l,error_description:b}=v,j=K(v,["error","error_description"]),{ok:k}=_;if(!k){const S=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Er(l,S,j.mfa_token):l==="missing_refresh_token"?new Wt(h,d):new H(l||"request_error",S)}return j}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:f,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Zt))}},e,s)}const Xe=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let le=class Rt{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 Rt({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new Rt({scope:n,audience:r,clientId:i})}},Cr=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@@"))}},Ft=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)}}()}},Ar=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Mt}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 p=this.matchExistingCacheKey(e,s);p&&(i=await this.cache.get(p))}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(" "))||[],p=o.scope&&s.reduce((f,u)=>f&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&p})[0]}},$r=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"],Nr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,p,f]=a;if(a.length!==3||!s||!p||!f)throw new Error("ID token could not be decoded");const u=JSON.parse(Xt(p)),c={__raw:o},h={};return Object.keys(u).forEach(d=>{c[d]=u[d],zr.includes(d)||(h[d]=u[d])}),{encoded:{header:s,payload:p,signature:f},header:JSON.parse(Xt(s)),claims:c,user:h}})(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=lt(function(t,e){var n=ce&&ce.__assign||function(){return n=Object.assign||function(p){for(var f,u=1,c=arguments.length;u<c;u++)for(var h in f=arguments[u])Object.prototype.hasOwnProperty.call(f,h)&&(p[h]=f[h]);return p},n.apply(this,arguments)};function r(p,f){if(!f)return"";var u="; "+p;return f===!0?u:u+"="+f}function i(p,f,u){return encodeURIComponent(p).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(f).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*c.expires),c.expires=h}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(p){for(var f={},u=p?p.split("; "):[],c=/(%[\dA-F]{2})+/gi,h=0;h<u.length;h++){var d=u[h].split("="),w=d.slice(1).join("=");w.charAt(0)==='"'&&(w=w.slice(1,-1));try{f[d[0].replace(c,decodeURIComponent)]=w.replace(c,decodeURIComponent)}catch{}}return f}function a(){return o(document.cookie)}function s(p,f,u){document.cookie=i(p,f,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(p){return a()[p]},e.set=s,e.remove=function(p,f){s(p,"",n(n({},f),{expires:-1}))}});ut(de),de.encode,de.parse,de.getAll;var Dr=de.get,Ht=de.set,Vt=de.remove;const be={get(t){const e=Dr(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),Ht(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Vt(t,n)}},Ur={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),Ht(`_legacy_${t}`,JSON.stringify(e),r),be.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Vt(t,n),be.remove(t,e),be.remove(`_legacy_${t}`,e)}},Lr={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 Rr(t,e,n){var r=e===void 0?null:e,i=function(p,f){var u=atob(p);if(f){for(var c=new Uint8Array(u.length),h=0,d=u.length;h<d;++h)c[h]=u.charCodeAt(h);return String.fromCharCode.apply(null,new Uint16Array(c.buffer))}return u}(t,n!==void 0&&n),o=i.indexOf(`
2
2
  `,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var Yt,Gt,Bt,pt,Zr=(Yt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Gt=null,Bt=!1,function(t){return pt=pt||Rr(Yt,Gt,Bt),new Worker(pt,t)});const mt={};let Mr=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 Wr={memory:()=>new Ft().enclosedCache,localstorage:()=>new Cr},qt=t=>Wr[t],Qt=t=>{const{openUrl:e,onRedirect:n}=t,r=K(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},gt=new br;let Kr=class{constructor(e){let n,r;if(this.userCache=new Ft().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await gt.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(!Je())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Je().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",!qt(n))throw new Error(`Invalid cache location "${n}"`);r=qt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?be:Ur,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:Lr;var o;this.scope=Xe("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new $r(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Mt,this.cacheManager=new Ar(r,r.allKeys?void 0:new Mr(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 Zr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Zt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${ft(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Nr({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(ht()),o=Jt(ht()),a=ht(),s=(u=>{const c=new Uint8Array(u);return(h=>{const d={"+":"-","/":"_","=":""};return h.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Je().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),p=((u,c,h,d,w,I,y,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),h),{scope:Xe(c,h.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:y||u.authorizationParams.redirect_uri,code_challenge:I,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(p);return{nonce:o,code_verifier:a,scope:p.scope,audience:p.audience||"default",redirect_uri:p.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const p=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${p},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((p,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(h),window.removeEventListener("message",u,!1),f(new _r(s.popup)))},1e3),h=setTimeout(()=>{clearInterval(c),f(new Sr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(h),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(H.fromPayload(d.data.response));p(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 H("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=K(r,["openUrl","fragment","appState"]),p=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=K(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),p&&{organization:p}));const h=o?`${u}#${o}`:u;i?await i(h):window.location.assign(h)}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 h=new URLSearchParams(c);return{state:h.get("state"),code:h.get("code")||void 0,error:h.get("error")||void 0,error_description:h.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new H("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Ir(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new H("state_mismatch","Invalid state");const p=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization:p}),{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:Xe(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=mt[a];return s||(s=o().finally(()=>{delete mt[a],s=null}),mt[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})(()=>gt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new dt;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:p}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:p})}finally{await gt.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:Xe(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},kr),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=K(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${ft(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Qt(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:p,scope:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new H("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,h=await((w,I,y=60)=>new Promise((_,E)=>{const v=window.document.createElement("iframe");v.setAttribute("width","0"),v.setAttribute("height","0"),v.style.display="none";const l=()=>{window.document.body.contains(v)&&(window.document.body.removeChild(v),window.removeEventListener("message",b,!1))};let b;const j=setTimeout(()=>{E(new dt),l()},1e3*y);b=function(k){if(k.origin!=I||!k.data||k.data.type!=="authorization_response")return;const S=k.source;S&&S.close(),k.data.response.error?E(H.fromPayload(k.data.response)):_(k.data.response),clearTimeout(j),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(v),v.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==h.state)throw new H("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:h.code,grant_type:"authorization_code",redirect_uri:p,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new 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 Wt(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 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,p=await this._getIdTokenFromCache();return p&&Object.assign(Object.assign({id_token:p.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await xr(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 Jr(t){const e=new Kr(t);return await e.checkSession(),e}const en="sesamy.com",Xr="https://logs.sesamy.com/events";var he=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.SOFT_PAYWALL="sesamyJsSoftPaywall",t))(he||{});let V;const yt="sesamyAccessToken",vt="sesamyExpiresAt";function wt(){const t=localStorage.getItem(vt);if(!(!t||parseInt(t,10)<new Date().getTime()))return localStorage.getItem(yt)}async function Fr(t){if(t.enabled!==!1&&(V=await Jr({domain:t.endpoint||`token.${en}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await V.handleRedirectCallback();const e=await V.getUser();B(he.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function Hr(){if(wt())return!0;if(!V)throw new Error("Auth0 client not initialized");return V.isAuthenticated()}async function Vr(){if(wt())return{sub:"local",name:"Local User"};if(!V)throw new Error("Auth0 client not initialized");return V.getUser()}function Yr(){if(!V)throw new Error("Auth0 client not initialized");return V.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function Gr(){const t=wt();if(t)return t;if(!V)throw new Error("Auth0 client not initialized");return V.getTokenSilently()}async function Br(){if(localStorage.removeItem(yt),localStorage.removeItem(vt),!V)throw new Error("Auth0 client not initialized");return B(he.LOGOUT,{}),V.logout({logoutParams:{returnTo:window.location.href}})}function qr(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 tn(t,e){localStorage.setItem(yt,t),localStorage.setItem(vt,JSON.stringify(e*1e3+new Date().getTime()));const n=qr(t);B(he.AUTHENTICATED,n)}const Qr=(t,e)=>e.skipDedupe||e.method!=="GET",ei=(t,e)=>e.method+"@"+t,ti=t=>t.clone(),nn=({skip:t=Qr,key:e=ei,resolver:n=ti}={})=>{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((p,f)=>{r.get(s).push([p,f])});try{return i(o,a).then(p=>(r.get(s).forEach(([f])=>f(n(p))),r.delete(s),p)).catch(p=>{throw r.get(s).forEach(([f,u])=>u(p)),r.delete(s),p})}catch(p){return r.delete(s),Promise.reject(p)}}},ni=(t,e)=>t*e,ri=t=>t&&t.ok,rn=({delayTimer:t=500,delayRamp:e=ni,maxAttempts:n=10,until:r=ri,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>p=>(f,u)=>{let c=0;if(s&&s(f,u))return p(f,u);const h=(d,w)=>Promise.resolve(r(d,w)).then(I=>I?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(y=>{const _=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:f,options:u})).then((E={})=>{var v,l;y(p((v=E&&E.url)!==null&&v!==void 0?v:f,(l=E&&E.options)!==null&&l!==void 0?l:u))}):y(p(f,u))},_)}).then(h).catch(y=>{if(!o)throw y;return h(null,y)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return p(f,u).then(h).catch(d=>{if(!o)throw d;return h(null,d)})},ii="application/json",on="Content-Type",ke=Symbol(),an=Symbol();function sn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===on.toLowerCase()))===null||e===void 0?void 0:e[1]}function cn(t){return/^application\/.*json.*/.test(t)}const fe=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]=fe(a,o,n):r[i]=o,r},{...t})},Ie={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 oi(t,e=!1){Ie.options=e?t:fe(Ie.options,t)}function ai(t,e=!1){Ie.polyfills=e?t:fe(Ie.polyfills,t)}function si(t){Ie.errorType=t}const ci=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class un extends Error{}const ui=t=>{const e=Object.create(null);t=t._addons.reduce((v,l)=>l.beforeRequest&&l.beforeRequest(v,t._options,e)||v,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:p}=t,f=new Map(o),u=fe(i.options,r);let c=n;const h=ci(s)((v,l)=>(c=v,i.polyfill("fetch")(v,l)))(n,u),d=new Error,w=h.catch(v=>{throw{[ke]:v}}).then(v=>{if(!v.ok){const l=new un;if(l.cause=d,l.stack=l.stack+`
5
- CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(b=>{var j;if(l.message=b,i.errorType==="json"||((j=v.headers.get("Content-Type"))===null||j===void 0?void 0:j.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=v.status,l})}return v}),I=v=>v.catch(l=>{const b=l.hasOwnProperty(ke),j=b?l[ke]:l,k=(j==null?void 0:j.status)&&f.get(j.status)||f.get(j==null?void 0:j.name)||b&&f.has(ke)&&f.get(ke);if(k)return k(j,t);const S=f.get(an);if(S)return S(j,t);throw j}),y=v=>l=>I(v?w.then(b=>b&&b[v]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),_={_wretchReq:t,_fetchReq:h,_sharedState:e,res:y(null),json:y("json"),blob:y("blob"),formData:y("formData"),arrayBuffer:y("arrayBuffer"),text:y("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(ke,v)}},E=p.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),_);return a.reduce((v,l)=>l(v,t),E)},li={_url:"",_options:{},_config:Ie,_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:fe(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:fe(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:fe(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[on]: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(an,t)},resolve(t,e=!1){return{...this,_resolvers:e?[t]:[...this._resolvers,t]}},defer(t,e=!1){return{...this,_deferred:e?[t]:[...this._deferred,t]}},middlewares(t,e=!1){return{...this,_middlewares:e?t:[...this._middlewares,...t]}},fetch(t=this._options.method,e="",n=null){let r=this.url(e).options({method:t});const i=sn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||cn(i));return r=n?o?r.json(n,i):r.body(n):r,ui(r._deferred.reduce((a,s)=>s(a,a._url,a._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=sn(this._options.headers);return this.content(e||cn(n)&&n||ii).body(JSON.stringify(t))}};function re(t="",e={}){return{...li,_url:t,_options:e}}re.default=re,re.options=oi,re.errorType=si,re.polyfills=ai,re.WretchError=un;function di(t){const e=t.endpoint||`https://api2.${en}`,n=(k=!0)=>S=>async($,U)=>{let R=null;if(R=await Gr(),!R&&k)throw new Error("No access token available");const L={...U,headers:{...U.headers,...R?{Authorization:`Bearer ${R}`}:{}}};return S($,L)},r=k=>(S,$)=>{const U=localStorage.getItem("__anon_id"),R=btoa(`${U}:`),L={...$,headers:{...$.headers,Authorization:`Basic ${R}`}};return k(S,L)},i=re(e).headers({"Content-Type":"application/json"}).middlewares([n(),nn(),rn({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]),o=re(e).headers({"Content-Type":"application/json"}).middlewares([n(!1),r,nn(),rn({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]);async function a(){return i.get("/entitlements").json()}async function s(k){const S=await i.get("/entitlements").json();return S==null?void 0:S.find($=>$.id===k)}async function p(){return i.get("/contracts").json()}async function f(k){const S=await i.get("/contracts").json();return S==null?void 0:S.find($=>$.id===k)}async function u(){return i.get("/bills").json()}async function c(k){const S=await i.get("/bills").json();return S==null?void 0:S.find($=>$.id===k)}async function h(k,S){return await i.url(`/user-metadata/${k}`).put(S).json()}async function d(k){return(await i.url(`/user-metadata/${k}`).delete().res()).ok}async function w(k){return(await i.url(`/user-metadata/${k}`).get().json())[k]}async function I(){return i.url("/user-metadata").get().json()}async function y(){return await i.url("/tags").get().json()}async function _(k){return(await i.url(`/tags/${k}`).delete().res()).ok}async function E(k){return(await i.url("/tags").post(k).res()).ok}async function v(k){return(await o.url("/tallies").get().json())[k]}async function l(){return await o.url("/tallies").get().json()}async function b(k){return(await o.url(`/tallies/${k}`).delete().res()).ok}async function j(k,S){return await o.url(`/tallies/${k}/push`).post(S).json()}return{getEntitlements:a,getEntitlement:s,getContracts:p,getContract:f,getBills:u,getBill:c,setUserMetadata:h,deleteUserMetadata:d,getUserMetadata:w,listUserMetadata:I,getTags:y,deleteTag:_,setTag:E,getTally:v,getTallies:l,deleteTally:b,pushTally:j}}const ln="@sesamy/sesamy-js",bt="1.3.2";function hi(t){const{getEntitlement:e,getEntitlements:n,getContract:r,getContracts:i,getBill:o,getBills:a,getTags:s,deleteTag:p,setTag:f,getUserMetadata:u,listUserMetadata:c,setUserMetadata:h,deleteUserMetadata:d,getTally:w,getTallies:I,pushTally:y,deleteTally:_}=di(t),E={auth:{getUser:Vr,isAuthenticated:Hr,loginWithRedirect:Yr,logout:Br,setToken:tn},tags:{list:s,set:f,delete:p},entitlements:{get:e,list:n},contracts:{get:r,list:i},bills:{get:o,list:a},userMetadata:{get:u,list:c,set:h,delete:d},tallies:{get:w,list:I,push:y,delete:_},getVersion:fi};return t.namespace&&(window[t.namespace]=E),E}function fi(){return bt}function dn(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",hn="object",pi=function(){},fn="any",pn="*",pe="__",He=typeof process<"u"?process:{};He.env&&He.env.NODE_ENV;var Y=typeof document<"u";He.versions!=null&&He.versions.node!=null,typeof Deno<"u"&&Deno.core,Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function mn(t,e){return e.charAt(0)[t]()+e.slice(1)}var mi=mn.bind(null,"toUpperCase"),gi=mn.bind(null,"toLowerCase");function yi(t){return gn(t)?mi("null"):typeof t=="object"?ki(t):Object.prototype.toString.call(t).slice(8,-1)}function Ve(t,e){e===void 0&&(e=!0);var n=yi(t);return e?gi(n):n}function ze(t,e){return typeof e===t}var q=ze.bind(null,"function"),ie=ze.bind(null,"string"),Se=ze.bind(null,"undefined"),vi=ze.bind(null,"boolean");ze.bind(null,"symbol");function gn(t){return t===null}function wi(t){return Ve(t)==="number"&&!isNaN(t)}function yn(t){return Ve(t)==="array"}function X(t){if(!bi(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function bi(t){return t&&(typeof t=="object"||t!==null)}function ki(t){return q(t.constructor)?t.constructor.name:null}function Ii(t){return t instanceof Error||ie(t.message)&&t.constructor&&wi(t.constructor.stackTraceLimit)}function vn(t,e){if(typeof e!="object"||gn(e))return!1;if(e instanceof t)return!0;var n=Ve(new t(""));if(Ii(e))for(;e;){if(Ve(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}vn.bind(null,TypeError),vn.bind(null,SyntaxError);function Ye(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Si(t,e):n}function Si(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Ge(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Ge(Ye,"form"),Ge(Ye,"button"),Ge(Ye,"input"),Ge(Ye,"select");function _i(t){return t?yn(t)?t:[t]:[]}function wn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ei(){if(Y){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Oi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ti(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=wn(n[1]),a=wn(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 p=s.split("[");p.length>1&&(Pi(r,p.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return Y&&window.location.search.substring(1)}(t))}function Pi(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 Be(){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 Ne="global",_e=pe+"global"+pe,Ee=typeof self===hn&&self.self===self&&self||typeof global===hn&&global.global===global&&global||void 0;function me(t){return Ee[_e][t]}function ge(t,e){return Ee[_e][t]=e}function Oe(t){delete Ee[_e][t]}function Te(t,e,n){var r;try{if(kt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Ee[_e]||(Ee[_e]={});var qe={};function kt(t){if(typeof qe[t]!==Fe)return qe[t];try{var e=window[t];e.setItem(Fe,Fe),e.removeItem(Fe)}catch{return qe[t]=!1}return qe[t]=!0}function T(){return T=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},T.apply(this,arguments)}var oe="function",ne="undefined",ji="@@redux/"+Math.random().toString(36),bn=function(){return typeof Symbol===oe&&Symbol.observable||"@@observable"}(),Qe=" != "+oe;function kn(t,e,n){var r;if(typeof e===oe&&typeof n===ne&&(n=e,e=void 0),typeof n!==ne){if(typeof n!==oe)throw new Error("enhancer"+Qe);return n(kn)(t,e)}if(typeof t!==oe)throw new Error("reducer"+Qe);var i=t,o=e,a=[],s=a,p=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==oe)throw new Error("Listener"+Qe);var w=!0;return f(),s.push(d),function(){if(w){w=!1,f();var I=s.indexOf(d);s.splice(I,1)}}}function h(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===ne)throw new Error("ActType "+ne);if(p)throw new Error("Dispatch in reducer");try{p=!0,o=i(o,d)}finally{p=!1}for(var w=a=s,I=0;I<w.length;I++)(0,w[I])();return d}return h({type:"@@redux/INIT"}),(r={dispatch:h,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==oe)throw new Error("next reducer"+Qe);i=d,h({type:"@@redux/INIT"})}})[bn]=function(){var d,w=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function y(){I.next&&I.next(u())}return y(),{unsubscribe:w(y)}}})[bn]=function(){return this},d},r}function xi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ne}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 Ci(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,p={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(p)}),T({},a,{dispatch:s=Pe.apply(void 0,o)(a.dispatch)})}}}var ae=pe+"anon_id",ye=pe+"user_id",je=pe+"user_traits",se="userId",xe="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"],It=["name","EVENTS","config","loaded"],P=et.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),In=/^utm_/,Sn=/^an_prop_/,_n=/^an_trait_/;function Ai(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,p=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ae,a.anonymousId),f||e(ye,a.userId),p.traits&&e(je,T({},f&&s.traits?s.traits:{},p.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,h=o.an_event,d=u.reduce(function(w,I){if(I.match(In)||I.match(/^(d|g)clid/)){var y=I.replace(In,"");w.campaign[y==="campaign"?"name":y]=o[I]}return I.match(Sn)&&(w.props[I.replace(Sn,"")]=o[I]),I.match(_n)&&(w.traits[I.replace(_n,"")]=o[I]),w},{campaign:{},props:{},traits:{}});n.dispatch(T({type:P.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:P.campaign,campaign:d.campaign})}}return r(i)}}}}function $i(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===P.setItemEnd){if(n.key===ae)return T({},e,{anonymousId:n.value});if(n.key===ye)return T({},e,{userId:n.value})}switch(n.type){case P.identify:return Object.assign({},e,{userId:n.userId,traits:T({},e.traits,n.traits)});case P.reset:return[ye,ae,je].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function En(t){return{userId:t.getItem(ye),anonymousId:t.getItem(ae),traits:t.getItem(je)}}var St=function(t){return pe+"TEMP"+pe+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 p=s.userId,f=s.traits,u=s.options;if(s.type===P.reset&&([ye,je,ae].forEach(function(d){r(d)}),[se,xe,"traits"].forEach(function(d){Oe(St(d))})),s.type===P.identify){i(ae)||n(ae,Be());var c=i(ye),h=i(je)||{};c&&c!==p&&o.dispatch({type:P.userIdChanged,old:{userId:c,traits:h},new:{userId:p,traits:f},options:u}),p&&n(ye,p),f&&n(je,T({},h,f))}return a(s)}}}}var De={};function On(t,e){De[t]&&q(De[t])&&(De[t](e),delete De[t])}function Tn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(T({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return Tn(t,e,n-10).then(r,i)})})}function Ni(t){return{abort:t}}function Pn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,p=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,h,d){return a[h.plugin].loaded?(c.process.push(h),c.processIndex.push(d)):(c.requeue.push(h),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var h=s.actions[c],d=h.plugin,w=h.payload.type,I=i[d][w];if(I&&q(I)){var y,_=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[se,xe].reduce(function(j,k){return l.hasOwnProperty(k)&&b[k]&&b[k]!==l[k]&&(j[k]=b[k]),j},l)}(h.payload,p),E=r[_.meta.rid];if(!E&&(y=I({payload:_,config:a[d].config,instance:n,abort:Ni}))&&X(y)&&y.abort)return void(r[_.meta.rid]=!0);if(!E){var v=w+":"+d;t.dispatch(T({},_,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,h){return!~f.processIndex.indexOf(h)});s.actions=u}}}var _t=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,p=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,h=c.match(Ce),d=e.exact.map(function(y){return y.pluginName});h&&(d=a.during.map(function(y){return y.pluginName}));var w=function(y,_){return function(E,v,l){var b=v.config,j=v.name,k=j+"."+E.type;l&&(k=l.event);var S=E.type.match(Ce)?function($,U,R,L,G){return function(M,x){var J=L?L.name:$,F=x&&Ue(x)?x:R;if(L&&(!(F=x&&Ue(x)?x:[$]).includes($)||F.length!==1))throw new Error("Method "+U+" can only abort "+$+" plugin. "+JSON.stringify(F)+" input valid");return T({},G,{abort:{reason:M,plugins:F,caller:U,_:J}})}}(j,k,_,l,E):function($,U){return function(){throw new Error($.type+" action not cancellable. Remove abort in "+U)}}(E,k);return{payload:Di(E),instance:y,config:b||{},abort:S}}}(r,d),I=e.exact.reduce(function(y,_){var E=_.pluginName,v=_.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[E].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),y[""+E]=l,y},{});return Promise.resolve(e.exact.reduce(function(y,_,E){try{var v=_.pluginName;return Promise.resolve(y).then(function(l){function b(){return Promise.resolve(l)}var j=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(k,S,$){try{return Promise.resolve(k).then(function(U){return S.method&&q(S.method)?(function(M,x){var J=Dn(M);if(J&&J.name===x){var F=Dn(J.method);throw new Error([x+" plugin is calling method "+M,"Plugins cant call self","Use "+J.method+" "+(F?"or "+F.method:"")+" in "+x+" plugin insteadof "+M].join(`
6
- `))}}(S.methodName,S.pluginName),Promise.resolve(S.method({payload:U,instance:r,abort:(R=U,L=v,G=S.pluginName,function(M,x){return T({},R,{abort:{reason:M,plugins:x||[L],caller:c,from:G||L}})}),config:Cn(S.pluginName,f,o),plugins:f})).then(function(M){var x=X(M)?M:{};return Promise.resolve(T({},U,x))})):U;var R,L,G})}catch(U){return Promise.reject(U)}},Promise.resolve(n))).then(function(k){l[v]=k});l[v]=n}();return j&&j.then?j.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(y){return Promise.resolve(e.exact.reduce(function(_,E,v){try{var l=e.exact.length===v+1,b=E.pluginName,j=o[b];return Promise.resolve(_).then(function(k){var S=y[b]?y[b]:{};if(h&&(S=k),Ot(S,b))return Et({data:S,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(k);if(Ot(k,b))return l&&Et({data:k,method:c,instance:r,store:s}),Promise.resolve(k);if(I.hasOwnProperty(b)&&I[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:S,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(k);var $=w(y[b],o[b]);return Promise.resolve(j[c]({abort:$.abort,payload:S,instance:r,config:Cn(b,f,o),plugins:f})).then(function(U){var R=X(U)?U:{},L=T({},k,R),G=y[b];if(Ot(G,b))Et({data:G,method:c,instance:r,pluginName:b,store:s});else{var M=c+":"+b;(M.match(/:/g)||[]).length<2&&!c.match(jn)&&!c.match(xn)&&r.dispatch(T({},h?L:S,{type:M,_:{called:M,from:"submethod"}}))}return Promise.resolve(L)})})}catch(k){return Promise.reject(k)}},Promise.resolve(n))).then(function(_){if(!(c.match(Ce)||c.match(/^registerPlugin/)||c.match(xn)||c.match(jn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(p.plugins.includes(c),_._&&_._.originalAction===c)return _;var E=T({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});zn(_,e.exact.length)&&!c.match(/End$/)&&(E=T({},E,{type:_.type+"Aborted"})),s.dispatch(E)}return _})})}catch(y){return Promise.reject(y)}},Ce=/Start$/,jn=/^bootstrap/,xn=/^ready/;function Et(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(T({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Cn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function An(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function $n(t,e){var n=t.replace(Ce,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function Ot(t,e){var n=t.abort;return!!n&&(n===!0||Nn(n,e)||n&&Nn(n.plugins,e))}function zn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ie(n))return!0;var r=n.plugins;return Ue(n)&&n.length===e||Ue(r)&&r.length===e}function Ue(t){return Array.isArray(t)}function Nn(t,e){return!(!t||!Ue(t))&&t.includes(e)}function Dn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Di(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 Ui(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,p=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===P.enablePlugin&&i.dispatch({type:P.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===P.disablePlugin&&setTimeout(function(){return On(a.meta.rid,{payload:a})},0),f===P.initializeEnd){var h=e(),d=Object.keys(h),w=d.filter(function(l){return u.includes(l)}).map(function(l){return h[l]}),I=[],y=[],_=a.disabled,E=w.map(function(l){var b=l.loaded,j=l.name,k=l.config;return Tn(l,function(){return b({config:k})},1e4).then(function(S){return r[j]||(i.dispatch({type:P.pluginReadyType(j),name:j,events:Object.keys(l).filter(function($){return!It.includes($)})}),r[j]=!0),I=I.concat(j),l}).catch(function(S){if(S instanceof Error)throw new Error(S);return y=y.concat(S.name),S})});Promise.all(E).then(function(l){var b={plugins:I,failed:y,disabled:_};setTimeout(function(){d.length===E.length+_.length&&i.dispatch(T({},{type:P.ready},b))},0)})}var v=function(){if(f!==P.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Pn(i,e,t)},0),Promise.resolve(function(l,b,j,k,S){try{var $=q(b)?b():b,U=l.type,R=U.replace(Ce,"");if(l._&&l._.called)return Promise.resolve(l);var L=j.getState(),G=(J=$,(F=L.plugins)===void 0&&(F={}),(We=l.options)===void 0&&(We={}),Object.keys(J).filter(function(m){var g=We.plugins||{};return vi(g[m])?g[m]:g.all!==!1&&(!F[m]||F[m].enabled!==!1)}).map(function(m){return J[m]}));U===P.initializeStart&&l.fromEnable&&(G=Object.keys(L.plugins).filter(function(m){var g=L.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return $[m]}));var M=G.map(function(m){return m.name}),x=function(m,g,O){var C=$n(m).map(function(A){return An(A,g)});return g.reduce(function(A,z){var W=z.name,D=$n(m,W).map(function(Ke){return An(Ke,g)}),Z=D[0],N=D[1],ee=D[2];return Z.length&&(A.beforeNS[W]=Z),N.length&&(A.duringNS[W]=N),ee.length&&(A.afterNS[W]=ee),A},{before:C[0],beforeNS:{},during:C[1],duringNS:{},after:C[2],afterNS:{}})}(U,G);return Promise.resolve(_t({action:l,data:{exact:x.before,namespaced:x.beforeNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(m){function g(){var A=function(){if(U.match(Ce))return Promise.resolve(_t({action:T({},O,{type:R+"End"}),data:{exact:x.after,namespaced:x.afterNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(z){z.meta&&z.meta.hasCallback&&On(z.meta.rid,{payload:z})})}();return A&&A.then?A.then(function(){return m}):m}if(zn(m,M.length))return m;var O,C=function(){if(U!==R)return Promise.resolve(_t({action:T({},m,{type:R}),data:{exact:x.during,namespaced:x.duringNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(A){O=A});O=m}();return C&&C.then?C.then(g):g()})}catch(m){return Promise.reject(m)}var J,F,We}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(v&&v.then?v.then(p):p(v))}catch(l){return Promise.reject(l)}}}}}function Li(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 Ri=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 Zi(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=Un(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},T({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var p=Un(n.type,P.initialize),f=t()[p];return f&&p?(r[p]=T({},e[p],{initialized:!0,loaded:!!f.loaded({config:f.config})}),T({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=T({},e[n.name],{loaded:!0}),T({},e,r);switch(n.type){case P.disablePlugin:return T({},e,Ln(n.plugins,!1,e));case P.enablePlugin:return T({},e,Ln(n.plugins,!0,e));default:return e}}}function Un(t,e){return t.substring(e.length+1,t.length)}function Ln(t,e,n){return t.reduce(function(r,i){return r[i]=T({},n[i],{enabled:e}),r},n)}function Rn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Mi={last:{},history:[]};function Wi(t,e){t===void 0&&(t=Mi);var n=e.options,r=e.meta;if(e.type===P.track){var i=Rn(T({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return T({},t,{last:i,history:t.history.concat(i)})}return t}var Ki={actions:[]};function Ji(t,e){t===void 0&&(t=Ki);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),T({},t,{actions:r});case"dequeue":return[];default:return t}}var Zn=/#.*$/;function Xi(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Zn,""):"")}var Mn,Wn,Kn,Jn,Fi=function(t){if(t===void 0&&(t={}),!Y)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,p=o.hash,f=o.search,u=function(h){var d=function(){if(Y){for(var w,I=document.getElementsByTagName("link"),y=0;w=I[y];y++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+h:window.location.href.replace(Zn,"")}(f),c={title:n,url:u,path:Xi(u),hash:p,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),T({},c,t)},Hi={last:{},history:[]};function Vi(t,e){t===void 0&&(t=Hi);var n=e.options;if(e.type===P.page){var r=Rn(T({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return T({},t,{last:r,history:t.history.concat(r)})}return t}Mn=function(){if(!Y)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"}(),Wn=Y?document.referrer:null,Kn=Ei(),Jn=Oi();var Xn={initialized:!1,sessionId:Be(),app:null,version:null,debug:!1,offline:!!Y&&!navigator.onLine,os:{name:Mn},userAgent:Y?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Jn,locale:Kn,campaign:{},referrer:Wn};function Yi(t,e){t===void 0&&(t=Xn);var n=t.initialized,r=e.campaign;switch(e.type){case P.campaign:return T({},t,{campaign:r});case P.offline:return T({},t,{offline:!0});case P.online:return T({},t,{offline:!1});default:return n?t:T({},Xn,t,{initialized:!0})}}var Gi=["plugins","reducers","storage"];function Bi(t,e,n){if(Y){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function qi(t){var e=Bi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function Fn(){return ge("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 Ee[_e].analytics.push(a.action||a),o(a)}})}}}function Hn(t){return function(){return Pe(Pe.apply(null,arguments),Fn())}}function Tt(t){return t?yn(t)?t:[t]:[]}function Vn(t,e,n){t===void 0&&(t={});var r,i,o=Be();return e&&(De[o]=(r=e,i=function(a){for(var s,p=a||Array.prototype.slice.call(arguments),f=0;f<p.length;f++)if(q(p[f])){s=p[f];break}return s}(n),function(a){i&&i(a),r(a)})),T({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function Qi(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,g){if(q(g))return m.middlewares=m.middlewares.concat(g),m;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var O=g.EVENTS?Object.keys(g.EVENTS).map(function(z){return g.EVENTS[z]}):[];m.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(m.methods[g.name]=Object.keys(g.methods).reduce(function(z,W){var D;return z[W]=(D=g.methods[W],function(){for(var Z=Array.prototype.slice.call(arguments),N=new Array(D.length),ee=0;ee<Z.length;ee++)N[ee]=Z[ee];return N[N.length]=b,D.apply({instance:b},N)}),z},{}),delete g.methods);var C=Object.keys(g).concat(O),A=new Set(m.events.concat(C));if(m.events=Array.from(A),m.pluginsArray=m.pluginsArray.concat(g),m.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return m.plugins[g.name]=g,m.plugins[g.name].loaded||(m.plugins[g.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:me,setItem:ge,removeItem:Oe},o=function(m){return function(g,O,C){return O.getState("user")[g]||(C&&X(C)&&C[g]?C[g]:En(m)[g]||me(St(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!It.includes(m)}).sort(),p=new Set(s.concat(et).filter(function(m){return!It.includes(m)})),f=Array.from(p).sort(),u=function(){return a},c=new Ri,h=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},y=Ti(),_=En(i),E=T({},_,n,y.an_uid?{userId:y.an_uid}:{},y.an_aid?{anonymousId:y.an_aid}:{});E.anonymousId||(E.anonymousId=Be());var v=T({enable:function(m,g){return new Promise(function(O){x.dispatch({type:P.enablePlugin,plugins:Tt(m),_:{originalAction:P.enablePlugin}},O,[g])})},disable:function(m,g){return new Promise(function(O){x.dispatch({type:P.disablePlugin,plugins:Tt(m),_:{originalAction:P.disablePlugin}},O,[g])})}},r.methods),l=!1,b={identify:function(m,g,O,C){try{var A=ie(m)?m:null,z=X(m)?m:g,W=O||{},D=b.user();ge(St(se),A);var Z=A||z.userId||o(se,b,z);return Promise.resolve(new Promise(function(N){x.dispatch(T({type:P.identifyStart,userId:Z,traits:z||{},options:W,anonymousId:D.anonymousId},D.id&&D.id!==A&&{previousId:D.id}),N,[g,O,C])}))}catch(N){return Promise.reject(N)}},track:function(m,g,O,C){try{var A=X(m)?m.event:m;if(!A||!ie(A))throw new Error("EventMissing");var z=X(m)?m:g||{},W=X(O)?O:{};return Promise.resolve(new Promise(function(D){x.dispatch({type:P.trackStart,event:A,properties:z,options:W,userId:o(se,b,g),anonymousId:o(xe,b,g)},D,[g,O,C])}))}catch(D){return Promise.reject(D)}},page:function(m,g,O){try{var C=X(m)?m:{},A=X(g)?g:{};return Promise.resolve(new Promise(function(z){x.dispatch({type:P.pageStart,properties:Fi(C),options:A,userId:o(se,b,C),anonymousId:o(xe,b,C)},z,[m,g,O])}))}catch(z){return Promise.reject(z)}},user:function(m){if(m===se||m==="id")return o(se,b);if(m===xe||m==="anonId")return o(xe,b);var g=b.getState("user");return m?dn(g,m):g},reset:function(m){return new Promise(function(g){x.dispatch({type:P.resetStart},g,m)})},ready:function(m){return l&&m({plugins:v,instance:b}),b.on(P.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!q(g))return!1;if(m===P.bootstrap)throw new Error(".on disabled for "+m);var O=/Start$|Start:/;if(m==="*"){var C=function(D){return function(Z){return function(N){return N.type.match(O)&&g({payload:N,instance:b,plugins:a}),Z(N)}}},A=function(D){return function(Z){return function(N){return N.type.match(O)||g({payload:N,instance:b,plugins:a}),Z(N)}}};return h(C,tt),h(A,nt),function(){d(C,tt),d(A,nt)}}var z=m.match(O)?tt:nt,W=function(D){return function(Z){return function(N){return N.type===m&&g({payload:N,instance:b,plugins:a,abort:I}),Z(N)}}};return h(W,z),function(){return d(W,z)}},once:function(m,g){if(!m||!q(g))return!1;if(m===P.bootstrap)throw new Error(".once disabled for "+m);var O=b.on(m,function(C){g({payload:C.payload,instance:b,plugins:a,abort:I}),O()});return O},getState:function(m){var g=x.getState();return m?dn(g,m):Object.assign({},g)},dispatch:function(m){var g=ie(m)?{type:m}:m;if(et.includes(g.type))throw new Error("reserved action "+g.type);var O=T({},g,{_:T({originalAction:g.type},m._||{})});x.dispatch(O)},enablePlugin:v.enable,disablePlugin:v.disable,plugins:v,storage:{getItem:i.getItem,setItem:function(m,g,O){x.dispatch({type:P.setItemStart,key:m,value:g,options:O})},removeItem:function(m,g){x.dispatch({type:P.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){b.storage.setItem(ae,m,g)},events:{core:et,plugins:s}},j=r.middlewares.concat([function(m){return function(g){return function(O){return O.meta||(O.meta=Vn()),g(O)}}},w(tt),Ui(b,u,{all:f,plugins:s}),Li(i),Ai(b),zi(b),w(nt)]),k={context:Yi,user:$i(i),page:Vi,track:Wi,plugins:Zi(u),queue:Ji},S=Pe,$=Pe;if(Y&&t.debug){var U=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;U&&(S=U({trace:!0,traceLimit:25})),$=function(){return arguments.length===0?Fn():X(typeof arguments[0])?Hn():Hn().apply(null,arguments)}}var R,L=function(m){return Object.keys(m).reduce(function(g,O){return Gi.includes(O)||(g[O]=m[O]),g},{})}(t),G=r.pluginsArray.reduce(function(m,g){var O=g.name,C=g.config,A=g.loaded,z=r.pluginEnabled[O];return m[O]={enabled:z,initialized:!!z&&!g.initialize,loaded:!!A({config:C}),config:C},m},{}),M={context:L,user:E,plugins:G},x=kn(function(m){for(var g=Object.keys(m),O={},C=0;C<g.length;C++){var A=g[C];typeof m[A]===oe&&(O[A]=m[A])}var z,W=Object.keys(O);try{(function(D){Object.keys(D).forEach(function(Z){var N=D[Z];if(typeof N(void 0,{type:"@@redux/INIT"})===ne||typeof N(void 0,{type:ji})===ne)throw new Error("reducer "+Z+" "+ne)})})(O)}catch(D){z=D}return function(D,Z){if(D===void 0&&(D={}),z)throw z;for(var N=!1,ee={},Ke=0;Ke<W.length;Ke++){var ct=W[Ke],fr=D[ct],Ut=(0,O[ct])(fr,Z);if(typeof Ut===ne){var Co=xi(ct,Z);throw new Error(Co)}ee[ct]=Ut,N=N||Ut!==fr}return N?ee:D}}(T({},k,e)),M,$(S(Ci.apply(void 0,j))));x.dispatch=(R=x.dispatch,function(m,g,O){var C=T({},m,{meta:Vn(m.meta,g,Tt(O))});return R.apply(null,[C])});var J=Object.keys(a);x.dispatch({type:P.bootstrap,plugins:J,config:L,params:y,user:E,initialUser:n,persistedUser:_});var F=J.filter(function(m){return r.pluginEnabled[m]}),We=J.filter(function(m){return!r.pluginEnabled[m]});return x.dispatch({type:P.registerPlugins,plugins:J,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var O=m.bootstrap,C=m.config,A=m.name;O&&q(O)&&O({instance:b,config:C,payload:m}),x.dispatch({type:P.registerPluginType(A),name:A,enabled:r.pluginEnabled[A],plugin:m}),r.pluginsArray.length===g+1&&x.dispatch({type:P.initializeStart,plugins:F,disabled:We})}),qi(function(m){x.dispatch({type:m?P.offline:P.online})}),function(m,g,O){setInterval(function(){return Pn(m,g,O)},3e3)}(x,u,b),b}var tt="before",nt="after",Le="cookie",ve=Bn(),Yn=rt,eo=rt;function Gn(t){return ve?rt(t,"",-1):Oe(t)}function Bn(){if(ve!==void 0)return ve;var t="cookiecookie";try{rt(t,t),ve=document.cookie.indexOf(t)!==-1,Gn(t)}catch{ve=!1}return ve}function rt(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ve===!1&&(a?ge(t,e):me(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",to=kt.bind(null,"localStorage");Te("localStorage","getItem",me),Te("localStorage","setItem",ge),Te("localStorage","removeItem",Oe);var Ze="sessionStorage",no=kt.bind(null,"sessionStorage");Te("sessionStorage","getItem",me),Te("sessionStorage","setItem",ge),Te("sessionStorage","removeItem",Oe);function Ae(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 ro=to(),io=no(),oo=Bn();function qn(t,e){if(t){var n=Pt(e),r=!At(n),i=jt(n)?Ae(localStorage.getItem(t)):void 0;if(r&&!Se(i))return i;var o=xt(n)?Ae(Yn(t)):void 0;if(r&&o)return o;var a=Ct(n)?Ae(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=me(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function ao(t,e,n){if(t&&!Se(e)){var r={},i=Pt(n),o=JSON.stringify(e),a=!At(i);return jt(i)&&(r[Re]=ot(Re,e,Ae(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Re]:xt(i)&&(r[Le]=ot(Le,e,Ae(Yn(t))),eo(t,o),a)?r[Le]:Ct(i)&&(r[Ze]=ot(Ze,e,Ae(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ze]:(r[Ne]=ot(Ne,e,me(t)),ge(t,e),a?r[Ne]:r)}}function so(t,e){if(t){var n=Pt(e),r=qn(t,pn),i={};return!Se(r.localStorage)&&jt(n)&&(localStorage.removeItem(t),i[Re]=r.localStorage),!Se(r.cookie)&&xt(n)&&(Gn(t),i[Le]=r.cookie),!Se(r.sessionStorage)&&Ct(n)&&(sessionStorage.removeItem(t),i[Ze]=r.sessionStorage),!Se(r.global)&&it(n,Ne)&&(Oe(t),i[Ne]=r.global),i}}function Pt(t){return t?ie(t)?t:t.storage:fn}function jt(t){return ro&&it(t,Re)}function xt(t){return oo&&it(t,Le)}function Ct(t){return io&&it(t,Ze)}function At(t){return t===pn||t==="all"}function it(t,e){return t===fn||t===e||At(t)}function ot(t,e,n){return{location:t,current:e,previous:n}}var co={setItem:ao,getItem:qn,removeItem:so};function uo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qn(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 er(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Qn(Object(n),!0).forEach(function(r){uo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Qn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:co};return Qi(er(er({},e),t))}function ho(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(p){return r=i.push(p),r>=o&&a(),r},size:function(){return i.length},end:function(p){p&&a(),clearInterval(n)}}}function fo(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(...p){var c;const f=((c=p[2])==null?void 0:c.toString())||"",u=mo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,p)}})}function po(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function mo(t){return["#","?"].forEach(e=>t=po(t,e)),t}function go(){fo(()=>{we.page()})}var tr="EventListener";function yo(t){return function(e,n,r,i){var o=r||pi,a=i||!1;if(!Y)return o;var s=at(n),p=at(e,!0);if(!p.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var h=c?"add"+tr:"remove"+tr,d=0;d<p.length;d++){var w=p[d];f[d]=c?a&&a.once?vo(o):o:f[d]||o;for(var I=0;I<s.length;I++)w[h]?w["on"+s[I]]=c?f[d]:null:w[h](s[I],f[d],a)}return u.bind(null,!c)}(t)}}function at(t,e){if(ie(t))return e?at(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=_i(t);return e?o.map(function(a){return ie(a)?at(a,!0):a}).flat():o}function vo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var $t=yo("Event");function nr(t,e){return Y&&q(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),q(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}nr.bind(null,"onerror"),nr.bind(null,"onload");var rr=typeof window>"u",ir="hidden";function wo(t){if(rr)return!1;var e=bo(),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 bo(){var t=["webkit","moz","ms","o"];return rr||ir in document?ir:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var ko=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Io(t,e){e===void 0&&(e={});var n=function(a,s){var p=this,f=!1;return function(u){f||(a.call(p,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=wo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(ko.map(function(s){return $t(document,s,n)})).concat($t(window,"load",n)).concat($t(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function So(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,p=t.throttle,f=p===void 0?2e3:p,u=!1,c=!1,h=new Date,d=function(){return clearTimeout(e)};function w(y){d(),o&&!u&&o(Me(h),y),i&&u&&(u=!1,i(Me(n),y),h=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Me(h),y))},s)}var I=Io(w,{throttle:f});return{disable:function(){c=!0,u=!1,d();var y=I();return function(){return c=!1,h=new Date,w({type:"load"}),y()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Me(h,c),idle:u?Me(n,c):0}}}}function Me(t,e){return e?0:Math.round((new Date-t)/1e3)}const or=5e3;class _o{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),So({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:or})}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*or:Date.now(),this.isInViewport&&this.trackAwake(e,n)}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 ar="sesamy_session_id";function Eo(){let t=sessionStorage.getItem(ar);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(ar,t)),t}let sr=!1,zt,cr,st;function Oo({clientId:t,enabled:e=!0,endpoint:n=Xr}){if(zt=t,cr=e,st=n,!cr)return;go();const r=new _o({element:document.body,viewCallback:()=>{we.page()},activeDurationCallback:(i,o,a)=>{we.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{we.track("idleDuration",{duration:i,durationStart:a,flushing:o})}});Po(document.body,()=>{r.flush()}),jo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(he.AUTHENTICATED,async i=>{const o=i;await we.identify(o.detail.sub)}),window.addEventListener(he.LOGOUT,async()=>{await we.track("logout",{}),Nt.flush(),await we.reset()})}function ur(t){return JSON.stringify(t.map(e=>({...e,clientId:zt,requestId:Math.random().toString(36).slice(2,9),sessionId:Eo(),timestamp:new Date().toISOString(),version:bt,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:ln,userAgent:navigator.userAgent,clientId:zt}})))}const Nt=ho(async t=>{if(t.length>0){const e=ur(t);sr?navigator.sendBeacon(st,e):(await fetch(st,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Dt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(st,ur([n]))}else Nt.push(t)}const we=lo({app:ln,version:bt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Dt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Dt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Dt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function To(){return sr=!0,Nt.flush()}const lr=new Map;function Po(t,e){lr.set(t,e)}window.addEventListener("beforeunload",()=>{lr.forEach((t,e)=>{t.bind(e)()}),To()});const dr=new Map;function jo(t,e){dr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&dr.forEach((t,e)=>{t.bind(e)()})});function xo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e&&n){tn(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 hr(t){Oo({clientId:t.clientId,...t.analytics}),await Fr({clientId:t.clientId,...t.auth});const e=hi(t.api||{});return B(he.READY,{}),xo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);hr(e)}catch(e){console.error("Failed to parse config",e)}}return te.init=hr,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"}),te}({});
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",!qt(n))throw new Error(`Invalid cache location "${n}"`);r=qt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?be:Ur,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:Lr;var o;this.scope=Xe("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new $r(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Mt,this.cacheManager=new Ar(r,r.allKeys?void 0:new Mr(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 Zr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Zt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${ft(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Nr({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(ht()),o=Jt(ht()),a=ht(),s=(u=>{const c=new Uint8Array(u);return(h=>{const d={"+":"-","/":"_","=":""};return h.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Je().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),p=((u,c,h,d,w,I,y,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),h),{scope:Xe(c,h.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:y||u.authorizationParams.redirect_uri,code_challenge:I,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(p);return{nonce:o,code_verifier:a,scope:p.scope,audience:p.audience||"default",redirect_uri:p.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const p=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${p},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((p,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(h),window.removeEventListener("message",u,!1),f(new _r(s.popup)))},1e3),h=setTimeout(()=>{clearInterval(c),f(new Sr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(h),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(H.fromPayload(d.data.response));p(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 H("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=K(r,["openUrl","fragment","appState"]),p=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=K(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),p&&{organization:p}));const h=o?`${u}#${o}`:u;i?await i(h):window.location.assign(h)}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 h=new URLSearchParams(c);return{state:h.get("state"),code:h.get("code")||void 0,error:h.get("error")||void 0,error_description:h.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new H("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Ir(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new H("state_mismatch","Invalid state");const p=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization:p}),{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:Xe(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=mt[a];return s||(s=o().finally(()=>{delete mt[a],s=null}),mt[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})(()=>gt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new dt;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:p}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:p})}finally{await gt.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:Xe(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},kr),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=K(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${ft(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Qt(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:p,scope:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new H("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,h=await((w,I,y=60)=>new Promise((_,E)=>{const v=window.document.createElement("iframe");v.setAttribute("width","0"),v.setAttribute("height","0"),v.style.display="none";const l=()=>{window.document.body.contains(v)&&(window.document.body.removeChild(v),window.removeEventListener("message",b,!1))};let b;const j=setTimeout(()=>{E(new dt),l()},1e3*y);b=function(k){if(k.origin!=I||!k.data||k.data.type!=="authorization_response")return;const S=k.source;S&&S.close(),k.data.response.error?E(H.fromPayload(k.data.response)):_(k.data.response),clearTimeout(j),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(v),v.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==h.state)throw new H("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:h.code,grant_type:"authorization_code",redirect_uri:p,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new 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 Wt(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 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,p=await this._getIdTokenFromCache();return p&&Object.assign(Object.assign({id_token:p.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await xr(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 Jr(t){const e=new Kr(t);return await e.checkSession(),e}const en="sesamy.com",Xr="https://logs.sesamy.com/events";var he=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.SOFT_PAYWALL="sesamyJsSoftPaywall",t))(he||{});let V;const yt="sesamyAccessToken",vt="sesamyExpiresAt";function wt(){const t=localStorage.getItem(vt);if(!(!t||parseInt(t,10)<new Date().getTime()))return localStorage.getItem(yt)}async function Fr(t){if(t.enabled!==!1&&(V=await Jr({domain:t.endpoint||`token.${en}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await V.handleRedirectCallback();const e=await V.getUser();B(he.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function Hr(){if(wt())return!0;if(!V)throw new Error("Auth0 client not initialized");return V.isAuthenticated()}async function Vr(){if(wt())return{sub:"local",name:"Local User"};if(!V)throw new Error("Auth0 client not initialized");return V.getUser()}function Yr(){if(!V)throw new Error("Auth0 client not initialized");return V.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function Gr(t=!0){const e=wt();if(e)return e;try{if(!V)throw new Error("Auth0 client not initialized");return await V.getTokenSilently()}catch(n){if(t)throw n;return null}}async function Br(){if(localStorage.removeItem(yt),localStorage.removeItem(vt),!V)throw new Error("Auth0 client not initialized");return B(he.LOGOUT,{}),V.logout({logoutParams:{returnTo:window.location.href}})}function qr(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 tn(t,e){localStorage.setItem(yt,t),localStorage.setItem(vt,JSON.stringify(e*1e3+new Date().getTime()));const n=qr(t);B(he.AUTHENTICATED,n)}const Qr=(t,e)=>e.skipDedupe||e.method!=="GET",ei=(t,e)=>e.method+"@"+t,ti=t=>t.clone(),nn=({skip:t=Qr,key:e=ei,resolver:n=ti}={})=>{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((p,f)=>{r.get(s).push([p,f])});try{return i(o,a).then(p=>(r.get(s).forEach(([f])=>f(n(p))),r.delete(s),p)).catch(p=>{throw r.get(s).forEach(([f,u])=>u(p)),r.delete(s),p})}catch(p){return r.delete(s),Promise.reject(p)}}},ni=(t,e)=>t*e,ri=t=>t&&t.ok,rn=({delayTimer:t=500,delayRamp:e=ni,maxAttempts:n=10,until:r=ri,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>p=>(f,u)=>{let c=0;if(s&&s(f,u))return p(f,u);const h=(d,w)=>Promise.resolve(r(d,w)).then(I=>I?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(y=>{const _=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:f,options:u})).then((E={})=>{var v,l;y(p((v=E&&E.url)!==null&&v!==void 0?v:f,(l=E&&E.options)!==null&&l!==void 0?l:u))}):y(p(f,u))},_)}).then(h).catch(y=>{if(!o)throw y;return h(null,y)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return p(f,u).then(h).catch(d=>{if(!o)throw d;return h(null,d)})},ii="application/json",on="Content-Type",ke=Symbol(),an=Symbol();function sn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===on.toLowerCase()))===null||e===void 0?void 0:e[1]}function cn(t){return/^application\/.*json.*/.test(t)}const fe=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]=fe(a,o,n):r[i]=o,r},{...t})},Ie={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 oi(t,e=!1){Ie.options=e?t:fe(Ie.options,t)}function ai(t,e=!1){Ie.polyfills=e?t:fe(Ie.polyfills,t)}function si(t){Ie.errorType=t}const ci=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class un extends Error{}const ui=t=>{const e=Object.create(null);t=t._addons.reduce((v,l)=>l.beforeRequest&&l.beforeRequest(v,t._options,e)||v,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:p}=t,f=new Map(o),u=fe(i.options,r);let c=n;const h=ci(s)((v,l)=>(c=v,i.polyfill("fetch")(v,l)))(n,u),d=new Error,w=h.catch(v=>{throw{[ke]:v}}).then(v=>{if(!v.ok){const l=new un;if(l.cause=d,l.stack=l.stack+`
5
+ CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(b=>{var j;if(l.message=b,i.errorType==="json"||((j=v.headers.get("Content-Type"))===null||j===void 0?void 0:j.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=v.status,l})}return v}),I=v=>v.catch(l=>{const b=l.hasOwnProperty(ke),j=b?l[ke]:l,k=(j==null?void 0:j.status)&&f.get(j.status)||f.get(j==null?void 0:j.name)||b&&f.has(ke)&&f.get(ke);if(k)return k(j,t);const S=f.get(an);if(S)return S(j,t);throw j}),y=v=>l=>I(v?w.then(b=>b&&b[v]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),_={_wretchReq:t,_fetchReq:h,_sharedState:e,res:y(null),json:y("json"),blob:y("blob"),formData:y("formData"),arrayBuffer:y("arrayBuffer"),text:y("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(ke,v)}},E=p.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),_);return a.reduce((v,l)=>l(v,t),E)},li={_url:"",_options:{},_config:Ie,_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:fe(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:fe(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:fe(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[on]: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(an,t)},resolve(t,e=!1){return{...this,_resolvers:e?[t]:[...this._resolvers,t]}},defer(t,e=!1){return{...this,_deferred:e?[t]:[...this._deferred,t]}},middlewares(t,e=!1){return{...this,_middlewares:e?t:[...this._middlewares,...t]}},fetch(t=this._options.method,e="",n=null){let r=this.url(e).options({method:t});const i=sn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||cn(i));return r=n?o?r.json(n,i):r.body(n):r,ui(r._deferred.reduce((a,s)=>s(a,a._url,a._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=sn(this._options.headers);return this.content(e||cn(n)&&n||ii).body(JSON.stringify(t))}};function re(t="",e={}){return{...li,_url:t,_options:e}}re.default=re,re.options=oi,re.errorType=si,re.polyfills=ai,re.WretchError=un;function di(t){const e=t.endpoint||`https://api2.${en}`,n=(k=!0)=>S=>async($,D)=>{let R=null;if(R=await Gr(k),!R){if(k)throw new Error("No access token available");return S($,D)}const L={...D,headers:{...D.headers,...R?{Authorization:`Bearer ${R}`}:{}}};return S($,L)},r=k=>(S,$)=>{const D=localStorage.getItem("__anon_id"),R=btoa(`${D}:`),L={...$,headers:{...$.headers,Authorization:`Basic ${R}`}};return k(S,L)},i=re(e).headers({"Content-Type":"application/json"}).middlewares([n(),nn(),rn({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]),o=re(e).headers({"Content-Type":"application/json"}).middlewares([n(!1),r,nn(),rn({delayTimer:1e3,delayRamp:(k,S)=>k*S,maxAttempts:3,until:k=>!!(k&&(k.ok||k.status>=400&&k.status<500)),retryOnNetworkError:!1})]);async function a(){return i.get("/entitlements").json()}async function s(k){const S=await i.get("/entitlements").json();return S==null?void 0:S.find($=>$.id===k)}async function p(){return i.get("/contracts").json()}async function f(k){const S=await i.get("/contracts").json();return S==null?void 0:S.find($=>$.id===k)}async function u(){return i.get("/bills").json()}async function c(k){const S=await i.get("/bills").json();return S==null?void 0:S.find($=>$.id===k)}async function h(k,S){return await i.url(`/user-metadata/${k}`).put(S).json()}async function d(k){return(await i.url(`/user-metadata/${k}`).delete().res()).ok}async function w(k){return(await i.url(`/user-metadata/${k}`).get().json())[k]}async function I(){return i.url("/user-metadata").get().json()}async function y(){return await i.url("/tags").get().json()}async function _(k){return(await i.url(`/tags/${k}`).delete().res()).ok}async function E(k){return(await i.url("/tags").post(k).res()).ok}async function v(k){return(await o.url("/tallies").get().json())[k]}async function l(){return await o.url("/tallies").get().json()}async function b(k){return(await o.url(`/tallies/${k}`).delete().res()).ok}async function j(k,S){return await o.url(`/tallies/${k}/push`).post(S).json()}return{getEntitlements:a,getEntitlement:s,getContracts:p,getContract:f,getBills:u,getBill:c,setUserMetadata:h,deleteUserMetadata:d,getUserMetadata:w,listUserMetadata:I,getTags:y,deleteTag:_,setTag:E,getTally:v,getTallies:l,deleteTally:b,pushTally:j}}const ln="@sesamy/sesamy-js",bt="1.3.2";function hi(t){const{getEntitlement:e,getEntitlements:n,getContract:r,getContracts:i,getBill:o,getBills:a,getTags:s,deleteTag:p,setTag:f,getUserMetadata:u,listUserMetadata:c,setUserMetadata:h,deleteUserMetadata:d,getTally:w,getTallies:I,pushTally:y,deleteTally:_}=di(t),E={auth:{getUser:Vr,isAuthenticated:Hr,loginWithRedirect:Yr,logout:Br,setToken:tn},tags:{list:s,set:f,delete:p},entitlements:{get:e,list:n},contracts:{get:r,list:i},bills:{get:o,list:a},userMetadata:{get:u,list:c,set:h,delete:d},tallies:{get:w,list:I,push:y,delete:_},getVersion:fi};return t.namespace&&(window[t.namespace]=E),E}function fi(){return bt}function dn(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",hn="object",pi=function(){},fn="any",pn="*",pe="__",He=typeof process<"u"?process:{};He.env&&He.env.NODE_ENV;var Y=typeof document<"u";He.versions!=null&&He.versions.node!=null,typeof Deno<"u"&&Deno.core,Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function mn(t,e){return e.charAt(0)[t]()+e.slice(1)}var mi=mn.bind(null,"toUpperCase"),gi=mn.bind(null,"toLowerCase");function yi(t){return gn(t)?mi("null"):typeof t=="object"?ki(t):Object.prototype.toString.call(t).slice(8,-1)}function Ve(t,e){e===void 0&&(e=!0);var n=yi(t);return e?gi(n):n}function ze(t,e){return typeof e===t}var q=ze.bind(null,"function"),ie=ze.bind(null,"string"),Se=ze.bind(null,"undefined"),vi=ze.bind(null,"boolean");ze.bind(null,"symbol");function gn(t){return t===null}function wi(t){return Ve(t)==="number"&&!isNaN(t)}function yn(t){return Ve(t)==="array"}function X(t){if(!bi(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function bi(t){return t&&(typeof t=="object"||t!==null)}function ki(t){return q(t.constructor)?t.constructor.name:null}function Ii(t){return t instanceof Error||ie(t.message)&&t.constructor&&wi(t.constructor.stackTraceLimit)}function vn(t,e){if(typeof e!="object"||gn(e))return!1;if(e instanceof t)return!0;var n=Ve(new t(""));if(Ii(e))for(;e;){if(Ve(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}vn.bind(null,TypeError),vn.bind(null,SyntaxError);function Ye(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Si(t,e):n}function Si(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Ge(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Ge(Ye,"form"),Ge(Ye,"button"),Ge(Ye,"input"),Ge(Ye,"select");function _i(t){return t?yn(t)?t:[t]:[]}function wn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ei(){if(Y){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Oi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ti(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=wn(n[1]),a=wn(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 p=s.split("[");p.length>1&&(Pi(r,p.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return Y&&window.location.search.substring(1)}(t))}function Pi(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 Be(){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 Ne="global",_e=pe+"global"+pe,Ee=typeof self===hn&&self.self===self&&self||typeof global===hn&&global.global===global&&global||void 0;function me(t){return Ee[_e][t]}function ge(t,e){return Ee[_e][t]=e}function Oe(t){delete Ee[_e][t]}function Te(t,e,n){var r;try{if(kt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Ee[_e]||(Ee[_e]={});var qe={};function kt(t){if(typeof qe[t]!==Fe)return qe[t];try{var e=window[t];e.setItem(Fe,Fe),e.removeItem(Fe)}catch{return qe[t]=!1}return qe[t]=!0}function T(){return T=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},T.apply(this,arguments)}var oe="function",ne="undefined",ji="@@redux/"+Math.random().toString(36),bn=function(){return typeof Symbol===oe&&Symbol.observable||"@@observable"}(),Qe=" != "+oe;function kn(t,e,n){var r;if(typeof e===oe&&typeof n===ne&&(n=e,e=void 0),typeof n!==ne){if(typeof n!==oe)throw new Error("enhancer"+Qe);return n(kn)(t,e)}if(typeof t!==oe)throw new Error("reducer"+Qe);var i=t,o=e,a=[],s=a,p=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==oe)throw new Error("Listener"+Qe);var w=!0;return f(),s.push(d),function(){if(w){w=!1,f();var I=s.indexOf(d);s.splice(I,1)}}}function h(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===ne)throw new Error("ActType "+ne);if(p)throw new Error("Dispatch in reducer");try{p=!0,o=i(o,d)}finally{p=!1}for(var w=a=s,I=0;I<w.length;I++)(0,w[I])();return d}return h({type:"@@redux/INIT"}),(r={dispatch:h,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==oe)throw new Error("next reducer"+Qe);i=d,h({type:"@@redux/INIT"})}})[bn]=function(){var d,w=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function y(){I.next&&I.next(u())}return y(),{unsubscribe:w(y)}}})[bn]=function(){return this},d},r}function xi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ne}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 Ci(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,p={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(p)}),T({},a,{dispatch:s=Pe.apply(void 0,o)(a.dispatch)})}}}var ae=pe+"anon_id",ye=pe+"user_id",je=pe+"user_traits",se="userId",xe="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"],It=["name","EVENTS","config","loaded"],P=et.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),In=/^utm_/,Sn=/^an_prop_/,_n=/^an_trait_/;function Ai(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,p=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ae,a.anonymousId),f||e(ye,a.userId),p.traits&&e(je,T({},f&&s.traits?s.traits:{},p.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,h=o.an_event,d=u.reduce(function(w,I){if(I.match(In)||I.match(/^(d|g)clid/)){var y=I.replace(In,"");w.campaign[y==="campaign"?"name":y]=o[I]}return I.match(Sn)&&(w.props[I.replace(Sn,"")]=o[I]),I.match(_n)&&(w.traits[I.replace(_n,"")]=o[I]),w},{campaign:{},props:{},traits:{}});n.dispatch(T({type:P.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:P.campaign,campaign:d.campaign})}}return r(i)}}}}function $i(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===P.setItemEnd){if(n.key===ae)return T({},e,{anonymousId:n.value});if(n.key===ye)return T({},e,{userId:n.value})}switch(n.type){case P.identify:return Object.assign({},e,{userId:n.userId,traits:T({},e.traits,n.traits)});case P.reset:return[ye,ae,je].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function En(t){return{userId:t.getItem(ye),anonymousId:t.getItem(ae),traits:t.getItem(je)}}var St=function(t){return pe+"TEMP"+pe+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 p=s.userId,f=s.traits,u=s.options;if(s.type===P.reset&&([ye,je,ae].forEach(function(d){r(d)}),[se,xe,"traits"].forEach(function(d){Oe(St(d))})),s.type===P.identify){i(ae)||n(ae,Be());var c=i(ye),h=i(je)||{};c&&c!==p&&o.dispatch({type:P.userIdChanged,old:{userId:c,traits:h},new:{userId:p,traits:f},options:u}),p&&n(ye,p),f&&n(je,T({},h,f))}return a(s)}}}}var De={};function On(t,e){De[t]&&q(De[t])&&(De[t](e),delete De[t])}function Tn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(T({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return Tn(t,e,n-10).then(r,i)})})}function Ni(t){return{abort:t}}function Pn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,p=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,h,d){return a[h.plugin].loaded?(c.process.push(h),c.processIndex.push(d)):(c.requeue.push(h),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var h=s.actions[c],d=h.plugin,w=h.payload.type,I=i[d][w];if(I&&q(I)){var y,_=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[se,xe].reduce(function(j,k){return l.hasOwnProperty(k)&&b[k]&&b[k]!==l[k]&&(j[k]=b[k]),j},l)}(h.payload,p),E=r[_.meta.rid];if(!E&&(y=I({payload:_,config:a[d].config,instance:n,abort:Ni}))&&X(y)&&y.abort)return void(r[_.meta.rid]=!0);if(!E){var v=w+":"+d;t.dispatch(T({},_,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,h){return!~f.processIndex.indexOf(h)});s.actions=u}}}var _t=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,p=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,h=c.match(Ce),d=e.exact.map(function(y){return y.pluginName});h&&(d=a.during.map(function(y){return y.pluginName}));var w=function(y,_){return function(E,v,l){var b=v.config,j=v.name,k=j+"."+E.type;l&&(k=l.event);var S=E.type.match(Ce)?function($,D,R,L,G){return function(M,x){var J=L?L.name:$,F=x&&Ue(x)?x:R;if(L&&(!(F=x&&Ue(x)?x:[$]).includes($)||F.length!==1))throw new Error("Method "+D+" can only abort "+$+" plugin. "+JSON.stringify(F)+" input valid");return T({},G,{abort:{reason:M,plugins:F,caller:D,_:J}})}}(j,k,_,l,E):function($,D){return function(){throw new Error($.type+" action not cancellable. Remove abort in "+D)}}(E,k);return{payload:Di(E),instance:y,config:b||{},abort:S}}}(r,d),I=e.exact.reduce(function(y,_){var E=_.pluginName,v=_.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[E].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),y[""+E]=l,y},{});return Promise.resolve(e.exact.reduce(function(y,_,E){try{var v=_.pluginName;return Promise.resolve(y).then(function(l){function b(){return Promise.resolve(l)}var j=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(k,S,$){try{return Promise.resolve(k).then(function(D){return S.method&&q(S.method)?(function(M,x){var J=Dn(M);if(J&&J.name===x){var F=Dn(J.method);throw new Error([x+" plugin is calling method "+M,"Plugins cant call self","Use "+J.method+" "+(F?"or "+F.method:"")+" in "+x+" plugin insteadof "+M].join(`
6
+ `))}}(S.methodName,S.pluginName),Promise.resolve(S.method({payload:D,instance:r,abort:(R=D,L=v,G=S.pluginName,function(M,x){return T({},R,{abort:{reason:M,plugins:x||[L],caller:c,from:G||L}})}),config:Cn(S.pluginName,f,o),plugins:f})).then(function(M){var x=X(M)?M:{};return Promise.resolve(T({},D,x))})):D;var R,L,G})}catch(D){return Promise.reject(D)}},Promise.resolve(n))).then(function(k){l[v]=k});l[v]=n}();return j&&j.then?j.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(y){return Promise.resolve(e.exact.reduce(function(_,E,v){try{var l=e.exact.length===v+1,b=E.pluginName,j=o[b];return Promise.resolve(_).then(function(k){var S=y[b]?y[b]:{};if(h&&(S=k),Ot(S,b))return Et({data:S,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(k);if(Ot(k,b))return l&&Et({data:k,method:c,instance:r,store:s}),Promise.resolve(k);if(I.hasOwnProperty(b)&&I[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:S,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(k);var $=w(y[b],o[b]);return Promise.resolve(j[c]({abort:$.abort,payload:S,instance:r,config:Cn(b,f,o),plugins:f})).then(function(D){var R=X(D)?D:{},L=T({},k,R),G=y[b];if(Ot(G,b))Et({data:G,method:c,instance:r,pluginName:b,store:s});else{var M=c+":"+b;(M.match(/:/g)||[]).length<2&&!c.match(jn)&&!c.match(xn)&&r.dispatch(T({},h?L:S,{type:M,_:{called:M,from:"submethod"}}))}return Promise.resolve(L)})})}catch(k){return Promise.reject(k)}},Promise.resolve(n))).then(function(_){if(!(c.match(Ce)||c.match(/^registerPlugin/)||c.match(xn)||c.match(jn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(p.plugins.includes(c),_._&&_._.originalAction===c)return _;var E=T({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});zn(_,e.exact.length)&&!c.match(/End$/)&&(E=T({},E,{type:_.type+"Aborted"})),s.dispatch(E)}return _})})}catch(y){return Promise.reject(y)}},Ce=/Start$/,jn=/^bootstrap/,xn=/^ready/;function Et(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(T({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Cn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function An(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function $n(t,e){var n=t.replace(Ce,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function Ot(t,e){var n=t.abort;return!!n&&(n===!0||Nn(n,e)||n&&Nn(n.plugins,e))}function zn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ie(n))return!0;var r=n.plugins;return Ue(n)&&n.length===e||Ue(r)&&r.length===e}function Ue(t){return Array.isArray(t)}function Nn(t,e){return!(!t||!Ue(t))&&t.includes(e)}function Dn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Di(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 Ui(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,p=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===P.enablePlugin&&i.dispatch({type:P.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===P.disablePlugin&&setTimeout(function(){return On(a.meta.rid,{payload:a})},0),f===P.initializeEnd){var h=e(),d=Object.keys(h),w=d.filter(function(l){return u.includes(l)}).map(function(l){return h[l]}),I=[],y=[],_=a.disabled,E=w.map(function(l){var b=l.loaded,j=l.name,k=l.config;return Tn(l,function(){return b({config:k})},1e4).then(function(S){return r[j]||(i.dispatch({type:P.pluginReadyType(j),name:j,events:Object.keys(l).filter(function($){return!It.includes($)})}),r[j]=!0),I=I.concat(j),l}).catch(function(S){if(S instanceof Error)throw new Error(S);return y=y.concat(S.name),S})});Promise.all(E).then(function(l){var b={plugins:I,failed:y,disabled:_};setTimeout(function(){d.length===E.length+_.length&&i.dispatch(T({},{type:P.ready},b))},0)})}var v=function(){if(f!==P.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Pn(i,e,t)},0),Promise.resolve(function(l,b,j,k,S){try{var $=q(b)?b():b,D=l.type,R=D.replace(Ce,"");if(l._&&l._.called)return Promise.resolve(l);var L=j.getState(),G=(J=$,(F=L.plugins)===void 0&&(F={}),(We=l.options)===void 0&&(We={}),Object.keys(J).filter(function(m){var g=We.plugins||{};return vi(g[m])?g[m]:g.all!==!1&&(!F[m]||F[m].enabled!==!1)}).map(function(m){return J[m]}));D===P.initializeStart&&l.fromEnable&&(G=Object.keys(L.plugins).filter(function(m){var g=L.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return $[m]}));var M=G.map(function(m){return m.name}),x=function(m,g,O){var C=$n(m).map(function(A){return An(A,g)});return g.reduce(function(A,z){var W=z.name,U=$n(m,W).map(function(Ke){return An(Ke,g)}),Z=U[0],N=U[1],ee=U[2];return Z.length&&(A.beforeNS[W]=Z),N.length&&(A.duringNS[W]=N),ee.length&&(A.afterNS[W]=ee),A},{before:C[0],beforeNS:{},during:C[1],duringNS:{},after:C[2],afterNS:{}})}(D,G);return Promise.resolve(_t({action:l,data:{exact:x.before,namespaced:x.beforeNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(m){function g(){var A=function(){if(D.match(Ce))return Promise.resolve(_t({action:T({},O,{type:R+"End"}),data:{exact:x.after,namespaced:x.afterNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(z){z.meta&&z.meta.hasCallback&&On(z.meta.rid,{payload:z})})}();return A&&A.then?A.then(function(){return m}):m}if(zn(m,M.length))return m;var O,C=function(){if(D!==R)return Promise.resolve(_t({action:T({},m,{type:R}),data:{exact:x.during,namespaced:x.duringNS},state:L,allPlugins:$,allMatches:x,instance:j,store:k,EVENTS:S})).then(function(A){O=A});O=m}();return C&&C.then?C.then(g):g()})}catch(m){return Promise.reject(m)}var J,F,We}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(v&&v.then?v.then(p):p(v))}catch(l){return Promise.reject(l)}}}}}function Li(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 Ri=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 Zi(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=Un(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},T({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var p=Un(n.type,P.initialize),f=t()[p];return f&&p?(r[p]=T({},e[p],{initialized:!0,loaded:!!f.loaded({config:f.config})}),T({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=T({},e[n.name],{loaded:!0}),T({},e,r);switch(n.type){case P.disablePlugin:return T({},e,Ln(n.plugins,!1,e));case P.enablePlugin:return T({},e,Ln(n.plugins,!0,e));default:return e}}}function Un(t,e){return t.substring(e.length+1,t.length)}function Ln(t,e,n){return t.reduce(function(r,i){return r[i]=T({},n[i],{enabled:e}),r},n)}function Rn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Mi={last:{},history:[]};function Wi(t,e){t===void 0&&(t=Mi);var n=e.options,r=e.meta;if(e.type===P.track){var i=Rn(T({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return T({},t,{last:i,history:t.history.concat(i)})}return t}var Ki={actions:[]};function Ji(t,e){t===void 0&&(t=Ki);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),T({},t,{actions:r});case"dequeue":return[];default:return t}}var Zn=/#.*$/;function Xi(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Zn,""):"")}var Mn,Wn,Kn,Jn,Fi=function(t){if(t===void 0&&(t={}),!Y)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,p=o.hash,f=o.search,u=function(h){var d=function(){if(Y){for(var w,I=document.getElementsByTagName("link"),y=0;w=I[y];y++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+h:window.location.href.replace(Zn,"")}(f),c={title:n,url:u,path:Xi(u),hash:p,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),T({},c,t)},Hi={last:{},history:[]};function Vi(t,e){t===void 0&&(t=Hi);var n=e.options;if(e.type===P.page){var r=Rn(T({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return T({},t,{last:r,history:t.history.concat(r)})}return t}Mn=function(){if(!Y)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"}(),Wn=Y?document.referrer:null,Kn=Ei(),Jn=Oi();var Xn={initialized:!1,sessionId:Be(),app:null,version:null,debug:!1,offline:!!Y&&!navigator.onLine,os:{name:Mn},userAgent:Y?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Jn,locale:Kn,campaign:{},referrer:Wn};function Yi(t,e){t===void 0&&(t=Xn);var n=t.initialized,r=e.campaign;switch(e.type){case P.campaign:return T({},t,{campaign:r});case P.offline:return T({},t,{offline:!0});case P.online:return T({},t,{offline:!1});default:return n?t:T({},Xn,t,{initialized:!0})}}var Gi=["plugins","reducers","storage"];function Bi(t,e,n){if(Y){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function qi(t){var e=Bi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function Fn(){return ge("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 Ee[_e].analytics.push(a.action||a),o(a)}})}}}function Hn(t){return function(){return Pe(Pe.apply(null,arguments),Fn())}}function Tt(t){return t?yn(t)?t:[t]:[]}function Vn(t,e,n){t===void 0&&(t={});var r,i,o=Be();return e&&(De[o]=(r=e,i=function(a){for(var s,p=a||Array.prototype.slice.call(arguments),f=0;f<p.length;f++)if(q(p[f])){s=p[f];break}return s}(n),function(a){i&&i(a),r(a)})),T({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function Qi(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,g){if(q(g))return m.middlewares=m.middlewares.concat(g),m;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var O=g.EVENTS?Object.keys(g.EVENTS).map(function(z){return g.EVENTS[z]}):[];m.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(m.methods[g.name]=Object.keys(g.methods).reduce(function(z,W){var U;return z[W]=(U=g.methods[W],function(){for(var Z=Array.prototype.slice.call(arguments),N=new Array(U.length),ee=0;ee<Z.length;ee++)N[ee]=Z[ee];return N[N.length]=b,U.apply({instance:b},N)}),z},{}),delete g.methods);var C=Object.keys(g).concat(O),A=new Set(m.events.concat(C));if(m.events=Array.from(A),m.pluginsArray=m.pluginsArray.concat(g),m.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return m.plugins[g.name]=g,m.plugins[g.name].loaded||(m.plugins[g.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:me,setItem:ge,removeItem:Oe},o=function(m){return function(g,O,C){return O.getState("user")[g]||(C&&X(C)&&C[g]?C[g]:En(m)[g]||me(St(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!It.includes(m)}).sort(),p=new Set(s.concat(et).filter(function(m){return!It.includes(m)})),f=Array.from(p).sort(),u=function(){return a},c=new Ri,h=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},y=Ti(),_=En(i),E=T({},_,n,y.an_uid?{userId:y.an_uid}:{},y.an_aid?{anonymousId:y.an_aid}:{});E.anonymousId||(E.anonymousId=Be());var v=T({enable:function(m,g){return new Promise(function(O){x.dispatch({type:P.enablePlugin,plugins:Tt(m),_:{originalAction:P.enablePlugin}},O,[g])})},disable:function(m,g){return new Promise(function(O){x.dispatch({type:P.disablePlugin,plugins:Tt(m),_:{originalAction:P.disablePlugin}},O,[g])})}},r.methods),l=!1,b={identify:function(m,g,O,C){try{var A=ie(m)?m:null,z=X(m)?m:g,W=O||{},U=b.user();ge(St(se),A);var Z=A||z.userId||o(se,b,z);return Promise.resolve(new Promise(function(N){x.dispatch(T({type:P.identifyStart,userId:Z,traits:z||{},options:W,anonymousId:U.anonymousId},U.id&&U.id!==A&&{previousId:U.id}),N,[g,O,C])}))}catch(N){return Promise.reject(N)}},track:function(m,g,O,C){try{var A=X(m)?m.event:m;if(!A||!ie(A))throw new Error("EventMissing");var z=X(m)?m:g||{},W=X(O)?O:{};return Promise.resolve(new Promise(function(U){x.dispatch({type:P.trackStart,event:A,properties:z,options:W,userId:o(se,b,g),anonymousId:o(xe,b,g)},U,[g,O,C])}))}catch(U){return Promise.reject(U)}},page:function(m,g,O){try{var C=X(m)?m:{},A=X(g)?g:{};return Promise.resolve(new Promise(function(z){x.dispatch({type:P.pageStart,properties:Fi(C),options:A,userId:o(se,b,C),anonymousId:o(xe,b,C)},z,[m,g,O])}))}catch(z){return Promise.reject(z)}},user:function(m){if(m===se||m==="id")return o(se,b);if(m===xe||m==="anonId")return o(xe,b);var g=b.getState("user");return m?dn(g,m):g},reset:function(m){return new Promise(function(g){x.dispatch({type:P.resetStart},g,m)})},ready:function(m){return l&&m({plugins:v,instance:b}),b.on(P.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!q(g))return!1;if(m===P.bootstrap)throw new Error(".on disabled for "+m);var O=/Start$|Start:/;if(m==="*"){var C=function(U){return function(Z){return function(N){return N.type.match(O)&&g({payload:N,instance:b,plugins:a}),Z(N)}}},A=function(U){return function(Z){return function(N){return N.type.match(O)||g({payload:N,instance:b,plugins:a}),Z(N)}}};return h(C,tt),h(A,nt),function(){d(C,tt),d(A,nt)}}var z=m.match(O)?tt:nt,W=function(U){return function(Z){return function(N){return N.type===m&&g({payload:N,instance:b,plugins:a,abort:I}),Z(N)}}};return h(W,z),function(){return d(W,z)}},once:function(m,g){if(!m||!q(g))return!1;if(m===P.bootstrap)throw new Error(".once disabled for "+m);var O=b.on(m,function(C){g({payload:C.payload,instance:b,plugins:a,abort:I}),O()});return O},getState:function(m){var g=x.getState();return m?dn(g,m):Object.assign({},g)},dispatch:function(m){var g=ie(m)?{type:m}:m;if(et.includes(g.type))throw new Error("reserved action "+g.type);var O=T({},g,{_:T({originalAction:g.type},m._||{})});x.dispatch(O)},enablePlugin:v.enable,disablePlugin:v.disable,plugins:v,storage:{getItem:i.getItem,setItem:function(m,g,O){x.dispatch({type:P.setItemStart,key:m,value:g,options:O})},removeItem:function(m,g){x.dispatch({type:P.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){b.storage.setItem(ae,m,g)},events:{core:et,plugins:s}},j=r.middlewares.concat([function(m){return function(g){return function(O){return O.meta||(O.meta=Vn()),g(O)}}},w(tt),Ui(b,u,{all:f,plugins:s}),Li(i),Ai(b),zi(b),w(nt)]),k={context:Yi,user:$i(i),page:Vi,track:Wi,plugins:Zi(u),queue:Ji},S=Pe,$=Pe;if(Y&&t.debug){var D=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;D&&(S=D({trace:!0,traceLimit:25})),$=function(){return arguments.length===0?Fn():X(typeof arguments[0])?Hn():Hn().apply(null,arguments)}}var R,L=function(m){return Object.keys(m).reduce(function(g,O){return Gi.includes(O)||(g[O]=m[O]),g},{})}(t),G=r.pluginsArray.reduce(function(m,g){var O=g.name,C=g.config,A=g.loaded,z=r.pluginEnabled[O];return m[O]={enabled:z,initialized:!!z&&!g.initialize,loaded:!!A({config:C}),config:C},m},{}),M={context:L,user:E,plugins:G},x=kn(function(m){for(var g=Object.keys(m),O={},C=0;C<g.length;C++){var A=g[C];typeof m[A]===oe&&(O[A]=m[A])}var z,W=Object.keys(O);try{(function(U){Object.keys(U).forEach(function(Z){var N=U[Z];if(typeof N(void 0,{type:"@@redux/INIT"})===ne||typeof N(void 0,{type:ji})===ne)throw new Error("reducer "+Z+" "+ne)})})(O)}catch(U){z=U}return function(U,Z){if(U===void 0&&(U={}),z)throw z;for(var N=!1,ee={},Ke=0;Ke<W.length;Ke++){var ct=W[Ke],fr=U[ct],Ut=(0,O[ct])(fr,Z);if(typeof Ut===ne){var Co=xi(ct,Z);throw new Error(Co)}ee[ct]=Ut,N=N||Ut!==fr}return N?ee:U}}(T({},k,e)),M,$(S(Ci.apply(void 0,j))));x.dispatch=(R=x.dispatch,function(m,g,O){var C=T({},m,{meta:Vn(m.meta,g,Tt(O))});return R.apply(null,[C])});var J=Object.keys(a);x.dispatch({type:P.bootstrap,plugins:J,config:L,params:y,user:E,initialUser:n,persistedUser:_});var F=J.filter(function(m){return r.pluginEnabled[m]}),We=J.filter(function(m){return!r.pluginEnabled[m]});return x.dispatch({type:P.registerPlugins,plugins:J,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var O=m.bootstrap,C=m.config,A=m.name;O&&q(O)&&O({instance:b,config:C,payload:m}),x.dispatch({type:P.registerPluginType(A),name:A,enabled:r.pluginEnabled[A],plugin:m}),r.pluginsArray.length===g+1&&x.dispatch({type:P.initializeStart,plugins:F,disabled:We})}),qi(function(m){x.dispatch({type:m?P.offline:P.online})}),function(m,g,O){setInterval(function(){return Pn(m,g,O)},3e3)}(x,u,b),b}var tt="before",nt="after",Le="cookie",ve=Bn(),Yn=rt,eo=rt;function Gn(t){return ve?rt(t,"",-1):Oe(t)}function Bn(){if(ve!==void 0)return ve;var t="cookiecookie";try{rt(t,t),ve=document.cookie.indexOf(t)!==-1,Gn(t)}catch{ve=!1}return ve}function rt(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ve===!1&&(a?ge(t,e):me(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",to=kt.bind(null,"localStorage");Te("localStorage","getItem",me),Te("localStorage","setItem",ge),Te("localStorage","removeItem",Oe);var Ze="sessionStorage",no=kt.bind(null,"sessionStorage");Te("sessionStorage","getItem",me),Te("sessionStorage","setItem",ge),Te("sessionStorage","removeItem",Oe);function Ae(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 ro=to(),io=no(),oo=Bn();function qn(t,e){if(t){var n=Pt(e),r=!At(n),i=jt(n)?Ae(localStorage.getItem(t)):void 0;if(r&&!Se(i))return i;var o=xt(n)?Ae(Yn(t)):void 0;if(r&&o)return o;var a=Ct(n)?Ae(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=me(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function ao(t,e,n){if(t&&!Se(e)){var r={},i=Pt(n),o=JSON.stringify(e),a=!At(i);return jt(i)&&(r[Re]=ot(Re,e,Ae(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Re]:xt(i)&&(r[Le]=ot(Le,e,Ae(Yn(t))),eo(t,o),a)?r[Le]:Ct(i)&&(r[Ze]=ot(Ze,e,Ae(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ze]:(r[Ne]=ot(Ne,e,me(t)),ge(t,e),a?r[Ne]:r)}}function so(t,e){if(t){var n=Pt(e),r=qn(t,pn),i={};return!Se(r.localStorage)&&jt(n)&&(localStorage.removeItem(t),i[Re]=r.localStorage),!Se(r.cookie)&&xt(n)&&(Gn(t),i[Le]=r.cookie),!Se(r.sessionStorage)&&Ct(n)&&(sessionStorage.removeItem(t),i[Ze]=r.sessionStorage),!Se(r.global)&&it(n,Ne)&&(Oe(t),i[Ne]=r.global),i}}function Pt(t){return t?ie(t)?t:t.storage:fn}function jt(t){return ro&&it(t,Re)}function xt(t){return oo&&it(t,Le)}function Ct(t){return io&&it(t,Ze)}function At(t){return t===pn||t==="all"}function it(t,e){return t===fn||t===e||At(t)}function ot(t,e,n){return{location:t,current:e,previous:n}}var co={setItem:ao,getItem:qn,removeItem:so};function uo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qn(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 er(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Qn(Object(n),!0).forEach(function(r){uo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Qn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:co};return Qi(er(er({},e),t))}function ho(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(p){return r=i.push(p),r>=o&&a(),r},size:function(){return i.length},end:function(p){p&&a(),clearInterval(n)}}}function fo(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(...p){var c;const f=((c=p[2])==null?void 0:c.toString())||"",u=mo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,p)}})}function po(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function mo(t){return["#","?"].forEach(e=>t=po(t,e)),t}function go(){fo(()=>{we.page()})}var tr="EventListener";function yo(t){return function(e,n,r,i){var o=r||pi,a=i||!1;if(!Y)return o;var s=at(n),p=at(e,!0);if(!p.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var h=c?"add"+tr:"remove"+tr,d=0;d<p.length;d++){var w=p[d];f[d]=c?a&&a.once?vo(o):o:f[d]||o;for(var I=0;I<s.length;I++)w[h]?w["on"+s[I]]=c?f[d]:null:w[h](s[I],f[d],a)}return u.bind(null,!c)}(t)}}function at(t,e){if(ie(t))return e?at(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=_i(t);return e?o.map(function(a){return ie(a)?at(a,!0):a}).flat():o}function vo(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var $t=yo("Event");function nr(t,e){return Y&&q(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),q(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}nr.bind(null,"onerror"),nr.bind(null,"onload");var rr=typeof window>"u",ir="hidden";function wo(t){if(rr)return!1;var e=bo(),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 bo(){var t=["webkit","moz","ms","o"];return rr||ir in document?ir:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var ko=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Io(t,e){e===void 0&&(e={});var n=function(a,s){var p=this,f=!1;return function(u){f||(a.call(p,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=wo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(ko.map(function(s){return $t(document,s,n)})).concat($t(window,"load",n)).concat($t(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function So(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,p=t.throttle,f=p===void 0?2e3:p,u=!1,c=!1,h=new Date,d=function(){return clearTimeout(e)};function w(y){d(),o&&!u&&o(Me(h),y),i&&u&&(u=!1,i(Me(n),y),h=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Me(h),y))},s)}var I=Io(w,{throttle:f});return{disable:function(){c=!0,u=!1,d();var y=I();return function(){return c=!1,h=new Date,w({type:"load"}),y()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Me(h,c),idle:u?Me(n,c):0}}}}function Me(t,e){return e?0:Math.round((new Date-t)/1e3)}const or=5e3;class _o{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),So({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:or})}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*or:Date.now(),this.isInViewport&&this.trackAwake(e,n)}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 ar="sesamy_session_id";function Eo(){let t=sessionStorage.getItem(ar);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(ar,t)),t}let sr=!1,zt,cr,st;function Oo({clientId:t,enabled:e=!0,endpoint:n=Xr}){if(zt=t,cr=e,st=n,!cr)return;go();const r=new _o({element:document.body,viewCallback:()=>{we.page()},activeDurationCallback:(i,o,a)=>{we.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{we.track("idleDuration",{duration:i,durationStart:a,flushing:o})}});Po(document.body,()=>{r.flush()}),jo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(he.AUTHENTICATED,async i=>{const o=i;await we.identify(o.detail.sub)}),window.addEventListener(he.LOGOUT,async()=>{await we.track("logout",{}),Nt.flush(),await we.reset()})}function ur(t){return JSON.stringify(t.map(e=>({...e,clientId:zt,requestId:Math.random().toString(36).slice(2,9),sessionId:Eo(),timestamp:new Date().toISOString(),version:bt,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:ln,userAgent:navigator.userAgent,clientId:zt}})))}const Nt=ho(async t=>{if(t.length>0){const e=ur(t);sr?navigator.sendBeacon(st,e):(await fetch(st,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Dt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(st,ur([n]))}else Nt.push(t)}const we=lo({app:ln,version:bt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Dt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Dt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Dt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function To(){return sr=!0,Nt.flush()}const lr=new Map;function Po(t,e){lr.set(t,e)}window.addEventListener("beforeunload",()=>{lr.forEach((t,e)=>{t.bind(e)()}),To()});const dr=new Map;function jo(t,e){dr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&dr.forEach((t,e)=>{t.bind(e)()})});function xo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e&&n){tn(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 hr(t){Oo({clientId:t.clientId,...t.analytics}),await Fr({clientId:t.clientId,...t.auth});const e=hi(t.api||{});return B(he.READY,{}),xo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);hr(e)}catch(e){console.error("Failed to parse config",e)}}return te.init=hr,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"}),te}({});
@@ -1047,13 +1047,19 @@ function Gr() {
1047
1047
  }
1048
1048
  });
1049
1049
  }
1050
- async function Br() {
1051
- const t = xt();
1052
- if (t)
1053
- return t;
1054
- if (!V)
1055
- throw new Error("Auth0 client not initialized");
1056
- return V.getTokenSilently();
1050
+ async function Br(t = !0) {
1051
+ const e = xt();
1052
+ if (e)
1053
+ return e;
1054
+ try {
1055
+ if (!V)
1056
+ throw new Error("Auth0 client not initialized");
1057
+ return await V.getTokenSilently();
1058
+ } catch (n) {
1059
+ if (t)
1060
+ throw n;
1061
+ return null;
1062
+ }
1057
1063
  }
1058
1064
  async function qr() {
1059
1065
  if (localStorage.removeItem(Pt), localStorage.removeItem(jt), !V)
@@ -1364,20 +1370,23 @@ oe.errorType = ci;
1364
1370
  oe.polyfills = si;
1365
1371
  oe.WretchError = Kn;
1366
1372
  function hi(t) {
1367
- const e = t.endpoint || `https://api2.${Rn}`, n = (k = !0) => (_) => async ($, U) => {
1373
+ const e = t.endpoint || `https://api2.${Rn}`, n = (k = !0) => (_) => async ($, D) => {
1368
1374
  let R = null;
1369
- if (R = await Br(), !R && k)
1370
- throw new Error("No access token available");
1375
+ if (R = await Br(k), !R) {
1376
+ if (k)
1377
+ throw new Error("No access token available");
1378
+ return _($, D);
1379
+ }
1371
1380
  const L = {
1372
- ...U,
1381
+ ...D,
1373
1382
  headers: {
1374
- ...U.headers,
1383
+ ...D.headers,
1375
1384
  ...R ? { Authorization: `Bearer ${R}` } : {}
1376
1385
  }
1377
1386
  };
1378
1387
  return _($, L);
1379
1388
  }, r = (k) => (_, $) => {
1380
- const U = localStorage.getItem("__anon_id"), R = btoa(`${U}:`), L = {
1389
+ const D = localStorage.getItem("__anon_id"), R = btoa(`${D}:`), L = {
1381
1390
  ...$,
1382
1391
  headers: {
1383
1392
  ...$.headers,
@@ -1968,16 +1977,16 @@ var ft = function(t) {
1968
1977
  return function(E, v, l) {
1969
1978
  var b = v.config, j = v.name, k = j + "." + E.type;
1970
1979
  l && (k = l.event);
1971
- var _ = E.type.match(_e) ? /* @__PURE__ */ function($, U, R, L, F) {
1980
+ var _ = E.type.match(_e) ? /* @__PURE__ */ function($, D, R, L, F) {
1972
1981
  return function(W, x) {
1973
1982
  var K = L ? L.name : $, J = x && Ze(x) ? x : R;
1974
1983
  if (L && (!(J = x && Ze(x) ? x : [$]).includes($) || J.length !== 1))
1975
- throw new Error("Method " + U + " can only abort " + $ + " plugin. " + JSON.stringify(J) + " input valid");
1976
- return P({}, F, { abort: { reason: W, plugins: J, caller: U, _: K } });
1984
+ throw new Error("Method " + D + " can only abort " + $ + " plugin. " + JSON.stringify(J) + " input valid");
1985
+ return P({}, F, { abort: { reason: W, plugins: J, caller: D, _: K } });
1977
1986
  };
1978
- }(j, k, S, l, E) : /* @__PURE__ */ function($, U) {
1987
+ }(j, k, S, l, E) : /* @__PURE__ */ function($, D) {
1979
1988
  return function() {
1980
- throw new Error($.type + " action not cancellable. Remove abort in " + U);
1989
+ throw new Error($.type + " action not cancellable. Remove abort in " + D);
1981
1990
  };
1982
1991
  }(E, k);
1983
1992
  return { payload: Ui(E), instance: y, config: b || {}, abort: _ };
@@ -1997,7 +2006,7 @@ var ft = function(t) {
1997
2006
  if (e.namespaced && e.namespaced[v])
1998
2007
  return Promise.resolve(e.namespaced[v].reduce(function(k, _, $) {
1999
2008
  try {
2000
- return Promise.resolve(k).then(function(U) {
2009
+ return Promise.resolve(k).then(function(D) {
2001
2010
  return _.method && G(_.method) ? (function(W, x) {
2002
2011
  var K = pn(W);
2003
2012
  if (K && K.name === x) {
@@ -2005,16 +2014,16 @@ var ft = function(t) {
2005
2014
  throw new Error([x + " plugin is calling method " + W, "Plugins cant call self", "Use " + K.method + " " + (J ? "or " + J.method : "") + " in " + x + " plugin insteadof " + W].join(`
2006
2015
  `));
2007
2016
  }
2008
- }(_.methodName, _.pluginName), Promise.resolve(_.method({ payload: U, instance: r, abort: (R = U, L = v, F = _.pluginName, function(W, x) {
2017
+ }(_.methodName, _.pluginName), Promise.resolve(_.method({ payload: D, instance: r, abort: (R = D, L = v, F = _.pluginName, function(W, x) {
2009
2018
  return P({}, R, { abort: { reason: W, plugins: x || [L], caller: c, from: F || L } });
2010
2019
  }), config: ln(_.pluginName, f, o), plugins: f })).then(function(W) {
2011
2020
  var x = X(W) ? W : {};
2012
- return Promise.resolve(P({}, U, x));
2013
- })) : U;
2021
+ return Promise.resolve(P({}, D, x));
2022
+ })) : D;
2014
2023
  var R, L, F;
2015
2024
  });
2016
- } catch (U) {
2017
- return Promise.reject(U);
2025
+ } catch (D) {
2026
+ return Promise.reject(D);
2018
2027
  }
2019
2028
  }, Promise.resolve(n))).then(function(k) {
2020
2029
  l[v] = k;
@@ -2039,8 +2048,8 @@ var ft = function(t) {
2039
2048
  if (I.hasOwnProperty(b) && I[b] === !0)
2040
2049
  return s.dispatch({ type: "queue", plugin: b, payload: _, _: { called: "queue", from: "queueMechanism" } }), Promise.resolve(k);
2041
2050
  var $ = w(y[b], o[b]);
2042
- return Promise.resolve(j[c]({ abort: $.abort, payload: _, instance: r, config: ln(b, f, o), plugins: f })).then(function(U) {
2043
- var R = X(U) ? U : {}, L = P({}, k, R), F = y[b];
2051
+ return Promise.resolve(j[c]({ abort: $.abort, payload: _, instance: r, config: ln(b, f, o), plugins: f })).then(function(D) {
2052
+ var R = X(D) ? D : {}, L = P({}, k, R), F = y[b];
2044
2053
  if (mt(F, b))
2045
2054
  pt({ data: F, method: c, instance: r, pluginName: b, store: s });
2046
2055
  else {
@@ -2157,7 +2166,7 @@ function Li(t, e, n) {
2157
2166
  return Qn(i, e, t);
2158
2167
  }, 0), Promise.resolve(function(l, b, j, k, _) {
2159
2168
  try {
2160
- var $ = G(b) ? b() : b, U = l.type, R = U.replace(_e, "");
2169
+ var $ = G(b) ? b() : b, D = l.type, R = D.replace(_e, "");
2161
2170
  if (l._ && l._.called)
2162
2171
  return Promise.resolve(l);
2163
2172
  var L = j.getState(), F = (K = $, (J = L.plugins) === void 0 && (J = {}), (Ce = l.options) === void 0 && (Ce = {}), Object.keys(K).filter(function(m) {
@@ -2166,7 +2175,7 @@ function Li(t, e, n) {
2166
2175
  }).map(function(m) {
2167
2176
  return K[m];
2168
2177
  }));
2169
- U === T.initializeStart && l.fromEnable && (F = Object.keys(L.plugins).filter(function(m) {
2178
+ D === T.initializeStart && l.fromEnable && (F = Object.keys(L.plugins).filter(function(m) {
2170
2179
  var g = L.plugins[m];
2171
2180
  return l.plugins.includes(m) && !g.initialized;
2172
2181
  }).map(function(m) {
@@ -2179,16 +2188,16 @@ function Li(t, e, n) {
2179
2188
  return dn(A, g);
2180
2189
  });
2181
2190
  return g.reduce(function(A, z) {
2182
- var M = z.name, D = hn(m, M).map(function(Ae) {
2191
+ var M = z.name, U = hn(m, M).map(function(Ae) {
2183
2192
  return dn(Ae, g);
2184
- }), Z = D[0], N = D[1], q = D[2];
2193
+ }), Z = U[0], N = U[1], q = U[2];
2185
2194
  return Z.length && (A.beforeNS[M] = Z), N.length && (A.duringNS[M] = N), q.length && (A.afterNS[M] = q), A;
2186
2195
  }, { before: C[0], beforeNS: {}, during: C[1], duringNS: {}, after: C[2], afterNS: {} });
2187
- }(U, F);
2196
+ }(D, F);
2188
2197
  return Promise.resolve(ft({ action: l, data: { exact: x.before, namespaced: x.beforeNS }, state: L, allPlugins: $, allMatches: x, instance: j, store: k, EVENTS: _ })).then(function(m) {
2189
2198
  function g() {
2190
2199
  var A = function() {
2191
- if (U.match(_e))
2200
+ if (D.match(_e))
2192
2201
  return Promise.resolve(ft({ action: P({}, O, { type: R + "End" }), data: { exact: x.after, namespaced: x.afterNS }, state: L, allPlugins: $, allMatches: x, instance: j, store: k, EVENTS: _ })).then(function(z) {
2193
2202
  z.meta && z.meta.hasCallback && sn(z.meta.rid, { payload: z });
2194
2203
  });
@@ -2200,7 +2209,7 @@ function Li(t, e, n) {
2200
2209
  if (er(m, W.length))
2201
2210
  return m;
2202
2211
  var O, C = function() {
2203
- if (U !== R)
2212
+ if (D !== R)
2204
2213
  return Promise.resolve(ft({ action: P({}, m, { type: R }), data: { exact: x.during, namespaced: x.duringNS }, state: L, allPlugins: $, allMatches: x, instance: j, store: k, EVENTS: _ })).then(function(A) {
2205
2214
  O = A;
2206
2215
  });
@@ -2442,11 +2451,11 @@ function eo(t) {
2442
2451
  return g.EVENTS[z];
2443
2452
  }) : [];
2444
2453
  m.pluginEnabled[g.name] = !(g.enabled === !1 || g.config.enabled === !1), delete g.enabled, g.methods && (m.methods[g.name] = Object.keys(g.methods).reduce(function(z, M) {
2445
- var D;
2446
- return z[M] = (D = g.methods[M], function() {
2447
- for (var Z = Array.prototype.slice.call(arguments), N = new Array(D.length), q = 0; q < Z.length; q++)
2454
+ var U;
2455
+ return z[M] = (U = g.methods[M], function() {
2456
+ for (var Z = Array.prototype.slice.call(arguments), N = new Array(U.length), q = 0; q < Z.length; q++)
2448
2457
  N[q] = Z[q];
2449
- return N[N.length] = b, D.apply({ instance: b }, N);
2458
+ return N[N.length] = b, U.apply({ instance: b }, N);
2450
2459
  }), z;
2451
2460
  }, {}), delete g.methods);
2452
2461
  var C = Object.keys(g).concat(O), A = new Set(m.events.concat(C));
@@ -2479,11 +2488,11 @@ function eo(t) {
2479
2488
  });
2480
2489
  } }, r.methods), l = !1, b = { identify: function(m, g, O, C) {
2481
2490
  try {
2482
- var A = re(m) ? m : null, z = X(m) ? m : g, M = O || {}, D = b.user();
2491
+ var A = re(m) ? m : null, z = X(m) ? m : g, M = O || {}, U = b.user();
2483
2492
  ye(St(te), A);
2484
2493
  var Z = A || z.userId || o(te, b, z);
2485
2494
  return Promise.resolve(new Promise(function(N) {
2486
- x.dispatch(P({ type: T.identifyStart, userId: Z, traits: z || {}, options: M, anonymousId: D.anonymousId }, D.id && D.id !== A && { previousId: D.id }), N, [g, O, C]);
2495
+ x.dispatch(P({ type: T.identifyStart, userId: Z, traits: z || {}, options: M, anonymousId: U.anonymousId }, U.id && U.id !== A && { previousId: U.id }), N, [g, O, C]);
2487
2496
  }));
2488
2497
  } catch (N) {
2489
2498
  return Promise.reject(N);
@@ -2494,11 +2503,11 @@ function eo(t) {
2494
2503
  if (!A || !re(A))
2495
2504
  throw new Error("EventMissing");
2496
2505
  var z = X(m) ? m : g || {}, M = X(O) ? O : {};
2497
- return Promise.resolve(new Promise(function(D) {
2498
- x.dispatch({ type: T.trackStart, event: A, properties: z, options: M, userId: o(te, b, g), anonymousId: o(ke, b, g) }, D, [g, O, C]);
2506
+ return Promise.resolve(new Promise(function(U) {
2507
+ x.dispatch({ type: T.trackStart, event: A, properties: z, options: M, userId: o(te, b, g), anonymousId: o(ke, b, g) }, U, [g, O, C]);
2499
2508
  }));
2500
- } catch (D) {
2501
- return Promise.reject(D);
2509
+ } catch (U) {
2510
+ return Promise.reject(U);
2502
2511
  }
2503
2512
  }, page: function(m, g, O) {
2504
2513
  try {
@@ -2531,13 +2540,13 @@ function eo(t) {
2531
2540
  throw new Error(".on disabled for " + m);
2532
2541
  var O = /Start$|Start:/;
2533
2542
  if (m === "*") {
2534
- var C = function(D) {
2543
+ var C = function(U) {
2535
2544
  return function(Z) {
2536
2545
  return function(N) {
2537
2546
  return N.type.match(O) && g({ payload: N, instance: b, plugins: a }), Z(N);
2538
2547
  };
2539
2548
  };
2540
- }, A = function(D) {
2549
+ }, A = function(U) {
2541
2550
  return function(Z) {
2542
2551
  return function(N) {
2543
2552
  return N.type.match(O) || g({ payload: N, instance: b, plugins: a }), Z(N);
@@ -2548,7 +2557,7 @@ function eo(t) {
2548
2557
  d(C, He), d(A, Ve);
2549
2558
  };
2550
2559
  }
2551
- var z = m.match(O) ? He : Ve, M = function(D) {
2560
+ var z = m.match(O) ? He : Ve, M = function(U) {
2552
2561
  return function(Z) {
2553
2562
  return function(N) {
2554
2563
  return N.type === m && g({ payload: N, instance: b, plugins: a, abort: I }), Z(N);
@@ -2590,8 +2599,8 @@ function eo(t) {
2590
2599
  };
2591
2600
  }, w(He), Li(b, u, { all: f, plugins: s }), Ri(i), $i(b), Ni(b), w(Ve)]), k = { context: Gi, user: zi(i), page: Yi, track: Ki, plugins: Wi(u), queue: Xi }, _ = Pe, $ = Pe;
2592
2601
  if (Y && t.debug) {
2593
- var U = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
2594
- U && (_ = U({ trace: !0, traceLimit: 25 })), $ = function() {
2602
+ var D = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
2603
+ D && (_ = D({ trace: !0, traceLimit: 25 })), $ = function() {
2595
2604
  return arguments.length === 0 ? sr() : X(typeof arguments[0]) ? vn() : vn().apply(null, arguments);
2596
2605
  };
2597
2606
  }
@@ -2609,28 +2618,28 @@ function eo(t) {
2609
2618
  }
2610
2619
  var z, M = Object.keys(O);
2611
2620
  try {
2612
- (function(D) {
2613
- Object.keys(D).forEach(function(Z) {
2614
- var N = D[Z];
2621
+ (function(U) {
2622
+ Object.keys(U).forEach(function(Z) {
2623
+ var N = U[Z];
2615
2624
  if (typeof N(void 0, { type: "@@redux/INIT" }) === ee || typeof N(void 0, { type: xi }) === ee)
2616
2625
  throw new Error("reducer " + Z + " " + ee);
2617
2626
  });
2618
2627
  })(O);
2619
- } catch (D) {
2620
- z = D;
2628
+ } catch (U) {
2629
+ z = U;
2621
2630
  }
2622
- return function(D, Z) {
2623
- if (D === void 0 && (D = {}), z)
2631
+ return function(U, Z) {
2632
+ if (U === void 0 && (U = {}), z)
2624
2633
  throw z;
2625
2634
  for (var N = !1, q = {}, Ae = 0; Ae < M.length; Ae++) {
2626
- var Me = M[Ae], Rt = D[Me], ct = (0, O[Me])(Rt, Z);
2635
+ var Me = M[Ae], Rt = U[Me], ct = (0, O[Me])(Rt, Z);
2627
2636
  if (typeof ct === ee) {
2628
2637
  var vr = Ci(Me, Z);
2629
2638
  throw new Error(vr);
2630
2639
  }
2631
2640
  q[Me] = ct, N = N || ct !== Rt;
2632
2641
  }
2633
- return N ? q : D;
2642
+ return N ? q : U;
2634
2643
  };
2635
2644
  }(P({}, k, e)), W, $(_(Ai.apply(void 0, j))));
2636
2645
  x.dispatch = (R = x.dispatch, function(m, g, O) {
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "registry": "https://registry.npmjs.org/",
7
7
  "tag": "latest"
8
8
  },
9
- "version": "1.4.0",
9
+ "version": "1.4.1",
10
10
  "main": "dist/sesamy-js.cjs",
11
11
  "module": "dist/sesamy-js.mjs",
12
12
  "types": "dist/sesamy-js.d.ts",