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