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