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