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