@sesamy/sesamy-js 1.85.0 → 1.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sesamy-js.cjs +2 -2
- package/dist/sesamy-js.iife.js +2 -2
- package/dist/sesamy-js.mjs +68 -46
- package/package.json +1 -1
package/dist/sesamy-js.cjs
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* Please keep this comment intact in order to properly abide by the MIT License.
|
|
33
33
|
*
|
|
34
34
|
**/var Ps={d:(t,e)=>{for(var r in e)Ps.o(e,r)&&!Ps.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},ac={};Ps.d(ac,{A:()=>dy,k:()=>ic});var jr=function(t,e,r,n){return new(r||(r=Promise))(function(a,i){function o(l){try{u(n.next(l))}catch(c){i(c)}}function s(l){try{u(n.throw(l))}catch(c){i(c)}}function u(l){var c;l.done?a(l.value):(c=l.value,c instanceof r?c:new r(function(f){f(c)})).then(o,s)}u((n=n.apply(t,[])).next())})},Dr=function(t,e){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(u){return function(l){return(function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(a=o.trys,!((a=a.length>0&&a[a.length-1])||c[0]!==6&&c[0]!==2)){o=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(c[0]===6&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=e.call(t,o)}catch(f){c=[6,f],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}})([u,l])}}};function ic(){return jr(this,void 0,Promise,function(){return Dr(this,function(t){switch(t.label){case 0:return[4,new Promise(function(e,r){var n="Unknown",a=!1;function i(h){a||(a=!0,e({isPrivate:h,browserName:n}))}function o(){var h=0,d=parseInt("-1");try{d.toFixed(d)}catch(p){h=p.message.length}return h}function s(){return jr(this,void 0,void 0,function(){var h,d;return Dr(this,function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return p.sent(),i(!1),[3,3];case 2:return h=p.sent(),d=h instanceof Error&&typeof h.message=="string"?h.message:String(h),i(d.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function u(){var h;return jr(this,void 0,Promise,function(){return Dr(this,function(d){switch(d.label){case 0:return typeof((h=navigator.storage)===null||h===void 0?void 0:h.getDirectory)!="function"?[3,2]:[4,s()];case 1:return d.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var p=String(Math.random());try{var v=indexedDB.open(p,1);v.onupgradeneeded=function(g){var P=g.target.result,b=function(y){i(y)};try{P.createObjectStore("t",{autoIncrement:!0}).put(new Blob),b(!1)}catch(y){(y instanceof Error&&typeof y.message=="string"?y.message:String(y)).includes("are not yet supported")?b(!0):b(!1)}finally{P.close(),indexedDB.deleteDatabase(p)}},v.onerror=function(){return i(!1)}}catch{i(!1)}})():(function(){var p=window.openDatabase,v=window.localStorage;try{p(null,null,null,null)}catch{return void i(!0)}try{v.setItem("test","1"),v.removeItem("test")}catch{return void i(!0)}i(!1)})(),d.label=3;case 3:return[2]}})})}function l(){navigator.webkitTemporaryStorage.queryUsageAndQuota(function(h,d){var p=Math.round(d/1048576),v=2*Math.round((function(){var g,P,b,y=window;return(b=(P=(g=y?.performance)===null||g===void 0?void 0:g.memory)===null||P===void 0?void 0:P.jsHeapSizeLimit)!==null&&b!==void 0?b:1073741824})()/1048576);i(p<v)},function(h){r(new Error("detectIncognito somehow failed to query storage quota: "+h.message))})}function c(){self.Promise!==void 0&&self.Promise.allSettled!==void 0?l():(0,window.webkitRequestFileSystem)(0,1,function(){i(!1)},function(){i(!0)})}function f(){var h;return jr(this,void 0,Promise,function(){var d,p,v;return Dr(this,function(g){switch(g.label){case 0:if(typeof((h=navigator.storage)===null||h===void 0?void 0:h.getDirectory)!="function")return[3,5];g.label=1;case 1:return g.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return g.sent(),i(!1),[3,4];case 3:return d=g.sent(),p=d instanceof Error&&typeof d.message=="string"?d.message:String(d),i(p.includes("Security error")),[2];case 4:return[3,6];case 5:(v=indexedDB.open("inPrivate")).onerror=function(P){v.error&&v.error.name==="InvalidStateError"&&P.preventDefault(),i(!0)},v.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),i(!1)},g.label=6;case 6:return[2]}})})}(function(){return jr(this,void 0,Promise,function(){return Dr(this,function(h){switch(h.label){case 0:return o()!==44&&o()!==43?[3,2]:(n="Safari",[4,u()]);case 1:return h.sent(),[3,6];case 2:return o()!==51?[3,3]:(d=navigator.userAgent,n=d.match(/Chrome/)?navigator.brave!==void 0?"Brave":d.match(/Edg/)?"Edge":d.match(/OPR/)?"Opera":"Chrome":"Chromium",c(),[3,6]);case 3:return o()!==25?[3,5]:(n="Firefox",[4,f()]);case 4:return h.sent(),[3,6];case 5:navigator.msSaveBlob!==void 0?(n="Internet Explorer",i(window.indexedDB===void 0)):r(new Error("detectIncognito cannot determine the browser")),h.label=6;case 6:return[2]}var d})})})().catch(r)})];case 1:return[2,t.sent()]}})})}typeof window<"u"&&(window.detectIncognito=ic);const dy=ic;ac.A;const hy=ac.k,kn="sesamy_incognito_mode";function na(){try{const t=sessionStorage.getItem(kn);return t===null?void 0:t==="true"}catch{return}}async function Hp(){try{const t=sessionStorage.getItem(kn);if(t!==null)return t==="true";const{isPrivate:e}=await hy();return sessionStorage.setItem(kn,e.toString()),e}catch{try{sessionStorage.setItem(kn,"false")}catch{}return!1}}function Yt(){return typeof window<"u"}function py(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function vy(){return/android/i.test(navigator.userAgent)}let _e,oc,Xr,Es=!1,_n=!1,Tn=!1;Yt()&&window.addEventListener("pageshow",()=>{_n=!1,Tn=!1});const Xt="sesamyAccessToken",zr="sesamyRefreshToken",Ln="sesamySilentAuthThrottle",Bp="sesamy_is_authenticated",sc="sesamySilentRedirectState",my=300*1e3,Gp=60,gy=["login_required","consent_required","interaction_required","timeout","Timeout","access_denied"];function Wp(){if(!Yt())return!1;try{const t=document.cookie.split(";").map(a=>a.trim());if(t.some(a=>a.startsWith(`${Bp}=true`))||t.some(a=>a.startsWith("auth0.is.authenticated=true")))return!0;const n=Object.keys(localStorage).filter(a=>a.startsWith("@@auth0spajs@@"));if(n.length>0)for(const a of n)try{const i=JSON.parse(localStorage.getItem(a)||"{}");if(i?.body?.access_token||i?.body?.refresh_token)return!0}catch{}return!1}catch(t){return G(`Error checking session hint cookie: ${t.message}`),!1}}function ln(t){if(Yt())try{const e=t?2592e3:0,r=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${Bp}=${t}; path=/; max-age=${e}; SameSite=Lax${r}`}catch(e){G(`Error setting session hint cookie: ${e.message}`)}}function Rn(){ln(!1)}function yy(){try{sessionStorage.setItem(sc,JSON.stringify({timestamp:Date.now()}))}catch{G("Failed to set silent redirect state")}}function On(){try{const t=sessionStorage.getItem(sc);if(t)return JSON.parse(t)}catch{}return null}function Qr(){try{sessionStorage.removeItem(sc)}catch{}}function wy(t){const e=t.message||"";return gy.some(r=>e.includes(r)||t.error===r)}async function aa(){return Es?!0:new Promise((t,e)=>{const r=setTimeout(()=>{Es?t(!0):e(new Error("Initialization failed: Timeout"))},2e3);window.addEventListener(Ge.AUTH_INITIALIZED,()=>{clearTimeout(r),t(!0)})})}async function by(t){if(!t)return null;const e=localStorage.getItem(zr);if(!e)return G("No refresh token found in localstorage"),null;const r=new URLSearchParams;r.set("client_id",t.iss),r.set("refresh_token",e),r.set("grant_type","refresh_token");const n=new URL(t.iss);n.pathname="/oauth/token",n.searchParams.set("user_id",t.sub);try{const a=await fetch(n.href,{body:r.toString(),method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"}});if(!a.ok){const o=await a.text().catch(()=>"Unknown error");throw G(`Token refresh failed with status ${a.status}: ${o}`),localStorage.removeItem(zr),new Error(`Renew token failed: ${a.status}`)}const i=await a.json();if(!i.access_token)throw G("Token refresh response missing access_token"),new Error("Invalid token response");return i.refresh_token&&localStorage.setItem(zr,i.refresh_token),localStorage.setItem(Xt,i.access_token),i.access_token}catch(a){return G(`Token refresh error: ${a.message}`),localStorage.removeItem(zr),localStorage.removeItem(Xt),await uc(),null}}async function cc(){const t=localStorage.getItem(Xt);if(!t)return null;const e=lc(t),r=Date.now()/1e3;if(!e||!e.exp||e.exp<r+Gp){const n=await by(e);return n||(localStorage.removeItem(Xt),null)}return t}let mn=null;const Sy=64;function Iy(){try{if(mn!==null)return mn;const e=Object.keys(localStorage).filter(r=>r.startsWith("@@auth0spajs@@"));for(const r of e){const n=JSON.parse(localStorage.getItem(r)||"{}");let a;if(typeof n=="object"&&(n.body&&typeof n.body=="object"&&"refresh_token"in n.body?a=n.body.refresh_token:"refresh_token"in n&&(a=n.refresh_token)),a&&typeof a=="string"&&a.length===Sy)return mn=!0,!0}}catch(t){G(`Error checking for existing auth0 tokens: ${t.message}`)}return mn=!1,!1}function Py(t){if(t.domains&&t.domains.length>0){const e=Ht(window.location.href);if(e){for(const r of t.domains)if(Ht(`https://${r}`)===e)return G(`Found matching domain in domains array: ${r} for TLD: ${e}`),r;G(`No matching domain found in domains array for TLD: ${e}`)}}if(t.domain)return G(`Using fallback domain property: ${t.domain}`),t.domain}function Ht(t){try{const e=new URL(t).hostname,r=e.split(".");if(r.length<=1)return e;const n=["co.uk","com.au","co.nz","co.za","com.br","co.jp","gov.uk","ac.uk","org.uk","net.uk","com.sg","com.my","co.in","co.id","co.th","co.kr","com.mx","com.ar","com.co","com.pe","com.ph","com.pk","com.sa","com.eg","com.ng","co.ke","co.tz","co.zw","co.bw","co.mz","gov.au","edu.au","org.au","net.au","asn.au","id.au"];for(const a of n)if(e.endsWith(`.${a}`)){const i=a.split(".").length+1;return r.slice(-i).join(".")}return r.slice(-2).join(".")}catch{return null}}async function Ey(t){if(t.enabled===!1)return;oc=t.organization;const e=Py(t);Xr=e&&!Iy()?e:zp("token",t.environment);const r=Ht(window.location.href)!==Ht(`https://${Xr}`),n=Ht(window.location.href),a=n?`.${n}`:void 0,i={domain:Xr,clientId:t.clientId,useCookiesForTransactions:!0,legacySameSiteCookie:!1,...a&&{cookieDomain:a}};i.cacheLocation="localstorage",(r||t.useRefreshTokens)&&(i.useRefreshTokens=!0),G(`Initializing auth0 client: ${JSON.stringify(i)}`),_e=await cy(i);const o=new URLSearchParams(window.location.search),s=o.get("code"),u=o.get("state"),l=o.get("error");if(l){const c=o.get("error_description");G(`Auth error in URL: ${l}${c?` - ${c}`:""}`);const f=new URL(location.href);f.searchParams.delete("error"),f.searchParams.delete("error_description"),f.searchParams.delete("state"),window.history.replaceState({},document.title,f.toString());const h=On();if(h&&Qr(),l==="login_required")G("Silent redirect returned login_required - user is not authenticated"),Rn();else if(h)G(`Silent redirect returned ${l} - treating as unauthenticated`),Rn();else{const d=c||`Authentication failed: ${l}`;G(`Non-silent auth error, alerting user: ${d}`),setTimeout(()=>{alert(d)},0)}}if(s)if(window.opener)G("Code found in URL, posting to opener"),window.opener.postMessage({type:"authorization_response",response:{code:s,state:u}},window.location.origin);else{G("Code found in URL, handling redirect");const c=window.location.href,f=new URL(location.href),h=f.searchParams;h.delete("code"),h.delete("state"),f.search=h.toString(),window.history.replaceState({},document.title,f.toString()),G("Rewrote url to remove code and state");try{const d=await _e.handleRedirectCallback(c);G(`Login result: ${JSON.stringify(d)}`);const p=await _e.getUser();if(!p)throw G("No user found"),new Error("No user found");G(`User found ${JSON.stringify(p)}`),oa(),On()&&(G("Successfully recovered session via prompt=none redirect"),Qr()),ln(!0),G(`Triggering AUTHENTICATED event with appState: ${JSON.stringify(d.appState)}`),Zt(Ge.AUTHENTICATED,{...p,appState:d.appState})}catch(d){G(`Error handling redirect: ${d.message}`),On()?(Qr(),Rn(),G("Silent redirect failed, cleared session hints")):alert("There was an error logging in"),console.error(d)}}Es=!0,Zt(Ge.AUTH_INITIALIZED,{})}async function Ot(){if(await aa(),await cc())return!0;if(!_e)return!1;const e=await _e.isAuthenticated();return e&&ln(!0),e}async function ky(){return await aa(),await cc()?(G("Using local user"),{sub:"local",name:"Local User"}):_e?_e.getUser():null}function Vp(t){if(_n)return G("Login already in progress"),null;if(_n=!0,setTimeout(()=>{_n=!1},3e3),localStorage.removeItem(Xt),!_e)throw new Error("Auth0 client not initialized");const e=t?.authorizationParams||{};return{...t,authorizationParams:{organization:oc,redirect_uri:window.location.href,ui_locales:Yr(),incognito:na(),...e}}}async function ia(t){const e=Vp(t);if(e)return _e.loginWithRedirect(e)}async function Jp(t){const e=Vp(t);if(!e)return;await _e.loginWithPopup(e,{timeoutInSeconds:1800}),oa(),ln(!0);const r=await _e.getUser();if(!r)throw G("No user found after popup login"),new Error("No user found");const n=new CustomEvent(Ge.AUTHENTICATED,{detail:{...r,appState:t?.appState},composed:!0,bubbles:!0});window.dispatchEvent(n)&&window.location.reload()}function _y(){if(!Xr)return!1;const t=Ht(window.location.href),e=Ht(`https://${Xr}`);return t!==e}async function Ty(t){return _y()&&(py()||vy()||na())?(G("Using popup login for cross-domain auth on Safari/Android/Incognito"),Jp(t)):(G("Using redirect login"),ia(t))}function Ry(){try{const t=sessionStorage.getItem(Ln);if(!t)return!1;const{timestamp:e}=JSON.parse(t);return Date.now()-e<my}catch{return sessionStorage.removeItem(Ln),!1}}function Oy(){try{const t={timestamp:Date.now()};sessionStorage.setItem(Ln,JSON.stringify(t))}catch{G("Failed to set silent auth throttle in sessionStorage")}}function oa(){try{sessionStorage.removeItem(Ln)}catch{}}async function Cy(){if(Tn){G("Silent redirect already in progress");return}if(!Wp()){G("No session hint cookie - skipping prompt=none redirect for anonymous user");return}const t=On();if(t&&Date.now()-t.timestamp<3e4){G("Recently attempted silent redirect, skipping to prevent loop");return}G("Attempting prompt=none redirect to recover session"),Tn=!0,yy();try{await _e.loginWithRedirect({authorizationParams:{prompt:"none",redirect_uri:window.location.href,organization:oc}})}catch(e){G(`Prompt=none redirect failed: ${e.message}`),Tn=!1,Qr()}}async function pt(t=!0,e=!1){await aa();const r=await cc();if(r)return r;if(!e&&Ry()){if(G("Silent auth is throttled due to recent failures, skipping request"),t)throw new Error("Silent auth throttled");return null}try{if(!_e)return G("Auth client not initialized"),null;let n=await _e.getTokenSilently();const a=lc(n),i=Date.now()/1e3;return e&&a?.exp&&a.exp-i<3600+Gp&&(n=await _e.getTokenSilently({cacheMode:"off"})),oa(),ln(!0),n}catch(n){const a=n;if(G(`Failed to get token silently: ${a.message}`),wy(a)){if(G("Iframe-based auth blocked by browser privacy restrictions"),Wp())return G("Session hint present - attempting prompt=none redirect recovery"),await Cy(),null;G("No session hint - user is likely anonymous, not attempting redirect")}if(Oy(),await _e.isAuthenticated()&&(a.message==="Invalid refresh token"||a.message.includes("Missing Refresh Token"))&&await uc(),t)throw n;return null}}async function uc(t={}){if(await aa(),localStorage.removeItem(Xt),localStorage.removeItem(zr),Rn(),Qr(),oa(),Zt(Ge.LOGOUT,{}),!!_e)return G(`Logout with options: ${JSON.stringify(t)}`),_e.logout({...t,logoutParams:{returnTo:window.location.href,...t.logoutParams}})}function lc(t){const e=t.split(".");if(e.length!==3)return null;const n=e[1].replace(/-/g,"+").replace(/_/g,"/"),a=decodeURIComponent(atob(n).split("").map(function(i){return"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(a)}async function ks(t){const e=lc(t);if(!e||!e.exp||e.exp<new Date().getTime()/1e3)throw new Error("Invalid token");G("Set token"),localStorage.setItem(Xt,t),Zt(Ge.AUTHENTICATED,{...e,appState:void 0})}const Ay=(t,e)=>e.skipDedupe||e.method!=="GET",$y=(t,e)=>e.method+"@"+t,Uy=t=>t.clone(),Ly=({skip:t=Ay,key:e=$y,resolver:r=Uy}={})=>{const n=new Map;return a=>(i,o)=>{if(t(i,o))return a(i,o);const s=e(i,o);if(!n.has(s))n.set(s,[]);else return new Promise((u,l)=>{n.get(s).push([u,l])});try{return a(i,o).then(u=>(n.get(s).forEach(([l])=>l(r(u))),n.delete(s),u)).catch(u=>{throw n.get(s).forEach(([,l])=>l(u)),n.delete(s),u})}catch(u){return n.delete(s),Promise.reject(u)}}},qy=(t,e)=>t*e,Ny=t=>t&&t.ok,xy=({delayTimer:t=500,delayRamp:e=qy,maxAttempts:r=10,until:n=Ny,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:s}={})=>u=>(l,c)=>{let f=0;if(s&&s(l,c))return u(l,c);const h=(d,p)=>Promise.resolve(n(d,p)).then(v=>v?d&&o?d:p?Promise.reject(p):d:(f++,!r||f<=r?new Promise(g=>{const P=e(t,f);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:d,error:p,url:l,options:c})).then((b={})=>{var y,m;g(u((y=b&&b.url)!==null&&y!==void 0?y:l,(m=b&&b.options)!==null&&m!==void 0?m:c))}):g(u(l,c))},P)}).then(h).catch(g=>{if(!i)throw g;return h(null,g)}):d&&o?d:Promise.reject(p||new Error("Number of attempts exceeded."))));return u(l,c).then(h).catch(d=>{if(!i)throw d;return h(null,d)})};let is=class Zp extends Error{status;statusText;url;body;constructor(e,r,n,a,i){super(a),this.name="APIError",this.status=e,this.statusText=r,this.url=n,this.body=i,Error.captureStackTrace&&Error.captureStackTrace(this,Zp)}isClientError(){return this.status>=400&&this.status<500}isServerError(){return this.status>=500}isForbiddenError(){return this.status===403}isNotFoundError(){return this.status===404}};var qn=(t=>(t.BROWSER="browser",t.NORMAL="normal",t))(qn||{});const jy="application/json",Yp="Content-Type",fr=Symbol(),Xp=Symbol();function Ld(t={}){var e;const r=t instanceof Array?Object.fromEntries(t):t;return(e=Object.entries(r).find(([n])=>n.toLowerCase()===Yp.toLowerCase()))===null||e===void 0?void 0:e[1]}function qd(t){return/^application\/.*json.*/.test(t)}const Bt=function(t,e,r=!1){return Object.entries(e).reduce((n,[a,i])=>{const o=t[a];return Array.isArray(o)&&Array.isArray(i)?n[a]=r?[...o,...i]:i:typeof o=="object"&&typeof i=="object"?n[a]=Bt(o,i,r):n[a]=i,n},{...t})},Sr={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,r=!1,...n){const a=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!a)throw new Error(t+" is not defined");return r&&a?new a(...n):a}};function Dy(t,e=!1){Sr.options=e?t:Bt(Sr.options,t)}function My(t,e=!1){Sr.polyfills=e?t:Bt(Sr.polyfills,t)}function Fy(t){Sr.errorType=t}const Ky=t=>e=>t.reduceRight((r,n)=>n(r),e)||e;let Qp=class extends Error{};const zy=t=>{const e=Object.create(null);t=t._addons.reduce((y,m)=>m.beforeRequest&&m.beforeRequest(y,t._options,e)||y,t);const{_url:r,_options:n,_config:a,_catchers:i,_resolvers:o,_middlewares:s,_addons:u}=t,l=new Map(i),c=Bt(a.options,n);let f=r;const h=Ky(s)((y,m)=>(f=y,a.polyfill("fetch")(y,m)))(r,c),d=new Error,p=h.catch(y=>{throw{[fr]:y}}).then(y=>{var m;if(!y.ok){const w=new Qp;if(w.cause=d,w.stack=w.stack+`
|
|
35
|
-
CAUSE: `+d.stack,w.response=y,w.status=y.status,w.url=f,y.type==="opaque")throw w;const R=a.errorType==="json"||((m=y.headers.get("Content-Type"))===null||m===void 0?void 0:m.split(";")[0])==="application/json";return(a.errorType?R?y.text():y[a.errorType]():Promise.resolve(y.body)).then(A=>{if(w.message=typeof A=="string"?A:y.statusText,A)if(R&&typeof A=="string"){w.text=A;try{w.json=JSON.parse(A)}catch{}}else w[a.errorType]=A;throw w})}return y}),v=y=>y.catch(m=>{const w=Object.prototype.hasOwnProperty.call(m,fr),R=w?m[fr]:m,A=R?.status&&l.get(R.status)||l.get(R?.name)||w&&l.has(fr)&&l.get(fr);if(A)return A(R,t);const j=l.get(Xp);if(j)return j(R,t);throw R}),g=y=>m=>v(y?p.then(w=>w&&w[y]()).then(w=>m?m(w):w):p.then(w=>m?m(w):w)),P={_wretchReq:t,_fetchReq:h,_sharedState:e,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(y,m){return l.set(y,m),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(fr,y)}},b=u.reduce((y,m)=>({...y,...typeof m.resolver=="function"?m.resolver(y):m.resolver}),P);return o.reduce((y,m)=>m(y,t),b)},Hy={_url:"",_options:{},_config:Sr,_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:Bt(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+t+"?"+r[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:Bt(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:Bt(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Yp]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const r=new Map(this._catchers);return r.set(t,e),{...this,_catchers:r}},catcherFallback(t){return this.catcher(Xp,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="",r=null){let n=this.url(e).options({method:t});const a=Ld(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||qd(a));return n=r?o?n.json(r,a):n.body(r):n,zy(n._deferred.reduce((s,u)=>u(s,s._url,s._options),n))},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 r=Ld(this._options.headers);return this.content(e||qd(r)&&r||jy).body(JSON.stringify(t))}};function ut(t="",e={}){return{...Hy,_url:t,_options:e}}ut.default=ut;ut.options=Dy;ut.errorType=Fy;ut.polyfills=My;ut.WretchError=Qp;const By=(t,e)=>e.skipDedupe||e.method!=="GET",Gy=(t,e)=>e.method+"@"+t,Wy=t=>t.clone(),Vy=({skip:t=By,key:e=Gy,resolver:r=Wy}={})=>{const n=new Map;return a=>(i,o)=>{if(t(i,o))return a(i,o);const s=e(i,o);if(!n.has(s))n.set(s,[]);else return new Promise((u,l)=>{n.get(s).push([u,l])});try{return a(i,o).then(u=>(n.get(s).forEach(([l])=>l(r(u))),n.delete(s),u)).catch(u=>{throw n.get(s).forEach(([,l])=>l(u)),n.delete(s),u})}catch(u){return n.delete(s),Promise.reject(u)}}},Jy=(t,e)=>e.skipCache||e.method!=="GET",Zy=(t,e)=>e.method+"@"+t,Yy=()=>!1,Xy=()=>null,Qy=t=>t.ok,ew=({throttle:t=1e3,skip:e=Jy,key:r=Zy,clear:n=Yy,invalidate:a=Xy,condition:i=Qy,flagResponseOnCacheHit:o="__cached"}={})=>{const s=new Map,u=new Map,l=new Set,c=h=>{t&&!l.has(h)&&(l.add(h),setTimeout(()=>{l.delete(h)},t))},f=h=>(d,p)=>{const v=r(d,p);let g=a(d,p);if(g&&(g instanceof Array||(g=[g]),g.forEach(P=>{typeof P=="string"?s.delete(P):P instanceof RegExp&&s.forEach((b,y)=>{P.test(y)&&s.delete(y)})})),n(d,p)&&s.clear(),e(d,p))return h(d,p);if(l.has(v)){if(s.has(v)){const P=s.get(v).clone();return o&&Object.defineProperty(P,o,{value:v,enumerable:!1}),Promise.resolve(P)}else if(u.has(v))return new Promise((P,b)=>{u.get(v).push([P,b])})}return u.has(v)||u.set(v,[]),c(v),h(d,p).then(P=>(i(P.clone())&&s.set(v,P.clone()),u.get(v).forEach(([b])=>b(P.clone())),u.delete(v),P)).catch(P=>{throw u.get(v).forEach(([,b])=>b(P)),u.delete(v),P})};return f.cacheResponse=function(h,d){c(h),s.set(h,d)},f.cache=s,f.inflight=u,f.throttling=l,f},tw=(t,e)=>t*e,rw=t=>t&&t.ok,nw=({delayTimer:t=500,delayRamp:e=tw,maxAttempts:r=10,until:n=rw,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:s}={})=>u=>(l,c)=>{let f=0;if(s&&s(l,c))return u(l,c);const h=(d,p)=>Promise.resolve(n(d,p)).then(v=>v?d&&o?d:p?Promise.reject(p):d:(f++,!r||f<=r?new Promise(g=>{const P=e(t,f);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:d,error:p,url:l,options:c})).then((b={})=>{var y,m;g(u((y=b&&b.url)!==null&&y!==void 0?y:l,(m=b&&b.options)!==null&&m!==void 0?m:c))}):g(u(l,c))},P)}).then(h).catch(g=>{if(!i)throw g;return h(null,g)}):d&&o?d:Promise.reject(p||new Error("Number of attempts exceeded."))));return u(l,c).then(h).catch(d=>{if(!i)throw d;return h(null,d)})},aw="@sesamy/sdk",iw="1.23.0";let ow=class{cache=new Map;get(e){return this.cache.get(e)||null}set(e,r){this.cache.set(e,r)}remove(e){this.cache.delete(e)}clear(){this.cache.clear()}};const Hr="sesamyCacheTimestamp",sw=t=>{const{libraryName:e=aw,libraryVersion:r=iw,cache:n}=t,a=n?.storage||new ow,i=[s=>async(u,l)=>{if(n?.mode===qn.BROWSER){let c;typeof sessionStorage<"u"?(c=sessionStorage.getItem(Hr),c||(c=Date.now().toString(),sessionStorage.setItem(Hr,c))):(c=a.get(Hr),c||(c=Date.now().toString(),a.set(Hr,c)));const f={...l,headers:{...l.headers,"Cache-Timestamp":c}};return s(u,f)}return s(u,l)},s=>async(u,l)=>{const c=await t.tokenProvider(),f={...l,headers:{...l.headers,Authorization:c}};return s(u,f)},Vy()];n?.mode===qn.NORMAL&&i.push(ew({throttle:300*1e3,skip:(s,u)=>u.method!=="GET"})),i.push(nw({delayTimer:1e3,delayRamp:(s,u)=>s*u,maxAttempts:3,until:s=>!!(s&&(s.ok||s.status>=400&&s.status<500)),retryOnNetworkError:!1}));const o=ut(t.baseUrl).headers({"Content-Type":"application/json","X-Sesamy-Client":`${e}/${r}`,...t.headers}).middlewares(i);return{async request(s,u={}){try{const l=/^https?:\/\//.test(s);let c=o.url(s,l);u.headers&&(c=c.headers(u.headers));const f=(u.method||"GET").toLowerCase();let h;switch(f){case"get":h=c.get();break;case"post":h=c.post(u.body);break;case"put":h=c.put(u.body);break;case"patch":h=c.patch(u.body);break;case"delete":h=c.delete();break;default:h=c.get()}const d=await h.res();if(d.ok&&["post","patch","put","delete"].includes(f)&&mt(),d.status===204)return null;if(!d.ok){const p=await d.text().catch(()=>"Unknown error");throw new is(d.status,d.statusText,d.url,`API Error ${d.status}: ${p}`,p)}return await d.json()}catch(l){if(l instanceof is)throw l;const c=l.status||500,f=l.message||"Unknown error",h=`${t.baseUrl}${s}`;throw new is(c,f,h,`API Error ${c}: ${l.message||"Unknown error"}`,l.message||"Unknown error")}}}},mt=()=>(typeof sessionStorage<"u"&&sessionStorage.removeItem(Hr),"Cache cleared"),Mr={get:async(t,e)=>t.request(`/profile/${e}`),update:async(t,e,r)=>t.request(`/profile/${e}`,{method:"PATCH",body:JSON.stringify(r)}),checkSpotifyLink:async t=>t.request("/profile/spotify-link"),unlinkSpotify:async t=>t.request("/profile/unlink-spotify",{method:"POST"}),delete:async t=>{await t.request("/profile",{method:"DELETE"})}},os={list:async(t,e)=>{const r=new URLSearchParams;e?.type&&r.append("type",e.type),e?.sku&&r.append("sku",e.sku),e?.purchaseOptionId&&r.append("purchase-option-id",e.purchaseOptionId),e?.waitForEntitlementAfter&&r.append("wait-for-entitlement-after",e.waitForEntitlementAfter);const n=r.toString(),a=n?`/entitlements?${n}`:"/entitlements";return t.request(a)},get:async(t,e)=>t.request(`/entitlements/${e}`),getAccess:async(t,e)=>t.request(`/entitlements/${e}/access`)},Nd={list:async t=>t.request("/subscriptions"),get:async(t,e)=>t.request(`/subscriptions/${e}`)},xd={get:async(t,e)=>t.request(`/products/${e}`),autoOnboard:async(t,e)=>t.request(`/products/${e}/auto-onboard`,{method:"POST"})},cw=(t,e)=>{if(!t||!e)return t;const r=new URL(t);return r.hash=`access_token=${e}`,r.toString()},jd=(t,e)=>!t.manageUrl||!e?t:{...t,manageUrl:cw(t.manageUrl,e)},Fr={list:async t=>t.request("/contracts"),get:async(t,e)=>t.request(`/contracts/${e}`),cancel:async(t,e)=>t.request(`/contracts/${e}/cancel`,{method:"POST"}),createAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments`,{method:"POST",body:JSON.stringify(r)}),confirmAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments/${r}/confirm`,{method:"POST"})},ss={get:async t=>t.request("/user-metadata"),set:async(t,e,r)=>{await t.request(`/user-metadata/${e}`,{method:"PUT",body:r})},delete:async(t,e)=>{await t.request(`/user-metadata/${e}`,{method:"DELETE"})}},dr={list:async t=>t.request("/tallies"),get:async(t,e)=>t.request(`/tallies/${e}`),update:async(t,e,r)=>t.request(`/tallies/${e}`,{method:"PUT",body:JSON.stringify(r)}),create:async(t,e)=>t.request("/tallies",{method:"POST",body:JSON.stringify(e)}),delete:async(t,e)=>{try{return await t.request(`/tallies/${e}`,{method:"DELETE"}),!0}catch{return!1}},push:async(t,e,r)=>t.request(`/tallies/${e}/push`,{method:"POST",body:JSON.stringify(r)})},cs={list:async t=>t.request("/tags"),add:async(t,e)=>{await t.request("/tags",{method:"POST",body:JSON.stringify({tag:e})})},remove:async(t,e)=>{await t.request(`/tags/${e}`,{method:"DELETE"})}},hr={generateCheckoutLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},generateAccountLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}${e.contractId?`/${encodeURIComponent(e.contractId)}`:""}`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePaymentLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/change-payment-method`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePlanLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/edit-plan`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateConsumeLink:(t,e)=>{const r=e.language||"en";let n=new URL(`${t.baseUrl}/consume/${encodeURIComponent(r)}/@${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.sku)}`);return e.episodeId?n.href+=`/${encodeURIComponent(e.episodeId)}`:n.href+="/listen",n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()}},us={generateLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},create:async(t,e)=>t.request("/checkouts",{method:"POST",body:JSON.stringify(e)}),get:async(t,e)=>t.request(`/checkouts/${e}`),update:async(t,e,r)=>t.request(`/checkouts/${e}`,{method:"PATCH",body:JSON.stringify(r)})},Dd={list:async t=>t.request("/bills"),get:async(t,e)=>t.request(`/bills/${e}`)},Md={list:async t=>t.request("/fulfillments"),create:async(t,e)=>t.request("/fulfillments",{method:"POST",body:JSON.stringify(e)})},uw={get:async(t,e)=>{try{return new URL(e),t.request(e)}catch{return t.request(`/paywalls/${e}`)}}},lw={list:async t=>t.request("/payment-issues")},fw={content:async(t,e,r,n,a)=>{const i=new URLSearchParams({url:e});return r&&i.append("selector",r),n&&i.append("cache",n),t.request(`/proxy?${i.toString()}`,a)}},dw={list:async(t,e)=>{const r=(e?new URLSearchParams({q:e}):new URLSearchParams).toString(),n=r?`/transactions?${r}`:"/transactions";return t.request(n)}},Fd={get:async t=>t.request("/vendor"),list:async t=>t.request("/vendors")},hw=t=>{const e=sw(t);return{profile:{get:r=>Mr.get(e,r),update:(r,n)=>Mr.update(e,r,n),checkSpotifyLink:()=>Mr.checkSpotifyLink(e),unlinkSpotify:()=>Mr.unlinkSpotify(e),delete:()=>Mr.delete(e)},entitlements:{list:r=>os.list(e,r),get:r=>os.get(e,r),getAccess:r=>os.getAccess(e,r)},subscriptions:{list:()=>Nd.list(e),get:r=>Nd.get(e,r)},products:{get:r=>xd.get(e,r),autoOnboard:r=>xd.autoOnboard(e,r)},contracts:{list:async()=>{const r=await Fr.list(e),n=await t.tokenProvider();if(!n.toLowerCase().startsWith("bearer "))return r;const a=n.substring(7);return r.map(i=>jd(i,a))},get:async r=>{const n=await Fr.get(e,r),a=await t.tokenProvider();if(!a.toLowerCase().startsWith("bearer "))return n;const i=a.substring(7);return jd(n,i)},cancel:r=>Fr.cancel(e,r),createAmendment:(r,n)=>Fr.createAmendment(e,r,n),confirmAmendment:(r,n)=>Fr.confirmAmendment(e,r,n)},userMetadata:{get:()=>ss.get(e),set:(r,n)=>ss.set(e,r,n),delete:r=>ss.delete(e,r)},tallies:{list:()=>dr.list(e),get:r=>dr.get(e,r),update:(r,n)=>dr.update(e,r,n),create:r=>dr.create(e,r),delete:r=>dr.delete(e,r),push:(r,n)=>dr.push(e,r,n)},tags:{list:()=>cs.list(e),add:r=>cs.add(e,r),remove:r=>cs.remove(e,r)},checkouts:{generateLink:(r,n)=>hr.generateCheckoutLink(r,n),create:r=>us.create(e,r),get:r=>us.get(e,r),update:(r,n)=>us.update(e,r,n)},links:{generateCheckoutLink:(r,n)=>hr.generateCheckoutLink(r,n),generateAccountLink:(r,n)=>hr.generateAccountLink(r,n),generateChangePaymentLink:(r,n)=>hr.generateChangePaymentLink(r,n),generateChangePlanLink:(r,n)=>hr.generateChangePlanLink(r,n),generateConsumeLink:(r,n)=>hr.generateConsumeLink(r,n)},bills:{list:()=>Dd.list(e),get:r=>Dd.get(e,r)},fulfillments:{list:()=>Md.list(e),create:r=>Md.create(e,r)},paywalls:{get:r=>uw.get(e,r)},paymentIssues:{list:()=>lw.list(e)},proxy:{content:(r,n,a,i)=>fw.content(e,r,n,a,i)},transactions:{list:r=>dw.list(e,r)},vendor:{get:()=>Fd.get(e),list:()=>Fd.list(e)}}};class pw{get(e){return typeof sessionStorage>"u"?null:sessionStorage.getItem(e)}set(e,r){typeof sessionStorage<"u"&&sessionStorage.setItem(e,r)}remove(e){typeof sessionStorage<"u"&&sessionStorage.removeItem(e)}clear(){}}function _s(t){let e;try{e=new URL(t)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function ev(t,e){if(_s(t))return{itemSrc:t};const r=t.split(":");if(r.length<2)throw new Error(`Invalid itemSrc format: expected at least 2 segments separated by ':', got ${r.length}`);const[n,a,i]=r;if(!a)throw new Error("Invalid itemSrc format: sku segment is empty");return{sku:`${n}:${a}`,purchaseOption:e||i}}function Kd(t){return t.endsWith("/")?t.slice(0,-1):t}function zd(t,e){if(!_s(t)||!_s(e))return!1;const r=new URL(t),n=new URL(e);return r.origin===n.origin&&Kd(r.pathname)===Kd(n.pathname)}function vw(t,e,r){const n=new URL(`${rt("checkout3",t.environment)}`);e.language&&n.searchParams.set("lang",e.language);let a=e.sku,i=e.purchaseOptionId,o=e.itemSrc;if(e.itemSrc){const c=ev(e.itemSrc,e.purchaseOptionId);a=c.sku||a,i=c.purchaseOption||i,o=c.itemSrc}a?(n.searchParams.set("sku",a),i&&n.searchParams.set("po-id",i)):o&&n.searchParams.set("url",o),e.email&&n.searchParams.set("email",e.email),e.business&&n.searchParams.set("business","true"),e.currency&&n.searchParams.set("currency",e.currency),e.price&&n.searchParams.set("price",e.price.toString()),e.discountCode&&n.searchParams.set("discount-code",e.discountCode),e.attributionItemSrc?n.searchParams.set("itemSrc",e.attributionItemSrc):r.itemSrc&&n.searchParams.set("itemSrc",r.itemSrc),e.attributionPublisherContentId?n.searchParams.set("publisherContentId",e.attributionPublisherContentId):r.publisherContentId&&n.searchParams.set("publisherContentId",r.publisherContentId),e.utmSource?n.searchParams.set("utm_source",e.utmSource):r.utmSource&&n.searchParams.set("utm_source",r.utmSource),e.utmMedium?n.searchParams.set("utm_medium",e.utmMedium):r.utmMedium&&n.searchParams.set("utm_medium",r.utmMedium),e.utmCampaign?n.searchParams.set("utm_campaign",e.utmCampaign):r.utmCampaign&&n.searchParams.set("utm_campaign",r.utmCampaign),e.utmTerm?n.searchParams.set("utm_term",e.utmTerm):r.utmTerm&&n.searchParams.set("utm_term",r.utmTerm),e.utmContent?n.searchParams.set("utm_content",e.utmContent):r.utmContent&&n.searchParams.set("utm_content",r.utmContent);const s=["_ga","_gid","_fbp","_fbc"];document.cookie.split(";").map(c=>{const[f,h]=c.trim().split("=");return{key:f,value:h}}).filter(c=>s.some(f=>f===c.key)).forEach(c=>{n.searchParams.append(c.key,c.value)});let l=new URL(window.location.href);if(e.redirectUrl)try{l=new URL(e.redirectUrl)}catch{console.warn("Invalid redirect URL provided, using current URL instead:",e.redirectUrl)}return l.searchParams.set("force-refetch-entitlements","true"),e.itemSrc&&l.searchParams.set("sesamy-purchase",e.itemSrc),n.searchParams.set("redirect-url",l.toString()),e.paymentMethodsFilter&&n.searchParams.set("paymentmethods-filter",e.paymentMethodsFilter.flatMap(({provider:c,methods:f})=>f?f.map(h=>`${c}|${h}`):c).join(",")),e.requireAddress&&n.searchParams.set("require-address","true"),e.giftMode&&n.searchParams.set("gift-mode","true"),e.payerEmail&&n.searchParams.set("payer-email",e.payerEmail),e.metadata&&Object.entries(e.metadata).forEach(([c,f])=>{n.searchParams.set(`metadata.${c}`,String(f))}),n}const tv="sesamySignedURLs";function fc(){const t=sessionStorage.getItem(tv);return t?JSON.parse(t):[]}function mw(t){const e=fc();e.push(t),G(`Adding signed URL: ${t}`),sessionStorage.setItem(tv,JSON.stringify(e))}function gw(t){const e={};return Object.keys(t).forEach(r=>{const n=t[r];n!=null&&(e[r]=n.toString())}),e}const Ts="sesamyAttribution";function yw(t){const e=localStorage.getItem(t);if(!e)return null;try{return JSON.parse(e).value}catch{return console.error(`Failed to parse ${t}`),null}}function ww(t){return Object.keys(t).find(e=>e.startsWith("utm_"))?{utmSource:void 0,utmMedium:void 0,utmCampaign:void 0,...t}:t}function Nn(){return yw(Ts)||{}}function rv(t){if(t===null)localStorage.removeItem(Ts);else{G(`Setting attribution ${JSON.stringify(t)}`);const e=Nn()??{},r=gw({...e,...ww(t)});localStorage.setItem(Ts,JSON.stringify({value:r}))}}const dc="@sesamy/sesamy-js",fn="1.85.0",nv="sesamyFlags";async function av(t){try{localStorage.setItem(nv,JSON.stringify(t))}catch{G("Failed to save flags to localStorage")}}async function iv(t,e){const r=await dn();r[t]=e,await av(r)}async function ov(t){return(await dn())[t]}async function sv(t){const e=await dn();t in e&&(delete e[t],await av(e))}async function dn(){try{const t=localStorage.getItem(nv);return t?JSON.parse(t):{}}catch{return{}}}function cv(t){function e(n){return n.id?`#${n.id}`:n.classList.length>0?Array.from(n.classList).map(i=>`.${i}`).join(""):null}function r(n){const a=[];let i=n;for(;i&&i!==document.body&&i!==document.documentElement;){const o=e(i);if(o){a.unshift(o);break}if(i.parentElement){const s=Array.from(i.parentElement.children),u=s.indexOf(i)+1,l=i.tagName.toLowerCase();s.filter(f=>f.tagName.toLowerCase()===l).length>1?a.unshift(`${l}:nth-child(${u})`):a.unshift(l)}i=i.parentElement}return a.join(" > ")}return r(t)}function uv(t){return t?Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0)):{}}function bw(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}let Ke={article:{selector:"sesamy-article"},image:{selector:"img",attribute:"src"},title:{selector:"h1",attribute:"textContent"},excerpt:{selector:"p",attribute:"textContent"},price:{selector:"sesamy-article",attribute:"price"},currency:{selector:"sesamy-article",attribute:"currency"},url:{selector:"sesamy-article",attribute:"item-src"},accessLevel:{selector:"sesamy-article",attribute:"access-level"},id:{selector:"sesamy-article",attribute:"publisher-content-id"},pass:{selector:"sesamy-article",attribute:"pass"},paywallUrl:{selector:"sesamy-article",attribute:"paywall-url"}},lv=[],fv=!1,Rt;function hc(){const t=window.location.pathname,e=new URLSearchParams(window.location.search),r=navigator.userAgent;return lv.find(n=>{if(n.path&&!t.includes(n.path)||n.queryParam&&e.get(n.queryParam.key)!==n.queryParam.value)return!1;if(n.headers){const a=n.headers.name.toLowerCase(),i=n.headers.contains.toLowerCase();if(a==="user-agent"){if(!r.toLowerCase().includes(i))return!1}else return!1}return!(n.userAgentContains&&!r.includes(n.userAgentContains))})}function Sw(){return hc()}function Iw(t,e){lv=t.content||[];const r=hc();r&&r.type==="article"&&(Ke={...Ke,...uv(r.selectors)},fv=r.enablePaywallSettingsUrlFallback||!1),Rt=e}function Pw(t,e){const{selector:r,attribute:n}=e;return r===Ke.article.selector||n&&t.hasAttribute(n)?t:t.querySelector(r)}function dv(t,e,r=!1){if(t){if(e.attribute){if(e.attribute==="textContent")return t.textContent??void 0;const n=t.getAttribute(e.attribute),a=dv(t.parentElement,e,r);if(r){const i=[];return n&&i.push(...n.split(",").map(o=>o.trim()).filter(Boolean)),a&&i.push(...a.split(",").map(o=>o.trim()).filter(Boolean)),i.length>0?[...new Set(i)].join(","):void 0}return n??a}return t.textContent??void 0}}function ge(t){const e=document.head.querySelectorAll(`[property~='${t}'][content]`);for(let n=0;n<e.length;n+=1)if(e[n].content)return e[n].content;const r=document.head.querySelectorAll(`[name~='${t}'][content]`);for(let n=0;n<r.length;n+=1)if(r[n].content)return r[n].content}function Br(t){const e=[];return document.head.querySelectorAll(`[property~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),document.head.querySelectorAll(`[name~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),e}let Gr=null;function hv(){const t=[],e=document.querySelectorAll('script[type="application/ld+json"]');for(const r of e)try{const n=JSON.parse(r.textContent||"");Array.isArray(n)?t.push(...n):n["@graph"]&&Array.isArray(n["@graph"])?t.push(...n["@graph"]):t.push(n)}catch{}return t}function Wr(t){const e=hv(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.find(r)||null}function Ew(t){const e=hv(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.filter(r)}function Rs(t,e,r){if(!t||typeof t!="object")return typeof t=="string"?t:void 0;const a=t[e];if(typeof a=="string")return a;if(a&&typeof a=="object"&&r)return a[r]}function kw(t){if(!t)return;const r=(Array.isArray(t)?t:[t]).map(n=>{if(typeof n=="string")return{name:n};if(typeof n=="object"&&n!==null){const a=n,i=a.name;return i?{name:i,url:a.url,image:Rs(a,"image","url"),jobTitle:a.jobTitle,sameAs:a.sameAs}:null}return null}).filter(n=>n!==null&&!!n.name);return r.length>0?r:void 0}function ls(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string"){const e=t.split(",").map(r=>r.trim()).filter(Boolean);return e.length>0?e:void 0}}function pv(){if(Gr)return Gr;const t=Wr("NewsArticle")||Wr("Article")||Wr("BlogPosting")||Wr("WebPage"),e=(...a)=>a.find(i=>i!=null&&i!=="")||void 0,r=(...a)=>a.find(i=>i&&i.length>0),n={contentType:t?Array.isArray(t["@type"])?t["@type"][0]:t["@type"]:void 0,authors:kw(t?.author)||(Br("article:author").length>0?Br("article:author").map(a=>({name:a})):void 0)||(ge("author")?[{name:ge("author")}]:void 0),keywords:r(ls(t?.keywords),ls(ge("keywords"))),tags:Br("article:tag").length>0?Br("article:tag"):void 0,categories:ls(ge("news_keywords")),section:e(t?.articleSection,ge("article:section")),publishedAt:e(t?.datePublished,ge("article:published_time")),modifiedAt:e(t?.dateModified,ge("article:modified_time")),ogType:ge("og:type"),ogSiteName:ge("og:site_name"),ogLocale:ge("og:locale"),twitterCard:ge("twitter:card"),twitterSite:ge("twitter:site"),twitterCreator:ge("twitter:creator"),creator:e(ge("creator"),ge("dc.creator")),mainEntityOfPage:t?Rs(t.mainEntityOfPage,"@id")||(typeof t.mainEntityOfPage=="string"?t.mainEntityOfPage:void 0):void 0,isAccessibleForFree:typeof t?.isAccessibleForFree=="boolean"?t.isAccessibleForFree:void 0,wordCount:typeof t?.wordCount=="number"?t.wordCount:void 0,publisher:t?.publisher&&typeof t.publisher=="object"?{name:t.publisher.name||"",url:t.publisher.url,logo:Rs(t.publisher,"logo","url")}:void 0};return Gr=uv(n),Gr}function _w(){Gr=null}function pc({publisherContentId:t,key:e,defaultValue:r=""}){const n=t?document.body.querySelector(`sesamy-content-data[id='${t}']`):null,a=e.replace(/-([a-z])/g,(i,o)=>o.toUpperCase());return n?.getAttribute(e)||ge(`sesamy:${e}`)||ge(`sesamy:${a}`)||ge(`og:${e}`)||ge(e)||r}function vv(){const t=document.querySelectorAll(Ke.article.selector);return Array.from(t).map(hn).filter(e=>e!==null)}function hn(t){const e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;const r={element:e,selector:typeof t=="string"?t:cv(e)},n=(i,o,s,u)=>{const{transform:l,collect:c=!1}=u||{},f=Pw(e,o),h=dv(f,o,c),d=pc({publisherContentId:s,key:bw(String(i))}),p=h||d||void 0;p&&(r[i]=l?l(p):p)};n("id",Ke.id),n("title",Ke.title,r.id),n("excerpt",Ke.excerpt,r.id),n("image",Ke.image,r.id),n("price",Ke.price,r.id,{transform:i=>{const o=parseFloat(i);return Number.isNaN(o)?void 0:o}}),n("currency",Ke.currency,r.id),n("url",Ke.url,r.id),n("pass",Ke.pass,r.id,{collect:!0}),n("paywallUrl",Ke.paywallUrl,r.id),n("accessLevel",Ke.accessLevel,r.id,{transform:i=>i||"entitlement"});const a=hc();if(a&&a.type==="article"&&(a.pass&&(r.pass=r.pass?`${r.pass},${a.pass}`:a.pass),a.price&&!r.price&&(r.price=a.price.amount),a.price?.currency&&!r.currency&&(r.currency=a.price.currency),a.paywallUrl&&!r.paywallUrl&&(r.paywallUrl=a.paywallUrl)),fv&&!r.paywallUrl){const i=document.querySelector("sesamy-paywall");if(i){const o=i.getAttribute("settings-url");o&&(r.paywallUrl=o)}}return r.url||(r.url=window.location.href),r.metadata=pv(),r}async function Tw(t){const e=hn(t);if(!e)throw new Error("Could not find article element");if(e.accessLevel==="public")return!0;if(e.accessLevel==="logged-in"&&!e.paywallUrl)return await Rt.auth.isAuthenticated()?!0:null;if(e.paywallUrl&&((await Rt.paywalls.get(e.paywallUrl)).settings.template==="LOGIN"?"logged-in":"entitlement")==="logged-in")return await Rt.auth.isAuthenticated()?!0:null;if(!e.url)throw new Error("Article must have a URL");return await Rt.entitlements.hasAccess(e.url,e.pass?.split(",")||[])||null}async function mv(t,e){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error("Could not find element");const n=hn(r);if(!n?.url)throw new Error("Could not find content for element");const a=await Rt.entitlements.hasAccess(n.url,n.pass?.split(",")||[]);if(!a)throw new Error("User does not have access to the content");const i=await Rt.entitlements.access(a.id);if(!i.token)throw new Error("Could not get access token");const o=e||cv(r.parentElement||r);return Rt.proxy.getContent(i.token,n.url,o)}function gv(t,e={}){const{closeOnBackdropClick:r=!0,closeOnEscape:n=!0,zIndex:a=2147483647,backdropBlur:i="5px",overlayBackground:o="rgba(0,0,0,0.5)"}=e,s=document.createElement("div");s.setAttribute("data-sesamy-modal","true"),Object.assign(s.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",background:o,zIndex:String(a),display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:`blur(${i})`});const u=document.createElement("div");u.setAttribute("data-sesamy-modal-content","true"),typeof t=="string"?u.innerHTML=t:u.appendChild(t),s.appendChild(u);const l=()=>{s.remove(),n&&document.removeEventListener("keydown",c)},c=f=>{f.key==="Escape"&&l()};return r&&s.addEventListener("click",f=>{f.target===s&&l()}),n&&document.addEventListener("keydown",c),document.body.appendChild(s),{element:s,close:l}}function Rw(t,e={}){const{position:r="top",fixed:n=!0,zIndex:a=2147483647,autoDismissMs:i,pushContent:o=!1,height:s,transitionDuration:u="0.3s"}=e,l=document.createElement("div");l.setAttribute("data-sesamy-notification-bar","true"),l.setAttribute("data-sesamy-notification-position",r),Object.assign(l.style,{position:n?"fixed":"absolute",[r]:"0",left:"0",width:"100%",zIndex:String(a),boxSizing:"border-box",...s&&{height:s}}),typeof t=="string"?l.innerHTML=t:l.appendChild(t);let c,f,h;const d=()=>{if(h&&clearTimeout(h),o&&s){const p=document.documentElement;p.style.transform=c||"",setTimeout(()=>{l.remove(),p.style.transition=f||""},parseFloat(u)*1e3)}else l.remove()};if(i&&(h=setTimeout(d,i)),o&&s){const p=document.documentElement;c=p.style.transform,f=p.style.transition,p.style.transition=`transform ${u} ease`,l.style.transition=`transform ${u} ease`,r==="top"?(p.style.transform=`translateY(${s})`,l.style.transform=`translateY(-${s})`):(p.style.transform=`translateY(-${s})`,l.style.transform=`translateY(${s})`),document.documentElement.prepend(l)}else document.body.appendChild(l);return{element:l,close:d}}function Ow(t){const e=t.endpoint||rt("api2",t.environment),n=hw({baseUrl:e,tokenProvider:async()=>{if(await Ot())try{const q=await pt(!1);if(q)return`Bearer ${q}`}catch{}const S=localStorage.getItem("__anon_id");return`Basic ${btoa(`${t.vendorId||t.clientId}|${S}:`)}`},libraryName:dc,libraryVersion:fn,vendorId:t.vendorId,cache:{mode:qn.BROWSER,storage:new pw}}),a=S=>async(O,q)=>{let F=sessionStorage.getItem($d);F||(F=Date.now().toString(),sessionStorage.setItem($d,F));const I={...q,headers:{...q.headers,"Cache-Timestamp":F}};return S(O,I)},i=(S=!0)=>O=>async(q,F)=>{let I=null;if(I=await pt(S),!I){if(S)throw new Error("No access token available");return O(q,F)}const _={...F,headers:{...F.headers,...I?{Authorization:`Bearer ${I}`}:{}}};return O(q,_)},o=ut(e).headers({"Content-Type":"application/json"}).middlewares([a,i(),Ly(),xy({delayTimer:1e3,delayRamp:(S,O)=>S*O,maxAttempts:3,until:S=>!!(S&&(S.ok||S.status>=400&&S.status<500)),retryOnNetworkError:!1})]);async function s(S={}){const{waitForEntitlementAfter:O,includeSignedLinks:q=!0}=S,F=await Ot()?await n.entitlements.list({waitForEntitlementAfter:O?.toISOString()}):[];return q&&F.push(...fc()),F}async function u(S,O=[]){return(await s())?.find(I=>{if(S){const{sku:_,purchaseOption:x}=ev(S);if("sku"in I&&_===I.sku||x&&"purchaseOptionsId"in I&&x===I.purchaseOptionsId||zd(S,I.url))return!0}return!!O.some(_=>zd(_,I.url))})}async function l(S,O,q){const F=new URL(rt("api2",t.environment));return F.pathname="/proxy",F.searchParams.set("url",O),q&&F.searchParams.set("selector",q),ut(F.toString()).headers({Authorization:`Bearer ${S}`}).get().text()}async function c(S){if(!S)throw new Error("SKU is required to get fulfillments");return await Ot()?await o.get(`/fulfillments?sku=${encodeURIComponent(S)}`).json():[]}async function f(S,O){if(!S||!O)throw new Error("SKU and itemId are required to request delivery");return(await o.post({sku:S},`/fulfillments/${encodeURIComponent(O)}/request-delivery?`).res()).ok}async function h(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),o.get("/subscriptions").json()}async function d(S){return(await n.transactions.list())?.find(q=>q.id===S)}async function p(){return await o.url("/tags").get().json()}async function v(S){const O=await o.url(`/tags/${encodeURIComponent(S)}`).delete().res();return mt(),O.ok}async function g(S){const O=await o.url("/tags").post(encodeURIComponent(S)).res();return Zt(Ge.USER_ATTRIBUTE_CHANGED,{}),mt(),O.ok}async function P(S){return(await n.tallies.get(S)).value}async function b(){const S=await n.tallies.list(),O={};for(const q of S)O[q.id]=q.value;return O}async function y(S){return await n.tallies.delete(S)}async function m(S,O){return await n.tallies.push(S,O)}async function w(){return await pt(!1)?await o.url("/profile").get().json():null}async function R(S){const O=await o.url("/profile").patch(S).res();return mt(),O.ok}async function A(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function j(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function K(S){const O=await pt(!1);if(!O)throw new Error("No access token available");const q=new URL(`${rt("access-sync",t.environment)}/spotify/sesamy-callback`);q.searchParams.set("access_token",O),q.searchParams.set("state",S),window.location.href=q.toString()}async function B(S){const O=await o.url(`/products/${encodeURIComponent(S)}/auto-onboard`).post().json();return O.length&&mt(),O}async function re(S,O=3600){const{shortlink:q}=await ut(fy).post({url:S,ttl:O}).json();return q}async function L(S){const O=await pt(!1,!0);let q;const F=S.language||Yr(),I=Nn();switch(S.target){case"account":q=new URL(`${rt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}${S.contractId?`/${encodeURIComponent(S.contractId)}`:""}`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-payment":q=new URL(`${rt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/change-payment-method`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-plan":q=new URL(`${rt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/edit-plan`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"consume":q=new URL(`${rt("consume",t.environment)}/${encodeURIComponent(S.language||F)}/@${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.sku)}`),S.episodeId?q.href+=`/${S.episodeId}`:q.href+="/listen",q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"checkout":q=vw(t,{language:F,...S},I);break;default:throw new Error("Invalid target")}return O&&(q.hash=`#access_token=${O}`),S.shorten?re(q.href,S.ttl):q.href}async function M(){const S=await pt(!1),O=new URL(`${rt("account",t.environment)}/subscriptions/${t.vendorId||t.clientId}`);S&&(O.hash=`#access_token=${S}`),window.location.href=O.toString()}async function N(S){const O=Nn(),q=["_ga","_gid","_fbp","_fbc"];return document.cookie.split(";").forEach(F=>{const[I,_]=F.trim().split("=");q.includes(I)&&!O[I]&&(O[I]=_)}),n.checkouts.create({language:Yr(),...S,attribution:{...O,...S.attribution}})}return{autoOnboardProduct:B,bills:n.bills,checkouts:{create:N,get:n.checkouts.get,update:n.checkouts.update},content:{list:vv,get:hn,getLanguage:Yr,unlock:mv,getPropertyFromHTML:pc},contracts:n.contracts,deleteTag:v,deleteTally:y,entitlements:n.entitlements,flags:{get:ov,set:iv,list:dn,delete:sv},generateLink:L,getProxyContent:l,getEntitlements:s,getFulfillments:c,requestDelivery:f,hasAccess:u,isSpotifyLinked:A,linkSpotify:K,openHostedAccountPage:M,paywalls:n.paywalls,paymentIssues:n.paymentIssues,getProfile:w,products:n.products,getSubscriptions:h,getTally:P,getTallies:b,getTags:p,getTransaction:d,transactions:n.transactions,userMetadata:n.userMetadata,pushTally:m,setTag:g,unlinkSpotify:j,updateProfile:R,vendor:n.vendor}}function Hd(t,e,r,n,a){for(e=e.split?e.split("."):e,n=0;n<e.length;n++)t=t?t[e[n]]:a;return t===a?r:t}var Cw="function",Aw="string",nt="undefined",$w="boolean",xn="object",Uw="array",Lw="number",qw="symbol",Nw="null",Os=function(){},yv="any",wv="*",Qt="__",xw="form",jw="input",Dw="button",Mw="select",jn=typeof process!==nt?process:{};jn.env&&jn.env.NODE_ENV;var Ae=typeof document!==nt;jn.versions!=null&&jn.versions.node!=null;typeof Deno!==nt&&Deno.core;Ae&&window.name==="nodejs"||typeof navigator!==nt&&typeof navigator.userAgent!==nt&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function bv(t,e){return e.charAt(0)[t]()+e.slice(1)}var Fw=bv.bind(null,"toUpperCase"),Kw=bv.bind(null,"toLowerCase");function zw(t){return Sv(t)?Fw(Nw):typeof t===xn?Ww(t):Object.prototype.toString.call(t).slice(8,-1)}function Dn(t,e){e===void 0&&(e=!0);var r=zw(t);return e?Kw(r):r}function pn(t,e){return typeof e===t}var He=pn.bind(null,Cw),Ct=pn.bind(null,Aw),mr=pn.bind(null,nt),Hw=pn.bind(null,$w);pn.bind(null,qw);function Sv(t){return t===null}function Bw(t){return Dn(t)===Lw&&!isNaN(t)}function Iv(t){return Dn(t)===Uw}function ze(t){if(!Gw(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Gw(t){return t&&(typeof t===xn||t!==null)}function Ww(t){return He(t.constructor)?t.constructor.name:null}function Vw(t){return t instanceof Error||Ct(t.message)&&t.constructor&&Bw(t.constructor.stackTraceLimit)}function Pv(t,e){if(typeof e!="object"||Sv(e))return!1;if(e instanceof t)return!0;var r=Dn(new t(""));if(Vw(e))for(;e;){if(Dn(e)===r)return!0;e=Object.getPrototypeOf(e)}return!1}Pv.bind(null,TypeError);Pv.bind(null,SyntaxError);function sa(t,e){var r=t instanceof Element||t instanceof HTMLDocument;return r&&e?Jw(t,e):r}function Jw(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function ca(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}ca(sa,xw);ca(sa,Dw);ca(sa,jw);ca(sa,Mw);function Zw(t){return t?Iv(t)?t:[t]:[]}function Bd(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Yw(){if(Ae){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Xw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Qw(t){return(function(e){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(e);){var i=Bd(r[1]),o=Bd(r[2]);if(i)if(i.substring(i.length-2)==="[]"){var s=n[i=i.substring(0,i.length-2)]||(n[i]=[]);n[i]=Array.isArray(s)?s:[],n[i].push(o)}else n[i]=o===""||o}for(var u in n){var l=u.split("[");l.length>1&&(eb(n,l.map(function(c){return c.replace(/[?[\]\\ ]/g,"")}),n[u]),delete n[u])}return n})((function(e){return Ae&&window.location.search.substring(1)})())}function eb(t,e,r){for(var n=e.length-1,a=0;a<n;++a){var i=e[a];if(i==="__proto__"||i==="constructor")break;i in t||(t[i]={}),t=t[i]}t[e[n]]=r}function ua(){for(var t="",e=0,r=4294967295*Math.random()|0;e++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],a=15&r;t+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=e%8==0?4294967295*Math.random()|0:r>>4}return t}function tb(t,e){var r,n,a,i=null,o=0,s=function(){o=new Date,i=null,a=t.apply(r,n)};return function(){var u=new Date;o||(o=u);var l=e-(u-o);return r=this,n=arguments,l<=0?(clearTimeout(i),i=null,o=u,a=t.apply(r,n)):i||(i=setTimeout(s,l)),a}}var Gt="global",Ir=Qt+Gt+Qt,Pr=typeof self===xn&&self.self===self&&self||typeof global===xn&&global[Gt]===global&&global||void 0;function er(t){return Pr[Ir][t]}function tr(t,e){return Pr[Ir][t]=e}function Cr(t){delete Pr[Ir][t]}function Ar(t,e,r){var n;try{if(vc(t)){var a=window[t];n=a[e].bind(a)}}catch{}return n||r}Pr[Ir]||(Pr[Ir]={});var gn={};function vc(t){if(typeof gn[t]!==nt)return gn[t];try{var e=window[t];e.setItem(nt,nt),e.removeItem(nt)}catch{return gn[t]=!1}return gn[t]=!0}function te(){return te=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},te.apply(null,arguments)}var _t="function",gt="undefined",en="reducer",Ev="@@redux/",Cs=Ev+"INIT",rb=Ev+Math.random().toString(36),Gd=(function(){return typeof Symbol===_t&&Symbol.observable||"@@observable"})(),yn=" != "+_t;function kv(t,e,r){var n;if(typeof e===_t&&typeof r===gt&&(r=e,e=void 0),typeof r!==gt){if(typeof r!==_t)throw new Error("enhancer"+yn);return r(kv)(t,e)}if(typeof t!==_t)throw new Error(en+yn);var a=t,i=e,o=[],s=o,u=!1;function l(){s===o&&(s=o.slice())}function c(){return i}function f(d){if(typeof d!==_t)throw new Error("Listener"+yn);var p=!0;return l(),s.push(d),function(){if(p){p=!1,l();var v=s.indexOf(d);s.splice(v,1)}}}function h(d){if(!ze(d))throw new Error("Act != obj");if(typeof d.type===gt)throw new Error("ActType "+gt);if(u)throw new Error("Dispatch in "+en);try{u=!0,i=a(i,d)}finally{u=!1}for(var p=o=s,v=0;v<p.length;v++)(0,p[v])();return d}return h({type:Cs}),(n={dispatch:h,subscribe:f,getState:c,replaceReducer:function(d){if(typeof d!==_t)throw new Error("next "+en+yn);a=d,h({type:Cs})}})[Gd]=function(){var d,p=f;return(d={subscribe:function(v){if(typeof v!="object")throw new TypeError("Observer != obj");function g(){v.next&&v.next(c())}return g(),{unsubscribe:p(g)}}})[Gd]=function(){return this},d},n}function nb(t,e){var r=e&&e.type;return"action "+(r&&r.toString()||"?")+en+" "+t+" returns "+gt}function Er(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,r){return function(){return e(r.apply(void 0,[].slice.call(arguments)))}})}function ab(){var t=arguments;return function(e){return function(r,n,a){var i,o=e(r,n,a),s=o.dispatch,u={getState:o.getState,dispatch:function(l){return s(l)}};return i=[].slice.call(t).map(function(l){return l(u)}),te({},o,{dispatch:s=Er.apply(void 0,i)(o.dispatch)})}}}var At=Qt+"anon_id",Wt=Qt+"user_id",yr=Qt+"user_traits",As="analytics",kt="userId",gr="anonymousId",Cn=["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"],$s=["name","EVENTS","config","loaded"],ee=Cn.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),Wd=/^utm_/,Vd=/^an_prop_/,Jd=/^an_trait_/;function ib(t){var e=t.storage.setItem;return function(r){return function(n){return function(a){if(a.type===ee.bootstrap){var i=a.params,o=a.user,s=a.persistedUser,u=a.initialUser,l=s.userId===o.userId;s.anonymousId!==o.anonymousId&&e(At,o.anonymousId),l||e(Wt,o.userId),u.traits&&e(yr,te({},l&&s.traits?s.traits:{},u.traits));var c=Object.keys(a.params);if(c.length){var f=i.an_uid,h=i.an_event,d=c.reduce(function(p,v){if(v.match(Wd)||v.match(/^(d|g)clid/)){var g=v.replace(Wd,"");p.campaign[g==="campaign"?"name":g]=i[v]}return v.match(Vd)&&(p.props[v.replace(Vd,"")]=i[v]),v.match(Jd)&&(p.traits[v.replace(Jd,"")]=i[v]),p},{campaign:{},props:{},traits:{}});r.dispatch(te({type:ee.params,raw:i},d,f?{userId:f}:{})),f&&setTimeout(function(){return t.identify(f,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&r.dispatch({type:ee.campaign,campaign:d.campaign})}}return n(a)}}}}function ob(t){return function(e,r){if(e===void 0&&(e={}),r===void 0&&(r={}),r.type===ee.setItemEnd){if(r.key===At)return te({},e,{anonymousId:r.value});if(r.key===Wt)return te({},e,{userId:r.value})}switch(r.type){case ee.identify:return Object.assign({},e,{userId:r.userId,traits:te({},e.traits,r.traits)});case ee.reset:return[Wt,At,yr].forEach(function(n){t.removeItem(n)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Zd(t){return{userId:t.getItem(Wt),anonymousId:t.getItem(At),traits:t.getItem(yr)}}var Us=function(t){return Qt+"TEMP"+Qt+t};function sb(t){var e=t.storage,r=e.setItem,n=e.removeItem,a=e.getItem;return function(i){return function(o){return function(s){var u=s.userId,l=s.traits,c=s.options;if(s.type===ee.reset&&([Wt,yr,At].forEach(function(d){n(d)}),[kt,gr,"traits"].forEach(function(d){Cr(Us(d))})),s.type===ee.identify){a(At)||r(At,ua());var f=a(Wt),h=a(yr)||{};f&&f!==u&&i.dispatch({type:ee.userIdChanged,old:{userId:f,traits:h},new:{userId:u,traits:l},options:c}),u&&r(Wt,u),l&&r(yr,te({},h,l))}return o(s)}}}}var Vr={};function Yd(t,e){Vr[t]&&He(Vr[t])&&(Vr[t](e),delete Vr[t])}function _v(t,e,r){return new Promise(function(n,a){return e()?n(t):r<1?a(te({},t,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return _v(t,e,r-10).then(n,a)})})}function cb(t){return{abort:t}}function Tv(t,e,r){var n={},a=e(),i=t.getState(),o=i.plugins,s=i.queue,u=i.user;if(!i.context.offline&&s&&s.actions&&s.actions.length){var l=s.actions.reduce(function(f,h,d){return o[h.plugin].loaded?(f.process.push(h),f.processIndex.push(d)):(f.requeue.push(h),f.requeueIndex.push(d)),f},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(f){var h=s.actions[f],d=h.plugin,p=h.payload.type,v=a[d][p];if(v&&He(v)){var g,P=(function(m,w){return m===void 0&&(m={}),w===void 0&&(w={}),[kt,gr].reduce(function(R,A){return m.hasOwnProperty(A)&&w[A]&&w[A]!==m[A]&&(R[A]=w[A]),R},m)})(h.payload,u),b=n[P.meta.rid];if(!b&&(g=v({payload:P,config:o[d].config,instance:r,abort:cb}))&&ze(g)&&g.abort)return void(n[P.meta.rid]=!0);if(!b){var y=p+":"+d;t.dispatch(te({},P,{type:y,_:{called:y,from:"queueDrain"}}))}}});var c=s.actions.filter(function(f,h){return!~l.processIndex.indexOf(h)});s.actions=c}}}var fs=function(t){var e=t.data,r=t.action,n=t.instance,a=t.state,i=t.allPlugins,o=t.allMatches,s=t.store,u=t.EVENTS;try{var l=a.plugins,c=a.context,f=r.type,h=f.match(wr),d=e.exact.map(function(g){return g.pluginName});h&&(d=o.during.map(function(g){return g.pluginName}));var p=(function(g,P){return function(b,y,m){var w=y.config,R=y.name,A=R+"."+b.type;m&&(A=m.event);var j=b.type.match(wr)?(function(K,B,re,L,M){return function(N,S){var O=L?L.name:K,q=S&&tn(S)?S:re;if(L&&(!(q=S&&tn(S)?S:[K]).includes(K)||q.length!==1))throw new Error("Method "+B+" can only abort "+K+" plugin. "+JSON.stringify(q)+" input valid");return te({},M,{abort:{reason:N,plugins:q,caller:B,_:O}})}})(R,A,P,m,b):(function(K,B){return function(){throw new Error(K.type+" action not cancellable. Remove abort in "+B)}})(b,A);return{payload:ub(b),instance:g,config:w||{},abort:j}}})(n,d),v=e.exact.reduce(function(g,P){var b=P.pluginName,y=P.methodName,m=!1;return y.match(/^initialize/)||y.match(/^reset/)||(m=!l[b].loaded),c.offline&&y.match(/^(page|track|identify)/)&&(m=!0),g[""+b]=m,g},{});return Promise.resolve(e.exact.reduce(function(g,P,b){var y=P.pluginName;return Promise.resolve(g).then(function(m){function w(){return Promise.resolve(m)}var R=(function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(A,j,K){return Promise.resolve(A).then(function(B){return j.method&&He(j.method)?((function(N,S){var O=ah(N);if(O&&O.name===S){var q=ah(O.method);throw new Error([S+" plugin is calling method "+N,"Plugins cant call self","Use "+O.method+" "+(q?"or "+q.method:"")+" in "+S+" plugin insteadof "+N].join(`
|
|
35
|
+
CAUSE: `+d.stack,w.response=y,w.status=y.status,w.url=f,y.type==="opaque")throw w;const R=a.errorType==="json"||((m=y.headers.get("Content-Type"))===null||m===void 0?void 0:m.split(";")[0])==="application/json";return(a.errorType?R?y.text():y[a.errorType]():Promise.resolve(y.body)).then(A=>{if(w.message=typeof A=="string"?A:y.statusText,A)if(R&&typeof A=="string"){w.text=A;try{w.json=JSON.parse(A)}catch{}}else w[a.errorType]=A;throw w})}return y}),v=y=>y.catch(m=>{const w=Object.prototype.hasOwnProperty.call(m,fr),R=w?m[fr]:m,A=R?.status&&l.get(R.status)||l.get(R?.name)||w&&l.has(fr)&&l.get(fr);if(A)return A(R,t);const j=l.get(Xp);if(j)return j(R,t);throw R}),g=y=>m=>v(y?p.then(w=>w&&w[y]()).then(w=>m?m(w):w):p.then(w=>m?m(w):w)),P={_wretchReq:t,_fetchReq:h,_sharedState:e,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(y,m){return l.set(y,m),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(fr,y)}},b=u.reduce((y,m)=>({...y,...typeof m.resolver=="function"?m.resolver(y):m.resolver}),P);return o.reduce((y,m)=>m(y,t),b)},Hy={_url:"",_options:{},_config:Sr,_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:Bt(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+t+"?"+r[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:Bt(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:Bt(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Yp]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const r=new Map(this._catchers);return r.set(t,e),{...this,_catchers:r}},catcherFallback(t){return this.catcher(Xp,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="",r=null){let n=this.url(e).options({method:t});const a=Ld(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||qd(a));return n=r?o?n.json(r,a):n.body(r):n,zy(n._deferred.reduce((s,u)=>u(s,s._url,s._options),n))},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 r=Ld(this._options.headers);return this.content(e||qd(r)&&r||jy).body(JSON.stringify(t))}};function ut(t="",e={}){return{...Hy,_url:t,_options:e}}ut.default=ut;ut.options=Dy;ut.errorType=Fy;ut.polyfills=My;ut.WretchError=Qp;const By=(t,e)=>e.skipDedupe||e.method!=="GET",Gy=(t,e)=>e.method+"@"+t,Wy=t=>t.clone(),Vy=({skip:t=By,key:e=Gy,resolver:r=Wy}={})=>{const n=new Map;return a=>(i,o)=>{if(t(i,o))return a(i,o);const s=e(i,o);if(!n.has(s))n.set(s,[]);else return new Promise((u,l)=>{n.get(s).push([u,l])});try{return a(i,o).then(u=>(n.get(s).forEach(([l])=>l(r(u))),n.delete(s),u)).catch(u=>{throw n.get(s).forEach(([,l])=>l(u)),n.delete(s),u})}catch(u){return n.delete(s),Promise.reject(u)}}},Jy=(t,e)=>e.skipCache||e.method!=="GET",Zy=(t,e)=>e.method+"@"+t,Yy=()=>!1,Xy=()=>null,Qy=t=>t.ok,ew=({throttle:t=1e3,skip:e=Jy,key:r=Zy,clear:n=Yy,invalidate:a=Xy,condition:i=Qy,flagResponseOnCacheHit:o="__cached"}={})=>{const s=new Map,u=new Map,l=new Set,c=h=>{t&&!l.has(h)&&(l.add(h),setTimeout(()=>{l.delete(h)},t))},f=h=>(d,p)=>{const v=r(d,p);let g=a(d,p);if(g&&(g instanceof Array||(g=[g]),g.forEach(P=>{typeof P=="string"?s.delete(P):P instanceof RegExp&&s.forEach((b,y)=>{P.test(y)&&s.delete(y)})})),n(d,p)&&s.clear(),e(d,p))return h(d,p);if(l.has(v)){if(s.has(v)){const P=s.get(v).clone();return o&&Object.defineProperty(P,o,{value:v,enumerable:!1}),Promise.resolve(P)}else if(u.has(v))return new Promise((P,b)=>{u.get(v).push([P,b])})}return u.has(v)||u.set(v,[]),c(v),h(d,p).then(P=>(i(P.clone())&&s.set(v,P.clone()),u.get(v).forEach(([b])=>b(P.clone())),u.delete(v),P)).catch(P=>{throw u.get(v).forEach(([,b])=>b(P)),u.delete(v),P})};return f.cacheResponse=function(h,d){c(h),s.set(h,d)},f.cache=s,f.inflight=u,f.throttling=l,f},tw=(t,e)=>t*e,rw=t=>t&&t.ok,nw=({delayTimer:t=500,delayRamp:e=tw,maxAttempts:r=10,until:n=rw,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:s}={})=>u=>(l,c)=>{let f=0;if(s&&s(l,c))return u(l,c);const h=(d,p)=>Promise.resolve(n(d,p)).then(v=>v?d&&o?d:p?Promise.reject(p):d:(f++,!r||f<=r?new Promise(g=>{const P=e(t,f);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:d,error:p,url:l,options:c})).then((b={})=>{var y,m;g(u((y=b&&b.url)!==null&&y!==void 0?y:l,(m=b&&b.options)!==null&&m!==void 0?m:c))}):g(u(l,c))},P)}).then(h).catch(g=>{if(!i)throw g;return h(null,g)}):d&&o?d:Promise.reject(p||new Error("Number of attempts exceeded."))));return u(l,c).then(h).catch(d=>{if(!i)throw d;return h(null,d)})},aw="@sesamy/sdk",iw="1.23.0";let ow=class{cache=new Map;get(e){return this.cache.get(e)||null}set(e,r){this.cache.set(e,r)}remove(e){this.cache.delete(e)}clear(){this.cache.clear()}};const Hr="sesamyCacheTimestamp",sw=t=>{const{libraryName:e=aw,libraryVersion:r=iw,cache:n}=t,a=n?.storage||new ow,i=[s=>async(u,l)=>{if(n?.mode===qn.BROWSER){let c;typeof sessionStorage<"u"?(c=sessionStorage.getItem(Hr),c||(c=Date.now().toString(),sessionStorage.setItem(Hr,c))):(c=a.get(Hr),c||(c=Date.now().toString(),a.set(Hr,c)));const f={...l,headers:{...l.headers,"Cache-Timestamp":c}};return s(u,f)}return s(u,l)},s=>async(u,l)=>{const c=await t.tokenProvider(),f={...l,headers:{...l.headers,Authorization:c}};return s(u,f)},Vy()];n?.mode===qn.NORMAL&&i.push(ew({throttle:300*1e3,skip:(s,u)=>u.method!=="GET"})),i.push(nw({delayTimer:1e3,delayRamp:(s,u)=>s*u,maxAttempts:3,until:s=>!!(s&&(s.ok||s.status>=400&&s.status<500)),retryOnNetworkError:!1}));const o=ut(t.baseUrl).headers({"Content-Type":"application/json","X-Sesamy-Client":`${e}/${r}`,...t.headers}).middlewares(i);return{async request(s,u={}){try{const l=/^https?:\/\//.test(s);let c=o.url(s,l);u.headers&&(c=c.headers(u.headers));const f=(u.method||"GET").toLowerCase();let h;switch(f){case"get":h=c.get();break;case"post":h=c.post(u.body);break;case"put":h=c.put(u.body);break;case"patch":h=c.patch(u.body);break;case"delete":h=c.delete();break;default:h=c.get()}const d=await h.res();if(d.ok&&["post","patch","put","delete"].includes(f)&&mt(),d.status===204)return null;if(!d.ok){const p=await d.text().catch(()=>"Unknown error");throw new is(d.status,d.statusText,d.url,`API Error ${d.status}: ${p}`,p)}return await d.json()}catch(l){if(l instanceof is)throw l;const c=l.status||500,f=l.message||"Unknown error",h=`${t.baseUrl}${s}`;throw new is(c,f,h,`API Error ${c}: ${l.message||"Unknown error"}`,l.message||"Unknown error")}}}},mt=()=>(typeof sessionStorage<"u"&&sessionStorage.removeItem(Hr),"Cache cleared"),Mr={get:async(t,e)=>t.request(`/profile/${e}`),update:async(t,e,r)=>t.request(`/profile/${e}`,{method:"PATCH",body:JSON.stringify(r)}),checkSpotifyLink:async t=>t.request("/profile/spotify-link"),unlinkSpotify:async t=>t.request("/profile/unlink-spotify",{method:"POST"}),delete:async t=>{await t.request("/profile",{method:"DELETE"})}},os={list:async(t,e)=>{const r=new URLSearchParams;e?.type&&r.append("type",e.type),e?.sku&&r.append("sku",e.sku),e?.purchaseOptionId&&r.append("purchase-option-id",e.purchaseOptionId),e?.waitForEntitlementAfter&&r.append("wait-for-entitlement-after",e.waitForEntitlementAfter);const n=r.toString(),a=n?`/entitlements?${n}`:"/entitlements";return t.request(a)},get:async(t,e)=>t.request(`/entitlements/${e}`),getAccess:async(t,e)=>t.request(`/entitlements/${e}/access`)},Nd={list:async t=>t.request("/subscriptions"),get:async(t,e)=>t.request(`/subscriptions/${e}`)},xd={get:async(t,e)=>t.request(`/products/${e}`),autoOnboard:async(t,e)=>t.request(`/products/${e}/auto-onboard`,{method:"POST"})},cw=(t,e)=>{if(!t||!e)return t;const r=new URL(t);return r.hash=`access_token=${e}`,r.toString()},jd=(t,e)=>!t.manageUrl||!e?t:{...t,manageUrl:cw(t.manageUrl,e)},Fr={list:async t=>t.request("/contracts"),get:async(t,e)=>t.request(`/contracts/${e}`),cancel:async(t,e)=>t.request(`/contracts/${e}/cancel`,{method:"POST"}),createAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments`,{method:"POST",body:JSON.stringify(r)}),confirmAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments/${r}/confirm`,{method:"POST"})},ss={get:async t=>t.request("/user-metadata"),set:async(t,e,r)=>{await t.request(`/user-metadata/${e}`,{method:"PUT",body:r})},delete:async(t,e)=>{await t.request(`/user-metadata/${e}`,{method:"DELETE"})}},dr={list:async t=>t.request("/tallies"),get:async(t,e)=>t.request(`/tallies/${e}`),update:async(t,e,r)=>t.request(`/tallies/${e}`,{method:"PUT",body:JSON.stringify(r)}),create:async(t,e)=>t.request("/tallies",{method:"POST",body:JSON.stringify(e)}),delete:async(t,e)=>{try{return await t.request(`/tallies/${e}`,{method:"DELETE"}),!0}catch{return!1}},push:async(t,e,r)=>t.request(`/tallies/${e}/push`,{method:"POST",body:JSON.stringify(r)})},cs={list:async t=>t.request("/tags"),add:async(t,e)=>{await t.request("/tags",{method:"POST",body:JSON.stringify({tag:e})})},remove:async(t,e)=>{await t.request(`/tags/${e}`,{method:"DELETE"})}},hr={generateCheckoutLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},generateAccountLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}${e.contractId?`/${encodeURIComponent(e.contractId)}`:""}`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePaymentLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/change-payment-method`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePlanLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/edit-plan`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateConsumeLink:(t,e)=>{const r=e.language||"en";let n=new URL(`${t.baseUrl}/consume/${encodeURIComponent(r)}/@${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.sku)}`);return e.episodeId?n.href+=`/${encodeURIComponent(e.episodeId)}`:n.href+="/listen",n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()}},us={generateLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},create:async(t,e)=>t.request("/checkouts",{method:"POST",body:JSON.stringify(e)}),get:async(t,e)=>t.request(`/checkouts/${e}`),update:async(t,e,r)=>t.request(`/checkouts/${e}`,{method:"PATCH",body:JSON.stringify(r)})},Dd={list:async t=>t.request("/bills"),get:async(t,e)=>t.request(`/bills/${e}`)},Md={list:async t=>t.request("/fulfillments"),create:async(t,e)=>t.request("/fulfillments",{method:"POST",body:JSON.stringify(e)})},uw={get:async(t,e)=>{try{return new URL(e),t.request(e)}catch{return t.request(`/paywalls/${e}`)}}},lw={list:async t=>t.request("/payment-issues")},fw={content:async(t,e,r,n,a)=>{const i=new URLSearchParams({url:e});return r&&i.append("selector",r),n&&i.append("cache",n),t.request(`/proxy?${i.toString()}`,a)}},dw={list:async(t,e)=>{const r=(e?new URLSearchParams({q:e}):new URLSearchParams).toString(),n=r?`/transactions?${r}`:"/transactions";return t.request(n)}},Fd={get:async t=>t.request("/vendor"),list:async t=>t.request("/vendors")},hw=t=>{const e=sw(t);return{profile:{get:r=>Mr.get(e,r),update:(r,n)=>Mr.update(e,r,n),checkSpotifyLink:()=>Mr.checkSpotifyLink(e),unlinkSpotify:()=>Mr.unlinkSpotify(e),delete:()=>Mr.delete(e)},entitlements:{list:r=>os.list(e,r),get:r=>os.get(e,r),getAccess:r=>os.getAccess(e,r)},subscriptions:{list:()=>Nd.list(e),get:r=>Nd.get(e,r)},products:{get:r=>xd.get(e,r),autoOnboard:r=>xd.autoOnboard(e,r)},contracts:{list:async()=>{const r=await Fr.list(e),n=await t.tokenProvider();if(!n.toLowerCase().startsWith("bearer "))return r;const a=n.substring(7);return r.map(i=>jd(i,a))},get:async r=>{const n=await Fr.get(e,r),a=await t.tokenProvider();if(!a.toLowerCase().startsWith("bearer "))return n;const i=a.substring(7);return jd(n,i)},cancel:r=>Fr.cancel(e,r),createAmendment:(r,n)=>Fr.createAmendment(e,r,n),confirmAmendment:(r,n)=>Fr.confirmAmendment(e,r,n)},userMetadata:{get:()=>ss.get(e),set:(r,n)=>ss.set(e,r,n),delete:r=>ss.delete(e,r)},tallies:{list:()=>dr.list(e),get:r=>dr.get(e,r),update:(r,n)=>dr.update(e,r,n),create:r=>dr.create(e,r),delete:r=>dr.delete(e,r),push:(r,n)=>dr.push(e,r,n)},tags:{list:()=>cs.list(e),add:r=>cs.add(e,r),remove:r=>cs.remove(e,r)},checkouts:{generateLink:(r,n)=>hr.generateCheckoutLink(r,n),create:r=>us.create(e,r),get:r=>us.get(e,r),update:(r,n)=>us.update(e,r,n)},links:{generateCheckoutLink:(r,n)=>hr.generateCheckoutLink(r,n),generateAccountLink:(r,n)=>hr.generateAccountLink(r,n),generateChangePaymentLink:(r,n)=>hr.generateChangePaymentLink(r,n),generateChangePlanLink:(r,n)=>hr.generateChangePlanLink(r,n),generateConsumeLink:(r,n)=>hr.generateConsumeLink(r,n)},bills:{list:()=>Dd.list(e),get:r=>Dd.get(e,r)},fulfillments:{list:()=>Md.list(e),create:r=>Md.create(e,r)},paywalls:{get:r=>uw.get(e,r)},paymentIssues:{list:()=>lw.list(e)},proxy:{content:(r,n,a,i)=>fw.content(e,r,n,a,i)},transactions:{list:r=>dw.list(e,r)},vendor:{get:()=>Fd.get(e),list:()=>Fd.list(e)}}};class pw{get(e){return typeof sessionStorage>"u"?null:sessionStorage.getItem(e)}set(e,r){typeof sessionStorage<"u"&&sessionStorage.setItem(e,r)}remove(e){typeof sessionStorage<"u"&&sessionStorage.removeItem(e)}clear(){}}function _s(t){let e;try{e=new URL(t)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function ev(t,e){if(_s(t))return{itemSrc:t};const r=t.split(":");if(r.length<2)throw new Error(`Invalid itemSrc format: expected at least 2 segments separated by ':', got ${r.length}`);const[n,a,i]=r;if(!a)throw new Error("Invalid itemSrc format: sku segment is empty");return{sku:`${n}:${a}`,purchaseOption:e||i}}function Kd(t){return t.endsWith("/")?t.slice(0,-1):t}function zd(t,e){if(!_s(t)||!_s(e))return!1;const r=new URL(t),n=new URL(e);return r.origin===n.origin&&Kd(r.pathname)===Kd(n.pathname)}function vw(t,e,r){const n=new URL(`${rt("checkout3",t.environment)}`);e.language&&n.searchParams.set("lang",e.language);let a=e.sku,i=e.purchaseOptionId,o=e.itemSrc;if(e.itemSrc){const c=ev(e.itemSrc,e.purchaseOptionId);a=c.sku||a,i=c.purchaseOption||i,o=c.itemSrc}a?(n.searchParams.set("sku",a),i&&n.searchParams.set("po-id",i)):o&&n.searchParams.set("url",o),e.email&&n.searchParams.set("email",e.email),e.business&&n.searchParams.set("business","true"),e.currency&&n.searchParams.set("currency",e.currency),e.price&&n.searchParams.set("price",e.price.toString()),e.discountCode&&n.searchParams.set("discount-code",e.discountCode),e.attributionItemSrc?n.searchParams.set("itemSrc",e.attributionItemSrc):r.itemSrc&&n.searchParams.set("itemSrc",r.itemSrc),e.attributionPublisherContentId?n.searchParams.set("publisherContentId",e.attributionPublisherContentId):r.publisherContentId&&n.searchParams.set("publisherContentId",r.publisherContentId),e.utmSource?n.searchParams.set("utm_source",e.utmSource):r.utmSource&&n.searchParams.set("utm_source",r.utmSource),e.utmMedium?n.searchParams.set("utm_medium",e.utmMedium):r.utmMedium&&n.searchParams.set("utm_medium",r.utmMedium),e.utmCampaign?n.searchParams.set("utm_campaign",e.utmCampaign):r.utmCampaign&&n.searchParams.set("utm_campaign",r.utmCampaign),e.utmTerm?n.searchParams.set("utm_term",e.utmTerm):r.utmTerm&&n.searchParams.set("utm_term",r.utmTerm),e.utmContent?n.searchParams.set("utm_content",e.utmContent):r.utmContent&&n.searchParams.set("utm_content",r.utmContent);const s=["_ga","_gid","_fbp","_fbc"];document.cookie.split(";").map(c=>{const[f,h]=c.trim().split("=");return{key:f,value:h}}).filter(c=>s.some(f=>f===c.key)).forEach(c=>{n.searchParams.append(c.key,c.value)});let l=new URL(window.location.href);if(e.redirectUrl)try{l=new URL(e.redirectUrl)}catch{console.warn("Invalid redirect URL provided, using current URL instead:",e.redirectUrl)}return l.searchParams.set("force-refetch-entitlements","true"),e.itemSrc&&l.searchParams.set("sesamy-purchase",e.itemSrc),n.searchParams.set("redirect-url",l.toString()),e.paymentMethodsFilter&&n.searchParams.set("paymentmethods-filter",e.paymentMethodsFilter.flatMap(({provider:c,methods:f})=>f?f.map(h=>`${c}|${h}`):c).join(",")),e.requireAddress&&n.searchParams.set("require-address","true"),e.giftMode&&n.searchParams.set("gift-mode","true"),e.payerEmail&&n.searchParams.set("payer-email",e.payerEmail),e.metadata&&Object.entries(e.metadata).forEach(([c,f])=>{n.searchParams.set(`metadata.${c}`,String(f))}),n}const tv="sesamySignedURLs";function fc(){const t=sessionStorage.getItem(tv);return t?JSON.parse(t):[]}function mw(t){const e=fc();e.push(t),G(`Adding signed URL: ${t}`),sessionStorage.setItem(tv,JSON.stringify(e))}function gw(t){const e={};return Object.keys(t).forEach(r=>{const n=t[r];n!=null&&(e[r]=n.toString())}),e}const Ts="sesamyAttribution";function yw(t){const e=localStorage.getItem(t);if(!e)return null;try{return JSON.parse(e).value}catch{return console.error(`Failed to parse ${t}`),null}}function ww(t){return Object.keys(t).find(e=>e.startsWith("utm_"))?{utmSource:void 0,utmMedium:void 0,utmCampaign:void 0,...t}:t}function Nn(){return yw(Ts)||{}}function rv(t){if(t===null)localStorage.removeItem(Ts);else{G(`Setting attribution ${JSON.stringify(t)}`);const e=Nn()??{},r=gw({...e,...ww(t)});localStorage.setItem(Ts,JSON.stringify({value:r}))}}const dc="@sesamy/sesamy-js",fn="1.87.0",nv="sesamyFlags";async function av(t){try{localStorage.setItem(nv,JSON.stringify(t))}catch{G("Failed to save flags to localStorage")}}async function iv(t,e){const r=await dn();r[t]=e,await av(r)}async function ov(t){return(await dn())[t]}async function sv(t){const e=await dn();t in e&&(delete e[t],await av(e))}async function dn(){try{const t=localStorage.getItem(nv);return t?JSON.parse(t):{}}catch{return{}}}function cv(t){function e(n){return n.id?`#${n.id}`:n.classList.length>0?Array.from(n.classList).map(i=>`.${i}`).join(""):null}function r(n){const a=[];let i=n;for(;i&&i!==document.body&&i!==document.documentElement;){const o=e(i);if(o){a.unshift(o);break}if(i.parentElement){const s=Array.from(i.parentElement.children),u=s.indexOf(i)+1,l=i.tagName.toLowerCase();s.filter(f=>f.tagName.toLowerCase()===l).length>1?a.unshift(`${l}:nth-child(${u})`):a.unshift(l)}i=i.parentElement}return a.join(" > ")}return r(t)}function uv(t){return t?Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0)):{}}function bw(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}let Ke={article:{selector:"sesamy-article"},image:{selector:"img",attribute:"src"},title:{selector:"h1",attribute:"textContent"},excerpt:{selector:"p",attribute:"textContent"},price:{selector:"sesamy-article",attribute:"price"},currency:{selector:"sesamy-article",attribute:"currency"},url:{selector:"sesamy-article",attribute:"item-src"},accessLevel:{selector:"sesamy-article",attribute:"access-level"},id:{selector:"sesamy-article",attribute:"publisher-content-id"},pass:{selector:"sesamy-article",attribute:"pass"},paywallUrl:{selector:"sesamy-article",attribute:"paywall-url"}},lv=[],fv=!1,Rt;function hc(){const t=window.location.pathname,e=new URLSearchParams(window.location.search),r=navigator.userAgent;return lv.find(n=>{if(n.path&&!t.includes(n.path)||n.queryParam&&e.get(n.queryParam.key)!==n.queryParam.value)return!1;if(n.headers){const a=n.headers.name.toLowerCase(),i=n.headers.contains.toLowerCase();if(a==="user-agent"){if(!r.toLowerCase().includes(i))return!1}else return!1}return!(n.userAgentContains&&!r.includes(n.userAgentContains))})}function Sw(){return hc()}function Iw(t,e){lv=t.content||[];const r=hc();r&&r.type==="article"&&(Ke={...Ke,...uv(r.selectors)},fv=r.enablePaywallSettingsUrlFallback||!1),Rt=e}function Pw(t,e){const{selector:r,attribute:n}=e;return r===Ke.article.selector||n&&t.hasAttribute(n)?t:t.querySelector(r)}function dv(t,e,r=!1){if(t){if(e.attribute){if(e.attribute==="textContent")return t.textContent??void 0;const n=t.getAttribute(e.attribute),a=dv(t.parentElement,e,r);if(r){const i=[];return n&&i.push(...n.split(",").map(o=>o.trim()).filter(Boolean)),a&&i.push(...a.split(",").map(o=>o.trim()).filter(Boolean)),i.length>0?[...new Set(i)].join(","):void 0}return n??a}return t.textContent??void 0}}function ge(t){const e=document.head.querySelectorAll(`[property~='${t}'][content]`);for(let n=0;n<e.length;n+=1)if(e[n].content)return e[n].content;const r=document.head.querySelectorAll(`[name~='${t}'][content]`);for(let n=0;n<r.length;n+=1)if(r[n].content)return r[n].content}function Br(t){const e=[];return document.head.querySelectorAll(`[property~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),document.head.querySelectorAll(`[name~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),e}let Gr=null;function hv(){const t=[],e=document.querySelectorAll('script[type="application/ld+json"]');for(const r of e)try{const n=JSON.parse(r.textContent||"");Array.isArray(n)?t.push(...n):n["@graph"]&&Array.isArray(n["@graph"])?t.push(...n["@graph"]):t.push(n)}catch{}return t}function Wr(t){const e=hv(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.find(r)||null}function Ew(t){const e=hv(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.filter(r)}function Rs(t,e,r){if(!t||typeof t!="object")return typeof t=="string"?t:void 0;const a=t[e];if(typeof a=="string")return a;if(a&&typeof a=="object"&&r)return a[r]}function kw(t){if(!t)return;const r=(Array.isArray(t)?t:[t]).map(n=>{if(typeof n=="string")return{name:n};if(typeof n=="object"&&n!==null){const a=n,i=a.name;return i?{name:i,url:a.url,image:Rs(a,"image","url"),jobTitle:a.jobTitle,sameAs:a.sameAs}:null}return null}).filter(n=>n!==null&&!!n.name);return r.length>0?r:void 0}function ls(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string"){const e=t.split(",").map(r=>r.trim()).filter(Boolean);return e.length>0?e:void 0}}function pv(){if(Gr)return Gr;const t=Wr("NewsArticle")||Wr("Article")||Wr("BlogPosting")||Wr("WebPage"),e=(...a)=>a.find(i=>i!=null&&i!=="")||void 0,r=(...a)=>a.find(i=>i&&i.length>0),n={contentType:t?Array.isArray(t["@type"])?t["@type"][0]:t["@type"]:void 0,authors:kw(t?.author)||(Br("article:author").length>0?Br("article:author").map(a=>({name:a})):void 0)||(ge("author")?[{name:ge("author")}]:void 0),keywords:r(ls(t?.keywords),ls(ge("keywords"))),tags:Br("article:tag").length>0?Br("article:tag"):void 0,categories:ls(ge("news_keywords")),section:e(t?.articleSection,ge("article:section")),publishedAt:e(t?.datePublished,ge("article:published_time")),modifiedAt:e(t?.dateModified,ge("article:modified_time")),ogType:ge("og:type"),ogSiteName:ge("og:site_name"),ogLocale:ge("og:locale"),twitterCard:ge("twitter:card"),twitterSite:ge("twitter:site"),twitterCreator:ge("twitter:creator"),creator:e(ge("creator"),ge("dc.creator")),mainEntityOfPage:t?Rs(t.mainEntityOfPage,"@id")||(typeof t.mainEntityOfPage=="string"?t.mainEntityOfPage:void 0):void 0,isAccessibleForFree:typeof t?.isAccessibleForFree=="boolean"?t.isAccessibleForFree:void 0,wordCount:typeof t?.wordCount=="number"?t.wordCount:void 0,publisher:t?.publisher&&typeof t.publisher=="object"?{name:t.publisher.name||"",url:t.publisher.url,logo:Rs(t.publisher,"logo","url")}:void 0};return Gr=uv(n),Gr}function _w(){Gr=null}function pc({publisherContentId:t,key:e,defaultValue:r=""}){const n=t?document.body.querySelector(`sesamy-content-data[id='${t}']`):null,a=e.replace(/-([a-z])/g,(i,o)=>o.toUpperCase());return n?.getAttribute(e)||ge(`sesamy:${e}`)||ge(`sesamy:${a}`)||ge(`og:${e}`)||ge(e)||r}function vv(){const t=document.querySelectorAll(Ke.article.selector);return Array.from(t).map(hn).filter(e=>e!==null)}function hn(t){const e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;const r={element:e,selector:typeof t=="string"?t:cv(e)},n=(i,o,s,u)=>{const{transform:l,collect:c=!1}=u||{},f=Pw(e,o),h=dv(f,o,c),d=pc({publisherContentId:s,key:bw(String(i))}),p=h||d||void 0;p&&(r[i]=l?l(p):p)};n("id",Ke.id),n("title",Ke.title,r.id),n("excerpt",Ke.excerpt,r.id),n("image",Ke.image,r.id),n("price",Ke.price,r.id,{transform:i=>{const o=parseFloat(i);return Number.isNaN(o)?void 0:o}}),n("currency",Ke.currency,r.id),n("url",Ke.url,r.id),n("pass",Ke.pass,r.id,{collect:!0}),n("paywallUrl",Ke.paywallUrl,r.id),n("accessLevel",Ke.accessLevel,r.id,{transform:i=>i||"entitlement"});const a=hc();if(a&&a.type==="article"&&(a.pass&&(r.pass=r.pass?`${r.pass},${a.pass}`:a.pass),a.price&&!r.price&&(r.price=a.price.amount),a.price?.currency&&!r.currency&&(r.currency=a.price.currency),a.paywallUrl&&!r.paywallUrl&&(r.paywallUrl=a.paywallUrl)),fv&&!r.paywallUrl){const i=document.querySelector("sesamy-paywall");if(i){const o=i.getAttribute("settings-url");o&&(r.paywallUrl=o)}}return r.url||(r.url=window.location.href),r.metadata=pv(),r}async function Tw(t){const e=hn(t);if(!e)throw new Error("Could not find article element");if(e.accessLevel==="public")return!0;if(e.accessLevel==="logged-in"&&!e.paywallUrl)return await Rt.auth.isAuthenticated()?!0:null;if(e.paywallUrl&&((await Rt.paywalls.get(e.paywallUrl)).settings.template==="LOGIN"?"logged-in":"entitlement")==="logged-in")return await Rt.auth.isAuthenticated()?!0:null;if(!e.url)throw new Error("Article must have a URL");return await Rt.entitlements.hasAccess(e.url,e.pass?.split(",")||[])||null}async function mv(t,e){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error("Could not find element");const n=hn(r);if(!n?.url)throw new Error("Could not find content for element");const a=await Rt.entitlements.hasAccess(n.url,n.pass?.split(",")||[]);if(!a)throw new Error("User does not have access to the content");const i=await Rt.entitlements.access(a.id);if(!i.token)throw new Error("Could not get access token");const o=e||cv(r.parentElement||r);return Rt.proxy.getContent(i.token,n.url,o)}function gv(t,e={}){const{closeOnBackdropClick:r=!0,closeOnEscape:n=!0,zIndex:a=2147483647,backdropBlur:i="5px",overlayBackground:o="rgba(0,0,0,0.5)"}=e,s=document.createElement("div");s.setAttribute("data-sesamy-modal","true"),Object.assign(s.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",background:o,zIndex:String(a),display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:`blur(${i})`});const u=document.createElement("div");u.setAttribute("data-sesamy-modal-content","true"),typeof t=="string"?u.innerHTML=t:u.appendChild(t),s.appendChild(u);const l=()=>{s.remove(),n&&document.removeEventListener("keydown",c)},c=f=>{f.key==="Escape"&&l()};return r&&s.addEventListener("click",f=>{f.target===s&&l()}),n&&document.addEventListener("keydown",c),document.body.appendChild(s),{element:s,close:l}}function Rw(t,e={}){const{position:r="top",fixed:n=!0,zIndex:a=2147483647,autoDismissMs:i,pushContent:o=!1,height:s,transitionDuration:u="0.3s"}=e,l=document.createElement("div");l.setAttribute("data-sesamy-notification-bar","true"),l.setAttribute("data-sesamy-notification-position",r),Object.assign(l.style,{position:n?"fixed":"absolute",[r]:"0",left:"0",width:"100%",zIndex:String(a),boxSizing:"border-box",...s&&{height:s}}),typeof t=="string"?l.innerHTML=t:l.appendChild(t);let c,f,h;const d=()=>{if(h&&clearTimeout(h),o&&s){const p=document.documentElement;p.style.transform=c||"",setTimeout(()=>{l.remove(),p.style.transition=f||""},parseFloat(u)*1e3)}else l.remove()};if(i&&(h=setTimeout(d,i)),o&&s){const p=document.documentElement;c=p.style.transform,f=p.style.transition,p.style.transition=`transform ${u} ease`,l.style.transition=`transform ${u} ease`,r==="top"?(p.style.transform=`translateY(${s})`,l.style.transform=`translateY(-${s})`):(p.style.transform=`translateY(-${s})`,l.style.transform=`translateY(${s})`),document.documentElement.prepend(l)}else document.body.appendChild(l);return{element:l,close:d}}function Ow(t){const e=t.endpoint||rt("api2",t.environment),n=hw({baseUrl:e,tokenProvider:async()=>{if(await Ot())try{const q=await pt(!1);if(q)return`Bearer ${q}`}catch{}const S=localStorage.getItem("__anon_id");return`Basic ${btoa(`${t.vendorId||t.clientId}|${S}:`)}`},libraryName:dc,libraryVersion:fn,vendorId:t.vendorId,cache:{mode:qn.BROWSER,storage:new pw}}),a=S=>async(O,q)=>{let F=sessionStorage.getItem($d);F||(F=Date.now().toString(),sessionStorage.setItem($d,F));const I={...q,headers:{...q.headers,"Cache-Timestamp":F}};return S(O,I)},i=(S=!0)=>O=>async(q,F)=>{let I=null;if(I=await pt(S),!I){if(S)throw new Error("No access token available");return O(q,F)}const _={...F,headers:{...F.headers,...I?{Authorization:`Bearer ${I}`}:{}}};return O(q,_)},o=ut(e).headers({"Content-Type":"application/json"}).middlewares([a,i(),Ly(),xy({delayTimer:1e3,delayRamp:(S,O)=>S*O,maxAttempts:3,until:S=>!!(S&&(S.ok||S.status>=400&&S.status<500)),retryOnNetworkError:!1})]);async function s(S={}){const{waitForEntitlementAfter:O,includeSignedLinks:q=!0}=S,F=await Ot()?await n.entitlements.list({waitForEntitlementAfter:O?.toISOString()}):[];return q&&F.push(...fc()),F}async function u(S,O=[]){return(await s())?.find(I=>{if(S){const{sku:_,purchaseOption:x}=ev(S);if("sku"in I&&_===I.sku||x&&"purchaseOptionsId"in I&&x===I.purchaseOptionsId||zd(S,I.url))return!0}return!!O.some(_=>zd(_,I.url))})}async function l(S,O,q){const F=new URL(rt("api2",t.environment));return F.pathname="/proxy",F.searchParams.set("url",O),q&&F.searchParams.set("selector",q),ut(F.toString()).headers({Authorization:`Bearer ${S}`}).get().text()}async function c(S){if(!S)throw new Error("SKU is required to get fulfillments");return await Ot()?await o.get(`/fulfillments?sku=${encodeURIComponent(S)}`).json():[]}async function f(S,O){if(!S||!O)throw new Error("SKU and itemId are required to request delivery");return(await o.post({sku:S},`/fulfillments/${encodeURIComponent(O)}/request-delivery?`).res()).ok}async function h(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),o.get("/subscriptions").json()}async function d(S){return(await n.transactions.list())?.find(q=>q.id===S)}async function p(){return await o.url("/tags").get().json()}async function v(S){const O=await o.url(`/tags/${encodeURIComponent(S)}`).delete().res();return mt(),O.ok}async function g(S){const O=await o.url("/tags").post(encodeURIComponent(S)).res();return Zt(Ge.USER_ATTRIBUTE_CHANGED,{}),mt(),O.ok}async function P(S){return(await n.tallies.get(S)).value}async function b(){const S=await n.tallies.list(),O={};for(const q of S)O[q.id]=q.value;return O}async function y(S){return await n.tallies.delete(S)}async function m(S,O){return await n.tallies.push(S,O)}async function w(){return await pt(!1)?await o.url("/profile").get().json():null}async function R(S){const O=await o.url("/profile").patch(S).res();return mt(),O.ok}async function A(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function j(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function K(S){const O=await pt(!1);if(!O)throw new Error("No access token available");const q=new URL(`${rt("access-sync",t.environment)}/spotify/sesamy-callback`);q.searchParams.set("access_token",O),q.searchParams.set("state",S),window.location.href=q.toString()}async function B(S){const O=await o.url(`/products/${encodeURIComponent(S)}/auto-onboard`).post().json();return O.length&&mt(),O}async function re(S,O=3600){const{shortlink:q}=await ut(fy).post({url:S,ttl:O}).json();return q}async function L(S){const O=await pt(!1,!0);let q;const F=S.language||Yr(),I=Nn();switch(S.target){case"account":q=new URL(`${rt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}${S.contractId?`/${encodeURIComponent(S.contractId)}`:""}`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-payment":q=new URL(`${rt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/change-payment-method`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-plan":q=new URL(`${rt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/edit-plan`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"consume":q=new URL(`${rt("consume",t.environment)}/${encodeURIComponent(S.language||F)}/@${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.sku)}`),S.episodeId?q.href+=`/${S.episodeId}`:q.href+="/listen",q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"checkout":q=vw(t,{language:F,...S},I);break;default:throw new Error("Invalid target")}return O&&(q.hash=`#access_token=${O}`),S.shorten?re(q.href,S.ttl):q.href}async function M(){const S=await pt(!1),O=new URL(`${rt("account",t.environment)}/subscriptions/${t.vendorId||t.clientId}`);S&&(O.hash=`#access_token=${S}`),window.location.href=O.toString()}async function N(S){const O=Nn(),q=["_ga","_gid","_fbp","_fbc"];return document.cookie.split(";").forEach(F=>{const[I,_]=F.trim().split("=");q.includes(I)&&!O[I]&&(O[I]=_)}),n.checkouts.create({language:Yr(),...S,attribution:{...O,...S.attribution}})}return{autoOnboardProduct:B,bills:n.bills,checkouts:{create:N,get:n.checkouts.get,update:n.checkouts.update},content:{list:vv,get:hn,getLanguage:Yr,unlock:mv,getPropertyFromHTML:pc},contracts:n.contracts,deleteTag:v,deleteTally:y,entitlements:n.entitlements,flags:{get:ov,set:iv,list:dn,delete:sv},generateLink:L,getProxyContent:l,getEntitlements:s,getFulfillments:c,requestDelivery:f,hasAccess:u,isSpotifyLinked:A,linkSpotify:K,openHostedAccountPage:M,paywalls:n.paywalls,paymentIssues:n.paymentIssues,getProfile:w,products:n.products,getSubscriptions:h,getTally:P,getTallies:b,getTags:p,getTransaction:d,transactions:n.transactions,userMetadata:n.userMetadata,pushTally:m,setTag:g,unlinkSpotify:j,updateProfile:R,vendor:n.vendor}}function Hd(t,e,r,n,a){for(e=e.split?e.split("."):e,n=0;n<e.length;n++)t=t?t[e[n]]:a;return t===a?r:t}var Cw="function",Aw="string",nt="undefined",$w="boolean",xn="object",Uw="array",Lw="number",qw="symbol",Nw="null",Os=function(){},yv="any",wv="*",Qt="__",xw="form",jw="input",Dw="button",Mw="select",jn=typeof process!==nt?process:{};jn.env&&jn.env.NODE_ENV;var Ae=typeof document!==nt;jn.versions!=null&&jn.versions.node!=null;typeof Deno!==nt&&Deno.core;Ae&&window.name==="nodejs"||typeof navigator!==nt&&typeof navigator.userAgent!==nt&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function bv(t,e){return e.charAt(0)[t]()+e.slice(1)}var Fw=bv.bind(null,"toUpperCase"),Kw=bv.bind(null,"toLowerCase");function zw(t){return Sv(t)?Fw(Nw):typeof t===xn?Ww(t):Object.prototype.toString.call(t).slice(8,-1)}function Dn(t,e){e===void 0&&(e=!0);var r=zw(t);return e?Kw(r):r}function pn(t,e){return typeof e===t}var He=pn.bind(null,Cw),Ct=pn.bind(null,Aw),mr=pn.bind(null,nt),Hw=pn.bind(null,$w);pn.bind(null,qw);function Sv(t){return t===null}function Bw(t){return Dn(t)===Lw&&!isNaN(t)}function Iv(t){return Dn(t)===Uw}function ze(t){if(!Gw(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Gw(t){return t&&(typeof t===xn||t!==null)}function Ww(t){return He(t.constructor)?t.constructor.name:null}function Vw(t){return t instanceof Error||Ct(t.message)&&t.constructor&&Bw(t.constructor.stackTraceLimit)}function Pv(t,e){if(typeof e!="object"||Sv(e))return!1;if(e instanceof t)return!0;var r=Dn(new t(""));if(Vw(e))for(;e;){if(Dn(e)===r)return!0;e=Object.getPrototypeOf(e)}return!1}Pv.bind(null,TypeError);Pv.bind(null,SyntaxError);function sa(t,e){var r=t instanceof Element||t instanceof HTMLDocument;return r&&e?Jw(t,e):r}function Jw(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function ca(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}ca(sa,xw);ca(sa,Dw);ca(sa,jw);ca(sa,Mw);function Zw(t){return t?Iv(t)?t:[t]:[]}function Bd(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Yw(){if(Ae){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Xw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Qw(t){return(function(e){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(e);){var i=Bd(r[1]),o=Bd(r[2]);if(i)if(i.substring(i.length-2)==="[]"){var s=n[i=i.substring(0,i.length-2)]||(n[i]=[]);n[i]=Array.isArray(s)?s:[],n[i].push(o)}else n[i]=o===""||o}for(var u in n){var l=u.split("[");l.length>1&&(eb(n,l.map(function(c){return c.replace(/[?[\]\\ ]/g,"")}),n[u]),delete n[u])}return n})((function(e){return Ae&&window.location.search.substring(1)})())}function eb(t,e,r){for(var n=e.length-1,a=0;a<n;++a){var i=e[a];if(i==="__proto__"||i==="constructor")break;i in t||(t[i]={}),t=t[i]}t[e[n]]=r}function ua(){for(var t="",e=0,r=4294967295*Math.random()|0;e++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],a=15&r;t+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=e%8==0?4294967295*Math.random()|0:r>>4}return t}function tb(t,e){var r,n,a,i=null,o=0,s=function(){o=new Date,i=null,a=t.apply(r,n)};return function(){var u=new Date;o||(o=u);var l=e-(u-o);return r=this,n=arguments,l<=0?(clearTimeout(i),i=null,o=u,a=t.apply(r,n)):i||(i=setTimeout(s,l)),a}}var Gt="global",Ir=Qt+Gt+Qt,Pr=typeof self===xn&&self.self===self&&self||typeof global===xn&&global[Gt]===global&&global||void 0;function er(t){return Pr[Ir][t]}function tr(t,e){return Pr[Ir][t]=e}function Cr(t){delete Pr[Ir][t]}function Ar(t,e,r){var n;try{if(vc(t)){var a=window[t];n=a[e].bind(a)}}catch{}return n||r}Pr[Ir]||(Pr[Ir]={});var gn={};function vc(t){if(typeof gn[t]!==nt)return gn[t];try{var e=window[t];e.setItem(nt,nt),e.removeItem(nt)}catch{return gn[t]=!1}return gn[t]=!0}function te(){return te=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},te.apply(null,arguments)}var _t="function",gt="undefined",en="reducer",Ev="@@redux/",Cs=Ev+"INIT",rb=Ev+Math.random().toString(36),Gd=(function(){return typeof Symbol===_t&&Symbol.observable||"@@observable"})(),yn=" != "+_t;function kv(t,e,r){var n;if(typeof e===_t&&typeof r===gt&&(r=e,e=void 0),typeof r!==gt){if(typeof r!==_t)throw new Error("enhancer"+yn);return r(kv)(t,e)}if(typeof t!==_t)throw new Error(en+yn);var a=t,i=e,o=[],s=o,u=!1;function l(){s===o&&(s=o.slice())}function c(){return i}function f(d){if(typeof d!==_t)throw new Error("Listener"+yn);var p=!0;return l(),s.push(d),function(){if(p){p=!1,l();var v=s.indexOf(d);s.splice(v,1)}}}function h(d){if(!ze(d))throw new Error("Act != obj");if(typeof d.type===gt)throw new Error("ActType "+gt);if(u)throw new Error("Dispatch in "+en);try{u=!0,i=a(i,d)}finally{u=!1}for(var p=o=s,v=0;v<p.length;v++)(0,p[v])();return d}return h({type:Cs}),(n={dispatch:h,subscribe:f,getState:c,replaceReducer:function(d){if(typeof d!==_t)throw new Error("next "+en+yn);a=d,h({type:Cs})}})[Gd]=function(){var d,p=f;return(d={subscribe:function(v){if(typeof v!="object")throw new TypeError("Observer != obj");function g(){v.next&&v.next(c())}return g(),{unsubscribe:p(g)}}})[Gd]=function(){return this},d},n}function nb(t,e){var r=e&&e.type;return"action "+(r&&r.toString()||"?")+en+" "+t+" returns "+gt}function Er(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,r){return function(){return e(r.apply(void 0,[].slice.call(arguments)))}})}function ab(){var t=arguments;return function(e){return function(r,n,a){var i,o=e(r,n,a),s=o.dispatch,u={getState:o.getState,dispatch:function(l){return s(l)}};return i=[].slice.call(t).map(function(l){return l(u)}),te({},o,{dispatch:s=Er.apply(void 0,i)(o.dispatch)})}}}var At=Qt+"anon_id",Wt=Qt+"user_id",yr=Qt+"user_traits",As="analytics",kt="userId",gr="anonymousId",Cn=["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"],$s=["name","EVENTS","config","loaded"],ee=Cn.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),Wd=/^utm_/,Vd=/^an_prop_/,Jd=/^an_trait_/;function ib(t){var e=t.storage.setItem;return function(r){return function(n){return function(a){if(a.type===ee.bootstrap){var i=a.params,o=a.user,s=a.persistedUser,u=a.initialUser,l=s.userId===o.userId;s.anonymousId!==o.anonymousId&&e(At,o.anonymousId),l||e(Wt,o.userId),u.traits&&e(yr,te({},l&&s.traits?s.traits:{},u.traits));var c=Object.keys(a.params);if(c.length){var f=i.an_uid,h=i.an_event,d=c.reduce(function(p,v){if(v.match(Wd)||v.match(/^(d|g)clid/)){var g=v.replace(Wd,"");p.campaign[g==="campaign"?"name":g]=i[v]}return v.match(Vd)&&(p.props[v.replace(Vd,"")]=i[v]),v.match(Jd)&&(p.traits[v.replace(Jd,"")]=i[v]),p},{campaign:{},props:{},traits:{}});r.dispatch(te({type:ee.params,raw:i},d,f?{userId:f}:{})),f&&setTimeout(function(){return t.identify(f,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&r.dispatch({type:ee.campaign,campaign:d.campaign})}}return n(a)}}}}function ob(t){return function(e,r){if(e===void 0&&(e={}),r===void 0&&(r={}),r.type===ee.setItemEnd){if(r.key===At)return te({},e,{anonymousId:r.value});if(r.key===Wt)return te({},e,{userId:r.value})}switch(r.type){case ee.identify:return Object.assign({},e,{userId:r.userId,traits:te({},e.traits,r.traits)});case ee.reset:return[Wt,At,yr].forEach(function(n){t.removeItem(n)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Zd(t){return{userId:t.getItem(Wt),anonymousId:t.getItem(At),traits:t.getItem(yr)}}var Us=function(t){return Qt+"TEMP"+Qt+t};function sb(t){var e=t.storage,r=e.setItem,n=e.removeItem,a=e.getItem;return function(i){return function(o){return function(s){var u=s.userId,l=s.traits,c=s.options;if(s.type===ee.reset&&([Wt,yr,At].forEach(function(d){n(d)}),[kt,gr,"traits"].forEach(function(d){Cr(Us(d))})),s.type===ee.identify){a(At)||r(At,ua());var f=a(Wt),h=a(yr)||{};f&&f!==u&&i.dispatch({type:ee.userIdChanged,old:{userId:f,traits:h},new:{userId:u,traits:l},options:c}),u&&r(Wt,u),l&&r(yr,te({},h,l))}return o(s)}}}}var Vr={};function Yd(t,e){Vr[t]&&He(Vr[t])&&(Vr[t](e),delete Vr[t])}function _v(t,e,r){return new Promise(function(n,a){return e()?n(t):r<1?a(te({},t,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return _v(t,e,r-10).then(n,a)})})}function cb(t){return{abort:t}}function Tv(t,e,r){var n={},a=e(),i=t.getState(),o=i.plugins,s=i.queue,u=i.user;if(!i.context.offline&&s&&s.actions&&s.actions.length){var l=s.actions.reduce(function(f,h,d){return o[h.plugin].loaded?(f.process.push(h),f.processIndex.push(d)):(f.requeue.push(h),f.requeueIndex.push(d)),f},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(f){var h=s.actions[f],d=h.plugin,p=h.payload.type,v=a[d][p];if(v&&He(v)){var g,P=(function(m,w){return m===void 0&&(m={}),w===void 0&&(w={}),[kt,gr].reduce(function(R,A){return m.hasOwnProperty(A)&&w[A]&&w[A]!==m[A]&&(R[A]=w[A]),R},m)})(h.payload,u),b=n[P.meta.rid];if(!b&&(g=v({payload:P,config:o[d].config,instance:r,abort:cb}))&&ze(g)&&g.abort)return void(n[P.meta.rid]=!0);if(!b){var y=p+":"+d;t.dispatch(te({},P,{type:y,_:{called:y,from:"queueDrain"}}))}}});var c=s.actions.filter(function(f,h){return!~l.processIndex.indexOf(h)});s.actions=c}}}var fs=function(t){var e=t.data,r=t.action,n=t.instance,a=t.state,i=t.allPlugins,o=t.allMatches,s=t.store,u=t.EVENTS;try{var l=a.plugins,c=a.context,f=r.type,h=f.match(wr),d=e.exact.map(function(g){return g.pluginName});h&&(d=o.during.map(function(g){return g.pluginName}));var p=(function(g,P){return function(b,y,m){var w=y.config,R=y.name,A=R+"."+b.type;m&&(A=m.event);var j=b.type.match(wr)?(function(K,B,re,L,M){return function(N,S){var O=L?L.name:K,q=S&&tn(S)?S:re;if(L&&(!(q=S&&tn(S)?S:[K]).includes(K)||q.length!==1))throw new Error("Method "+B+" can only abort "+K+" plugin. "+JSON.stringify(q)+" input valid");return te({},M,{abort:{reason:N,plugins:q,caller:B,_:O}})}})(R,A,P,m,b):(function(K,B){return function(){throw new Error(K.type+" action not cancellable. Remove abort in "+B)}})(b,A);return{payload:ub(b),instance:g,config:w||{},abort:j}}})(n,d),v=e.exact.reduce(function(g,P){var b=P.pluginName,y=P.methodName,m=!1;return y.match(/^initialize/)||y.match(/^reset/)||(m=!l[b].loaded),c.offline&&y.match(/^(page|track|identify)/)&&(m=!0),g[""+b]=m,g},{});return Promise.resolve(e.exact.reduce(function(g,P,b){var y=P.pluginName;return Promise.resolve(g).then(function(m){function w(){return Promise.resolve(m)}var R=(function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(A,j,K){return Promise.resolve(A).then(function(B){return j.method&&He(j.method)?((function(N,S){var O=ah(N);if(O&&O.name===S){var q=ah(O.method);throw new Error([S+" plugin is calling method "+N,"Plugins cant call self","Use "+O.method+" "+(q?"or "+q.method:"")+" in "+S+" plugin insteadof "+N].join(`
|
|
36
36
|
`))}})(j.methodName,j.pluginName),Promise.resolve(j.method({payload:B,instance:n,abort:(re=B,L=y,M=j.pluginName,function(N,S){return te({},re,{abort:{reason:N,plugins:S||[L],caller:f,from:M||L}})}),config:eh(j.pluginName,l,i),plugins:l})).then(function(N){var S=ze(N)?N:{};return Promise.resolve(te({},B,S))})):B;var re,L,M})},Promise.resolve(r))).then(function(A){m[y]=A});m[y]=r})();return R&&R.then?R.then(w):w()})},Promise.resolve({}))).then(function(g){return Promise.resolve(e.exact.reduce(function(P,b,y){try{var m=e.exact.length===y+1,w=b.pluginName,R=i[w];return Promise.resolve(P).then(function(A){var j=g[w]?g[w]:{};if(h&&(j=A),hs(j,w))return ds({data:j,method:f,instance:n,pluginName:w,store:s}),Promise.resolve(A);if(hs(A,w))return m&&ds({data:A,method:f,instance:n,store:s}),Promise.resolve(A);if(v.hasOwnProperty(w)&&v[w]===!0)return s.dispatch({type:"queue",plugin:w,payload:j,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(A);var K=p(g[w],i[w]);return Promise.resolve(R[f]({abort:K.abort,payload:j,instance:n,config:eh(w,l,i),plugins:l})).then(function(B){var re=ze(B)?B:{},L=te({},A,re),M=g[w];if(hs(M,w))ds({data:M,method:f,instance:n,pluginName:w,store:s});else{var N=f+":"+w;(N.match(/:/g)||[]).length<2&&!f.match(Xd)&&!f.match(Qd)&&n.dispatch(te({},h?L:j,{type:N,_:{called:N,from:"submethod"}}))}return Promise.resolve(L)})})}catch(A){return Promise.reject(A)}},Promise.resolve(r))).then(function(P){if(!(f.match(wr)||f.match(/^registerPlugin/)||f.match(Qd)||f.match(Xd)||f.match(/^params/)||f.match(/^userIdChanged/))){if(u.plugins.includes(f),P._&&P._.originalAction===f)return P;var b=te({},P,{_:{originalAction:P.type,called:P.type,from:"engineEnd"}});Rv(P,e.exact.length)&&!f.match(/End$/)&&(b=te({},b,{type:P.type+"Aborted"})),s.dispatch(b)}return P})})}catch(g){return Promise.reject(g)}},wr=/Start$/,Xd=/^bootstrap/,Qd=/^ready/;function ds(t){var e=t.pluginName,r=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(te({},t.data,{type:r,_:{called:r,from:"abort"}}))}function eh(t,e,r){var n=e[t]||r[t];return n&&n.config?n.config:{}}function th(t,e){return e.reduce(function(r,n){return n[t]?r.concat({methodName:t,pluginName:n.name,method:n[t]}):r},[])}function rh(t,e){var r=t.replace(wr,""),n=e?":"+e:"";return[""+t+n,""+r+n,r+"End"+n]}function hs(t,e){var r=t.abort;return!!r&&(r===!0||nh(r,e)||r&&nh(r.plugins,e))}function Rv(t,e){var r=t.abort;if(!r)return!1;if(r===!0||Ct(r))return!0;var n=r.plugins;return tn(r)&&r.length===e||tn(n)&&n.length===e}function tn(t){return Array.isArray(t)}function nh(t,e){return!(!t||!tn(t))&&t.includes(e)}function ah(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function ub(t){return Object.keys(t).reduce(function(e,r){return r==="type"||(e[r]=ze(t[r])?Object.assign({},t[r]):t[r]),e},{})}function lb(t,e,r){var n={};return function(a){return function(i){return function(o){try{var s,u=function(m){return s?m:i(f)},l=o.type,c=o.plugins,f=o;if(o.abort)return Promise.resolve(i(o));if(l===ee.enablePlugin&&a.dispatch({type:ee.initializeStart,plugins:c,disabled:[],fromEnable:!0,meta:o.meta}),l===ee.disablePlugin&&setTimeout(function(){return Yd(o.meta.rid,{payload:o})},0),l===ee.initializeEnd){var h=e(),d=Object.keys(h),p=d.filter(function(m){return c.includes(m)}).map(function(m){return h[m]}),v=[],g=[],P=o.disabled,b=p.map(function(m){var w=m.loaded,R=m.name,A=m.config;return _v(m,function(){return w({config:A})},1e4).then(function(j){return n[R]||(a.dispatch({type:ee.pluginReadyType(R),name:R,events:Object.keys(m).filter(function(K){return!$s.includes(K)})}),n[R]=!0),v=v.concat(R),m}).catch(function(j){if(j instanceof Error)throw new Error(j);return g=g.concat(j.name),j})});Promise.all(b).then(function(m){var w={plugins:v,failed:g,disabled:P};setTimeout(function(){d.length===b.length+P.length&&a.dispatch(te({},{type:ee.ready},w))},0)})}var y=(function(){if(l!==ee.bootstrap)return/^ready:([^:]*)$/.test(l)&&setTimeout(function(){return Tv(a,e,t)},0),Promise.resolve((function(m,w,R,A,j){try{var K=He(w)?w():w,B=m.type,re=B.replace(wr,"");if(m._&&m._.called)return Promise.resolve(m);var L=R.getState(),M=(O=K,(q=L.plugins)===void 0&&(q={}),(F=m.options)===void 0&&(F={}),Object.keys(O).filter(function(I){var _=F.plugins||{};return Hw(_[I])?_[I]:_.all!==!1&&(!q[I]||q[I].enabled!==!1)}).map(function(I){return O[I]}));B===ee.initializeStart&&m.fromEnable&&(M=Object.keys(L.plugins).filter(function(I){var _=L.plugins[I];return m.plugins.includes(I)&&!_.initialized}).map(function(I){return K[I]}));var N=M.map(function(I){return I.name}),S=(function(I,_){var x=rh(I).map(function(H){return th(H,_)});return _.reduce(function(H,X){var Z=X.name,fe=rh(I,Z).map(function(Te){return th(Te,_)}),ae=fe[0],ue=fe[1],ie=fe[2];return ae.length&&(H.beforeNS[Z]=ae),ue.length&&(H.duringNS[Z]=ue),ie.length&&(H.afterNS[Z]=ie),H},{before:x[0],beforeNS:{},during:x[1],duringNS:{},after:x[2],afterNS:{}})})(B,M);return Promise.resolve(fs({action:m,data:{exact:S.before,namespaced:S.beforeNS},state:L,allPlugins:K,allMatches:S,instance:R,store:A,EVENTS:j})).then(function(I){function _(){var X=(function(){if(B.match(wr))return Promise.resolve(fs({action:te({},x,{type:re+"End"}),data:{exact:S.after,namespaced:S.afterNS},state:L,allPlugins:K,allMatches:S,instance:R,store:A,EVENTS:j})).then(function(Z){Z.meta&&Z.meta.hasCallback&&Yd(Z.meta.rid,{payload:Z})})})();return X&&X.then?X.then(function(){return I}):I}if(Rv(I,N.length))return I;var x,H=(function(){if(B!==re)return Promise.resolve(fs({action:te({},I,{type:re}),data:{exact:S.during,namespaced:S.duringNS},state:L,allPlugins:K,allMatches:S,instance:R,store:A,EVENTS:j})).then(function(X){x=X});x=I})();return H&&H.then?H.then(_):_()})}catch(I){return Promise.reject(I)}var O,q,F})(o,e,t,a,r)).then(function(m){var w=i(m);return s=1,w})})();return Promise.resolve(y&&y.then?y.then(u):u(y))}catch(m){return Promise.reject(m)}}}}}function fb(t){return function(e){return function(r){return function(n){var a=n.type,i=n.key,o=n.value,s=n.options;if(a===ee.setItem||a===ee.removeItem){if(n.abort)return r(n);a===ee.setItem?t.setItem(i,o,s):t.removeItem(i,s)}return r(n)}}}}var db=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,r){t[r]=t[r].concat(e)},this.removeMiddleware=function(e,r){var n=t[r].findIndex(function(a){return a===e});n!==-1&&(t[r]=[].concat(t[r].slice(0,n),t[r].slice(n+1)))},this.dynamicMiddlewares=function(e){return function(r){return function(n){return function(a){var i={getState:r.getState,dispatch:function(s){return r.dispatch(s)}},o=t[e].map(function(s){return s(i)});return Er.apply(void 0,o)(n)(a)}}}}};function hb(t){return function(e,r){e===void 0&&(e={});var n={};if(r.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(r.type)){var a=ih(r.type,"registerPlugin"),i=t()[a];if(!i||!a)return e;var o=r.enabled,s=i.config;return n[a]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:s}),config:s},te({},e,n)}if(/^initialize:([^:]*)$/.test(r.type)){var u=ih(r.type,ee.initialize),l=t()[u];return l&&u?(n[u]=te({},e[u],{initialized:!0,loaded:!!l.loaded({config:l.config})}),te({},e,n)):e}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=te({},e[r.name],{loaded:!0}),te({},e,n);switch(r.type){case ee.disablePlugin:return te({},e,oh(r.plugins,!1,e));case ee.enablePlugin:return te({},e,oh(r.plugins,!0,e));default:return e}}}function ih(t,e){return t.substring(e.length+1,t.length)}function oh(t,e,r){return t.reduce(function(n,a){return n[a]=te({},r[a],{enabled:e}),n},r)}function Ov(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var pb={last:{},history:[]};function vb(t,e){t===void 0&&(t=pb);var r=e.options,n=e.meta;if(e.type===ee.track){var a=Ov(te({event:e.event,properties:e.properties},Object.keys(r).length&&{options:r},{meta:n}));return te({},t,{last:a,history:t.history.concat(a)})}return t}var mb={actions:[]};function gb(t,e){t===void 0&&(t=mb);var r=e.payload;switch(e.type){case"queue":var n;return n=r&&r.type&&r.type===ee.identify?[e].concat(t.actions):t.actions.concat(e),te({},t,{actions:n});case"dequeue":return[];default:return t}}var Cv=/#.*$/;function yb(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Cv,""):"")}var Av,$v,Uv,Lv,wb=function(t){if(t===void 0&&(t={}),!Ae)return t;var e=document,r=e.title,n=e.referrer,a=window,i=a.location,o=a.innerWidth,s=a.innerHeight,u=i.hash,l=i.search,c=(function(h){var d=(function(){if(Ae){for(var p,v=document.getElementsByTagName("link"),g=0;p=v[g];g++)if(p.getAttribute("rel")==="canonical")return p.getAttribute("href")}})();return d?d.match(/\?/)?d:d+h:window.location.href.replace(Cv,"")})(l),f={title:r,url:c,path:yb(c),hash:u,search:l,width:o,height:s};return n&&n!==""&&(f.referrer=n),te({},f,t)},bb={last:{},history:[]};function Sb(t,e){t===void 0&&(t=bb);var r=e.options;if(e.type===ee.page){var n=Ov(te({properties:e.properties,meta:e.meta},Object.keys(r).length&&{options:r}));return te({},t,{last:n,history:t.history.concat(n)})}return t}Av=(function(){if(!Ae)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"})(),$v=Ae?document.referrer:null,Uv=Yw(),Lv=Xw();var sh={initialized:!1,sessionId:ua(),app:null,version:null,debug:!1,offline:!!Ae&&!navigator.onLine,os:{name:Av},userAgent:Ae?navigator.userAgent:"node",library:{name:As,version:"0.13.1"},timezone:Lv,locale:Uv,campaign:{},referrer:$v};function Ib(t,e){t===void 0&&(t=sh);var r=t.initialized,n=e.campaign;switch(e.type){case ee.campaign:return te({},t,{campaign:n});case ee.offline:return te({},t,{offline:!0});case ee.online:return te({},t,{offline:!1});default:return r?t:te({},sh,t,{initialized:!0})}}var Pb=["plugins","reducers","storage"];function Eb(t,e,r){if(Ae){var n=window[(r?"add":"remove")+"EventListener"];t.split(" ").forEach(function(a){n(a,e)})}}function kb(t){var e=Eb.bind(null,"online offline",function(r){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(r){return e(!1)}}function qv(){return tr(As,[]),function(t){return function(e,r,n){var a=t(e,r,n),i=a.dispatch;return Object.assign(a,{dispatch:function(o){return Pr[Ir][As].push(o.action||o),i(o)}})}}}function ch(t){return function(){return Er(Er.apply(null,arguments),qv())}}function ps(t){return t?Iv(t)?t:[t]:[]}function uh(t,e,r){t===void 0&&(t={});var n,a,i=ua();return e&&(Vr[i]=(n=e,a=(function(o){for(var s,u=o||Array.prototype.slice.call(arguments),l=0;l<u.length;l++)if(He(u[l])){s=u[l];break}return s})(r),function(o){a&&a(o),n(o)})),te({},t,{rid:i,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function _b(t){t===void 0&&(t={});var e=t.reducers||{},r=t.initialUser||{},n=(t.plugins||[]).reduce(function(I,_){if(He(_))return I.middlewares=I.middlewares.concat(_),I;if(_.NAMESPACE&&(_.name=_.NAMESPACE),!_.name)throw new Error("https://lytics.dev/errors/1");_.config||(_.config={});var x=_.EVENTS?Object.keys(_.EVENTS).map(function(Z){return _.EVENTS[Z]}):[];I.pluginEnabled[_.name]=!(_.enabled===!1||_.config.enabled===!1),delete _.enabled,_.methods&&(I.methods[_.name]=Object.keys(_.methods).reduce(function(Z,fe){var ae;return Z[fe]=(ae=_.methods[fe],function(){for(var ue=Array.prototype.slice.call(arguments),ie=new Array(ae.length),Te=0;Te<ue.length;Te++)ie[Te]=ue[Te];return ie[ie.length]=w,ae.apply({instance:w},ie)}),Z},{}),delete _.methods);var H=Object.keys(_).concat(x),X=new Set(I.events.concat(H));if(I.events=Array.from(X),I.pluginsArray=I.pluginsArray.concat(_),I.plugins[_.name])throw new Error(_.name+"AlreadyLoaded");return I.plugins[_.name]=_,I.plugins[_.name].loaded||(I.plugins[_.name].loaded=function(){return!0}),I},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),a=t.storage?t.storage:{getItem:er,setItem:tr,removeItem:Cr},i=(function(I){return function(_,x,H){return x.getState("user")[_]||(H&&ze(H)&&H[_]?H[_]:Zd(I)[_]||er(Us(_))||null)}})(a),o=n.plugins,s=n.events.filter(function(I){return!$s.includes(I)}).sort(),u=new Set(s.concat(Cn).filter(function(I){return!$s.includes(I)})),l=Array.from(u).sort(),c=function(){return o},f=new db,h=f.addMiddleware,d=f.removeMiddleware,p=f.dynamicMiddlewares,v=function(){throw new Error("Abort disabled inListener")},g=Qw(),P=Zd(a),b=te({},P,r,g.an_uid?{userId:g.an_uid}:{},g.an_aid?{anonymousId:g.an_aid}:{});b.anonymousId||(b.anonymousId=ua());var y=te({enable:function(I,_){return new Promise(function(x){S.dispatch({type:ee.enablePlugin,plugins:ps(I),_:{originalAction:ee.enablePlugin}},x,[_])})},disable:function(I,_){return new Promise(function(x){S.dispatch({type:ee.disablePlugin,plugins:ps(I),_:{originalAction:ee.disablePlugin}},x,[_])})}},n.methods),m=!1,w={identify:function(I,_,x,H){try{var X=Ct(I)?I:null,Z=ze(I)?I:_,fe=x||{},ae=w.user();tr(Us(kt),X);var ue=X||Z.userId||i(kt,w,Z);return Promise.resolve(new Promise(function(ie){S.dispatch(te({type:ee.identifyStart,userId:ue,traits:Z||{},options:fe,anonymousId:ae.anonymousId},ae.id&&ae.id!==X&&{previousId:ae.id}),ie,[_,x,H])}))}catch(ie){return Promise.reject(ie)}},track:function(I,_,x,H){try{var X=ze(I)?I.event:I;if(!X||!Ct(X))throw new Error("EventMissing");var Z=ze(I)?I:_||{},fe=ze(x)?x:{};return Promise.resolve(new Promise(function(ae){S.dispatch({type:ee.trackStart,event:X,properties:Z,options:fe,userId:i(kt,w,_),anonymousId:i(gr,w,_)},ae,[_,x,H])}))}catch(ae){return Promise.reject(ae)}},page:function(I,_,x){try{var H=ze(I)?I:{},X=ze(_)?_:{};return Promise.resolve(new Promise(function(Z){S.dispatch({type:ee.pageStart,properties:wb(H),options:X,userId:i(kt,w,H),anonymousId:i(gr,w,H)},Z,[I,_,x])}))}catch(Z){return Promise.reject(Z)}},user:function(I){if(I===kt||I==="id")return i(kt,w);if(I===gr||I==="anonId")return i(gr,w);var _=w.getState("user");return I?Hd(_,I):_},reset:function(I){return new Promise(function(_){S.dispatch({type:ee.resetStart},_,I)})},ready:function(I){return m&&I({plugins:y,instance:w}),w.on(ee.ready,function(_){I&&I(_),m=!0})},on:function(I,_){if(!I||!He(_))return!1;if(I===ee.bootstrap)throw new Error(".on disabled for "+I);var x=/Start$|Start:/;if(I==="*"){var H=function(ae){return function(ue){return function(ie){return ie.type.match(x)&&_({payload:ie,instance:w,plugins:o}),ue(ie)}}},X=function(ae){return function(ue){return function(ie){return ie.type.match(x)||_({payload:ie,instance:w,plugins:o}),ue(ie)}}};return h(H,wn),h(X,bn),function(){d(H,wn),d(X,bn)}}var Z=I.match(x)?wn:bn,fe=function(ae){return function(ue){return function(ie){return ie.type===I&&_({payload:ie,instance:w,plugins:o,abort:v}),ue(ie)}}};return h(fe,Z),function(){return d(fe,Z)}},once:function(I,_){if(!I||!He(_))return!1;if(I===ee.bootstrap)throw new Error(".once disabled for "+I);var x=w.on(I,function(H){_({payload:H.payload,instance:w,plugins:o,abort:v}),x()});return x},getState:function(I){var _=S.getState();return I?Hd(_,I):Object.assign({},_)},dispatch:function(I){var _=Ct(I)?{type:I}:I;if(Cn.includes(_.type))throw new Error("reserved action "+_.type);var x=te({},_,{_:te({originalAction:_.type},I._||{})});S.dispatch(x)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:a.getItem,setItem:function(I,_,x){S.dispatch({type:ee.setItemStart,key:I,value:_,options:x})},removeItem:function(I,_){S.dispatch({type:ee.removeItemStart,key:I,options:_})}},setAnonymousId:function(I,_){w.storage.setItem(At,I,_)},events:{core:Cn,plugins:s}},R=n.middlewares.concat([function(I){return function(_){return function(x){return x.meta||(x.meta=uh()),_(x)}}},p(wn),lb(w,c,{all:l,plugins:s}),fb(a),ib(w),sb(w),p(bn)]),A={context:Ib,user:ob(a),page:Sb,track:vb,plugins:hb(c),queue:gb},j=Er,K=Er;if(Ae&&t.debug){var B=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;B&&(j=B({trace:!0,traceLimit:25})),K=function(){return arguments.length===0?qv():ze(typeof arguments[0])?ch():ch().apply(null,arguments)}}var re,L=(function(I){return Object.keys(I).reduce(function(_,x){return Pb.includes(x)||(_[x]=I[x]),_},{})})(t),M=n.pluginsArray.reduce(function(I,_){var x=_.name,H=_.config,X=_.loaded,Z=n.pluginEnabled[x];return I[x]={enabled:Z,initialized:!!Z&&!_.initialize,loaded:!!X({config:H}),config:H},I},{}),N={context:L,user:b,plugins:M},S=kv((function(I){for(var _=Object.keys(I),x={},H=0;H<_.length;H++){var X=_[H];typeof I[X]===_t&&(x[X]=I[X])}var Z,fe=Object.keys(x);try{(function(ae){Object.keys(ae).forEach(function(ue){var ie=ae[ue];if(typeof ie(void 0,{type:Cs})===gt||typeof ie(void 0,{type:rb})===gt)throw new Error(en+" "+ue+" "+gt)})})(x)}catch(ae){Z=ae}return function(ae,ue){if(ae===void 0&&(ae={}),Z)throw Z;for(var ie=!1,Te={},je=0;je<fe.length;je++){var Me=fe[je],qe=ae[Me],et=(0,x[Me])(qe,ue);if(typeof et===gt){var Pt=nb(Me,ue);throw new Error(Pt)}Te[Me]=et,ie=ie||et!==qe}return ie?Te:ae}})(te({},A,e)),N,K(j(ab.apply(void 0,R))));S.dispatch=(re=S.dispatch,function(I,_,x){var H=te({},I,{meta:uh(I.meta,_,ps(x))});return re.apply(null,[H])});var O=Object.keys(o);S.dispatch({type:ee.bootstrap,plugins:O,config:L,params:g,user:b,initialUser:r,persistedUser:P});var q=O.filter(function(I){return n.pluginEnabled[I]}),F=O.filter(function(I){return!n.pluginEnabled[I]});return S.dispatch({type:ee.registerPlugins,plugins:O,enabled:n.pluginEnabled}),n.pluginsArray.map(function(I,_){var x=I.bootstrap,H=I.config,X=I.name;x&&He(x)&&x({instance:w,config:H,payload:I}),S.dispatch({type:ee.registerPluginType(X),name:X,enabled:n.pluginEnabled[X],plugin:I}),n.pluginsArray.length===_+1&&S.dispatch({type:ee.initializeStart,plugins:q,disabled:F})}),kb(function(I){S.dispatch({type:I?ee.offline:ee.online})}),(function(I,_,x){setInterval(function(){return Tv(I,_,x)},3e3)})(S,c,w),w}var wn="before",bn="after",Vt="cookie",Ft=jv(),Nv=la,Tb=la;function xv(t){return Ft?la(t,"",-1):Cr(t)}function jv(){if(Ft!==void 0)return Ft;var t=Vt+Vt;try{la(t,t),Ft=document.cookie.indexOf(t)!==-1,xv(t)}catch{Ft=!1}return Ft}function la(t,e,r,n,a,i){if(typeof window<"u"){var o=arguments.length>1;return Ft===!1&&(o?tr(t,e):er(t)),o?document.cookie=t+"="+encodeURIComponent(e)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(a?"; domain="+a:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var yt="localStorage",Rb=vc.bind(null,yt);Ar(yt,"getItem",er);Ar(yt,"setItem",tr);Ar(yt,"removeItem",Cr);var wt="sessionStorage",Ob=vc.bind(null,wt);Ar(wt,"getItem",er);Ar(wt,"setItem",tr);Ar(wt,"removeItem",Cr);function br(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(ze(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var Cb=Rb(),Ab=Ob(),$b=jv();function Jt(t,e){if(t){var r=mc(e),n=!bc(r),a=gc(r)?br(localStorage.getItem(t)):void 0;if(n&&!mr(a))return a;var i=yc(r)?br(Nv(t)):void 0;if(n&&i)return i;var o=wc(r)?br(sessionStorage.getItem(t)):void 0;if(n&&o)return o;var s=er(t);return n?s:{localStorage:a,sessionStorage:o,cookie:i,global:s}}}function Mn(t,e,r){if(t&&!mr(e)){var n={},a=mc(r),i=JSON.stringify(e),o=!bc(a);return gc(a)&&(n[yt]=Sn(yt,e,br(localStorage.getItem(t))),localStorage.setItem(t,i),o)?n[yt]:yc(a)&&(n[Vt]=Sn(Vt,e,br(Nv(t))),Tb(t,i),o)?n[Vt]:wc(a)&&(n[wt]=Sn(wt,e,br(sessionStorage.getItem(t))),sessionStorage.setItem(t,i),o)?n[wt]:(n[Gt]=Sn(Gt,e,er(t)),tr(t,e),o?n[Gt]:n)}}function Ub(t,e){if(t){var r=mc(e),n=Jt(t,wv),a={};return!mr(n.localStorage)&&gc(r)&&(localStorage.removeItem(t),a[yt]=n.localStorage),!mr(n.cookie)&&yc(r)&&(xv(t),a[Vt]=n.cookie),!mr(n.sessionStorage)&&wc(r)&&(sessionStorage.removeItem(t),a[wt]=n.sessionStorage),!mr(n.global)&&fa(r,Gt)&&(Cr(t),a[Gt]=n.global),a}}function mc(t){return t?Ct(t)?t:t.storage:yv}function gc(t){return Cb&&fa(t,yt)}function yc(t){return $b&&fa(t,Vt)}function wc(t){return Ab&&fa(t,wt)}function bc(t){return t===wv||t==="all"}function fa(t,e){return t===yv||t===e||bc(t)}function Sn(t,e,r){return{location:t,current:e,previous:r}}var Lb={setItem:Mn,getItem:Jt,removeItem:Ub};function qb(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function lh(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function fh(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?lh(Object(r),!0).forEach(function(n){qb(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):lh(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Nb(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Lb};return _b(fh(fh({},e),t))}function xb(t){if(typeof window>"u")return;const{addEventListener:e,history:r,location:n}=window;let a=n.pathname;e("popstate",()=>t(n.pathname)),["push","replace"].map(i=>{const o=`${i}State`;if(o!=="pushState"&&o!=="replaceState")return;const s=r[o];r[o]=function(...u){const l=u[2]?.toString()||"",c=Db(l);return a!==c&&(a=c,setTimeout(()=>t(l),0)),s.apply(r,u)}})}function jb(t,e){const r=t.indexOf(e);return r>-1?t.slice(0,r):t}function Db(t){return["#","?"].forEach(e=>t=jb(t,e)),t}function Mb(){xb(()=>{ht.page()})}var vs="up",ms="down";function Fb(t){if(t===void 0&&(t={}),!Ae)return Os;var e=hh(),r=Ls(),n=dh(),a=In(n,e),i=In(r,e),o=[],s=[],u=[],l=n,c=a,f=i,h=Object.keys(t);if(!h.length)return Os;var d=h.map(function(v){return Number(v)}),p=tb(function(){var v=hh(),g=(function(L,M){return M.map(function(N){return N===100?L-5:L*(N/100)})})(v,d),P=Ls(),b=dh(),y=In(b,v),m=In(P,v);if(c=y>c?y:c,f=m<f?m:f,!(o.length>=d.length)){var w=l===b,R=vs;w?R="initial":l<=b&&(R=ms);var A=g,j=d;(R===vs||w)&&(A=g.slice().reverse(),j=d.slice().reverse());var K=j.reduce(function(L,M,N){var S=A[N];return u.includes(M)&&b<=S&&(u=u.filter(function(O){return O!==M}),L.singleFunction=M),R===ms&&!o.includes(M)&&b>=S&&M>i?(s.push(M),L.callbacks=L.callbacks.concat(M),L):R===vs&&!o.includes(M)&&b<=S&&M<=y?(L.foundFunc=[M],L):(w&&b>=S&&L.foundFunc.length===0&&(L.foundFunc=[M]),!s.includes(M)&&b>=S&&(s.push(M),L.singleFunction?u.push(M):L.singleFunction=M),L)},{foundFunc:[],singleFunction:null,callbacks:[],direction:R});if(l=b,R===ms&&K.callbacks&&K.callbacks.forEach(function(L){He(t[L])&&(t[L]({trigger:L,direction:R,scrollMin:f,scrollMax:c,range:[f,c]}),o.push(L))}),K.singleFunction){var B=K.singleFunction,re=K.direction;He(t[B])&&t[B]({trigger:B,direction:re,scrollMin:f,scrollMax:c,range:[f,c]}),o.push(B)}}},500);return window.addEventListener("scroll",p),function(){return window.removeEventListener("scroll",p)}}function Ls(){return Ae?document.body.scrollTop||document.documentElement.scrollTop:0}function Kb(){return Ae?window.innerHeight||document.documentElement.clientHeight:0}function dh(){return Math.round(Ls()+Kb())}function hh(){if(!Ae)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function In(t,e){return Math.round(t/e*100)}var Sc="Event",ph=Sc+"Listener";function zb(t){return function(e,r,n,a){var i=n||Os,o=a||!1;if(!Ae)return i;var s=Fn(r),u=Fn(e,!0);if(!u.length)throw new Error("noElements");if(!s.length)throw new Error("no"+Sc);var l=[];return(function c(f){f&&(l=[]);for(var h=f?"add"+ph:"remove"+ph,d=0;d<u.length;d++){var p=u[d];l[d]=f?o&&o.once?Hb(i):i:l[d]||i;for(var v=0;v<s.length;v++)p[h]?p["on"+s[v]]=f?l[d]:null:p[h](s[v],l[d],o)}return c.bind(null,!f)})(t)}}function Fn(t,e){if(Ct(t))return e?Fn(document.querySelectorAll(t)):(r=t).split(r.indexOf(",")>-1?",":" ").map(function(o){return o.trim()});var r;if(NodeList.prototype.isPrototypeOf(t)){for(var n=[],a=t.length>>>0;a--;)n[a]=t[a];return n}var i=Zw(t);return e?i.map(function(o){return Ct(o)?Fn(o,!0):o}).flat():i}function Hb(t,e){var r;return function(){return t&&(r=t.apply(this,arguments),t=null),r}}var gs=zb(Sc);function Dv(t,e){return Ae&&He(window[t])?(r=window[t],n=e,(a=window)===void 0&&(a=null),He(r)?function(){r.apply(a,arguments),n.apply(a,arguments)}:n):window[t]=e;var r,n,a}Dv.bind(null,"onerror");Dv.bind(null,"onload");var Mv=typeof window>"u",vh="hidden";function Bb(t){if(Mv)return!1;var e=Gb(),r="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),n=function(){return t(!!document[e])},a=function(){return document.addEventListener(r,n)};return a(),function(){return document.removeEventListener(r,n),a}}function Gb(){var t=["webkit","moz","ms","o"];return Mv||vh in document?vh:t.reduce(function(e,r){var n=r+"Hidden";return!e&&n in document?n:e},null)}var Wb=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Vb(t,e){e===void 0&&(e={});var r=(function(o,s){var u=this,l=!1;return function(c){l||(o.call(u,c),l=!0,setTimeout(function(){return l=!1},s))}})(t,e.throttle||1e4),n=[];function a(){var o=Bb(function(s){s||r({type:"tabVisible"})});return n=[o].concat(Wb.map(function(s){return gs(document,s,r)})).concat(gs(window,"load",r)).concat(gs(window,"scroll",r,{capture:!0,passive:!0})),i}function i(){n.map(function(o){return o()})}return a(),function(){return i(),a}}function Jb(t){var e,r,n=t.onIdle,a=t.onWakeUp,i=t.onHeartbeat,o=t.timeout,s=o,u=t.throttle,l=u===void 0?2e3:u,c=!1,f=!1,h=new Date,d=function(){return clearTimeout(e)};function p(g){d(),i&&!c&&i(Kr(h),g),a&&c&&(c=!1,a(Kr(r),g),h=new Date),e=setTimeout(function(){c=!0,n&&(r=new Date,n(Kr(h),g))},s)}var v=Vb(p,{throttle:l});return{disable:function(){f=!0,c=!1,d();var g=v();return function(){return f=!1,h=new Date,p({type:"load"}),g()}},getStatus:function(){return{isIdle:c,isDisabled:f,active:c?0:Kr(h,f),idle:c?Kr(r,f):0}}}}function Kr(t,e){return e?0:Math.round((new Date-t)/1e3)}const mh=5e3;class Zb{element;isInViewport=!1;isAwake=!1;isFlushing;observer;lastEventAt=Date.now();registeredView=!1;viewCallback;activeDurationCallback;idleDurationCallback;scrollCallback;constructor(e){this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(r=>{r.forEach(n=>{this.handleInViewPort(n.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Jb({onIdle:r=>this.handleAwake(!1,r),onWakeUp:r=>this.handleAwake(!0,r),timeout:mh}),Fb({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,r=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-r*mh:Date.now(),this.isInViewport&&this.trackAwake(e,r)}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,r){!e&&this.activeDurationCallback&&this.activeDurationCallback(r,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(r,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}function Fv(t){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}function Yb(t,e){e=e||{};var r,n,a=[],i=e.max||1/0;function o(){clearInterval(r),t(a.splice(0,i)),s()}function s(){r=setInterval(o,e.interval||1e4)}return s(),{flush:o,push:function(u){return n=a.push(u),n>=i&&o(),n},size:function(){return a.length},end:function(u){u&&o(),clearInterval(r)}}}const gh="sesamy_session_id";function Xb(){let t=sessionStorage.getItem(gh);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(gh,t)),t}let Kv=!1,An,Kn,qs;function zv(t){return JSON.stringify(t.map(e=>{const{campaign:r,...n}=e.properties||{};return{anonymousId:e.anonymousId,userId:e.userId,type:e.type,properties:n,clientId:qs,requestId:Math.random().toString(36).slice(2,9),sessionId:Xb(),timestamp:new Date().toISOString(),version:fn,event:e.event,context:{...e.context,page:{url:window.location.href,title:document.title,referrer:document.referrer,itemSrc:ge("sesamy:item-src"),publisherContentId:ge("sesamy:publisher-content-id")},campaign:r,locale:navigator.language,library:dc,userAgent:navigator.userAgent,clientId:qs}}}))}const Hv=Yb(async t=>{if(t.length>0){const e=zv(t);Kv?navigator.sendBeacon(Kn,e):(await fetch(Kn,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function ys(t){if(t.anonymousId)if(t.properties?.flushing){const e={...t};delete e.properties.flushing,navigator.sendBeacon(Kn,zv([e]))}else Hv.push(t)}function Qb(){return Kv=!0,Hv.flush()}function eS(t,e,r){An=e,Kn=`${rt("logs",r)}/events`,qs=t}const tS={name:"custom-analytics-plugin",page:({payload:t})=>{if(!An)return;const{properties:e,anonymousId:r,userId:n,event:a}=t;ys({anonymousId:r,userId:n,properties:e,event:a,type:"page"})},track:({payload:t})=>{if(!An)return;const{properties:e,anonymousId:r,userId:n,event:a}=t;ys({anonymousId:r,userId:n,properties:e,event:a,type:"track"})},identify:({payload:t})=>{if(!An)return;const{properties:e,anonymousId:r,userId:n}=t;ys({anonymousId:r,userId:n,properties:e,type:"identify"})}},yh=["source","medium","campaign","term","content"],Tt="utm_",rS=1800*1e3;function Bv(t){return t?Date.now()-parseInt(t,10)>rS:!0}function wh(){const t=document.referrer||"";if(!t)return;const e=Jt(`${Tt}set_at`);(Bv(e)||!Jt(`${Tt}referrer`))&&Mn(`${Tt}referrer`,t)}function nS(){const t=()=>{const r={};for(const a of yh){const i=Jt(`${Tt}${a}`);i&&(r[`utm_${a}`]=i)}const n=Jt(`${Tt}referrer`);return n&&(r.utm_referrer=n),r};return{name:"attribution-tracking",initialize(){wh()},campaign({payload:r}){const n=r?.campaign||{},a=Jt(`${Tt}set_at`);if(Object.keys(n).length>0&&Bv(a)){for(const o of yh){const s=n[o];s&&Mn(`${Tt}${o}`,s)}Mn(`${Tt}set_at`,String(Date.now()))}wh()},page({payload:r}){return r.properties.campaign=t(),r},track({payload:r}){return r.properties.campaign=t(),r},getStoredCampaignData:t}}const aS=nS(),bh=new Map,Sh=new Map;function iS({clientId:t,enabled:e=!0,environment:r}){eS(t,e,r),e&&(window.addEventListener("beforeunload",()=>{Sh.forEach((n,a)=>{n.bind(a)()}),Qb()}),window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&bh.forEach((n,a)=>{n.bind(a)()})}),Mb(),Fv(()=>{const n=new Zb({element:document.body,viewCallback:()=>{ht.page()},activeDurationCallback:(a,i,o)=>{ht.track("activeDuration",{duration:a,durationStart:o,flushing:i})},idleDurationCallback:(a,i,o)=>{ht.track("idleDuration",{duration:a,durationStart:o,flushing:i})},scrollCallback:a=>{ht.track("scroll",{scroll:a.scrollMax})}});Sh.set(document.body,()=>{n.flush()}),bh.set(document.body,()=>{n.handleVisibilityChange()})}),window.addEventListener(Ge.AUTHENTICATED,async n=>{const a=n;await ht.identify(a.detail.sub)}),window.addEventListener(Ge.LOGOUT,async()=>{await ht.track("logout",{}),await ht.reset()}))}const ht=Nb({app:dc,version:fn,plugins:[aS,tS]});function Gv(t,e){ht.track(t,e)}const oS=["AdHeader","AdContainer","AD_Top","homead","ad-lead"];function Wv(){return new Promise(t=>{const e=oS.map(r=>{const n=document.createElement("div");return n.innerHTML=" ",n.id=r,n.style.position="absolute",document.body.appendChild(n),n});window.setTimeout(()=>{const r=!e.every(n=>document.querySelector(`#${n.id}`)?.offsetParent);e.forEach(n=>n.remove()),t(r)},100)})}function Vv(){const t=navigator.userAgent.toLowerCase(),e=[{name:"Facebook",regex:/fbav|fban/i},{name:"LinkedIn",regex:/linkedin/i},{name:"Instagram",regex:/instagram/i},{name:"Gmail",regex:/gmail/i},{name:"Twitter",regex:/twitter/i},{name:"WeChat",regex:/micromessenger/i},{name:"Line",regex:/line/i},{name:"Snapchat",regex:/snapchat/i},{name:"Pinterest",regex:/pinterest/i},{name:"Kakao",regex:/kakaotalk/i},{name:"Skype",regex:/skype/i},{name:"WhatsApp",regex:/whatsapp/i}];for(const r of e)if(r.regex.test(t))return{isInAppBrowser:!0,browserName:r.name};return/; wv\)/.test(t)?{isInAppBrowser:!0,browserName:"Unknown In-App Browser"}:{isInAppBrowser:!1,browserName:null}}function sS(t,e,r=!1){const n={name:t,data:e},a=new CustomEvent(t,{detail:n,cancelable:r,bubbles:!0});Gv(`event:${t}`,{...e,timestamp:new Date().toISOString()});const i=window.dispatchEvent(a);return r&&!i?{canceled:!0,message:n.cancellationMessage}:{canceled:!1}}function cS(t,e){t.cancelable&&(t.detail.cancellationMessage=e,t.preventDefault())}const uS=["sesamy","__sesamy","__anon_id","auth0","a0","_legacy_auth0"],lS=["access_token","id_token","refresh_token","token"];function Ns(t){const e=t.split(".");return e.length===3?`${e[0]}.${e[1]}.[REDACTED]`:t}function Jv(t){const e=t.toLowerCase();return lS.some(r=>e.includes(r))}function Zv(t){const e=t.split(".");return e.length===3&&e.every(r=>r.length>0)}function Ih(t){const e=[];for(let r=0;r<t.length;r++){const n=t.key(r);if(!n)continue;if(uS.some(i=>n.toLowerCase().startsWith(i.toLowerCase()))){let i=t.getItem(n)||"",o=!1;(Jv(n)||Zv(i))&&(i=Ns(i),o=!0);try{const s=JSON.parse(i);if(typeof s=="object"&&s!==null){const u=xs(s);u.wasRedacted&&(i=JSON.stringify(u.value),o=!0)}}catch{}e.push({key:n,value:i,redacted:o})}}return e}function xs(t){if(t==null)return{value:t,wasRedacted:!1};if(typeof t=="string")return Zv(t)?{value:Ns(t),wasRedacted:!0}:{value:t,wasRedacted:!1};if(Array.isArray(t)){let e=!1;return{value:t.map(n=>{const a=xs(n);return a.wasRedacted&&(e=!0),a.value}),wasRedacted:e}}if(typeof t=="object"){let e=!1;const r={};for(const[n,a]of Object.entries(t))if(Jv(n)&&typeof a=="string")r[n]=Ns(a),e=!0;else{const i=xs(a);i.wasRedacted&&(e=!0),r[n]=i.value}return{value:r,wasRedacted:e}}return{value:t,wasRedacted:!1}}function fS(){const t=navigator;return{userAgent:t.userAgent,platform:t.platform,language:t.language,languages:[...t.languages||[]],cookiesEnabled:t.cookieEnabled,onLine:t.onLine,hardwareConcurrency:t.hardwareConcurrency,deviceMemory:t.deviceMemory,maxTouchPoints:t.maxTouchPoints,vendor:t.vendor,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,screenWidth:screen.width,screenHeight:screen.height,pixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset()}}async function dS(){await Hp();const[t]=await Promise.all([Wv()]),e=Vv();return{adBlockEnabled:t,incognitoMode:na()??!1,inAppBrowser:e.isInAppBrowser}}async function Yv(t){const e=[],r={timestamp:new Date().toISOString(),sdkVersion:fn,clientId:t.clientId,fallbackId:t.fallbackId};r.pageUrl=window.location.href,r.pageTitle=document.title;try{r.browser=fS()}catch(a){e.push(`Browser info collection failed: ${a.message}`)}try{r.detection=await dS()}catch(a){e.push(`Detection collection failed: ${a.message}`)}try{r.localStorage=Ih(localStorage)}catch(a){e.push(`LocalStorage collection failed: ${a.message}`)}try{r.sessionStorage=Ih(sessionStorage)}catch(a){e.push(`SessionStorage collection failed: ${a.message}`)}if(await Ot()){try{const a=await pt(!1);if(a){const i=a.split(".");if(i.length>=2){const o=JSON.parse(atob(i[1]));r.userId=o.sub}}}catch(a){e.push(`User ID extraction failed: ${a.message}`)}if(t.getProfile)try{r.profile=await t.getProfile()||void 0}catch(a){e.push(`Profile collection failed: ${a.message}`)}if(t.getEntitlements)try{r.entitlements=await t.getEntitlements()}catch(a){e.push(`Entitlements collection failed: ${a.message}`)}if(t.getContracts)try{r.contracts=await t.getContracts()}catch(a){e.push(`Contracts collection failed: ${a.message}`)}if(t.getTags)try{r.tags=await t.getTags()}catch(a){e.push(`Tags collection failed: ${a.message}`)}if(t.getTallies)try{r.tallies=await t.getTallies()}catch(a){e.push(`Tallies collection failed: ${a.message}`)}}return e.length>0&&(r.errors=e),r}async function hS(t,e,r){const a=`${rt("api2",e)}/diagnostics`,i={"Content-Type":"application/json"};if(await Ot())try{const s=await pt(!1);s&&(i.Authorization=`Bearer ${s}`)}catch{}if(!i.Authorization&&r){const s=localStorage.getItem("__anon_id")?.replace(/"/g,"")||"",u=btoa(`${r}|${s}:`);i.Authorization=`Basic ${u}`}const o=await fetch(a,{method:"POST",headers:i,body:JSON.stringify(t)});if(!o.ok){const s=await o.text();throw new Error(`Failed to submit diagnostics: ${s}`)}return o.json()}const Ph="user-diagnostics",Eh="diagnostics-id",pS=`
|
|
37
37
|
.sesamy-diagnostics-modal {
|
|
38
38
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
@@ -153,4 +153,4 @@ CAUSE: `+d.stack,w.response=y,w.status=y.status,w.url=f,y.type==="opaque")throw
|
|
|
153
153
|
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), white);
|
|
154
154
|
pointer-events: none;
|
|
155
155
|
}
|
|
156
|
-
`,document.head.appendChild(i)}async function SS(t){try{const e=await fetch(t);return e.ok?await e.text():(console.error(`Failed to fetch content from ${t}: ${e.statusText}`),null)}catch(e){return console.error(`Error fetching content from ${t}:`,e),null}}async function Ic(t){if(t.contentType==="selector"&&t.content){const e=document.querySelector(t.content);if(e)return e.innerHTML;console.warn(`Source element for selector '${t.content}' not found`)}else if(t.contentType==="url"&&t.content){const e=await SS(t.content);if(e)return e;console.warn(`Failed to fetch content from URL '${t.content}'`)}else if(t.content)return t.content;return""}async function IS(t,e){const r=e.insertionPoint||"inside",n=await Ic(e);switch(r){case"before":t.insertAdjacentHTML("beforebegin",n);break;case"after":t.insertAdjacentHTML("afterend",n);break;case"inside":default:t.innerHTML+=n;break}}async function PS(t,e){const r=await Ic(e);t.innerHTML=r}async function ES(t,e){const r=await Ic(e);t.innerHTML=r.replace("${content}",t.innerHTML)}async function kS({enabled:t=!1,rules:e}){t&&Fv(async()=>{const r=await Ot(),n=window.location.href;for(const a of e){const i=document.querySelectorAll(a.selector);if(!(a.path&&!new RegExp(a.path).test(n)))for(const o of i){const s=o;if(!(a.authenticated!==void 0&&a.authenticated!==r))switch(a.transform){case"insert":await IS(s,a);break;case"replace":await PS(s,a);break;case"remove":o.remove();break;case"wrap":await ES(s,a);break;case"gradient":bS(s,a);break;default:console.warn(`Unknown transform type: ${a.transform}`)}}}})}const kh="access_token";function _S(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get(kh);if(e){ks(e);const r=new URL(window.location.href);t.delete(kh),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const _h="sesamy-refresh",Th="force-refetch-entitlements";function TS(){const t=new URLSearchParams(window.location.search),e=t.get(Th),r=t.get(_h);if(e!==null||r!==null){const n=new URL(window.location.href);t.delete(Th),t.delete(_h),n.search=t.toString(),mt(),window.history.replaceState(null,"",n)}}function RS(t){if(!t||typeof t!="string")throw new Error("Invalid token: token must be a non-empty string");const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT format: token must have exactly 3 parts separated by dots");const[,r]=e;if(!r)throw new Error("Invalid JWT format: payload is empty");let n;try{n=atob(r)}catch{throw new Error("Invalid JWT format: payload is not valid base64")}try{return JSON.parse(n)}catch{throw new Error("Invalid JWT format: payload is not valid JSON")}}function OS(){const
|
|
156
|
+
`,document.head.appendChild(i)}async function SS(t){try{const e=await fetch(t);return e.ok?await e.text():(console.error(`Failed to fetch content from ${t}: ${e.statusText}`),null)}catch(e){return console.error(`Error fetching content from ${t}:`,e),null}}async function Ic(t){if(t.contentType==="selector"&&t.content){const e=document.querySelector(t.content);if(e)return e.innerHTML;console.warn(`Source element for selector '${t.content}' not found`)}else if(t.contentType==="url"&&t.content){const e=await SS(t.content);if(e)return e;console.warn(`Failed to fetch content from URL '${t.content}'`)}else if(t.content)return t.content;return""}async function IS(t,e){const r=e.insertionPoint||"inside",n=await Ic(e);switch(r){case"before":t.insertAdjacentHTML("beforebegin",n);break;case"after":t.insertAdjacentHTML("afterend",n);break;case"inside":default:t.innerHTML+=n;break}}async function PS(t,e){const r=await Ic(e);t.innerHTML=r}async function ES(t,e){const r=await Ic(e);t.innerHTML=r.replace("${content}",t.innerHTML)}async function kS({enabled:t=!1,rules:e}){t&&Fv(async()=>{const r=await Ot(),n=window.location.href;for(const a of e){const i=document.querySelectorAll(a.selector);if(!(a.path&&!new RegExp(a.path).test(n)))for(const o of i){const s=o;if(!(a.authenticated!==void 0&&a.authenticated!==r))switch(a.transform){case"insert":await IS(s,a);break;case"replace":await PS(s,a);break;case"remove":o.remove();break;case"wrap":await ES(s,a);break;case"gradient":bS(s,a);break;default:console.warn(`Unknown transform type: ${a.transform}`)}}}})}const kh="access_token";function _S(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get(kh);if(e){ks(e);const r=new URL(window.location.href);t.delete(kh),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const _h="sesamy-refresh",Th="force-refetch-entitlements";function TS(){const t=new URLSearchParams(window.location.search),e=t.get(Th),r=t.get(_h);if(e!==null||r!==null){const n=new URL(window.location.href);t.delete(Th),t.delete(_h),n.search=t.toString(),mt(),window.history.replaceState(null,"",n)}}function RS(t){if(!t||typeof t!="string")throw new Error("Invalid token: token must be a non-empty string");const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT format: token must have exactly 3 parts separated by dots");const[,r]=e;if(!r)throw new Error("Invalid JWT format: payload is empty");let n;try{n=atob(r)}catch{throw new Error("Invalid JWT format: payload is not valid base64")}try{return JSON.parse(n)}catch{throw new Error("Invalid JWT format: payload is not valid JSON")}}function OS(t,e){const r=new Date(t.exp*1e3);return{id:"",title:t.p?.toString(),sku:t.s?.toString(),purchaseOption:t.p?.toString(),publisherContentId:t.pid?.toString(),url:t.url?.toString(),token:e,type:"article",hasAccess:!0,expiresAt:r.toISOString(),createdAt:new Date(t.iat*1e3).toISOString(),updatedAt:new Date(t.iat*1e3).toISOString()}}function CS(t,e){const r=new Date(t.exp*1e3),n=t.meta;return{id:t.tid?.toString()||"",title:n?.purchaseOption?.toString()||t.tier?.toString(),sku:t.tier?.toString(),purchaseOption:n?.purchaseOption?.toString(),publisherContentId:t.contentId?.toString(),url:t.url?.toString(),token:e,type:"article",hasAccess:!0,expiresAt:r.toISOString(),createdAt:new Date(t.iat*1e3).toISOString(),updatedAt:new Date(t.iat*1e3).toISOString()}}function AS(t){return t.v===1&&typeof t.tier=="string"&&typeof t.contentId=="string"}function $S(){const t=new URLSearchParams(window.location.search),e=t.get("sesamy_token")||t.get("sesamy-token")||t.get("token");if(!e)return;try{const n=RS(e),a=AS(n)?CS(n,e):OS(n,e);mw(a)}catch(n){G(`Failed to extract signed link ${n}`)}const r=new URL(window.location.href);r.searchParams.delete("ss"),r.searchParams.delete("se"),r.searchParams.delete("sp"),r.searchParams.delete("so"),r.searchParams.delete("token"),r.searchParams.delete("sesamy-token"),r.searchParams.delete("sesamy_token"),window.history.replaceState(null,"",r)}const Rh="sesamy-user";async function US(){const e=new URLSearchParams(window.location.search).get(Rh)?.toLowerCase();if(!e)return;const r=await ky();r?.email!==e?(G(`Current user does not match sesamy user: ${r?.email} !== ${e}`),mt(),ia({authorizationParams:{login_hint:e}})):G(`Current user matches sesamy user: ${r?.email} === ${e}`);const n=new URL(window.location.href);n.searchParams.delete(Rh),window.history.replaceState(null,"",n)}const Oh="sesamy-purchase";function LS(){const t=new URLSearchParams(window.location.search),e=t.get(Oh);if(e!==null){const r=new URL(window.location.href);t.delete(Oh),r.search=t.toString(),G(`Purchase ${e}`),Zt(Ge.PURCHASE,{itemSrc:e}),mt(),window.history.replaceState(null,"",r)}}const Ch="sesamy-login",qS="sesamy_login";async function NS(){const t=new URLSearchParams(window.location.search);if(!(t.get(Ch)||t.get(qS)))return;await Ot()||ia();const n=new URL(window.location.href);n.searchParams.delete(Ch),window.history.replaceState(null,"",n)}const Ah="sesamy-debug";async function xS(){const e=new URLSearchParams(window.location.search).get(Ah)?.toLowerCase();if(!e)return;yg(e==="true");const r=new URL(window.location.href);r.searchParams.delete(Ah),window.history.replaceState(null,"",r)}function jS(){if(!document.referrer.length)return;const t=new URL(document.referrer);if(!(t.hostname===window.location.hostname||t.hostname.includes("sesamy")))return document.referrer}async function DS(t){if(!Yt())return;const e=new URLSearchParams(window.location.search),r={utmSource:e.get("utm_source")??void 0,utmMedium:e.get("utm_medium")??void 0,utmCampaign:e.get("utm_campaign")??void 0,utmTerm:e.get("utm_term")??void 0,utmContent:e.get("utm_content")??void 0,ref:e.get("ref")??void 0,referrer:jS()},[n]=t.content.list();n?.url&&(r.itemSrc=n.url,r.publisherContentId=n.id),rv(r)}function MS(){const t=new URLSearchParams(window.location.search);let e=!1;try{e=!!window.opener&&window.opener.location.origin===window.location.origin}catch{e=!1}const r=sessionStorage.getItem(Ud)==="true",n=t.has("code")||t.has("error")||t.has("state");!e||r||(sessionStorage.setItem(Ud,"true"),n||(G("Reloading page to get query params in incognito browser"),window.location.reload()))}async function FS(t){const e=a=>i=>{i.preventDefault();try{a()}catch(o){console.error("Error handling click:",o)}},r=(a,i)=>{try{document.querySelectorAll(a).forEach(s=>{s.addEventListener("click",e(i))})}catch(o){console.error(`Error attaching event handlers (selector: ${a}):`,o)}};r('[sesamy-link="login"]',()=>t.auth.loginWithRedirect()),r('[sesamy-link="logout"]',()=>t.auth.logout());const n=await t.generateLink({target:"account"});n&&r('[sesamy-link="account"]',()=>{window.location.href=n})}async function KS(t){const e=await t.auth.isAuthenticated();try{document.querySelectorAll(`[sesamy-visibility="${e?"not-logged-in":"logged-in"}"]`).forEach(a=>{a instanceof HTMLElement&&(a.style.display="none")}),document.querySelectorAll(`[sesamy-visibility="${e?"logged-in":"not-logged-in"}"]`).forEach(a=>{a instanceof HTMLElement&&(a.style.display="")})}catch(r){console.error("Error handling visibility:",r)}}async function zS(t){const e=ge("sesamy:locked-content-redirect-url");if(!e)return;const[r]=t.content.list();if(!r)return;await t.entitlements.hasAccess(r.url||"",r.pass?.split(",")||[])||(location.href=e)}exports.isInitialized=!1;async function $h(t,e){G(`Init with config: ${JSON.stringify(t)}`);try{MS(),iS({clientId:t.clientId,environment:t.environment,...t.analytics}),await Ey({clientId:t.clientId,organization:t.organization,environment:t.environment,...t.auth}),Iw(t,e),t.transform&&await kS(t.transform),Hp(),xS(),mS({clientId:t.clientId||t.vendorId,environment:t.environment,getProfile:()=>e.profile.get(),getEntitlements:()=>e.entitlements.list(),getContracts:()=>e.contracts.list(),getTags:()=>e.tags.list(),getTallies:()=>e.tallies.list()}),DS(e),_S(),TS(),$S(),await NS(),await US(),LS(),await KS(e),await FS(e),await zS(e),exports.isInitialized=!0,Zt(Ge.READY,{})}catch(r){G(`Failed to init ${r.message}`)}}async function Qv(t){G("Initializing Sesamy");const e=t.api?.namespace||"sesamy";if(Yt()&&e in window)return G("Sesamy already initialized. This is likely due to a duplicate import"),exports.isInitialized=!0,window[e];const r=yS({clientId:t.clientId,vendorId:t.vendorId,environment:t.environment,...t.api});return Yt()?(t.awaitAllServices?await $h(t,r):$h(t,r),r):(exports.isInitialized=!0,r)}if(Yt()){const t=document.getElementById("sesamy-js");if(t?.textContent)try{const e=JSON.parse(t.textContent);Qv(e)}catch(e){console.error("Failed to parse config",e)}}exports.Events=Ge;exports.clearMetadataCache=_w;exports.getAllLdJson=Ew;exports.getAllMetaTags=Br;exports.getContentConfig=Sw;exports.getContentMetadata=pv;exports.getLdJson=Wr;exports.init=Qv;
|
package/dist/sesamy-js.iife.js
CHANGED
|
@@ -32,7 +32,7 @@ var sesamyJs=(function(xe){"use strict";var Ec=typeof globalThis<"u"?globalThis:
|
|
|
32
32
|
* Please keep this comment intact in order to properly abide by the MIT License.
|
|
33
33
|
*
|
|
34
34
|
**/var Ps={d:(t,e)=>{for(var r in e)Ps.o(e,r)&&!Ps.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Es={};Ps.d(Es,{A:()=>hy,k:()=>ks});var Wr=function(t,e,r,n){return new(r||(r=Promise))(function(a,i){function o(l){try{u(n.next(l))}catch(c){i(c)}}function s(l){try{u(n.throw(l))}catch(c){i(c)}}function u(l){var c;l.done?a(l.value):(c=l.value,c instanceof r?c:new r(function(f){f(c)})).then(o,s)}u((n=n.apply(t,[])).next())})},Vr=function(t,e){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(u){return function(l){return(function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(a=o.trys,!((a=a.length>0&&a[a.length-1])||c[0]!==6&&c[0]!==2)){o=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(c[0]===6&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=e.call(t,o)}catch(f){c=[6,f],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}})([u,l])}}};function ks(){return Wr(this,void 0,Promise,function(){return Vr(this,function(t){switch(t.label){case 0:return[4,new Promise(function(e,r){var n="Unknown",a=!1;function i(h){a||(a=!0,e({isPrivate:h,browserName:n}))}function o(){var h=0,d=parseInt("-1");try{d.toFixed(d)}catch(p){h=p.message.length}return h}function s(){return Wr(this,void 0,void 0,function(){var h,d;return Vr(this,function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return p.sent(),i(!1),[3,3];case 2:return h=p.sent(),d=h instanceof Error&&typeof h.message=="string"?h.message:String(h),i(d.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function u(){var h;return Wr(this,void 0,Promise,function(){return Vr(this,function(d){switch(d.label){case 0:return typeof((h=navigator.storage)===null||h===void 0?void 0:h.getDirectory)!="function"?[3,2]:[4,s()];case 1:return d.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var p=String(Math.random());try{var v=indexedDB.open(p,1);v.onupgradeneeded=function(g){var P=g.target.result,b=function(y){i(y)};try{P.createObjectStore("t",{autoIncrement:!0}).put(new Blob),b(!1)}catch(y){(y instanceof Error&&typeof y.message=="string"?y.message:String(y)).includes("are not yet supported")?b(!0):b(!1)}finally{P.close(),indexedDB.deleteDatabase(p)}},v.onerror=function(){return i(!1)}}catch{i(!1)}})():(function(){var p=window.openDatabase,v=window.localStorage;try{p(null,null,null,null)}catch{return void i(!0)}try{v.setItem("test","1"),v.removeItem("test")}catch{return void i(!0)}i(!1)})(),d.label=3;case 3:return[2]}})})}function l(){navigator.webkitTemporaryStorage.queryUsageAndQuota(function(h,d){var p=Math.round(d/1048576),v=2*Math.round((function(){var g,P,b,y=window;return(b=(P=(g=y?.performance)===null||g===void 0?void 0:g.memory)===null||P===void 0?void 0:P.jsHeapSizeLimit)!==null&&b!==void 0?b:1073741824})()/1048576);i(p<v)},function(h){r(new Error("detectIncognito somehow failed to query storage quota: "+h.message))})}function c(){self.Promise!==void 0&&self.Promise.allSettled!==void 0?l():(0,window.webkitRequestFileSystem)(0,1,function(){i(!1)},function(){i(!0)})}function f(){var h;return Wr(this,void 0,Promise,function(){var d,p,v;return Vr(this,function(g){switch(g.label){case 0:if(typeof((h=navigator.storage)===null||h===void 0?void 0:h.getDirectory)!="function")return[3,5];g.label=1;case 1:return g.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return g.sent(),i(!1),[3,4];case 3:return d=g.sent(),p=d instanceof Error&&typeof d.message=="string"?d.message:String(d),i(p.includes("Security error")),[2];case 4:return[3,6];case 5:(v=indexedDB.open("inPrivate")).onerror=function(P){v.error&&v.error.name==="InvalidStateError"&&P.preventDefault(),i(!0)},v.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),i(!1)},g.label=6;case 6:return[2]}})})}(function(){return Wr(this,void 0,Promise,function(){return Vr(this,function(h){switch(h.label){case 0:return o()!==44&&o()!==43?[3,2]:(n="Safari",[4,u()]);case 1:return h.sent(),[3,6];case 2:return o()!==51?[3,3]:(d=navigator.userAgent,n=d.match(/Chrome/)?navigator.brave!==void 0?"Brave":d.match(/Edg/)?"Edge":d.match(/OPR/)?"Opera":"Chrome":"Chromium",c(),[3,6]);case 3:return o()!==25?[3,5]:(n="Firefox",[4,f()]);case 4:return h.sent(),[3,6];case 5:navigator.msSaveBlob!==void 0?(n="Internet Explorer",i(window.indexedDB===void 0)):r(new Error("detectIncognito cannot determine the browser")),h.label=6;case 6:return[2]}var d})})})().catch(r)})];case 1:return[2,t.sent()]}})})}typeof window<"u"&&(window.detectIncognito=ks);const hy=ks;Es.A;const py=Es.k,qn="sesamy_incognito_mode";function Nn(){try{const t=sessionStorage.getItem(qn);return t===null?void 0:t==="true"}catch{return}}async function Ch(){try{const t=sessionStorage.getItem(qn);if(t!==null)return t==="true";const{isPrivate:e}=await py();return sessionStorage.setItem(qn,e.toString()),e}catch{try{sessionStorage.setItem(qn,"false")}catch{}return!1}}function zt(){return typeof window<"u"}function vy(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function my(){return/android/i.test(navigator.userAgent)}let ke,_s,Jr,Ts=!1,jn=!1,xn=!1;zt()&&window.addEventListener("pageshow",()=>{jn=!1,xn=!1});const Ht="sesamyAccessToken",Zr="sesamyRefreshToken",Dn="sesamySilentAuthThrottle",Ah="sesamy_is_authenticated",Rs="sesamySilentRedirectState",gy=300*1e3,$h=60,yy=["login_required","consent_required","interaction_required","timeout","Timeout","access_denied"];function Uh(){if(!zt())return!1;try{const t=document.cookie.split(";").map(a=>a.trim());if(t.some(a=>a.startsWith(`${Ah}=true`))||t.some(a=>a.startsWith("auth0.is.authenticated=true")))return!0;const n=Object.keys(localStorage).filter(a=>a.startsWith("@@auth0spajs@@"));if(n.length>0)for(const a of n)try{const i=JSON.parse(localStorage.getItem(a)||"{}");if(i?.body?.access_token||i?.body?.refresh_token)return!0}catch{}return!1}catch(t){return B(`Error checking session hint cookie: ${t.message}`),!1}}function Yr(t){if(zt())try{const e=t?2592e3:0,r=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${Ah}=${t}; path=/; max-age=${e}; SameSite=Lax${r}`}catch(e){B(`Error setting session hint cookie: ${e.message}`)}}function Mn(){Yr(!1)}function wy(){try{sessionStorage.setItem(Rs,JSON.stringify({timestamp:Date.now()}))}catch{B("Failed to set silent redirect state")}}function Fn(){try{const t=sessionStorage.getItem(Rs);if(t)return JSON.parse(t)}catch{}return null}function Xr(){try{sessionStorage.removeItem(Rs)}catch{}}function by(t){const e=t.message||"";return yy.some(r=>e.includes(r)||t.error===r)}async function Kn(){return Ts?!0:new Promise((t,e)=>{const r=setTimeout(()=>{Ts?t(!0):e(new Error("Initialization failed: Timeout"))},2e3);window.addEventListener(Ge.AUTH_INITIALIZED,()=>{clearTimeout(r),t(!0)})})}async function Sy(t){if(!t)return null;const e=localStorage.getItem(Zr);if(!e)return B("No refresh token found in localstorage"),null;const r=new URLSearchParams;r.set("client_id",t.iss),r.set("refresh_token",e),r.set("grant_type","refresh_token");const n=new URL(t.iss);n.pathname="/oauth/token",n.searchParams.set("user_id",t.sub);try{const a=await fetch(n.href,{body:r.toString(),method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"}});if(!a.ok){const o=await a.text().catch(()=>"Unknown error");throw B(`Token refresh failed with status ${a.status}: ${o}`),localStorage.removeItem(Zr),new Error(`Renew token failed: ${a.status}`)}const i=await a.json();if(!i.access_token)throw B("Token refresh response missing access_token"),new Error("Invalid token response");return i.refresh_token&&localStorage.setItem(Zr,i.refresh_token),localStorage.setItem(Ht,i.access_token),i.access_token}catch(a){return B(`Token refresh error: ${a.message}`),localStorage.removeItem(Zr),localStorage.removeItem(Ht),await Cs(),null}}async function Os(){const t=localStorage.getItem(Ht);if(!t)return null;const e=As(t),r=Date.now()/1e3;if(!e||!e.exp||e.exp<r+$h){const n=await Sy(e);return n||(localStorage.removeItem(Ht),null)}return t}let zn=null;const Iy=64;function Py(){try{if(zn!==null)return zn;const e=Object.keys(localStorage).filter(r=>r.startsWith("@@auth0spajs@@"));for(const r of e){const n=JSON.parse(localStorage.getItem(r)||"{}");let a;if(typeof n=="object"&&(n.body&&typeof n.body=="object"&&"refresh_token"in n.body?a=n.body.refresh_token:"refresh_token"in n&&(a=n.refresh_token)),a&&typeof a=="string"&&a.length===Iy)return zn=!0,!0}}catch(t){B(`Error checking for existing auth0 tokens: ${t.message}`)}return zn=!1,!1}function Ey(t){if(t.domains&&t.domains.length>0){const e=Bt(window.location.href);if(e){for(const r of t.domains)if(Bt(`https://${r}`)===e)return B(`Found matching domain in domains array: ${r} for TLD: ${e}`),r;B(`No matching domain found in domains array for TLD: ${e}`)}}if(t.domain)return B(`Using fallback domain property: ${t.domain}`),t.domain}function Bt(t){try{const e=new URL(t).hostname,r=e.split(".");if(r.length<=1)return e;const n=["co.uk","com.au","co.nz","co.za","com.br","co.jp","gov.uk","ac.uk","org.uk","net.uk","com.sg","com.my","co.in","co.id","co.th","co.kr","com.mx","com.ar","com.co","com.pe","com.ph","com.pk","com.sa","com.eg","com.ng","co.ke","co.tz","co.zw","co.bw","co.mz","gov.au","edu.au","org.au","net.au","asn.au","id.au"];for(const a of n)if(e.endsWith(`.${a}`)){const i=a.split(".").length+1;return r.slice(-i).join(".")}return r.slice(-2).join(".")}catch{return null}}async function ky(t){if(t.enabled===!1)return;_s=t.organization;const e=Ey(t);Jr=e&&!Py()?e:Oh("token",t.environment);const r=Bt(window.location.href)!==Bt(`https://${Jr}`),n=Bt(window.location.href),a=n?`.${n}`:void 0,i={domain:Jr,clientId:t.clientId,useCookiesForTransactions:!0,legacySameSiteCookie:!1,...a&&{cookieDomain:a}};i.cacheLocation="localstorage",(r||t.useRefreshTokens)&&(i.useRefreshTokens=!0),B(`Initializing auth0 client: ${JSON.stringify(i)}`),ke=await uy(i);const o=new URLSearchParams(window.location.search),s=o.get("code"),u=o.get("state"),l=o.get("error");if(l){const c=o.get("error_description");B(`Auth error in URL: ${l}${c?` - ${c}`:""}`);const f=new URL(location.href);f.searchParams.delete("error"),f.searchParams.delete("error_description"),f.searchParams.delete("state"),window.history.replaceState({},document.title,f.toString());const h=Fn();if(h&&Xr(),l==="login_required")B("Silent redirect returned login_required - user is not authenticated"),Mn();else if(h)B(`Silent redirect returned ${l} - treating as unauthenticated`),Mn();else{const d=c||`Authentication failed: ${l}`;B(`Non-silent auth error, alerting user: ${d}`),setTimeout(()=>{alert(d)},0)}}if(s)if(window.opener)B("Code found in URL, posting to opener"),window.opener.postMessage({type:"authorization_response",response:{code:s,state:u}},window.location.origin);else{B("Code found in URL, handling redirect");const c=window.location.href,f=new URL(location.href),h=f.searchParams;h.delete("code"),h.delete("state"),f.search=h.toString(),window.history.replaceState({},document.title,f.toString()),B("Rewrote url to remove code and state");try{const d=await ke.handleRedirectCallback(c);B(`Login result: ${JSON.stringify(d)}`);const p=await ke.getUser();if(!p)throw B("No user found"),new Error("No user found");B(`User found ${JSON.stringify(p)}`),Bn(),Fn()&&(B("Successfully recovered session via prompt=none redirect"),Xr()),Yr(!0),B(`Triggering AUTHENTICATED event with appState: ${JSON.stringify(d.appState)}`),Nt(Ge.AUTHENTICATED,{...p,appState:d.appState})}catch(d){B(`Error handling redirect: ${d.message}`),Fn()?(Xr(),Mn(),B("Silent redirect failed, cleared session hints")):alert("There was an error logging in"),console.error(d)}}Ts=!0,Nt(Ge.AUTH_INITIALIZED,{})}async function Et(){if(await Kn(),await Os())return!0;if(!ke)return!1;const e=await ke.isAuthenticated();return e&&Yr(!0),e}async function _y(){return await Kn(),await Os()?(B("Using local user"),{sub:"local",name:"Local User"}):ke?ke.getUser():null}function Lh(t){if(jn)return B("Login already in progress"),null;if(jn=!0,setTimeout(()=>{jn=!1},3e3),localStorage.removeItem(Ht),!ke)throw new Error("Auth0 client not initialized");const e=t?.authorizationParams||{};return{...t,authorizationParams:{organization:_s,redirect_uri:window.location.href,ui_locales:Gr(),incognito:Nn(),...e}}}async function Hn(t){const e=Lh(t);if(e)return ke.loginWithRedirect(e)}async function qh(t){const e=Lh(t);if(!e)return;await ke.loginWithPopup(e,{timeoutInSeconds:1800}),Bn(),Yr(!0);const r=await ke.getUser();if(!r)throw B("No user found after popup login"),new Error("No user found");const n=new CustomEvent(Ge.AUTHENTICATED,{detail:{...r,appState:t?.appState},composed:!0,bubbles:!0});window.dispatchEvent(n)&&window.location.reload()}function Ty(){if(!Jr)return!1;const t=Bt(window.location.href),e=Bt(`https://${Jr}`);return t!==e}async function Ry(t){return Ty()&&(vy()||my()||Nn())?(B("Using popup login for cross-domain auth on Safari/Android/Incognito"),qh(t)):(B("Using redirect login"),Hn(t))}function Oy(){try{const t=sessionStorage.getItem(Dn);if(!t)return!1;const{timestamp:e}=JSON.parse(t);return Date.now()-e<gy}catch{return sessionStorage.removeItem(Dn),!1}}function Cy(){try{const t={timestamp:Date.now()};sessionStorage.setItem(Dn,JSON.stringify(t))}catch{B("Failed to set silent auth throttle in sessionStorage")}}function Bn(){try{sessionStorage.removeItem(Dn)}catch{}}async function Ay(){if(xn){B("Silent redirect already in progress");return}if(!Uh()){B("No session hint cookie - skipping prompt=none redirect for anonymous user");return}const t=Fn();if(t&&Date.now()-t.timestamp<3e4){B("Recently attempted silent redirect, skipping to prevent loop");return}B("Attempting prompt=none redirect to recover session"),xn=!0,wy();try{await ke.loginWithRedirect({authorizationParams:{prompt:"none",redirect_uri:window.location.href,organization:_s}})}catch(e){B(`Prompt=none redirect failed: ${e.message}`),xn=!1,Xr()}}async function mt(t=!0,e=!1){await Kn();const r=await Os();if(r)return r;if(!e&&Oy()){if(B("Silent auth is throttled due to recent failures, skipping request"),t)throw new Error("Silent auth throttled");return null}try{if(!ke)return B("Auth client not initialized"),null;let n=await ke.getTokenSilently();const a=As(n),i=Date.now()/1e3;return e&&a?.exp&&a.exp-i<3600+$h&&(n=await ke.getTokenSilently({cacheMode:"off"})),Bn(),Yr(!0),n}catch(n){const a=n;if(B(`Failed to get token silently: ${a.message}`),by(a)){if(B("Iframe-based auth blocked by browser privacy restrictions"),Uh())return B("Session hint present - attempting prompt=none redirect recovery"),await Ay(),null;B("No session hint - user is likely anonymous, not attempting redirect")}if(Cy(),await ke.isAuthenticated()&&(a.message==="Invalid refresh token"||a.message.includes("Missing Refresh Token"))&&await Cs(),t)throw n;return null}}async function Cs(t={}){if(await Kn(),localStorage.removeItem(Ht),localStorage.removeItem(Zr),Mn(),Xr(),Bn(),Nt(Ge.LOGOUT,{}),!!ke)return B(`Logout with options: ${JSON.stringify(t)}`),ke.logout({...t,logoutParams:{returnTo:window.location.href,...t.logoutParams}})}function As(t){const e=t.split(".");if(e.length!==3)return null;const n=e[1].replace(/-/g,"+").replace(/_/g,"/"),a=decodeURIComponent(atob(n).split("").map(function(i){return"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(a)}async function $s(t){const e=As(t);if(!e||!e.exp||e.exp<new Date().getTime()/1e3)throw new Error("Invalid token");B("Set token"),localStorage.setItem(Ht,t),Nt(Ge.AUTHENTICATED,{...e,appState:void 0})}const $y=(t,e)=>e.skipDedupe||e.method!=="GET",Uy=(t,e)=>e.method+"@"+t,Ly=t=>t.clone(),qy=({skip:t=$y,key:e=Uy,resolver:r=Ly}={})=>{const n=new Map;return a=>(i,o)=>{if(t(i,o))return a(i,o);const s=e(i,o);if(!n.has(s))n.set(s,[]);else return new Promise((u,l)=>{n.get(s).push([u,l])});try{return a(i,o).then(u=>(n.get(s).forEach(([l])=>l(r(u))),n.delete(s),u)).catch(u=>{throw n.get(s).forEach(([,l])=>l(u)),n.delete(s),u})}catch(u){return n.delete(s),Promise.reject(u)}}},Ny=(t,e)=>t*e,jy=t=>t&&t.ok,xy=({delayTimer:t=500,delayRamp:e=Ny,maxAttempts:r=10,until:n=jy,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:s}={})=>u=>(l,c)=>{let f=0;if(s&&s(l,c))return u(l,c);const h=(d,p)=>Promise.resolve(n(d,p)).then(v=>v?d&&o?d:p?Promise.reject(p):d:(f++,!r||f<=r?new Promise(g=>{const P=e(t,f);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:d,error:p,url:l,options:c})).then((b={})=>{var y,m;g(u((y=b&&b.url)!==null&&y!==void 0?y:l,(m=b&&b.options)!==null&&m!==void 0?m:c))}):g(u(l,c))},P)}).then(h).catch(g=>{if(!i)throw g;return h(null,g)}):d&&o?d:Promise.reject(p||new Error("Number of attempts exceeded."))));return u(l,c).then(h).catch(d=>{if(!i)throw d;return h(null,d)})};let Us=class em extends Error{status;statusText;url;body;constructor(e,r,n,a,i){super(a),this.name="APIError",this.status=e,this.statusText=r,this.url=n,this.body=i,Error.captureStackTrace&&Error.captureStackTrace(this,em)}isClientError(){return this.status>=400&&this.status<500}isServerError(){return this.status>=500}isForbiddenError(){return this.status===403}isNotFoundError(){return this.status===404}};var Gn=(t=>(t.BROWSER="browser",t.NORMAL="normal",t))(Gn||{});const Dy="application/json",Nh="Content-Type",hr=Symbol(),jh=Symbol();function xh(t={}){var e;const r=t instanceof Array?Object.fromEntries(t):t;return(e=Object.entries(r).find(([n])=>n.toLowerCase()===Nh.toLowerCase()))===null||e===void 0?void 0:e[1]}function Dh(t){return/^application\/.*json.*/.test(t)}const Gt=function(t,e,r=!1){return Object.entries(e).reduce((n,[a,i])=>{const o=t[a];return Array.isArray(o)&&Array.isArray(i)?n[a]=r?[...o,...i]:i:typeof o=="object"&&typeof i=="object"?n[a]=Gt(o,i,r):n[a]=i,n},{...t})},pr={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,r=!1,...n){const a=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!a)throw new Error(t+" is not defined");return r&&a?new a(...n):a}};function My(t,e=!1){pr.options=e?t:Gt(pr.options,t)}function Fy(t,e=!1){pr.polyfills=e?t:Gt(pr.polyfills,t)}function Ky(t){pr.errorType=t}const zy=t=>e=>t.reduceRight((r,n)=>n(r),e)||e;let Mh=class extends Error{};const Hy=t=>{const e=Object.create(null);t=t._addons.reduce((y,m)=>m.beforeRequest&&m.beforeRequest(y,t._options,e)||y,t);const{_url:r,_options:n,_config:a,_catchers:i,_resolvers:o,_middlewares:s,_addons:u}=t,l=new Map(i),c=Gt(a.options,n);let f=r;const h=zy(s)((y,m)=>(f=y,a.polyfill("fetch")(y,m)))(r,c),d=new Error,p=h.catch(y=>{throw{[hr]:y}}).then(y=>{var m;if(!y.ok){const w=new Mh;if(w.cause=d,w.stack=w.stack+`
|
|
35
|
-
CAUSE: `+d.stack,w.response=y,w.status=y.status,w.url=f,y.type==="opaque")throw w;const R=a.errorType==="json"||((m=y.headers.get("Content-Type"))===null||m===void 0?void 0:m.split(";")[0])==="application/json";return(a.errorType?R?y.text():y[a.errorType]():Promise.resolve(y.body)).then(A=>{if(w.message=typeof A=="string"?A:y.statusText,A)if(R&&typeof A=="string"){w.text=A;try{w.json=JSON.parse(A)}catch{}}else w[a.errorType]=A;throw w})}return y}),v=y=>y.catch(m=>{const w=Object.prototype.hasOwnProperty.call(m,hr),R=w?m[hr]:m,A=R?.status&&l.get(R.status)||l.get(R?.name)||w&&l.has(hr)&&l.get(hr);if(A)return A(R,t);const x=l.get(jh);if(x)return x(R,t);throw R}),g=y=>m=>v(y?p.then(w=>w&&w[y]()).then(w=>m?m(w):w):p.then(w=>m?m(w):w)),P={_wretchReq:t,_fetchReq:h,_sharedState:e,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(y,m){return l.set(y,m),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(hr,y)}},b=u.reduce((y,m)=>({...y,...typeof m.resolver=="function"?m.resolver(y):m.resolver}),P);return o.reduce((y,m)=>m(y,t),b)},By={_url:"",_options:{},_config:pr,_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:Gt(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+t+"?"+r[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:Gt(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:Gt(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Nh]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const r=new Map(this._catchers);return r.set(t,e),{...this,_catchers:r}},catcherFallback(t){return this.catcher(jh,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="",r=null){let n=this.url(e).options({method:t});const a=xh(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||Dh(a));return n=r?o?n.json(r,a):n.body(r):n,Hy(n._deferred.reduce((s,u)=>u(s,s._url,s._options),n))},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 r=xh(this._options.headers);return this.content(e||Dh(r)&&r||Dy).body(JSON.stringify(t))}};function ut(t="",e={}){return{...By,_url:t,_options:e}}ut.default=ut,ut.options=My,ut.errorType=Ky,ut.polyfills=Fy,ut.WretchError=Mh;const Gy=(t,e)=>e.skipDedupe||e.method!=="GET",Wy=(t,e)=>e.method+"@"+t,Vy=t=>t.clone(),Jy=({skip:t=Gy,key:e=Wy,resolver:r=Vy}={})=>{const n=new Map;return a=>(i,o)=>{if(t(i,o))return a(i,o);const s=e(i,o);if(!n.has(s))n.set(s,[]);else return new Promise((u,l)=>{n.get(s).push([u,l])});try{return a(i,o).then(u=>(n.get(s).forEach(([l])=>l(r(u))),n.delete(s),u)).catch(u=>{throw n.get(s).forEach(([,l])=>l(u)),n.delete(s),u})}catch(u){return n.delete(s),Promise.reject(u)}}},Zy=(t,e)=>e.skipCache||e.method!=="GET",Yy=(t,e)=>e.method+"@"+t,Xy=()=>!1,Qy=()=>null,ew=t=>t.ok,tw=({throttle:t=1e3,skip:e=Zy,key:r=Yy,clear:n=Xy,invalidate:a=Qy,condition:i=ew,flagResponseOnCacheHit:o="__cached"}={})=>{const s=new Map,u=new Map,l=new Set,c=h=>{t&&!l.has(h)&&(l.add(h),setTimeout(()=>{l.delete(h)},t))},f=h=>(d,p)=>{const v=r(d,p);let g=a(d,p);if(g&&(g instanceof Array||(g=[g]),g.forEach(P=>{typeof P=="string"?s.delete(P):P instanceof RegExp&&s.forEach((b,y)=>{P.test(y)&&s.delete(y)})})),n(d,p)&&s.clear(),e(d,p))return h(d,p);if(l.has(v)){if(s.has(v)){const P=s.get(v).clone();return o&&Object.defineProperty(P,o,{value:v,enumerable:!1}),Promise.resolve(P)}else if(u.has(v))return new Promise((P,b)=>{u.get(v).push([P,b])})}return u.has(v)||u.set(v,[]),c(v),h(d,p).then(P=>(i(P.clone())&&s.set(v,P.clone()),u.get(v).forEach(([b])=>b(P.clone())),u.delete(v),P)).catch(P=>{throw u.get(v).forEach(([,b])=>b(P)),u.delete(v),P})};return f.cacheResponse=function(h,d){c(h),s.set(h,d)},f.cache=s,f.inflight=u,f.throttling=l,f},rw=(t,e)=>t*e,nw=t=>t&&t.ok,aw=({delayTimer:t=500,delayRamp:e=rw,maxAttempts:r=10,until:n=nw,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:s}={})=>u=>(l,c)=>{let f=0;if(s&&s(l,c))return u(l,c);const h=(d,p)=>Promise.resolve(n(d,p)).then(v=>v?d&&o?d:p?Promise.reject(p):d:(f++,!r||f<=r?new Promise(g=>{const P=e(t,f);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:d,error:p,url:l,options:c})).then((b={})=>{var y,m;g(u((y=b&&b.url)!==null&&y!==void 0?y:l,(m=b&&b.options)!==null&&m!==void 0?m:c))}):g(u(l,c))},P)}).then(h).catch(g=>{if(!i)throw g;return h(null,g)}):d&&o?d:Promise.reject(p||new Error("Number of attempts exceeded."))));return u(l,c).then(h).catch(d=>{if(!i)throw d;return h(null,d)})},iw="@sesamy/sdk",ow="1.23.0";let sw=class{cache=new Map;get(e){return this.cache.get(e)||null}set(e,r){this.cache.set(e,r)}remove(e){this.cache.delete(e)}clear(){this.cache.clear()}};const Qr="sesamyCacheTimestamp",cw=t=>{const{libraryName:e=iw,libraryVersion:r=ow,cache:n}=t,a=n?.storage||new sw,i=[s=>async(u,l)=>{if(n?.mode===Gn.BROWSER){let c;typeof sessionStorage<"u"?(c=sessionStorage.getItem(Qr),c||(c=Date.now().toString(),sessionStorage.setItem(Qr,c))):(c=a.get(Qr),c||(c=Date.now().toString(),a.set(Qr,c)));const f={...l,headers:{...l.headers,"Cache-Timestamp":c}};return s(u,f)}return s(u,l)},s=>async(u,l)=>{const c=await t.tokenProvider(),f={...l,headers:{...l.headers,Authorization:c}};return s(u,f)},Jy()];n?.mode===Gn.NORMAL&&i.push(tw({throttle:300*1e3,skip:(s,u)=>u.method!=="GET"})),i.push(aw({delayTimer:1e3,delayRamp:(s,u)=>s*u,maxAttempts:3,until:s=>!!(s&&(s.ok||s.status>=400&&s.status<500)),retryOnNetworkError:!1}));const o=ut(t.baseUrl).headers({"Content-Type":"application/json","X-Sesamy-Client":`${e}/${r}`,...t.headers}).middlewares(i);return{async request(s,u={}){try{const l=/^https?:\/\//.test(s);let c=o.url(s,l);u.headers&&(c=c.headers(u.headers));const f=(u.method||"GET").toLowerCase();let h;switch(f){case"get":h=c.get();break;case"post":h=c.post(u.body);break;case"put":h=c.put(u.body);break;case"patch":h=c.patch(u.body);break;case"delete":h=c.delete();break;default:h=c.get()}const d=await h.res();if(d.ok&&["post","patch","put","delete"].includes(f)&>(),d.status===204)return null;if(!d.ok){const p=await d.text().catch(()=>"Unknown error");throw new Us(d.status,d.statusText,d.url,`API Error ${d.status}: ${p}`,p)}return await d.json()}catch(l){if(l instanceof Us)throw l;const c=l.status||500,f=l.message||"Unknown error",h=`${t.baseUrl}${s}`;throw new Us(c,f,h,`API Error ${c}: ${l.message||"Unknown error"}`,l.message||"Unknown error")}}}},gt=()=>(typeof sessionStorage<"u"&&sessionStorage.removeItem(Qr),"Cache cleared"),en={get:async(t,e)=>t.request(`/profile/${e}`),update:async(t,e,r)=>t.request(`/profile/${e}`,{method:"PATCH",body:JSON.stringify(r)}),checkSpotifyLink:async t=>t.request("/profile/spotify-link"),unlinkSpotify:async t=>t.request("/profile/unlink-spotify",{method:"POST"}),delete:async t=>{await t.request("/profile",{method:"DELETE"})}},Ls={list:async(t,e)=>{const r=new URLSearchParams;e?.type&&r.append("type",e.type),e?.sku&&r.append("sku",e.sku),e?.purchaseOptionId&&r.append("purchase-option-id",e.purchaseOptionId),e?.waitForEntitlementAfter&&r.append("wait-for-entitlement-after",e.waitForEntitlementAfter);const n=r.toString(),a=n?`/entitlements?${n}`:"/entitlements";return t.request(a)},get:async(t,e)=>t.request(`/entitlements/${e}`),getAccess:async(t,e)=>t.request(`/entitlements/${e}/access`)},Fh={list:async t=>t.request("/subscriptions"),get:async(t,e)=>t.request(`/subscriptions/${e}`)},Kh={get:async(t,e)=>t.request(`/products/${e}`),autoOnboard:async(t,e)=>t.request(`/products/${e}/auto-onboard`,{method:"POST"})},uw=(t,e)=>{if(!t||!e)return t;const r=new URL(t);return r.hash=`access_token=${e}`,r.toString()},zh=(t,e)=>!t.manageUrl||!e?t:{...t,manageUrl:uw(t.manageUrl,e)},tn={list:async t=>t.request("/contracts"),get:async(t,e)=>t.request(`/contracts/${e}`),cancel:async(t,e)=>t.request(`/contracts/${e}/cancel`,{method:"POST"}),createAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments`,{method:"POST",body:JSON.stringify(r)}),confirmAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments/${r}/confirm`,{method:"POST"})},qs={get:async t=>t.request("/user-metadata"),set:async(t,e,r)=>{await t.request(`/user-metadata/${e}`,{method:"PUT",body:r})},delete:async(t,e)=>{await t.request(`/user-metadata/${e}`,{method:"DELETE"})}},vr={list:async t=>t.request("/tallies"),get:async(t,e)=>t.request(`/tallies/${e}`),update:async(t,e,r)=>t.request(`/tallies/${e}`,{method:"PUT",body:JSON.stringify(r)}),create:async(t,e)=>t.request("/tallies",{method:"POST",body:JSON.stringify(e)}),delete:async(t,e)=>{try{return await t.request(`/tallies/${e}`,{method:"DELETE"}),!0}catch{return!1}},push:async(t,e,r)=>t.request(`/tallies/${e}/push`,{method:"POST",body:JSON.stringify(r)})},Ns={list:async t=>t.request("/tags"),add:async(t,e)=>{await t.request("/tags",{method:"POST",body:JSON.stringify({tag:e})})},remove:async(t,e)=>{await t.request(`/tags/${e}`,{method:"DELETE"})}},mr={generateCheckoutLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},generateAccountLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}${e.contractId?`/${encodeURIComponent(e.contractId)}`:""}`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePaymentLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/change-payment-method`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePlanLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/edit-plan`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateConsumeLink:(t,e)=>{const r=e.language||"en";let n=new URL(`${t.baseUrl}/consume/${encodeURIComponent(r)}/@${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.sku)}`);return e.episodeId?n.href+=`/${encodeURIComponent(e.episodeId)}`:n.href+="/listen",n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()}},js={generateLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},create:async(t,e)=>t.request("/checkouts",{method:"POST",body:JSON.stringify(e)}),get:async(t,e)=>t.request(`/checkouts/${e}`),update:async(t,e,r)=>t.request(`/checkouts/${e}`,{method:"PATCH",body:JSON.stringify(r)})},Hh={list:async t=>t.request("/bills"),get:async(t,e)=>t.request(`/bills/${e}`)},Bh={list:async t=>t.request("/fulfillments"),create:async(t,e)=>t.request("/fulfillments",{method:"POST",body:JSON.stringify(e)})},lw={get:async(t,e)=>{try{return new URL(e),t.request(e)}catch{return t.request(`/paywalls/${e}`)}}},fw={list:async t=>t.request("/payment-issues")},dw={content:async(t,e,r,n,a)=>{const i=new URLSearchParams({url:e});return r&&i.append("selector",r),n&&i.append("cache",n),t.request(`/proxy?${i.toString()}`,a)}},hw={list:async(t,e)=>{const r=(e?new URLSearchParams({q:e}):new URLSearchParams).toString(),n=r?`/transactions?${r}`:"/transactions";return t.request(n)}},Gh={get:async t=>t.request("/vendor"),list:async t=>t.request("/vendors")},pw=t=>{const e=cw(t);return{profile:{get:r=>en.get(e,r),update:(r,n)=>en.update(e,r,n),checkSpotifyLink:()=>en.checkSpotifyLink(e),unlinkSpotify:()=>en.unlinkSpotify(e),delete:()=>en.delete(e)},entitlements:{list:r=>Ls.list(e,r),get:r=>Ls.get(e,r),getAccess:r=>Ls.getAccess(e,r)},subscriptions:{list:()=>Fh.list(e),get:r=>Fh.get(e,r)},products:{get:r=>Kh.get(e,r),autoOnboard:r=>Kh.autoOnboard(e,r)},contracts:{list:async()=>{const r=await tn.list(e),n=await t.tokenProvider();if(!n.toLowerCase().startsWith("bearer "))return r;const a=n.substring(7);return r.map(i=>zh(i,a))},get:async r=>{const n=await tn.get(e,r),a=await t.tokenProvider();if(!a.toLowerCase().startsWith("bearer "))return n;const i=a.substring(7);return zh(n,i)},cancel:r=>tn.cancel(e,r),createAmendment:(r,n)=>tn.createAmendment(e,r,n),confirmAmendment:(r,n)=>tn.confirmAmendment(e,r,n)},userMetadata:{get:()=>qs.get(e),set:(r,n)=>qs.set(e,r,n),delete:r=>qs.delete(e,r)},tallies:{list:()=>vr.list(e),get:r=>vr.get(e,r),update:(r,n)=>vr.update(e,r,n),create:r=>vr.create(e,r),delete:r=>vr.delete(e,r),push:(r,n)=>vr.push(e,r,n)},tags:{list:()=>Ns.list(e),add:r=>Ns.add(e,r),remove:r=>Ns.remove(e,r)},checkouts:{generateLink:(r,n)=>mr.generateCheckoutLink(r,n),create:r=>js.create(e,r),get:r=>js.get(e,r),update:(r,n)=>js.update(e,r,n)},links:{generateCheckoutLink:(r,n)=>mr.generateCheckoutLink(r,n),generateAccountLink:(r,n)=>mr.generateAccountLink(r,n),generateChangePaymentLink:(r,n)=>mr.generateChangePaymentLink(r,n),generateChangePlanLink:(r,n)=>mr.generateChangePlanLink(r,n),generateConsumeLink:(r,n)=>mr.generateConsumeLink(r,n)},bills:{list:()=>Hh.list(e),get:r=>Hh.get(e,r)},fulfillments:{list:()=>Bh.list(e),create:r=>Bh.create(e,r)},paywalls:{get:r=>lw.get(e,r)},paymentIssues:{list:()=>fw.list(e)},proxy:{content:(r,n,a,i)=>dw.content(e,r,n,a,i)},transactions:{list:r=>hw.list(e,r)},vendor:{get:()=>Gh.get(e),list:()=>Gh.list(e)}}};class vw{get(e){return typeof sessionStorage>"u"?null:sessionStorage.getItem(e)}set(e,r){typeof sessionStorage<"u"&&sessionStorage.setItem(e,r)}remove(e){typeof sessionStorage<"u"&&sessionStorage.removeItem(e)}clear(){}}function xs(t){let e;try{e=new URL(t)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function Wh(t,e){if(xs(t))return{itemSrc:t};const r=t.split(":");if(r.length<2)throw new Error(`Invalid itemSrc format: expected at least 2 segments separated by ':', got ${r.length}`);const[n,a,i]=r;if(!a)throw new Error("Invalid itemSrc format: sku segment is empty");return{sku:`${n}:${a}`,purchaseOption:e||i}}function Vh(t){return t.endsWith("/")?t.slice(0,-1):t}function Jh(t,e){if(!xs(t)||!xs(e))return!1;const r=new URL(t),n=new URL(e);return r.origin===n.origin&&Vh(r.pathname)===Vh(n.pathname)}function mw(t,e,r){const n=new URL(`${nt("checkout3",t.environment)}`);e.language&&n.searchParams.set("lang",e.language);let a=e.sku,i=e.purchaseOptionId,o=e.itemSrc;if(e.itemSrc){const c=Wh(e.itemSrc,e.purchaseOptionId);a=c.sku||a,i=c.purchaseOption||i,o=c.itemSrc}a?(n.searchParams.set("sku",a),i&&n.searchParams.set("po-id",i)):o&&n.searchParams.set("url",o),e.email&&n.searchParams.set("email",e.email),e.business&&n.searchParams.set("business","true"),e.currency&&n.searchParams.set("currency",e.currency),e.price&&n.searchParams.set("price",e.price.toString()),e.discountCode&&n.searchParams.set("discount-code",e.discountCode),e.attributionItemSrc?n.searchParams.set("itemSrc",e.attributionItemSrc):r.itemSrc&&n.searchParams.set("itemSrc",r.itemSrc),e.attributionPublisherContentId?n.searchParams.set("publisherContentId",e.attributionPublisherContentId):r.publisherContentId&&n.searchParams.set("publisherContentId",r.publisherContentId),e.utmSource?n.searchParams.set("utm_source",e.utmSource):r.utmSource&&n.searchParams.set("utm_source",r.utmSource),e.utmMedium?n.searchParams.set("utm_medium",e.utmMedium):r.utmMedium&&n.searchParams.set("utm_medium",r.utmMedium),e.utmCampaign?n.searchParams.set("utm_campaign",e.utmCampaign):r.utmCampaign&&n.searchParams.set("utm_campaign",r.utmCampaign),e.utmTerm?n.searchParams.set("utm_term",e.utmTerm):r.utmTerm&&n.searchParams.set("utm_term",r.utmTerm),e.utmContent?n.searchParams.set("utm_content",e.utmContent):r.utmContent&&n.searchParams.set("utm_content",r.utmContent);const s=["_ga","_gid","_fbp","_fbc"];document.cookie.split(";").map(c=>{const[f,h]=c.trim().split("=");return{key:f,value:h}}).filter(c=>s.some(f=>f===c.key)).forEach(c=>{n.searchParams.append(c.key,c.value)});let l=new URL(window.location.href);if(e.redirectUrl)try{l=new URL(e.redirectUrl)}catch{console.warn("Invalid redirect URL provided, using current URL instead:",e.redirectUrl)}return l.searchParams.set("force-refetch-entitlements","true"),e.itemSrc&&l.searchParams.set("sesamy-purchase",e.itemSrc),n.searchParams.set("redirect-url",l.toString()),e.paymentMethodsFilter&&n.searchParams.set("paymentmethods-filter",e.paymentMethodsFilter.flatMap(({provider:c,methods:f})=>f?f.map(h=>`${c}|${h}`):c).join(",")),e.requireAddress&&n.searchParams.set("require-address","true"),e.giftMode&&n.searchParams.set("gift-mode","true"),e.payerEmail&&n.searchParams.set("payer-email",e.payerEmail),e.metadata&&Object.entries(e.metadata).forEach(([c,f])=>{n.searchParams.set(`metadata.${c}`,String(f))}),n}const Zh="sesamySignedURLs";function Ds(){const t=sessionStorage.getItem(Zh);return t?JSON.parse(t):[]}function gw(t){const e=Ds();e.push(t),B(`Adding signed URL: ${t}`),sessionStorage.setItem(Zh,JSON.stringify(e))}function yw(t){const e={};return Object.keys(t).forEach(r=>{const n=t[r];n!=null&&(e[r]=n.toString())}),e}const Ms="sesamyAttribution";function ww(t){const e=localStorage.getItem(t);if(!e)return null;try{return JSON.parse(e).value}catch{return console.error(`Failed to parse ${t}`),null}}function bw(t){return Object.keys(t).find(e=>e.startsWith("utm_"))?{utmSource:void 0,utmMedium:void 0,utmCampaign:void 0,...t}:t}function Wn(){return ww(Ms)||{}}function Yh(t){if(t===null)localStorage.removeItem(Ms);else{B(`Setting attribution ${JSON.stringify(t)}`);const e=Wn()??{},r=yw({...e,...bw(t)});localStorage.setItem(Ms,JSON.stringify({value:r}))}}const Fs="@sesamy/sesamy-js",rn="1.85.0",Xh="sesamyFlags";async function Qh(t){try{localStorage.setItem(Xh,JSON.stringify(t))}catch{B("Failed to save flags to localStorage")}}async function ep(t,e){const r=await nn();r[t]=e,await Qh(r)}async function tp(t){return(await nn())[t]}async function rp(t){const e=await nn();t in e&&(delete e[t],await Qh(e))}async function nn(){try{const t=localStorage.getItem(Xh);return t?JSON.parse(t):{}}catch{return{}}}function np(t){function e(n){return n.id?`#${n.id}`:n.classList.length>0?Array.from(n.classList).map(i=>`.${i}`).join(""):null}function r(n){const a=[];let i=n;for(;i&&i!==document.body&&i!==document.documentElement;){const o=e(i);if(o){a.unshift(o);break}if(i.parentElement){const s=Array.from(i.parentElement.children),u=s.indexOf(i)+1,l=i.tagName.toLowerCase();s.filter(f=>f.tagName.toLowerCase()===l).length>1?a.unshift(`${l}:nth-child(${u})`):a.unshift(l)}i=i.parentElement}return a.join(" > ")}return r(t)}function ap(t){return t?Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0)):{}}function Sw(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}let Fe={article:{selector:"sesamy-article"},image:{selector:"img",attribute:"src"},title:{selector:"h1",attribute:"textContent"},excerpt:{selector:"p",attribute:"textContent"},price:{selector:"sesamy-article",attribute:"price"},currency:{selector:"sesamy-article",attribute:"currency"},url:{selector:"sesamy-article",attribute:"item-src"},accessLevel:{selector:"sesamy-article",attribute:"access-level"},id:{selector:"sesamy-article",attribute:"publisher-content-id"},pass:{selector:"sesamy-article",attribute:"pass"},paywallUrl:{selector:"sesamy-article",attribute:"paywall-url"}},ip=[],op=!1,kt;function Ks(){const t=window.location.pathname,e=new URLSearchParams(window.location.search),r=navigator.userAgent;return ip.find(n=>{if(n.path&&!t.includes(n.path)||n.queryParam&&e.get(n.queryParam.key)!==n.queryParam.value)return!1;if(n.headers){const a=n.headers.name.toLowerCase(),i=n.headers.contains.toLowerCase();if(a==="user-agent"){if(!r.toLowerCase().includes(i))return!1}else return!1}return!(n.userAgentContains&&!r.includes(n.userAgentContains))})}function Iw(){return Ks()}function Pw(t,e){ip=t.content||[];const r=Ks();r&&r.type==="article"&&(Fe={...Fe,...ap(r.selectors)},op=r.enablePaywallSettingsUrlFallback||!1),kt=e}function Ew(t,e){const{selector:r,attribute:n}=e;return r===Fe.article.selector||n&&t.hasAttribute(n)?t:t.querySelector(r)}function sp(t,e,r=!1){if(t){if(e.attribute){if(e.attribute==="textContent")return t.textContent??void 0;const n=t.getAttribute(e.attribute),a=sp(t.parentElement,e,r);if(r){const i=[];return n&&i.push(...n.split(",").map(o=>o.trim()).filter(Boolean)),a&&i.push(...a.split(",").map(o=>o.trim()).filter(Boolean)),i.length>0?[...new Set(i)].join(","):void 0}return n??a}return t.textContent??void 0}}function ge(t){const e=document.head.querySelectorAll(`[property~='${t}'][content]`);for(let n=0;n<e.length;n+=1)if(e[n].content)return e[n].content;const r=document.head.querySelectorAll(`[name~='${t}'][content]`);for(let n=0;n<r.length;n+=1)if(r[n].content)return r[n].content}function an(t){const e=[];return document.head.querySelectorAll(`[property~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),document.head.querySelectorAll(`[name~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),e}let on=null;function cp(){const t=[],e=document.querySelectorAll('script[type="application/ld+json"]');for(const r of e)try{const n=JSON.parse(r.textContent||"");Array.isArray(n)?t.push(...n):n["@graph"]&&Array.isArray(n["@graph"])?t.push(...n["@graph"]):t.push(n)}catch{}return t}function sn(t){const e=cp(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.find(r)||null}function kw(t){const e=cp(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.filter(r)}function zs(t,e,r){if(!t||typeof t!="object")return typeof t=="string"?t:void 0;const a=t[e];if(typeof a=="string")return a;if(a&&typeof a=="object"&&r)return a[r]}function _w(t){if(!t)return;const r=(Array.isArray(t)?t:[t]).map(n=>{if(typeof n=="string")return{name:n};if(typeof n=="object"&&n!==null){const a=n,i=a.name;return i?{name:i,url:a.url,image:zs(a,"image","url"),jobTitle:a.jobTitle,sameAs:a.sameAs}:null}return null}).filter(n=>n!==null&&!!n.name);return r.length>0?r:void 0}function Hs(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string"){const e=t.split(",").map(r=>r.trim()).filter(Boolean);return e.length>0?e:void 0}}function up(){if(on)return on;const t=sn("NewsArticle")||sn("Article")||sn("BlogPosting")||sn("WebPage"),e=(...a)=>a.find(i=>i!=null&&i!=="")||void 0,r=(...a)=>a.find(i=>i&&i.length>0),n={contentType:t?Array.isArray(t["@type"])?t["@type"][0]:t["@type"]:void 0,authors:_w(t?.author)||(an("article:author").length>0?an("article:author").map(a=>({name:a})):void 0)||(ge("author")?[{name:ge("author")}]:void 0),keywords:r(Hs(t?.keywords),Hs(ge("keywords"))),tags:an("article:tag").length>0?an("article:tag"):void 0,categories:Hs(ge("news_keywords")),section:e(t?.articleSection,ge("article:section")),publishedAt:e(t?.datePublished,ge("article:published_time")),modifiedAt:e(t?.dateModified,ge("article:modified_time")),ogType:ge("og:type"),ogSiteName:ge("og:site_name"),ogLocale:ge("og:locale"),twitterCard:ge("twitter:card"),twitterSite:ge("twitter:site"),twitterCreator:ge("twitter:creator"),creator:e(ge("creator"),ge("dc.creator")),mainEntityOfPage:t?zs(t.mainEntityOfPage,"@id")||(typeof t.mainEntityOfPage=="string"?t.mainEntityOfPage:void 0):void 0,isAccessibleForFree:typeof t?.isAccessibleForFree=="boolean"?t.isAccessibleForFree:void 0,wordCount:typeof t?.wordCount=="number"?t.wordCount:void 0,publisher:t?.publisher&&typeof t.publisher=="object"?{name:t.publisher.name||"",url:t.publisher.url,logo:zs(t.publisher,"logo","url")}:void 0};return on=ap(n),on}function Tw(){on=null}function Bs({publisherContentId:t,key:e,defaultValue:r=""}){const n=t?document.body.querySelector(`sesamy-content-data[id='${t}']`):null,a=e.replace(/-([a-z])/g,(i,o)=>o.toUpperCase());return n?.getAttribute(e)||ge(`sesamy:${e}`)||ge(`sesamy:${a}`)||ge(`og:${e}`)||ge(e)||r}function lp(){const t=document.querySelectorAll(Fe.article.selector);return Array.from(t).map(cn).filter(e=>e!==null)}function cn(t){const e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;const r={element:e,selector:typeof t=="string"?t:np(e)},n=(i,o,s,u)=>{const{transform:l,collect:c=!1}=u||{},f=Ew(e,o),h=sp(f,o,c),d=Bs({publisherContentId:s,key:Sw(String(i))}),p=h||d||void 0;p&&(r[i]=l?l(p):p)};n("id",Fe.id),n("title",Fe.title,r.id),n("excerpt",Fe.excerpt,r.id),n("image",Fe.image,r.id),n("price",Fe.price,r.id,{transform:i=>{const o=parseFloat(i);return Number.isNaN(o)?void 0:o}}),n("currency",Fe.currency,r.id),n("url",Fe.url,r.id),n("pass",Fe.pass,r.id,{collect:!0}),n("paywallUrl",Fe.paywallUrl,r.id),n("accessLevel",Fe.accessLevel,r.id,{transform:i=>i||"entitlement"});const a=Ks();if(a&&a.type==="article"&&(a.pass&&(r.pass=r.pass?`${r.pass},${a.pass}`:a.pass),a.price&&!r.price&&(r.price=a.price.amount),a.price?.currency&&!r.currency&&(r.currency=a.price.currency),a.paywallUrl&&!r.paywallUrl&&(r.paywallUrl=a.paywallUrl)),op&&!r.paywallUrl){const i=document.querySelector("sesamy-paywall");if(i){const o=i.getAttribute("settings-url");o&&(r.paywallUrl=o)}}return r.url||(r.url=window.location.href),r.metadata=up(),r}async function Rw(t){const e=cn(t);if(!e)throw new Error("Could not find article element");if(e.accessLevel==="public")return!0;if(e.accessLevel==="logged-in"&&!e.paywallUrl)return await kt.auth.isAuthenticated()?!0:null;if(e.paywallUrl&&((await kt.paywalls.get(e.paywallUrl)).settings.template==="LOGIN"?"logged-in":"entitlement")==="logged-in")return await kt.auth.isAuthenticated()?!0:null;if(!e.url)throw new Error("Article must have a URL");return await kt.entitlements.hasAccess(e.url,e.pass?.split(",")||[])||null}async function fp(t,e){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error("Could not find element");const n=cn(r);if(!n?.url)throw new Error("Could not find content for element");const a=await kt.entitlements.hasAccess(n.url,n.pass?.split(",")||[]);if(!a)throw new Error("User does not have access to the content");const i=await kt.entitlements.access(a.id);if(!i.token)throw new Error("Could not get access token");const o=e||np(r.parentElement||r);return kt.proxy.getContent(i.token,n.url,o)}function dp(t,e={}){const{closeOnBackdropClick:r=!0,closeOnEscape:n=!0,zIndex:a=2147483647,backdropBlur:i="5px",overlayBackground:o="rgba(0,0,0,0.5)"}=e,s=document.createElement("div");s.setAttribute("data-sesamy-modal","true"),Object.assign(s.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",background:o,zIndex:String(a),display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:`blur(${i})`});const u=document.createElement("div");u.setAttribute("data-sesamy-modal-content","true"),typeof t=="string"?u.innerHTML=t:u.appendChild(t),s.appendChild(u);const l=()=>{s.remove(),n&&document.removeEventListener("keydown",c)},c=f=>{f.key==="Escape"&&l()};return r&&s.addEventListener("click",f=>{f.target===s&&l()}),n&&document.addEventListener("keydown",c),document.body.appendChild(s),{element:s,close:l}}function Ow(t,e={}){const{position:r="top",fixed:n=!0,zIndex:a=2147483647,autoDismissMs:i,pushContent:o=!1,height:s,transitionDuration:u="0.3s"}=e,l=document.createElement("div");l.setAttribute("data-sesamy-notification-bar","true"),l.setAttribute("data-sesamy-notification-position",r),Object.assign(l.style,{position:n?"fixed":"absolute",[r]:"0",left:"0",width:"100%",zIndex:String(a),boxSizing:"border-box",...s&&{height:s}}),typeof t=="string"?l.innerHTML=t:l.appendChild(t);let c,f,h;const d=()=>{if(h&&clearTimeout(h),o&&s){const p=document.documentElement;p.style.transform=c||"",setTimeout(()=>{l.remove(),p.style.transition=f||""},parseFloat(u)*1e3)}else l.remove()};if(i&&(h=setTimeout(d,i)),o&&s){const p=document.documentElement;c=p.style.transform,f=p.style.transition,p.style.transition=`transform ${u} ease`,l.style.transition=`transform ${u} ease`,r==="top"?(p.style.transform=`translateY(${s})`,l.style.transform=`translateY(-${s})`):(p.style.transform=`translateY(-${s})`,l.style.transform=`translateY(${s})`),document.documentElement.prepend(l)}else document.body.appendChild(l);return{element:l,close:d}}function Cw(t){const e=t.endpoint||nt("api2",t.environment),n=pw({baseUrl:e,tokenProvider:async()=>{if(await Et())try{const q=await mt(!1);if(q)return`Bearer ${q}`}catch{}const S=localStorage.getItem("__anon_id");return`Basic ${btoa(`${t.vendorId||t.clientId}|${S}:`)}`},libraryName:Fs,libraryVersion:rn,vendorId:t.vendorId,cache:{mode:Gn.BROWSER,storage:new vw}}),a=S=>async(O,q)=>{let F=sessionStorage.getItem(Th);F||(F=Date.now().toString(),sessionStorage.setItem(Th,F));const I={...q,headers:{...q.headers,"Cache-Timestamp":F}};return S(O,I)},i=(S=!0)=>O=>async(q,F)=>{let I=null;if(I=await mt(S),!I){if(S)throw new Error("No access token available");return O(q,F)}const _={...F,headers:{...F.headers,...I?{Authorization:`Bearer ${I}`}:{}}};return O(q,_)},o=ut(e).headers({"Content-Type":"application/json"}).middlewares([a,i(),qy(),xy({delayTimer:1e3,delayRamp:(S,O)=>S*O,maxAttempts:3,until:S=>!!(S&&(S.ok||S.status>=400&&S.status<500)),retryOnNetworkError:!1})]);async function s(S={}){const{waitForEntitlementAfter:O,includeSignedLinks:q=!0}=S,F=await Et()?await n.entitlements.list({waitForEntitlementAfter:O?.toISOString()}):[];return q&&F.push(...Ds()),F}async function u(S,O=[]){return(await s())?.find(I=>{if(S){const{sku:_,purchaseOption:j}=Wh(S);if("sku"in I&&_===I.sku||j&&"purchaseOptionsId"in I&&j===I.purchaseOptionsId||Jh(S,I.url))return!0}return!!O.some(_=>Jh(_,I.url))})}async function l(S,O,q){const F=new URL(nt("api2",t.environment));return F.pathname="/proxy",F.searchParams.set("url",O),q&&F.searchParams.set("selector",q),ut(F.toString()).headers({Authorization:`Bearer ${S}`}).get().text()}async function c(S){if(!S)throw new Error("SKU is required to get fulfillments");return await Et()?await o.get(`/fulfillments?sku=${encodeURIComponent(S)}`).json():[]}async function f(S,O){if(!S||!O)throw new Error("SKU and itemId are required to request delivery");return(await o.post({sku:S},`/fulfillments/${encodeURIComponent(O)}/request-delivery?`).res()).ok}async function h(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),o.get("/subscriptions").json()}async function d(S){return(await n.transactions.list())?.find(q=>q.id===S)}async function p(){return await o.url("/tags").get().json()}async function v(S){const O=await o.url(`/tags/${encodeURIComponent(S)}`).delete().res();return gt(),O.ok}async function g(S){const O=await o.url("/tags").post(encodeURIComponent(S)).res();return Nt(Ge.USER_ATTRIBUTE_CHANGED,{}),gt(),O.ok}async function P(S){return(await n.tallies.get(S)).value}async function b(){const S=await n.tallies.list(),O={};for(const q of S)O[q.id]=q.value;return O}async function y(S){return await n.tallies.delete(S)}async function m(S,O){return await n.tallies.push(S,O)}async function w(){return await mt(!1)?await o.url("/profile").get().json():null}async function R(S){const O=await o.url("/profile").patch(S).res();return gt(),O.ok}async function A(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function x(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function K(S){const O=await mt(!1);if(!O)throw new Error("No access token available");const q=new URL(`${nt("access-sync",t.environment)}/spotify/sesamy-callback`);q.searchParams.set("access_token",O),q.searchParams.set("state",S),window.location.href=q.toString()}async function G(S){const O=await o.url(`/products/${encodeURIComponent(S)}/auto-onboard`).post().json();return O.length&>(),O}async function re(S,O=3600){const{shortlink:q}=await ut(dy).post({url:S,ttl:O}).json();return q}async function L(S){const O=await mt(!1,!0);let q;const F=S.language||Gr(),I=Wn();switch(S.target){case"account":q=new URL(`${nt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}${S.contractId?`/${encodeURIComponent(S.contractId)}`:""}`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-payment":q=new URL(`${nt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/change-payment-method`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-plan":q=new URL(`${nt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/edit-plan`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"consume":q=new URL(`${nt("consume",t.environment)}/${encodeURIComponent(S.language||F)}/@${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.sku)}`),S.episodeId?q.href+=`/${S.episodeId}`:q.href+="/listen",q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"checkout":q=mw(t,{language:F,...S},I);break;default:throw new Error("Invalid target")}return O&&(q.hash=`#access_token=${O}`),S.shorten?re(q.href,S.ttl):q.href}async function M(){const S=await mt(!1),O=new URL(`${nt("account",t.environment)}/subscriptions/${t.vendorId||t.clientId}`);S&&(O.hash=`#access_token=${S}`),window.location.href=O.toString()}async function N(S){const O=Wn(),q=["_ga","_gid","_fbp","_fbc"];return document.cookie.split(";").forEach(F=>{const[I,_]=F.trim().split("=");q.includes(I)&&!O[I]&&(O[I]=_)}),n.checkouts.create({language:Gr(),...S,attribution:{...O,...S.attribution}})}return{autoOnboardProduct:G,bills:n.bills,checkouts:{create:N,get:n.checkouts.get,update:n.checkouts.update},content:{list:lp,get:cn,getLanguage:Gr,unlock:fp,getPropertyFromHTML:Bs},contracts:n.contracts,deleteTag:v,deleteTally:y,entitlements:n.entitlements,flags:{get:tp,set:ep,list:nn,delete:rp},generateLink:L,getProxyContent:l,getEntitlements:s,getFulfillments:c,requestDelivery:f,hasAccess:u,isSpotifyLinked:A,linkSpotify:K,openHostedAccountPage:M,paywalls:n.paywalls,paymentIssues:n.paymentIssues,getProfile:w,products:n.products,getSubscriptions:h,getTally:P,getTallies:b,getTags:p,getTransaction:d,transactions:n.transactions,userMetadata:n.userMetadata,pushTally:m,setTag:g,unlinkSpotify:x,updateProfile:R,vendor:n.vendor}}function hp(t,e,r,n,a){for(e=e.split?e.split("."):e,n=0;n<e.length;n++)t=t?t[e[n]]:a;return t===a?r:t}var Aw="function",$w="string",at="undefined",Uw="boolean",Vn="object",Lw="array",qw="number",Nw="symbol",jw="null",Gs=function(){},pp="any",vp="*",Wt="__",xw="form",Dw="input",Mw="button",Fw="select",Jn=typeof process!==at?process:{};Jn.env&&Jn.env.NODE_ENV;var Ce=typeof document!==at;Jn.versions!=null&&Jn.versions.node!=null,typeof Deno!==at&&Deno.core,Ce&&window.name==="nodejs"||typeof navigator!==at&&typeof navigator.userAgent!==at&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function mp(t,e){return e.charAt(0)[t]()+e.slice(1)}var Kw=mp.bind(null,"toUpperCase"),zw=mp.bind(null,"toLowerCase");function Hw(t){return gp(t)?Kw(jw):typeof t===Vn?Vw(t):Object.prototype.toString.call(t).slice(8,-1)}function Zn(t,e){e===void 0&&(e=!0);var r=Hw(t);return e?zw(r):r}function un(t,e){return typeof e===t}var Ke=un.bind(null,Aw),_t=un.bind(null,$w),gr=un.bind(null,at),Bw=un.bind(null,Uw);un.bind(null,Nw);function gp(t){return t===null}function Gw(t){return Zn(t)===qw&&!isNaN(t)}function yp(t){return Zn(t)===Lw}function ze(t){if(!Ww(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ww(t){return t&&(typeof t===Vn||t!==null)}function Vw(t){return Ke(t.constructor)?t.constructor.name:null}function Jw(t){return t instanceof Error||_t(t.message)&&t.constructor&&Gw(t.constructor.stackTraceLimit)}function wp(t,e){if(typeof e!="object"||gp(e))return!1;if(e instanceof t)return!0;var r=Zn(new t(""));if(Jw(e))for(;e;){if(Zn(e)===r)return!0;e=Object.getPrototypeOf(e)}return!1}wp.bind(null,TypeError),wp.bind(null,SyntaxError);function Yn(t,e){var r=t instanceof Element||t instanceof HTMLDocument;return r&&e?Zw(t,e):r}function Zw(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Xn(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Xn(Yn,xw),Xn(Yn,Mw),Xn(Yn,Dw),Xn(Yn,Fw);function Yw(t){return t?yp(t)?t:[t]:[]}function bp(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Xw(){if(Ce){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Qw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function eb(t){return(function(e){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(e);){var i=bp(r[1]),o=bp(r[2]);if(i)if(i.substring(i.length-2)==="[]"){var s=n[i=i.substring(0,i.length-2)]||(n[i]=[]);n[i]=Array.isArray(s)?s:[],n[i].push(o)}else n[i]=o===""||o}for(var u in n){var l=u.split("[");l.length>1&&(tb(n,l.map(function(c){return c.replace(/[?[\]\\ ]/g,"")}),n[u]),delete n[u])}return n})((function(e){return Ce&&window.location.search.substring(1)})())}function tb(t,e,r){for(var n=e.length-1,a=0;a<n;++a){var i=e[a];if(i==="__proto__"||i==="constructor")break;i in t||(t[i]={}),t=t[i]}t[e[n]]=r}function Qn(){for(var t="",e=0,r=4294967295*Math.random()|0;e++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],a=15&r;t+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=e%8==0?4294967295*Math.random()|0:r>>4}return t}function rb(t,e){var r,n,a,i=null,o=0,s=function(){o=new Date,i=null,a=t.apply(r,n)};return function(){var u=new Date;o||(o=u);var l=e-(u-o);return r=this,n=arguments,l<=0?(clearTimeout(i),i=null,o=u,a=t.apply(r,n)):i||(i=setTimeout(s,l)),a}}var Vt="global",yr=Wt+Vt+Wt,wr=typeof self===Vn&&self.self===self&&self||typeof global===Vn&&global[Vt]===global&&global||void 0;function Jt(t){return wr[yr][t]}function Zt(t,e){return wr[yr][t]=e}function br(t){delete wr[yr][t]}function Sr(t,e,r){var n;try{if(Ws(t)){var a=window[t];n=a[e].bind(a)}}catch{}return n||r}wr[yr]||(wr[yr]={});var ea={};function Ws(t){if(typeof ea[t]!==at)return ea[t];try{var e=window[t];e.setItem(at,at),e.removeItem(at)}catch{return ea[t]=!1}return ea[t]=!0}function ee(){return ee=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ee.apply(null,arguments)}var Tt="function",yt="undefined",ln="reducer",Sp="@@redux/",Vs=Sp+"INIT",nb=Sp+Math.random().toString(36),Ip=(function(){return typeof Symbol===Tt&&Symbol.observable||"@@observable"})(),ta=" != "+Tt;function Pp(t,e,r){var n;if(typeof e===Tt&&typeof r===yt&&(r=e,e=void 0),typeof r!==yt){if(typeof r!==Tt)throw new Error("enhancer"+ta);return r(Pp)(t,e)}if(typeof t!==Tt)throw new Error(ln+ta);var a=t,i=e,o=[],s=o,u=!1;function l(){s===o&&(s=o.slice())}function c(){return i}function f(d){if(typeof d!==Tt)throw new Error("Listener"+ta);var p=!0;return l(),s.push(d),function(){if(p){p=!1,l();var v=s.indexOf(d);s.splice(v,1)}}}function h(d){if(!ze(d))throw new Error("Act != obj");if(typeof d.type===yt)throw new Error("ActType "+yt);if(u)throw new Error("Dispatch in "+ln);try{u=!0,i=a(i,d)}finally{u=!1}for(var p=o=s,v=0;v<p.length;v++)(0,p[v])();return d}return h({type:Vs}),(n={dispatch:h,subscribe:f,getState:c,replaceReducer:function(d){if(typeof d!==Tt)throw new Error("next "+ln+ta);a=d,h({type:Vs})}})[Ip]=function(){var d,p=f;return(d={subscribe:function(v){if(typeof v!="object")throw new TypeError("Observer != obj");function g(){v.next&&v.next(c())}return g(),{unsubscribe:p(g)}}})[Ip]=function(){return this},d},n}function ab(t,e){var r=e&&e.type;return"action "+(r&&r.toString()||"?")+ln+" "+t+" returns "+yt}function Ir(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,r){return function(){return e(r.apply(void 0,[].slice.call(arguments)))}})}function ib(){var t=arguments;return function(e){return function(r,n,a){var i,o=e(r,n,a),s=o.dispatch,u={getState:o.getState,dispatch:function(l){return s(l)}};return i=[].slice.call(t).map(function(l){return l(u)}),ee({},o,{dispatch:s=Ir.apply(void 0,i)(o.dispatch)})}}}var Rt=Wt+"anon_id",Yt=Wt+"user_id",Pr=Wt+"user_traits",Js="analytics",Ot="userId",Er="anonymousId",ra=["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"],Zs=["name","EVENTS","config","loaded"],te=ra.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),Ep=/^utm_/,kp=/^an_prop_/,_p=/^an_trait_/;function ob(t){var e=t.storage.setItem;return function(r){return function(n){return function(a){if(a.type===te.bootstrap){var i=a.params,o=a.user,s=a.persistedUser,u=a.initialUser,l=s.userId===o.userId;s.anonymousId!==o.anonymousId&&e(Rt,o.anonymousId),l||e(Yt,o.userId),u.traits&&e(Pr,ee({},l&&s.traits?s.traits:{},u.traits));var c=Object.keys(a.params);if(c.length){var f=i.an_uid,h=i.an_event,d=c.reduce(function(p,v){if(v.match(Ep)||v.match(/^(d|g)clid/)){var g=v.replace(Ep,"");p.campaign[g==="campaign"?"name":g]=i[v]}return v.match(kp)&&(p.props[v.replace(kp,"")]=i[v]),v.match(_p)&&(p.traits[v.replace(_p,"")]=i[v]),p},{campaign:{},props:{},traits:{}});r.dispatch(ee({type:te.params,raw:i},d,f?{userId:f}:{})),f&&setTimeout(function(){return t.identify(f,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&r.dispatch({type:te.campaign,campaign:d.campaign})}}return n(a)}}}}function sb(t){return function(e,r){if(e===void 0&&(e={}),r===void 0&&(r={}),r.type===te.setItemEnd){if(r.key===Rt)return ee({},e,{anonymousId:r.value});if(r.key===Yt)return ee({},e,{userId:r.value})}switch(r.type){case te.identify:return Object.assign({},e,{userId:r.userId,traits:ee({},e.traits,r.traits)});case te.reset:return[Yt,Rt,Pr].forEach(function(n){t.removeItem(n)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Tp(t){return{userId:t.getItem(Yt),anonymousId:t.getItem(Rt),traits:t.getItem(Pr)}}var Ys=function(t){return Wt+"TEMP"+Wt+t};function cb(t){var e=t.storage,r=e.setItem,n=e.removeItem,a=e.getItem;return function(i){return function(o){return function(s){var u=s.userId,l=s.traits,c=s.options;if(s.type===te.reset&&([Yt,Pr,Rt].forEach(function(d){n(d)}),[Ot,Er,"traits"].forEach(function(d){br(Ys(d))})),s.type===te.identify){a(Rt)||r(Rt,Qn());var f=a(Yt),h=a(Pr)||{};f&&f!==u&&i.dispatch({type:te.userIdChanged,old:{userId:f,traits:h},new:{userId:u,traits:l},options:c}),u&&r(Yt,u),l&&r(Pr,ee({},h,l))}return o(s)}}}}var fn={};function Rp(t,e){fn[t]&&Ke(fn[t])&&(fn[t](e),delete fn[t])}function Op(t,e,r){return new Promise(function(n,a){return e()?n(t):r<1?a(ee({},t,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return Op(t,e,r-10).then(n,a)})})}function ub(t){return{abort:t}}function Cp(t,e,r){var n={},a=e(),i=t.getState(),o=i.plugins,s=i.queue,u=i.user;if(!i.context.offline&&s&&s.actions&&s.actions.length){var l=s.actions.reduce(function(f,h,d){return o[h.plugin].loaded?(f.process.push(h),f.processIndex.push(d)):(f.requeue.push(h),f.requeueIndex.push(d)),f},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(f){var h=s.actions[f],d=h.plugin,p=h.payload.type,v=a[d][p];if(v&&Ke(v)){var g,P=(function(m,w){return m===void 0&&(m={}),w===void 0&&(w={}),[Ot,Er].reduce(function(R,A){return m.hasOwnProperty(A)&&w[A]&&w[A]!==m[A]&&(R[A]=w[A]),R},m)})(h.payload,u),b=n[P.meta.rid];if(!b&&(g=v({payload:P,config:o[d].config,instance:r,abort:ub}))&&ze(g)&&g.abort)return void(n[P.meta.rid]=!0);if(!b){var y=p+":"+d;t.dispatch(ee({},P,{type:y,_:{called:y,from:"queueDrain"}}))}}});var c=s.actions.filter(function(f,h){return!~l.processIndex.indexOf(h)});s.actions=c}}}var Xs=function(t){var e=t.data,r=t.action,n=t.instance,a=t.state,i=t.allPlugins,o=t.allMatches,s=t.store,u=t.EVENTS;try{var l=a.plugins,c=a.context,f=r.type,h=f.match(kr),d=e.exact.map(function(g){return g.pluginName});h&&(d=o.during.map(function(g){return g.pluginName}));var p=(function(g,P){return function(b,y,m){var w=y.config,R=y.name,A=R+"."+b.type;m&&(A=m.event);var x=b.type.match(kr)?(function(K,G,re,L,M){return function(N,S){var O=L?L.name:K,q=S&&dn(S)?S:re;if(L&&(!(q=S&&dn(S)?S:[K]).includes(K)||q.length!==1))throw new Error("Method "+G+" can only abort "+K+" plugin. "+JSON.stringify(q)+" input valid");return ee({},M,{abort:{reason:N,plugins:q,caller:G,_:O}})}})(R,A,P,m,b):(function(K,G){return function(){throw new Error(K.type+" action not cancellable. Remove abort in "+G)}})(b,A);return{payload:lb(b),instance:g,config:w||{},abort:x}}})(n,d),v=e.exact.reduce(function(g,P){var b=P.pluginName,y=P.methodName,m=!1;return y.match(/^initialize/)||y.match(/^reset/)||(m=!l[b].loaded),c.offline&&y.match(/^(page|track|identify)/)&&(m=!0),g[""+b]=m,g},{});return Promise.resolve(e.exact.reduce(function(g,P,b){var y=P.pluginName;return Promise.resolve(g).then(function(m){function w(){return Promise.resolve(m)}var R=(function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(A,x,K){return Promise.resolve(A).then(function(G){return x.method&&Ke(x.method)?((function(N,S){var O=xp(N);if(O&&O.name===S){var q=xp(O.method);throw new Error([S+" plugin is calling method "+N,"Plugins cant call self","Use "+O.method+" "+(q?"or "+q.method:"")+" in "+S+" plugin insteadof "+N].join(`
|
|
35
|
+
CAUSE: `+d.stack,w.response=y,w.status=y.status,w.url=f,y.type==="opaque")throw w;const R=a.errorType==="json"||((m=y.headers.get("Content-Type"))===null||m===void 0?void 0:m.split(";")[0])==="application/json";return(a.errorType?R?y.text():y[a.errorType]():Promise.resolve(y.body)).then(A=>{if(w.message=typeof A=="string"?A:y.statusText,A)if(R&&typeof A=="string"){w.text=A;try{w.json=JSON.parse(A)}catch{}}else w[a.errorType]=A;throw w})}return y}),v=y=>y.catch(m=>{const w=Object.prototype.hasOwnProperty.call(m,hr),R=w?m[hr]:m,A=R?.status&&l.get(R.status)||l.get(R?.name)||w&&l.has(hr)&&l.get(hr);if(A)return A(R,t);const x=l.get(jh);if(x)return x(R,t);throw R}),g=y=>m=>v(y?p.then(w=>w&&w[y]()).then(w=>m?m(w):w):p.then(w=>m?m(w):w)),P={_wretchReq:t,_fetchReq:h,_sharedState:e,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(y,m){return l.set(y,m),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(hr,y)}},b=u.reduce((y,m)=>({...y,...typeof m.resolver=="function"?m.resolver(y):m.resolver}),P);return o.reduce((y,m)=>m(y,t),b)},By={_url:"",_options:{},_config:pr,_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:Gt(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const r=this._url.split("?");return{...this,_url:r.length>1?r[0]+t+"?"+r[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:Gt(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:Gt(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Nh]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const r=new Map(this._catchers);return r.set(t,e),{...this,_catchers:r}},catcherFallback(t){return this.catcher(jh,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="",r=null){let n=this.url(e).options({method:t});const a=xh(n._options.headers),i=this._config.polyfill("FormData",!1),o=typeof r=="object"&&!(i&&r instanceof i)&&(!n._options.headers||!a||Dh(a));return n=r?o?n.json(r,a):n.body(r):n,Hy(n._deferred.reduce((s,u)=>u(s,s._url,s._options),n))},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 r=xh(this._options.headers);return this.content(e||Dh(r)&&r||Dy).body(JSON.stringify(t))}};function ut(t="",e={}){return{...By,_url:t,_options:e}}ut.default=ut,ut.options=My,ut.errorType=Ky,ut.polyfills=Fy,ut.WretchError=Mh;const Gy=(t,e)=>e.skipDedupe||e.method!=="GET",Wy=(t,e)=>e.method+"@"+t,Vy=t=>t.clone(),Jy=({skip:t=Gy,key:e=Wy,resolver:r=Vy}={})=>{const n=new Map;return a=>(i,o)=>{if(t(i,o))return a(i,o);const s=e(i,o);if(!n.has(s))n.set(s,[]);else return new Promise((u,l)=>{n.get(s).push([u,l])});try{return a(i,o).then(u=>(n.get(s).forEach(([l])=>l(r(u))),n.delete(s),u)).catch(u=>{throw n.get(s).forEach(([,l])=>l(u)),n.delete(s),u})}catch(u){return n.delete(s),Promise.reject(u)}}},Zy=(t,e)=>e.skipCache||e.method!=="GET",Yy=(t,e)=>e.method+"@"+t,Xy=()=>!1,Qy=()=>null,ew=t=>t.ok,tw=({throttle:t=1e3,skip:e=Zy,key:r=Yy,clear:n=Xy,invalidate:a=Qy,condition:i=ew,flagResponseOnCacheHit:o="__cached"}={})=>{const s=new Map,u=new Map,l=new Set,c=h=>{t&&!l.has(h)&&(l.add(h),setTimeout(()=>{l.delete(h)},t))},f=h=>(d,p)=>{const v=r(d,p);let g=a(d,p);if(g&&(g instanceof Array||(g=[g]),g.forEach(P=>{typeof P=="string"?s.delete(P):P instanceof RegExp&&s.forEach((b,y)=>{P.test(y)&&s.delete(y)})})),n(d,p)&&s.clear(),e(d,p))return h(d,p);if(l.has(v)){if(s.has(v)){const P=s.get(v).clone();return o&&Object.defineProperty(P,o,{value:v,enumerable:!1}),Promise.resolve(P)}else if(u.has(v))return new Promise((P,b)=>{u.get(v).push([P,b])})}return u.has(v)||u.set(v,[]),c(v),h(d,p).then(P=>(i(P.clone())&&s.set(v,P.clone()),u.get(v).forEach(([b])=>b(P.clone())),u.delete(v),P)).catch(P=>{throw u.get(v).forEach(([,b])=>b(P)),u.delete(v),P})};return f.cacheResponse=function(h,d){c(h),s.set(h,d)},f.cache=s,f.inflight=u,f.throttling=l,f},rw=(t,e)=>t*e,nw=t=>t&&t.ok,aw=({delayTimer:t=500,delayRamp:e=rw,maxAttempts:r=10,until:n=nw,onRetry:a=null,retryOnNetworkError:i=!1,resolveWithLatestResponse:o=!1,skip:s}={})=>u=>(l,c)=>{let f=0;if(s&&s(l,c))return u(l,c);const h=(d,p)=>Promise.resolve(n(d,p)).then(v=>v?d&&o?d:p?Promise.reject(p):d:(f++,!r||f<=r?new Promise(g=>{const P=e(t,f);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:d,error:p,url:l,options:c})).then((b={})=>{var y,m;g(u((y=b&&b.url)!==null&&y!==void 0?y:l,(m=b&&b.options)!==null&&m!==void 0?m:c))}):g(u(l,c))},P)}).then(h).catch(g=>{if(!i)throw g;return h(null,g)}):d&&o?d:Promise.reject(p||new Error("Number of attempts exceeded."))));return u(l,c).then(h).catch(d=>{if(!i)throw d;return h(null,d)})},iw="@sesamy/sdk",ow="1.23.0";let sw=class{cache=new Map;get(e){return this.cache.get(e)||null}set(e,r){this.cache.set(e,r)}remove(e){this.cache.delete(e)}clear(){this.cache.clear()}};const Qr="sesamyCacheTimestamp",cw=t=>{const{libraryName:e=iw,libraryVersion:r=ow,cache:n}=t,a=n?.storage||new sw,i=[s=>async(u,l)=>{if(n?.mode===Gn.BROWSER){let c;typeof sessionStorage<"u"?(c=sessionStorage.getItem(Qr),c||(c=Date.now().toString(),sessionStorage.setItem(Qr,c))):(c=a.get(Qr),c||(c=Date.now().toString(),a.set(Qr,c)));const f={...l,headers:{...l.headers,"Cache-Timestamp":c}};return s(u,f)}return s(u,l)},s=>async(u,l)=>{const c=await t.tokenProvider(),f={...l,headers:{...l.headers,Authorization:c}};return s(u,f)},Jy()];n?.mode===Gn.NORMAL&&i.push(tw({throttle:300*1e3,skip:(s,u)=>u.method!=="GET"})),i.push(aw({delayTimer:1e3,delayRamp:(s,u)=>s*u,maxAttempts:3,until:s=>!!(s&&(s.ok||s.status>=400&&s.status<500)),retryOnNetworkError:!1}));const o=ut(t.baseUrl).headers({"Content-Type":"application/json","X-Sesamy-Client":`${e}/${r}`,...t.headers}).middlewares(i);return{async request(s,u={}){try{const l=/^https?:\/\//.test(s);let c=o.url(s,l);u.headers&&(c=c.headers(u.headers));const f=(u.method||"GET").toLowerCase();let h;switch(f){case"get":h=c.get();break;case"post":h=c.post(u.body);break;case"put":h=c.put(u.body);break;case"patch":h=c.patch(u.body);break;case"delete":h=c.delete();break;default:h=c.get()}const d=await h.res();if(d.ok&&["post","patch","put","delete"].includes(f)&>(),d.status===204)return null;if(!d.ok){const p=await d.text().catch(()=>"Unknown error");throw new Us(d.status,d.statusText,d.url,`API Error ${d.status}: ${p}`,p)}return await d.json()}catch(l){if(l instanceof Us)throw l;const c=l.status||500,f=l.message||"Unknown error",h=`${t.baseUrl}${s}`;throw new Us(c,f,h,`API Error ${c}: ${l.message||"Unknown error"}`,l.message||"Unknown error")}}}},gt=()=>(typeof sessionStorage<"u"&&sessionStorage.removeItem(Qr),"Cache cleared"),en={get:async(t,e)=>t.request(`/profile/${e}`),update:async(t,e,r)=>t.request(`/profile/${e}`,{method:"PATCH",body:JSON.stringify(r)}),checkSpotifyLink:async t=>t.request("/profile/spotify-link"),unlinkSpotify:async t=>t.request("/profile/unlink-spotify",{method:"POST"}),delete:async t=>{await t.request("/profile",{method:"DELETE"})}},Ls={list:async(t,e)=>{const r=new URLSearchParams;e?.type&&r.append("type",e.type),e?.sku&&r.append("sku",e.sku),e?.purchaseOptionId&&r.append("purchase-option-id",e.purchaseOptionId),e?.waitForEntitlementAfter&&r.append("wait-for-entitlement-after",e.waitForEntitlementAfter);const n=r.toString(),a=n?`/entitlements?${n}`:"/entitlements";return t.request(a)},get:async(t,e)=>t.request(`/entitlements/${e}`),getAccess:async(t,e)=>t.request(`/entitlements/${e}/access`)},Fh={list:async t=>t.request("/subscriptions"),get:async(t,e)=>t.request(`/subscriptions/${e}`)},Kh={get:async(t,e)=>t.request(`/products/${e}`),autoOnboard:async(t,e)=>t.request(`/products/${e}/auto-onboard`,{method:"POST"})},uw=(t,e)=>{if(!t||!e)return t;const r=new URL(t);return r.hash=`access_token=${e}`,r.toString()},zh=(t,e)=>!t.manageUrl||!e?t:{...t,manageUrl:uw(t.manageUrl,e)},tn={list:async t=>t.request("/contracts"),get:async(t,e)=>t.request(`/contracts/${e}`),cancel:async(t,e)=>t.request(`/contracts/${e}/cancel`,{method:"POST"}),createAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments`,{method:"POST",body:JSON.stringify(r)}),confirmAmendment:async(t,e,r)=>t.request(`/contracts/${e}/amendments/${r}/confirm`,{method:"POST"})},qs={get:async t=>t.request("/user-metadata"),set:async(t,e,r)=>{await t.request(`/user-metadata/${e}`,{method:"PUT",body:r})},delete:async(t,e)=>{await t.request(`/user-metadata/${e}`,{method:"DELETE"})}},vr={list:async t=>t.request("/tallies"),get:async(t,e)=>t.request(`/tallies/${e}`),update:async(t,e,r)=>t.request(`/tallies/${e}`,{method:"PUT",body:JSON.stringify(r)}),create:async(t,e)=>t.request("/tallies",{method:"POST",body:JSON.stringify(e)}),delete:async(t,e)=>{try{return await t.request(`/tallies/${e}`,{method:"DELETE"}),!0}catch{return!1}},push:async(t,e,r)=>t.request(`/tallies/${e}/push`,{method:"POST",body:JSON.stringify(r)})},Ns={list:async t=>t.request("/tags"),add:async(t,e)=>{await t.request("/tags",{method:"POST",body:JSON.stringify({tag:e})})},remove:async(t,e)=>{await t.request(`/tags/${e}`,{method:"DELETE"})}},mr={generateCheckoutLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},generateAccountLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}${e.contractId?`/${encodeURIComponent(e.contractId)}`:""}`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePaymentLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/change-payment-method`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateChangePlanLink:(t,e)=>{const r=e.language||"en",n=new URL(`${t.baseUrl}/account/${encodeURIComponent(r)}/subscriptions/${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.contractId)}/edit-plan`);return n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()},generateConsumeLink:(t,e)=>{const r=e.language||"en";let n=new URL(`${t.baseUrl}/consume/${encodeURIComponent(r)}/@${encodeURIComponent(t.clientId)}/${encodeURIComponent(e.sku)}`);return e.episodeId?n.href+=`/${encodeURIComponent(e.episodeId)}`:n.href+="/listen",n.searchParams.set("sesamy-redirect-url",e.redirectUrl||"/"),n.toString()}},js={generateLink:(t,e)=>{const r=new URL(`${t.apiUrl}/checkouts`);return e.items&&r.searchParams.set("items",JSON.stringify(e.items)),e.email&&r.searchParams.set("email",e.email),e.language&&r.searchParams.set("lang",e.language),e.redirectUrl&&r.searchParams.set("redirect-url",e.redirectUrl),e.giftMode&&r.searchParams.set("gift-mode","true"),e.payerEmail&&r.searchParams.set("payer-email",e.payerEmail),e.requireAddress&&r.searchParams.set("require-address","true"),e.metadata&&Object.entries(e.metadata).forEach(([n,a])=>{r.searchParams.set(`metadata.${n}`,a)}),r.toString()},create:async(t,e)=>t.request("/checkouts",{method:"POST",body:JSON.stringify(e)}),get:async(t,e)=>t.request(`/checkouts/${e}`),update:async(t,e,r)=>t.request(`/checkouts/${e}`,{method:"PATCH",body:JSON.stringify(r)})},Hh={list:async t=>t.request("/bills"),get:async(t,e)=>t.request(`/bills/${e}`)},Bh={list:async t=>t.request("/fulfillments"),create:async(t,e)=>t.request("/fulfillments",{method:"POST",body:JSON.stringify(e)})},lw={get:async(t,e)=>{try{return new URL(e),t.request(e)}catch{return t.request(`/paywalls/${e}`)}}},fw={list:async t=>t.request("/payment-issues")},dw={content:async(t,e,r,n,a)=>{const i=new URLSearchParams({url:e});return r&&i.append("selector",r),n&&i.append("cache",n),t.request(`/proxy?${i.toString()}`,a)}},hw={list:async(t,e)=>{const r=(e?new URLSearchParams({q:e}):new URLSearchParams).toString(),n=r?`/transactions?${r}`:"/transactions";return t.request(n)}},Gh={get:async t=>t.request("/vendor"),list:async t=>t.request("/vendors")},pw=t=>{const e=cw(t);return{profile:{get:r=>en.get(e,r),update:(r,n)=>en.update(e,r,n),checkSpotifyLink:()=>en.checkSpotifyLink(e),unlinkSpotify:()=>en.unlinkSpotify(e),delete:()=>en.delete(e)},entitlements:{list:r=>Ls.list(e,r),get:r=>Ls.get(e,r),getAccess:r=>Ls.getAccess(e,r)},subscriptions:{list:()=>Fh.list(e),get:r=>Fh.get(e,r)},products:{get:r=>Kh.get(e,r),autoOnboard:r=>Kh.autoOnboard(e,r)},contracts:{list:async()=>{const r=await tn.list(e),n=await t.tokenProvider();if(!n.toLowerCase().startsWith("bearer "))return r;const a=n.substring(7);return r.map(i=>zh(i,a))},get:async r=>{const n=await tn.get(e,r),a=await t.tokenProvider();if(!a.toLowerCase().startsWith("bearer "))return n;const i=a.substring(7);return zh(n,i)},cancel:r=>tn.cancel(e,r),createAmendment:(r,n)=>tn.createAmendment(e,r,n),confirmAmendment:(r,n)=>tn.confirmAmendment(e,r,n)},userMetadata:{get:()=>qs.get(e),set:(r,n)=>qs.set(e,r,n),delete:r=>qs.delete(e,r)},tallies:{list:()=>vr.list(e),get:r=>vr.get(e,r),update:(r,n)=>vr.update(e,r,n),create:r=>vr.create(e,r),delete:r=>vr.delete(e,r),push:(r,n)=>vr.push(e,r,n)},tags:{list:()=>Ns.list(e),add:r=>Ns.add(e,r),remove:r=>Ns.remove(e,r)},checkouts:{generateLink:(r,n)=>mr.generateCheckoutLink(r,n),create:r=>js.create(e,r),get:r=>js.get(e,r),update:(r,n)=>js.update(e,r,n)},links:{generateCheckoutLink:(r,n)=>mr.generateCheckoutLink(r,n),generateAccountLink:(r,n)=>mr.generateAccountLink(r,n),generateChangePaymentLink:(r,n)=>mr.generateChangePaymentLink(r,n),generateChangePlanLink:(r,n)=>mr.generateChangePlanLink(r,n),generateConsumeLink:(r,n)=>mr.generateConsumeLink(r,n)},bills:{list:()=>Hh.list(e),get:r=>Hh.get(e,r)},fulfillments:{list:()=>Bh.list(e),create:r=>Bh.create(e,r)},paywalls:{get:r=>lw.get(e,r)},paymentIssues:{list:()=>fw.list(e)},proxy:{content:(r,n,a,i)=>dw.content(e,r,n,a,i)},transactions:{list:r=>hw.list(e,r)},vendor:{get:()=>Gh.get(e),list:()=>Gh.list(e)}}};class vw{get(e){return typeof sessionStorage>"u"?null:sessionStorage.getItem(e)}set(e,r){typeof sessionStorage<"u"&&sessionStorage.setItem(e,r)}remove(e){typeof sessionStorage<"u"&&sessionStorage.removeItem(e)}clear(){}}function xs(t){let e;try{e=new URL(t)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function Wh(t,e){if(xs(t))return{itemSrc:t};const r=t.split(":");if(r.length<2)throw new Error(`Invalid itemSrc format: expected at least 2 segments separated by ':', got ${r.length}`);const[n,a,i]=r;if(!a)throw new Error("Invalid itemSrc format: sku segment is empty");return{sku:`${n}:${a}`,purchaseOption:e||i}}function Vh(t){return t.endsWith("/")?t.slice(0,-1):t}function Jh(t,e){if(!xs(t)||!xs(e))return!1;const r=new URL(t),n=new URL(e);return r.origin===n.origin&&Vh(r.pathname)===Vh(n.pathname)}function mw(t,e,r){const n=new URL(`${nt("checkout3",t.environment)}`);e.language&&n.searchParams.set("lang",e.language);let a=e.sku,i=e.purchaseOptionId,o=e.itemSrc;if(e.itemSrc){const c=Wh(e.itemSrc,e.purchaseOptionId);a=c.sku||a,i=c.purchaseOption||i,o=c.itemSrc}a?(n.searchParams.set("sku",a),i&&n.searchParams.set("po-id",i)):o&&n.searchParams.set("url",o),e.email&&n.searchParams.set("email",e.email),e.business&&n.searchParams.set("business","true"),e.currency&&n.searchParams.set("currency",e.currency),e.price&&n.searchParams.set("price",e.price.toString()),e.discountCode&&n.searchParams.set("discount-code",e.discountCode),e.attributionItemSrc?n.searchParams.set("itemSrc",e.attributionItemSrc):r.itemSrc&&n.searchParams.set("itemSrc",r.itemSrc),e.attributionPublisherContentId?n.searchParams.set("publisherContentId",e.attributionPublisherContentId):r.publisherContentId&&n.searchParams.set("publisherContentId",r.publisherContentId),e.utmSource?n.searchParams.set("utm_source",e.utmSource):r.utmSource&&n.searchParams.set("utm_source",r.utmSource),e.utmMedium?n.searchParams.set("utm_medium",e.utmMedium):r.utmMedium&&n.searchParams.set("utm_medium",r.utmMedium),e.utmCampaign?n.searchParams.set("utm_campaign",e.utmCampaign):r.utmCampaign&&n.searchParams.set("utm_campaign",r.utmCampaign),e.utmTerm?n.searchParams.set("utm_term",e.utmTerm):r.utmTerm&&n.searchParams.set("utm_term",r.utmTerm),e.utmContent?n.searchParams.set("utm_content",e.utmContent):r.utmContent&&n.searchParams.set("utm_content",r.utmContent);const s=["_ga","_gid","_fbp","_fbc"];document.cookie.split(";").map(c=>{const[f,h]=c.trim().split("=");return{key:f,value:h}}).filter(c=>s.some(f=>f===c.key)).forEach(c=>{n.searchParams.append(c.key,c.value)});let l=new URL(window.location.href);if(e.redirectUrl)try{l=new URL(e.redirectUrl)}catch{console.warn("Invalid redirect URL provided, using current URL instead:",e.redirectUrl)}return l.searchParams.set("force-refetch-entitlements","true"),e.itemSrc&&l.searchParams.set("sesamy-purchase",e.itemSrc),n.searchParams.set("redirect-url",l.toString()),e.paymentMethodsFilter&&n.searchParams.set("paymentmethods-filter",e.paymentMethodsFilter.flatMap(({provider:c,methods:f})=>f?f.map(h=>`${c}|${h}`):c).join(",")),e.requireAddress&&n.searchParams.set("require-address","true"),e.giftMode&&n.searchParams.set("gift-mode","true"),e.payerEmail&&n.searchParams.set("payer-email",e.payerEmail),e.metadata&&Object.entries(e.metadata).forEach(([c,f])=>{n.searchParams.set(`metadata.${c}`,String(f))}),n}const Zh="sesamySignedURLs";function Ds(){const t=sessionStorage.getItem(Zh);return t?JSON.parse(t):[]}function gw(t){const e=Ds();e.push(t),B(`Adding signed URL: ${t}`),sessionStorage.setItem(Zh,JSON.stringify(e))}function yw(t){const e={};return Object.keys(t).forEach(r=>{const n=t[r];n!=null&&(e[r]=n.toString())}),e}const Ms="sesamyAttribution";function ww(t){const e=localStorage.getItem(t);if(!e)return null;try{return JSON.parse(e).value}catch{return console.error(`Failed to parse ${t}`),null}}function bw(t){return Object.keys(t).find(e=>e.startsWith("utm_"))?{utmSource:void 0,utmMedium:void 0,utmCampaign:void 0,...t}:t}function Wn(){return ww(Ms)||{}}function Yh(t){if(t===null)localStorage.removeItem(Ms);else{B(`Setting attribution ${JSON.stringify(t)}`);const e=Wn()??{},r=yw({...e,...bw(t)});localStorage.setItem(Ms,JSON.stringify({value:r}))}}const Fs="@sesamy/sesamy-js",rn="1.87.0",Xh="sesamyFlags";async function Qh(t){try{localStorage.setItem(Xh,JSON.stringify(t))}catch{B("Failed to save flags to localStorage")}}async function ep(t,e){const r=await nn();r[t]=e,await Qh(r)}async function tp(t){return(await nn())[t]}async function rp(t){const e=await nn();t in e&&(delete e[t],await Qh(e))}async function nn(){try{const t=localStorage.getItem(Xh);return t?JSON.parse(t):{}}catch{return{}}}function np(t){function e(n){return n.id?`#${n.id}`:n.classList.length>0?Array.from(n.classList).map(i=>`.${i}`).join(""):null}function r(n){const a=[];let i=n;for(;i&&i!==document.body&&i!==document.documentElement;){const o=e(i);if(o){a.unshift(o);break}if(i.parentElement){const s=Array.from(i.parentElement.children),u=s.indexOf(i)+1,l=i.tagName.toLowerCase();s.filter(f=>f.tagName.toLowerCase()===l).length>1?a.unshift(`${l}:nth-child(${u})`):a.unshift(l)}i=i.parentElement}return a.join(" > ")}return r(t)}function ap(t){return t?Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0)):{}}function Sw(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}let Fe={article:{selector:"sesamy-article"},image:{selector:"img",attribute:"src"},title:{selector:"h1",attribute:"textContent"},excerpt:{selector:"p",attribute:"textContent"},price:{selector:"sesamy-article",attribute:"price"},currency:{selector:"sesamy-article",attribute:"currency"},url:{selector:"sesamy-article",attribute:"item-src"},accessLevel:{selector:"sesamy-article",attribute:"access-level"},id:{selector:"sesamy-article",attribute:"publisher-content-id"},pass:{selector:"sesamy-article",attribute:"pass"},paywallUrl:{selector:"sesamy-article",attribute:"paywall-url"}},ip=[],op=!1,kt;function Ks(){const t=window.location.pathname,e=new URLSearchParams(window.location.search),r=navigator.userAgent;return ip.find(n=>{if(n.path&&!t.includes(n.path)||n.queryParam&&e.get(n.queryParam.key)!==n.queryParam.value)return!1;if(n.headers){const a=n.headers.name.toLowerCase(),i=n.headers.contains.toLowerCase();if(a==="user-agent"){if(!r.toLowerCase().includes(i))return!1}else return!1}return!(n.userAgentContains&&!r.includes(n.userAgentContains))})}function Iw(){return Ks()}function Pw(t,e){ip=t.content||[];const r=Ks();r&&r.type==="article"&&(Fe={...Fe,...ap(r.selectors)},op=r.enablePaywallSettingsUrlFallback||!1),kt=e}function Ew(t,e){const{selector:r,attribute:n}=e;return r===Fe.article.selector||n&&t.hasAttribute(n)?t:t.querySelector(r)}function sp(t,e,r=!1){if(t){if(e.attribute){if(e.attribute==="textContent")return t.textContent??void 0;const n=t.getAttribute(e.attribute),a=sp(t.parentElement,e,r);if(r){const i=[];return n&&i.push(...n.split(",").map(o=>o.trim()).filter(Boolean)),a&&i.push(...a.split(",").map(o=>o.trim()).filter(Boolean)),i.length>0?[...new Set(i)].join(","):void 0}return n??a}return t.textContent??void 0}}function ge(t){const e=document.head.querySelectorAll(`[property~='${t}'][content]`);for(let n=0;n<e.length;n+=1)if(e[n].content)return e[n].content;const r=document.head.querySelectorAll(`[name~='${t}'][content]`);for(let n=0;n<r.length;n+=1)if(r[n].content)return r[n].content}function an(t){const e=[];return document.head.querySelectorAll(`[property~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),document.head.querySelectorAll(`[name~='${t}'][content]`).forEach(a=>{a.content&&e.push(a.content)}),e}let on=null;function cp(){const t=[],e=document.querySelectorAll('script[type="application/ld+json"]');for(const r of e)try{const n=JSON.parse(r.textContent||"");Array.isArray(n)?t.push(...n):n["@graph"]&&Array.isArray(n["@graph"])?t.push(...n["@graph"]):t.push(n)}catch{}return t}function sn(t){const e=cp(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.find(r)||null}function kw(t){const e=cp(),r=n=>!t||n["@type"]===t||Array.isArray(n["@type"])&&n["@type"].includes(t);return e.filter(r)}function zs(t,e,r){if(!t||typeof t!="object")return typeof t=="string"?t:void 0;const a=t[e];if(typeof a=="string")return a;if(a&&typeof a=="object"&&r)return a[r]}function _w(t){if(!t)return;const r=(Array.isArray(t)?t:[t]).map(n=>{if(typeof n=="string")return{name:n};if(typeof n=="object"&&n!==null){const a=n,i=a.name;return i?{name:i,url:a.url,image:zs(a,"image","url"),jobTitle:a.jobTitle,sameAs:a.sameAs}:null}return null}).filter(n=>n!==null&&!!n.name);return r.length>0?r:void 0}function Hs(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string"){const e=t.split(",").map(r=>r.trim()).filter(Boolean);return e.length>0?e:void 0}}function up(){if(on)return on;const t=sn("NewsArticle")||sn("Article")||sn("BlogPosting")||sn("WebPage"),e=(...a)=>a.find(i=>i!=null&&i!=="")||void 0,r=(...a)=>a.find(i=>i&&i.length>0),n={contentType:t?Array.isArray(t["@type"])?t["@type"][0]:t["@type"]:void 0,authors:_w(t?.author)||(an("article:author").length>0?an("article:author").map(a=>({name:a})):void 0)||(ge("author")?[{name:ge("author")}]:void 0),keywords:r(Hs(t?.keywords),Hs(ge("keywords"))),tags:an("article:tag").length>0?an("article:tag"):void 0,categories:Hs(ge("news_keywords")),section:e(t?.articleSection,ge("article:section")),publishedAt:e(t?.datePublished,ge("article:published_time")),modifiedAt:e(t?.dateModified,ge("article:modified_time")),ogType:ge("og:type"),ogSiteName:ge("og:site_name"),ogLocale:ge("og:locale"),twitterCard:ge("twitter:card"),twitterSite:ge("twitter:site"),twitterCreator:ge("twitter:creator"),creator:e(ge("creator"),ge("dc.creator")),mainEntityOfPage:t?zs(t.mainEntityOfPage,"@id")||(typeof t.mainEntityOfPage=="string"?t.mainEntityOfPage:void 0):void 0,isAccessibleForFree:typeof t?.isAccessibleForFree=="boolean"?t.isAccessibleForFree:void 0,wordCount:typeof t?.wordCount=="number"?t.wordCount:void 0,publisher:t?.publisher&&typeof t.publisher=="object"?{name:t.publisher.name||"",url:t.publisher.url,logo:zs(t.publisher,"logo","url")}:void 0};return on=ap(n),on}function Tw(){on=null}function Bs({publisherContentId:t,key:e,defaultValue:r=""}){const n=t?document.body.querySelector(`sesamy-content-data[id='${t}']`):null,a=e.replace(/-([a-z])/g,(i,o)=>o.toUpperCase());return n?.getAttribute(e)||ge(`sesamy:${e}`)||ge(`sesamy:${a}`)||ge(`og:${e}`)||ge(e)||r}function lp(){const t=document.querySelectorAll(Fe.article.selector);return Array.from(t).map(cn).filter(e=>e!==null)}function cn(t){const e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;const r={element:e,selector:typeof t=="string"?t:np(e)},n=(i,o,s,u)=>{const{transform:l,collect:c=!1}=u||{},f=Ew(e,o),h=sp(f,o,c),d=Bs({publisherContentId:s,key:Sw(String(i))}),p=h||d||void 0;p&&(r[i]=l?l(p):p)};n("id",Fe.id),n("title",Fe.title,r.id),n("excerpt",Fe.excerpt,r.id),n("image",Fe.image,r.id),n("price",Fe.price,r.id,{transform:i=>{const o=parseFloat(i);return Number.isNaN(o)?void 0:o}}),n("currency",Fe.currency,r.id),n("url",Fe.url,r.id),n("pass",Fe.pass,r.id,{collect:!0}),n("paywallUrl",Fe.paywallUrl,r.id),n("accessLevel",Fe.accessLevel,r.id,{transform:i=>i||"entitlement"});const a=Ks();if(a&&a.type==="article"&&(a.pass&&(r.pass=r.pass?`${r.pass},${a.pass}`:a.pass),a.price&&!r.price&&(r.price=a.price.amount),a.price?.currency&&!r.currency&&(r.currency=a.price.currency),a.paywallUrl&&!r.paywallUrl&&(r.paywallUrl=a.paywallUrl)),op&&!r.paywallUrl){const i=document.querySelector("sesamy-paywall");if(i){const o=i.getAttribute("settings-url");o&&(r.paywallUrl=o)}}return r.url||(r.url=window.location.href),r.metadata=up(),r}async function Rw(t){const e=cn(t);if(!e)throw new Error("Could not find article element");if(e.accessLevel==="public")return!0;if(e.accessLevel==="logged-in"&&!e.paywallUrl)return await kt.auth.isAuthenticated()?!0:null;if(e.paywallUrl&&((await kt.paywalls.get(e.paywallUrl)).settings.template==="LOGIN"?"logged-in":"entitlement")==="logged-in")return await kt.auth.isAuthenticated()?!0:null;if(!e.url)throw new Error("Article must have a URL");return await kt.entitlements.hasAccess(e.url,e.pass?.split(",")||[])||null}async function fp(t,e){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error("Could not find element");const n=cn(r);if(!n?.url)throw new Error("Could not find content for element");const a=await kt.entitlements.hasAccess(n.url,n.pass?.split(",")||[]);if(!a)throw new Error("User does not have access to the content");const i=await kt.entitlements.access(a.id);if(!i.token)throw new Error("Could not get access token");const o=e||np(r.parentElement||r);return kt.proxy.getContent(i.token,n.url,o)}function dp(t,e={}){const{closeOnBackdropClick:r=!0,closeOnEscape:n=!0,zIndex:a=2147483647,backdropBlur:i="5px",overlayBackground:o="rgba(0,0,0,0.5)"}=e,s=document.createElement("div");s.setAttribute("data-sesamy-modal","true"),Object.assign(s.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",background:o,zIndex:String(a),display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:`blur(${i})`});const u=document.createElement("div");u.setAttribute("data-sesamy-modal-content","true"),typeof t=="string"?u.innerHTML=t:u.appendChild(t),s.appendChild(u);const l=()=>{s.remove(),n&&document.removeEventListener("keydown",c)},c=f=>{f.key==="Escape"&&l()};return r&&s.addEventListener("click",f=>{f.target===s&&l()}),n&&document.addEventListener("keydown",c),document.body.appendChild(s),{element:s,close:l}}function Ow(t,e={}){const{position:r="top",fixed:n=!0,zIndex:a=2147483647,autoDismissMs:i,pushContent:o=!1,height:s,transitionDuration:u="0.3s"}=e,l=document.createElement("div");l.setAttribute("data-sesamy-notification-bar","true"),l.setAttribute("data-sesamy-notification-position",r),Object.assign(l.style,{position:n?"fixed":"absolute",[r]:"0",left:"0",width:"100%",zIndex:String(a),boxSizing:"border-box",...s&&{height:s}}),typeof t=="string"?l.innerHTML=t:l.appendChild(t);let c,f,h;const d=()=>{if(h&&clearTimeout(h),o&&s){const p=document.documentElement;p.style.transform=c||"",setTimeout(()=>{l.remove(),p.style.transition=f||""},parseFloat(u)*1e3)}else l.remove()};if(i&&(h=setTimeout(d,i)),o&&s){const p=document.documentElement;c=p.style.transform,f=p.style.transition,p.style.transition=`transform ${u} ease`,l.style.transition=`transform ${u} ease`,r==="top"?(p.style.transform=`translateY(${s})`,l.style.transform=`translateY(-${s})`):(p.style.transform=`translateY(-${s})`,l.style.transform=`translateY(${s})`),document.documentElement.prepend(l)}else document.body.appendChild(l);return{element:l,close:d}}function Cw(t){const e=t.endpoint||nt("api2",t.environment),n=pw({baseUrl:e,tokenProvider:async()=>{if(await Et())try{const q=await mt(!1);if(q)return`Bearer ${q}`}catch{}const S=localStorage.getItem("__anon_id");return`Basic ${btoa(`${t.vendorId||t.clientId}|${S}:`)}`},libraryName:Fs,libraryVersion:rn,vendorId:t.vendorId,cache:{mode:Gn.BROWSER,storage:new vw}}),a=S=>async(O,q)=>{let F=sessionStorage.getItem(Th);F||(F=Date.now().toString(),sessionStorage.setItem(Th,F));const I={...q,headers:{...q.headers,"Cache-Timestamp":F}};return S(O,I)},i=(S=!0)=>O=>async(q,F)=>{let I=null;if(I=await mt(S),!I){if(S)throw new Error("No access token available");return O(q,F)}const _={...F,headers:{...F.headers,...I?{Authorization:`Bearer ${I}`}:{}}};return O(q,_)},o=ut(e).headers({"Content-Type":"application/json"}).middlewares([a,i(),qy(),xy({delayTimer:1e3,delayRamp:(S,O)=>S*O,maxAttempts:3,until:S=>!!(S&&(S.ok||S.status>=400&&S.status<500)),retryOnNetworkError:!1})]);async function s(S={}){const{waitForEntitlementAfter:O,includeSignedLinks:q=!0}=S,F=await Et()?await n.entitlements.list({waitForEntitlementAfter:O?.toISOString()}):[];return q&&F.push(...Ds()),F}async function u(S,O=[]){return(await s())?.find(I=>{if(S){const{sku:_,purchaseOption:j}=Wh(S);if("sku"in I&&_===I.sku||j&&"purchaseOptionsId"in I&&j===I.purchaseOptionsId||Jh(S,I.url))return!0}return!!O.some(_=>Jh(_,I.url))})}async function l(S,O,q){const F=new URL(nt("api2",t.environment));return F.pathname="/proxy",F.searchParams.set("url",O),q&&F.searchParams.set("selector",q),ut(F.toString()).headers({Authorization:`Bearer ${S}`}).get().text()}async function c(S){if(!S)throw new Error("SKU is required to get fulfillments");return await Et()?await o.get(`/fulfillments?sku=${encodeURIComponent(S)}`).json():[]}async function f(S,O){if(!S||!O)throw new Error("SKU and itemId are required to request delivery");return(await o.post({sku:S},`/fulfillments/${encodeURIComponent(O)}/request-delivery?`).res()).ok}async function h(){return console.warn("getSubscriptions is deprecated, use getContracts instead"),o.get("/subscriptions").json()}async function d(S){return(await n.transactions.list())?.find(q=>q.id===S)}async function p(){return await o.url("/tags").get().json()}async function v(S){const O=await o.url(`/tags/${encodeURIComponent(S)}`).delete().res();return gt(),O.ok}async function g(S){const O=await o.url("/tags").post(encodeURIComponent(S)).res();return Nt(Ge.USER_ATTRIBUTE_CHANGED,{}),gt(),O.ok}async function P(S){return(await n.tallies.get(S)).value}async function b(){const S=await n.tallies.list(),O={};for(const q of S)O[q.id]=q.value;return O}async function y(S){return await n.tallies.delete(S)}async function m(S,O){return await n.tallies.push(S,O)}async function w(){return await mt(!1)?await o.url("/profile").get().json():null}async function R(S){const O=await o.url("/profile").patch(S).res();return gt(),O.ok}async function A(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function x(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function K(S){const O=await mt(!1);if(!O)throw new Error("No access token available");const q=new URL(`${nt("access-sync",t.environment)}/spotify/sesamy-callback`);q.searchParams.set("access_token",O),q.searchParams.set("state",S),window.location.href=q.toString()}async function G(S){const O=await o.url(`/products/${encodeURIComponent(S)}/auto-onboard`).post().json();return O.length&>(),O}async function re(S,O=3600){const{shortlink:q}=await ut(dy).post({url:S,ttl:O}).json();return q}async function L(S){const O=await mt(!1,!0);let q;const F=S.language||Gr(),I=Wn();switch(S.target){case"account":q=new URL(`${nt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}${S.contractId?`/${encodeURIComponent(S.contractId)}`:""}`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-payment":q=new URL(`${nt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/change-payment-method`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"change-plan":q=new URL(`${nt("account",t.environment)}/${encodeURIComponent(S.language||F)}/subscriptions/${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.contractId)}/edit-plan`),q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"consume":q=new URL(`${nt("consume",t.environment)}/${encodeURIComponent(S.language||F)}/@${encodeURIComponent(t.vendorId||t.clientId)}/${encodeURIComponent(S.sku)}`),S.episodeId?q.href+=`/${S.episodeId}`:q.href+="/listen",q.searchParams.set("sesamy-redirect-url",S.redirectUrl||window.location.href);break;case"checkout":q=mw(t,{language:F,...S},I);break;default:throw new Error("Invalid target")}return O&&(q.hash=`#access_token=${O}`),S.shorten?re(q.href,S.ttl):q.href}async function M(){const S=await mt(!1),O=new URL(`${nt("account",t.environment)}/subscriptions/${t.vendorId||t.clientId}`);S&&(O.hash=`#access_token=${S}`),window.location.href=O.toString()}async function N(S){const O=Wn(),q=["_ga","_gid","_fbp","_fbc"];return document.cookie.split(";").forEach(F=>{const[I,_]=F.trim().split("=");q.includes(I)&&!O[I]&&(O[I]=_)}),n.checkouts.create({language:Gr(),...S,attribution:{...O,...S.attribution}})}return{autoOnboardProduct:G,bills:n.bills,checkouts:{create:N,get:n.checkouts.get,update:n.checkouts.update},content:{list:lp,get:cn,getLanguage:Gr,unlock:fp,getPropertyFromHTML:Bs},contracts:n.contracts,deleteTag:v,deleteTally:y,entitlements:n.entitlements,flags:{get:tp,set:ep,list:nn,delete:rp},generateLink:L,getProxyContent:l,getEntitlements:s,getFulfillments:c,requestDelivery:f,hasAccess:u,isSpotifyLinked:A,linkSpotify:K,openHostedAccountPage:M,paywalls:n.paywalls,paymentIssues:n.paymentIssues,getProfile:w,products:n.products,getSubscriptions:h,getTally:P,getTallies:b,getTags:p,getTransaction:d,transactions:n.transactions,userMetadata:n.userMetadata,pushTally:m,setTag:g,unlinkSpotify:x,updateProfile:R,vendor:n.vendor}}function hp(t,e,r,n,a){for(e=e.split?e.split("."):e,n=0;n<e.length;n++)t=t?t[e[n]]:a;return t===a?r:t}var Aw="function",$w="string",at="undefined",Uw="boolean",Vn="object",Lw="array",qw="number",Nw="symbol",jw="null",Gs=function(){},pp="any",vp="*",Wt="__",xw="form",Dw="input",Mw="button",Fw="select",Jn=typeof process!==at?process:{};Jn.env&&Jn.env.NODE_ENV;var Ce=typeof document!==at;Jn.versions!=null&&Jn.versions.node!=null,typeof Deno!==at&&Deno.core,Ce&&window.name==="nodejs"||typeof navigator!==at&&typeof navigator.userAgent!==at&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function mp(t,e){return e.charAt(0)[t]()+e.slice(1)}var Kw=mp.bind(null,"toUpperCase"),zw=mp.bind(null,"toLowerCase");function Hw(t){return gp(t)?Kw(jw):typeof t===Vn?Vw(t):Object.prototype.toString.call(t).slice(8,-1)}function Zn(t,e){e===void 0&&(e=!0);var r=Hw(t);return e?zw(r):r}function un(t,e){return typeof e===t}var Ke=un.bind(null,Aw),_t=un.bind(null,$w),gr=un.bind(null,at),Bw=un.bind(null,Uw);un.bind(null,Nw);function gp(t){return t===null}function Gw(t){return Zn(t)===qw&&!isNaN(t)}function yp(t){return Zn(t)===Lw}function ze(t){if(!Ww(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ww(t){return t&&(typeof t===Vn||t!==null)}function Vw(t){return Ke(t.constructor)?t.constructor.name:null}function Jw(t){return t instanceof Error||_t(t.message)&&t.constructor&&Gw(t.constructor.stackTraceLimit)}function wp(t,e){if(typeof e!="object"||gp(e))return!1;if(e instanceof t)return!0;var r=Zn(new t(""));if(Jw(e))for(;e;){if(Zn(e)===r)return!0;e=Object.getPrototypeOf(e)}return!1}wp.bind(null,TypeError),wp.bind(null,SyntaxError);function Yn(t,e){var r=t instanceof Element||t instanceof HTMLDocument;return r&&e?Zw(t,e):r}function Zw(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Xn(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Xn(Yn,xw),Xn(Yn,Mw),Xn(Yn,Dw),Xn(Yn,Fw);function Yw(t){return t?yp(t)?t:[t]:[]}function bp(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Xw(){if(Ce){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Qw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function eb(t){return(function(e){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(e);){var i=bp(r[1]),o=bp(r[2]);if(i)if(i.substring(i.length-2)==="[]"){var s=n[i=i.substring(0,i.length-2)]||(n[i]=[]);n[i]=Array.isArray(s)?s:[],n[i].push(o)}else n[i]=o===""||o}for(var u in n){var l=u.split("[");l.length>1&&(tb(n,l.map(function(c){return c.replace(/[?[\]\\ ]/g,"")}),n[u]),delete n[u])}return n})((function(e){return Ce&&window.location.search.substring(1)})())}function tb(t,e,r){for(var n=e.length-1,a=0;a<n;++a){var i=e[a];if(i==="__proto__"||i==="constructor")break;i in t||(t[i]={}),t=t[i]}t[e[n]]=r}function Qn(){for(var t="",e=0,r=4294967295*Math.random()|0;e++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],a=15&r;t+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=e%8==0?4294967295*Math.random()|0:r>>4}return t}function rb(t,e){var r,n,a,i=null,o=0,s=function(){o=new Date,i=null,a=t.apply(r,n)};return function(){var u=new Date;o||(o=u);var l=e-(u-o);return r=this,n=arguments,l<=0?(clearTimeout(i),i=null,o=u,a=t.apply(r,n)):i||(i=setTimeout(s,l)),a}}var Vt="global",yr=Wt+Vt+Wt,wr=typeof self===Vn&&self.self===self&&self||typeof global===Vn&&global[Vt]===global&&global||void 0;function Jt(t){return wr[yr][t]}function Zt(t,e){return wr[yr][t]=e}function br(t){delete wr[yr][t]}function Sr(t,e,r){var n;try{if(Ws(t)){var a=window[t];n=a[e].bind(a)}}catch{}return n||r}wr[yr]||(wr[yr]={});var ea={};function Ws(t){if(typeof ea[t]!==at)return ea[t];try{var e=window[t];e.setItem(at,at),e.removeItem(at)}catch{return ea[t]=!1}return ea[t]=!0}function ee(){return ee=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ee.apply(null,arguments)}var Tt="function",yt="undefined",ln="reducer",Sp="@@redux/",Vs=Sp+"INIT",nb=Sp+Math.random().toString(36),Ip=(function(){return typeof Symbol===Tt&&Symbol.observable||"@@observable"})(),ta=" != "+Tt;function Pp(t,e,r){var n;if(typeof e===Tt&&typeof r===yt&&(r=e,e=void 0),typeof r!==yt){if(typeof r!==Tt)throw new Error("enhancer"+ta);return r(Pp)(t,e)}if(typeof t!==Tt)throw new Error(ln+ta);var a=t,i=e,o=[],s=o,u=!1;function l(){s===o&&(s=o.slice())}function c(){return i}function f(d){if(typeof d!==Tt)throw new Error("Listener"+ta);var p=!0;return l(),s.push(d),function(){if(p){p=!1,l();var v=s.indexOf(d);s.splice(v,1)}}}function h(d){if(!ze(d))throw new Error("Act != obj");if(typeof d.type===yt)throw new Error("ActType "+yt);if(u)throw new Error("Dispatch in "+ln);try{u=!0,i=a(i,d)}finally{u=!1}for(var p=o=s,v=0;v<p.length;v++)(0,p[v])();return d}return h({type:Vs}),(n={dispatch:h,subscribe:f,getState:c,replaceReducer:function(d){if(typeof d!==Tt)throw new Error("next "+ln+ta);a=d,h({type:Vs})}})[Ip]=function(){var d,p=f;return(d={subscribe:function(v){if(typeof v!="object")throw new TypeError("Observer != obj");function g(){v.next&&v.next(c())}return g(),{unsubscribe:p(g)}}})[Ip]=function(){return this},d},n}function ab(t,e){var r=e&&e.type;return"action "+(r&&r.toString()||"?")+ln+" "+t+" returns "+yt}function Ir(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,r){return function(){return e(r.apply(void 0,[].slice.call(arguments)))}})}function ib(){var t=arguments;return function(e){return function(r,n,a){var i,o=e(r,n,a),s=o.dispatch,u={getState:o.getState,dispatch:function(l){return s(l)}};return i=[].slice.call(t).map(function(l){return l(u)}),ee({},o,{dispatch:s=Ir.apply(void 0,i)(o.dispatch)})}}}var Rt=Wt+"anon_id",Yt=Wt+"user_id",Pr=Wt+"user_traits",Js="analytics",Ot="userId",Er="anonymousId",ra=["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"],Zs=["name","EVENTS","config","loaded"],te=ra.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),Ep=/^utm_/,kp=/^an_prop_/,_p=/^an_trait_/;function ob(t){var e=t.storage.setItem;return function(r){return function(n){return function(a){if(a.type===te.bootstrap){var i=a.params,o=a.user,s=a.persistedUser,u=a.initialUser,l=s.userId===o.userId;s.anonymousId!==o.anonymousId&&e(Rt,o.anonymousId),l||e(Yt,o.userId),u.traits&&e(Pr,ee({},l&&s.traits?s.traits:{},u.traits));var c=Object.keys(a.params);if(c.length){var f=i.an_uid,h=i.an_event,d=c.reduce(function(p,v){if(v.match(Ep)||v.match(/^(d|g)clid/)){var g=v.replace(Ep,"");p.campaign[g==="campaign"?"name":g]=i[v]}return v.match(kp)&&(p.props[v.replace(kp,"")]=i[v]),v.match(_p)&&(p.traits[v.replace(_p,"")]=i[v]),p},{campaign:{},props:{},traits:{}});r.dispatch(ee({type:te.params,raw:i},d,f?{userId:f}:{})),f&&setTimeout(function(){return t.identify(f,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&r.dispatch({type:te.campaign,campaign:d.campaign})}}return n(a)}}}}function sb(t){return function(e,r){if(e===void 0&&(e={}),r===void 0&&(r={}),r.type===te.setItemEnd){if(r.key===Rt)return ee({},e,{anonymousId:r.value});if(r.key===Yt)return ee({},e,{userId:r.value})}switch(r.type){case te.identify:return Object.assign({},e,{userId:r.userId,traits:ee({},e.traits,r.traits)});case te.reset:return[Yt,Rt,Pr].forEach(function(n){t.removeItem(n)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Tp(t){return{userId:t.getItem(Yt),anonymousId:t.getItem(Rt),traits:t.getItem(Pr)}}var Ys=function(t){return Wt+"TEMP"+Wt+t};function cb(t){var e=t.storage,r=e.setItem,n=e.removeItem,a=e.getItem;return function(i){return function(o){return function(s){var u=s.userId,l=s.traits,c=s.options;if(s.type===te.reset&&([Yt,Pr,Rt].forEach(function(d){n(d)}),[Ot,Er,"traits"].forEach(function(d){br(Ys(d))})),s.type===te.identify){a(Rt)||r(Rt,Qn());var f=a(Yt),h=a(Pr)||{};f&&f!==u&&i.dispatch({type:te.userIdChanged,old:{userId:f,traits:h},new:{userId:u,traits:l},options:c}),u&&r(Yt,u),l&&r(Pr,ee({},h,l))}return o(s)}}}}var fn={};function Rp(t,e){fn[t]&&Ke(fn[t])&&(fn[t](e),delete fn[t])}function Op(t,e,r){return new Promise(function(n,a){return e()?n(t):r<1?a(ee({},t,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return Op(t,e,r-10).then(n,a)})})}function ub(t){return{abort:t}}function Cp(t,e,r){var n={},a=e(),i=t.getState(),o=i.plugins,s=i.queue,u=i.user;if(!i.context.offline&&s&&s.actions&&s.actions.length){var l=s.actions.reduce(function(f,h,d){return o[h.plugin].loaded?(f.process.push(h),f.processIndex.push(d)):(f.requeue.push(h),f.requeueIndex.push(d)),f},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(f){var h=s.actions[f],d=h.plugin,p=h.payload.type,v=a[d][p];if(v&&Ke(v)){var g,P=(function(m,w){return m===void 0&&(m={}),w===void 0&&(w={}),[Ot,Er].reduce(function(R,A){return m.hasOwnProperty(A)&&w[A]&&w[A]!==m[A]&&(R[A]=w[A]),R},m)})(h.payload,u),b=n[P.meta.rid];if(!b&&(g=v({payload:P,config:o[d].config,instance:r,abort:ub}))&&ze(g)&&g.abort)return void(n[P.meta.rid]=!0);if(!b){var y=p+":"+d;t.dispatch(ee({},P,{type:y,_:{called:y,from:"queueDrain"}}))}}});var c=s.actions.filter(function(f,h){return!~l.processIndex.indexOf(h)});s.actions=c}}}var Xs=function(t){var e=t.data,r=t.action,n=t.instance,a=t.state,i=t.allPlugins,o=t.allMatches,s=t.store,u=t.EVENTS;try{var l=a.plugins,c=a.context,f=r.type,h=f.match(kr),d=e.exact.map(function(g){return g.pluginName});h&&(d=o.during.map(function(g){return g.pluginName}));var p=(function(g,P){return function(b,y,m){var w=y.config,R=y.name,A=R+"."+b.type;m&&(A=m.event);var x=b.type.match(kr)?(function(K,G,re,L,M){return function(N,S){var O=L?L.name:K,q=S&&dn(S)?S:re;if(L&&(!(q=S&&dn(S)?S:[K]).includes(K)||q.length!==1))throw new Error("Method "+G+" can only abort "+K+" plugin. "+JSON.stringify(q)+" input valid");return ee({},M,{abort:{reason:N,plugins:q,caller:G,_:O}})}})(R,A,P,m,b):(function(K,G){return function(){throw new Error(K.type+" action not cancellable. Remove abort in "+G)}})(b,A);return{payload:lb(b),instance:g,config:w||{},abort:x}}})(n,d),v=e.exact.reduce(function(g,P){var b=P.pluginName,y=P.methodName,m=!1;return y.match(/^initialize/)||y.match(/^reset/)||(m=!l[b].loaded),c.offline&&y.match(/^(page|track|identify)/)&&(m=!0),g[""+b]=m,g},{});return Promise.resolve(e.exact.reduce(function(g,P,b){var y=P.pluginName;return Promise.resolve(g).then(function(m){function w(){return Promise.resolve(m)}var R=(function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(A,x,K){return Promise.resolve(A).then(function(G){return x.method&&Ke(x.method)?((function(N,S){var O=xp(N);if(O&&O.name===S){var q=xp(O.method);throw new Error([S+" plugin is calling method "+N,"Plugins cant call self","Use "+O.method+" "+(q?"or "+q.method:"")+" in "+S+" plugin insteadof "+N].join(`
|
|
36
36
|
`))}})(x.methodName,x.pluginName),Promise.resolve(x.method({payload:G,instance:n,abort:(re=G,L=y,M=x.pluginName,function(N,S){return ee({},re,{abort:{reason:N,plugins:S||[L],caller:f,from:M||L}})}),config:Up(x.pluginName,l,i),plugins:l})).then(function(N){var S=ze(N)?N:{};return Promise.resolve(ee({},G,S))})):G;var re,L,M})},Promise.resolve(r))).then(function(A){m[y]=A});m[y]=r})();return R&&R.then?R.then(w):w()})},Promise.resolve({}))).then(function(g){return Promise.resolve(e.exact.reduce(function(P,b,y){try{var m=e.exact.length===y+1,w=b.pluginName,R=i[w];return Promise.resolve(P).then(function(A){var x=g[w]?g[w]:{};if(h&&(x=A),ec(x,w))return Qs({data:x,method:f,instance:n,pluginName:w,store:s}),Promise.resolve(A);if(ec(A,w))return m&&Qs({data:A,method:f,instance:n,store:s}),Promise.resolve(A);if(v.hasOwnProperty(w)&&v[w]===!0)return s.dispatch({type:"queue",plugin:w,payload:x,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(A);var K=p(g[w],i[w]);return Promise.resolve(R[f]({abort:K.abort,payload:x,instance:n,config:Up(w,l,i),plugins:l})).then(function(G){var re=ze(G)?G:{},L=ee({},A,re),M=g[w];if(ec(M,w))Qs({data:M,method:f,instance:n,pluginName:w,store:s});else{var N=f+":"+w;(N.match(/:/g)||[]).length<2&&!f.match(Ap)&&!f.match($p)&&n.dispatch(ee({},h?L:x,{type:N,_:{called:N,from:"submethod"}}))}return Promise.resolve(L)})})}catch(A){return Promise.reject(A)}},Promise.resolve(r))).then(function(P){if(!(f.match(kr)||f.match(/^registerPlugin/)||f.match($p)||f.match(Ap)||f.match(/^params/)||f.match(/^userIdChanged/))){if(u.plugins.includes(f),P._&&P._.originalAction===f)return P;var b=ee({},P,{_:{originalAction:P.type,called:P.type,from:"engineEnd"}});Np(P,e.exact.length)&&!f.match(/End$/)&&(b=ee({},b,{type:P.type+"Aborted"})),s.dispatch(b)}return P})})}catch(g){return Promise.reject(g)}},kr=/Start$/,Ap=/^bootstrap/,$p=/^ready/;function Qs(t){var e=t.pluginName,r=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(ee({},t.data,{type:r,_:{called:r,from:"abort"}}))}function Up(t,e,r){var n=e[t]||r[t];return n&&n.config?n.config:{}}function Lp(t,e){return e.reduce(function(r,n){return n[t]?r.concat({methodName:t,pluginName:n.name,method:n[t]}):r},[])}function qp(t,e){var r=t.replace(kr,""),n=e?":"+e:"";return[""+t+n,""+r+n,r+"End"+n]}function ec(t,e){var r=t.abort;return!!r&&(r===!0||jp(r,e)||r&&jp(r.plugins,e))}function Np(t,e){var r=t.abort;if(!r)return!1;if(r===!0||_t(r))return!0;var n=r.plugins;return dn(r)&&r.length===e||dn(n)&&n.length===e}function dn(t){return Array.isArray(t)}function jp(t,e){return!(!t||!dn(t))&&t.includes(e)}function xp(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function lb(t){return Object.keys(t).reduce(function(e,r){return r==="type"||(e[r]=ze(t[r])?Object.assign({},t[r]):t[r]),e},{})}function fb(t,e,r){var n={};return function(a){return function(i){return function(o){try{var s,u=function(m){return s?m:i(f)},l=o.type,c=o.plugins,f=o;if(o.abort)return Promise.resolve(i(o));if(l===te.enablePlugin&&a.dispatch({type:te.initializeStart,plugins:c,disabled:[],fromEnable:!0,meta:o.meta}),l===te.disablePlugin&&setTimeout(function(){return Rp(o.meta.rid,{payload:o})},0),l===te.initializeEnd){var h=e(),d=Object.keys(h),p=d.filter(function(m){return c.includes(m)}).map(function(m){return h[m]}),v=[],g=[],P=o.disabled,b=p.map(function(m){var w=m.loaded,R=m.name,A=m.config;return Op(m,function(){return w({config:A})},1e4).then(function(x){return n[R]||(a.dispatch({type:te.pluginReadyType(R),name:R,events:Object.keys(m).filter(function(K){return!Zs.includes(K)})}),n[R]=!0),v=v.concat(R),m}).catch(function(x){if(x instanceof Error)throw new Error(x);return g=g.concat(x.name),x})});Promise.all(b).then(function(m){var w={plugins:v,failed:g,disabled:P};setTimeout(function(){d.length===b.length+P.length&&a.dispatch(ee({},{type:te.ready},w))},0)})}var y=(function(){if(l!==te.bootstrap)return/^ready:([^:]*)$/.test(l)&&setTimeout(function(){return Cp(a,e,t)},0),Promise.resolve((function(m,w,R,A,x){try{var K=Ke(w)?w():w,G=m.type,re=G.replace(kr,"");if(m._&&m._.called)return Promise.resolve(m);var L=R.getState(),M=(O=K,(q=L.plugins)===void 0&&(q={}),(F=m.options)===void 0&&(F={}),Object.keys(O).filter(function(I){var _=F.plugins||{};return Bw(_[I])?_[I]:_.all!==!1&&(!q[I]||q[I].enabled!==!1)}).map(function(I){return O[I]}));G===te.initializeStart&&m.fromEnable&&(M=Object.keys(L.plugins).filter(function(I){var _=L.plugins[I];return m.plugins.includes(I)&&!_.initialized}).map(function(I){return K[I]}));var N=M.map(function(I){return I.name}),S=(function(I,_){var j=qp(I).map(function(H){return Lp(H,_)});return _.reduce(function(H,X){var Z=X.name,fe=qp(I,Z).map(function(Ae){return Lp(Ae,_)}),ae=fe[0],ue=fe[1],ie=fe[2];return ae.length&&(H.beforeNS[Z]=ae),ue.length&&(H.duringNS[Z]=ue),ie.length&&(H.afterNS[Z]=ie),H},{before:j[0],beforeNS:{},during:j[1],duringNS:{},after:j[2],afterNS:{}})})(G,M);return Promise.resolve(Xs({action:m,data:{exact:S.before,namespaced:S.beforeNS},state:L,allPlugins:K,allMatches:S,instance:R,store:A,EVENTS:x})).then(function(I){function _(){var X=(function(){if(G.match(kr))return Promise.resolve(Xs({action:ee({},j,{type:re+"End"}),data:{exact:S.after,namespaced:S.afterNS},state:L,allPlugins:K,allMatches:S,instance:R,store:A,EVENTS:x})).then(function(Z){Z.meta&&Z.meta.hasCallback&&Rp(Z.meta.rid,{payload:Z})})})();return X&&X.then?X.then(function(){return I}):I}if(Np(I,N.length))return I;var j,H=(function(){if(G!==re)return Promise.resolve(Xs({action:ee({},I,{type:re}),data:{exact:S.during,namespaced:S.duringNS},state:L,allPlugins:K,allMatches:S,instance:R,store:A,EVENTS:x})).then(function(X){j=X});j=I})();return H&&H.then?H.then(_):_()})}catch(I){return Promise.reject(I)}var O,q,F})(o,e,t,a,r)).then(function(m){var w=i(m);return s=1,w})})();return Promise.resolve(y&&y.then?y.then(u):u(y))}catch(m){return Promise.reject(m)}}}}}function db(t){return function(e){return function(r){return function(n){var a=n.type,i=n.key,o=n.value,s=n.options;if(a===te.setItem||a===te.removeItem){if(n.abort)return r(n);a===te.setItem?t.setItem(i,o,s):t.removeItem(i,s)}return r(n)}}}}var hb=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,r){t[r]=t[r].concat(e)},this.removeMiddleware=function(e,r){var n=t[r].findIndex(function(a){return a===e});n!==-1&&(t[r]=[].concat(t[r].slice(0,n),t[r].slice(n+1)))},this.dynamicMiddlewares=function(e){return function(r){return function(n){return function(a){var i={getState:r.getState,dispatch:function(s){return r.dispatch(s)}},o=t[e].map(function(s){return s(i)});return Ir.apply(void 0,o)(n)(a)}}}}};function pb(t){return function(e,r){e===void 0&&(e={});var n={};if(r.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(r.type)){var a=Dp(r.type,"registerPlugin"),i=t()[a];if(!i||!a)return e;var o=r.enabled,s=i.config;return n[a]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:s}),config:s},ee({},e,n)}if(/^initialize:([^:]*)$/.test(r.type)){var u=Dp(r.type,te.initialize),l=t()[u];return l&&u?(n[u]=ee({},e[u],{initialized:!0,loaded:!!l.loaded({config:l.config})}),ee({},e,n)):e}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=ee({},e[r.name],{loaded:!0}),ee({},e,n);switch(r.type){case te.disablePlugin:return ee({},e,Mp(r.plugins,!1,e));case te.enablePlugin:return ee({},e,Mp(r.plugins,!0,e));default:return e}}}function Dp(t,e){return t.substring(e.length+1,t.length)}function Mp(t,e,r){return t.reduce(function(n,a){return n[a]=ee({},r[a],{enabled:e}),n},r)}function Fp(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var vb={last:{},history:[]};function mb(t,e){t===void 0&&(t=vb);var r=e.options,n=e.meta;if(e.type===te.track){var a=Fp(ee({event:e.event,properties:e.properties},Object.keys(r).length&&{options:r},{meta:n}));return ee({},t,{last:a,history:t.history.concat(a)})}return t}var gb={actions:[]};function yb(t,e){t===void 0&&(t=gb);var r=e.payload;switch(e.type){case"queue":var n;return n=r&&r.type&&r.type===te.identify?[e].concat(t.actions):t.actions.concat(e),ee({},t,{actions:n});case"dequeue":return[];default:return t}}var Kp=/#.*$/;function wb(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Kp,""):"")}var zp,Hp,Bp,Gp,bb=function(t){if(t===void 0&&(t={}),!Ce)return t;var e=document,r=e.title,n=e.referrer,a=window,i=a.location,o=a.innerWidth,s=a.innerHeight,u=i.hash,l=i.search,c=(function(h){var d=(function(){if(Ce){for(var p,v=document.getElementsByTagName("link"),g=0;p=v[g];g++)if(p.getAttribute("rel")==="canonical")return p.getAttribute("href")}})();return d?d.match(/\?/)?d:d+h:window.location.href.replace(Kp,"")})(l),f={title:r,url:c,path:wb(c),hash:u,search:l,width:o,height:s};return n&&n!==""&&(f.referrer=n),ee({},f,t)},Sb={last:{},history:[]};function Ib(t,e){t===void 0&&(t=Sb);var r=e.options;if(e.type===te.page){var n=Fp(ee({properties:e.properties,meta:e.meta},Object.keys(r).length&&{options:r}));return ee({},t,{last:n,history:t.history.concat(n)})}return t}zp=(function(){if(!Ce)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"})(),Hp=Ce?document.referrer:null,Bp=Xw(),Gp=Qw();var Wp={initialized:!1,sessionId:Qn(),app:null,version:null,debug:!1,offline:!!Ce&&!navigator.onLine,os:{name:zp},userAgent:Ce?navigator.userAgent:"node",library:{name:Js,version:"0.13.1"},timezone:Gp,locale:Bp,campaign:{},referrer:Hp};function Pb(t,e){t===void 0&&(t=Wp);var r=t.initialized,n=e.campaign;switch(e.type){case te.campaign:return ee({},t,{campaign:n});case te.offline:return ee({},t,{offline:!0});case te.online:return ee({},t,{offline:!1});default:return r?t:ee({},Wp,t,{initialized:!0})}}var Eb=["plugins","reducers","storage"];function kb(t,e,r){if(Ce){var n=window[(r?"add":"remove")+"EventListener"];t.split(" ").forEach(function(a){n(a,e)})}}function _b(t){var e=kb.bind(null,"online offline",function(r){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(r){return e(!1)}}function Vp(){return Zt(Js,[]),function(t){return function(e,r,n){var a=t(e,r,n),i=a.dispatch;return Object.assign(a,{dispatch:function(o){return wr[yr][Js].push(o.action||o),i(o)}})}}}function Jp(t){return function(){return Ir(Ir.apply(null,arguments),Vp())}}function tc(t){return t?yp(t)?t:[t]:[]}function Zp(t,e,r){t===void 0&&(t={});var n,a,i=Qn();return e&&(fn[i]=(n=e,a=(function(o){for(var s,u=o||Array.prototype.slice.call(arguments),l=0;l<u.length;l++)if(Ke(u[l])){s=u[l];break}return s})(r),function(o){a&&a(o),n(o)})),ee({},t,{rid:i,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function Tb(t){t===void 0&&(t={});var e=t.reducers||{},r=t.initialUser||{},n=(t.plugins||[]).reduce(function(I,_){if(Ke(_))return I.middlewares=I.middlewares.concat(_),I;if(_.NAMESPACE&&(_.name=_.NAMESPACE),!_.name)throw new Error("https://lytics.dev/errors/1");_.config||(_.config={});var j=_.EVENTS?Object.keys(_.EVENTS).map(function(Z){return _.EVENTS[Z]}):[];I.pluginEnabled[_.name]=!(_.enabled===!1||_.config.enabled===!1),delete _.enabled,_.methods&&(I.methods[_.name]=Object.keys(_.methods).reduce(function(Z,fe){var ae;return Z[fe]=(ae=_.methods[fe],function(){for(var ue=Array.prototype.slice.call(arguments),ie=new Array(ae.length),Ae=0;Ae<ue.length;Ae++)ie[Ae]=ue[Ae];return ie[ie.length]=w,ae.apply({instance:w},ie)}),Z},{}),delete _.methods);var H=Object.keys(_).concat(j),X=new Set(I.events.concat(H));if(I.events=Array.from(X),I.pluginsArray=I.pluginsArray.concat(_),I.plugins[_.name])throw new Error(_.name+"AlreadyLoaded");return I.plugins[_.name]=_,I.plugins[_.name].loaded||(I.plugins[_.name].loaded=function(){return!0}),I},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),a=t.storage?t.storage:{getItem:Jt,setItem:Zt,removeItem:br},i=(function(I){return function(_,j,H){return j.getState("user")[_]||(H&&ze(H)&&H[_]?H[_]:Tp(I)[_]||Jt(Ys(_))||null)}})(a),o=n.plugins,s=n.events.filter(function(I){return!Zs.includes(I)}).sort(),u=new Set(s.concat(ra).filter(function(I){return!Zs.includes(I)})),l=Array.from(u).sort(),c=function(){return o},f=new hb,h=f.addMiddleware,d=f.removeMiddleware,p=f.dynamicMiddlewares,v=function(){throw new Error("Abort disabled inListener")},g=eb(),P=Tp(a),b=ee({},P,r,g.an_uid?{userId:g.an_uid}:{},g.an_aid?{anonymousId:g.an_aid}:{});b.anonymousId||(b.anonymousId=Qn());var y=ee({enable:function(I,_){return new Promise(function(j){S.dispatch({type:te.enablePlugin,plugins:tc(I),_:{originalAction:te.enablePlugin}},j,[_])})},disable:function(I,_){return new Promise(function(j){S.dispatch({type:te.disablePlugin,plugins:tc(I),_:{originalAction:te.disablePlugin}},j,[_])})}},n.methods),m=!1,w={identify:function(I,_,j,H){try{var X=_t(I)?I:null,Z=ze(I)?I:_,fe=j||{},ae=w.user();Zt(Ys(Ot),X);var ue=X||Z.userId||i(Ot,w,Z);return Promise.resolve(new Promise(function(ie){S.dispatch(ee({type:te.identifyStart,userId:ue,traits:Z||{},options:fe,anonymousId:ae.anonymousId},ae.id&&ae.id!==X&&{previousId:ae.id}),ie,[_,j,H])}))}catch(ie){return Promise.reject(ie)}},track:function(I,_,j,H){try{var X=ze(I)?I.event:I;if(!X||!_t(X))throw new Error("EventMissing");var Z=ze(I)?I:_||{},fe=ze(j)?j:{};return Promise.resolve(new Promise(function(ae){S.dispatch({type:te.trackStart,event:X,properties:Z,options:fe,userId:i(Ot,w,_),anonymousId:i(Er,w,_)},ae,[_,j,H])}))}catch(ae){return Promise.reject(ae)}},page:function(I,_,j){try{var H=ze(I)?I:{},X=ze(_)?_:{};return Promise.resolve(new Promise(function(Z){S.dispatch({type:te.pageStart,properties:bb(H),options:X,userId:i(Ot,w,H),anonymousId:i(Er,w,H)},Z,[I,_,j])}))}catch(Z){return Promise.reject(Z)}},user:function(I){if(I===Ot||I==="id")return i(Ot,w);if(I===Er||I==="anonId")return i(Er,w);var _=w.getState("user");return I?hp(_,I):_},reset:function(I){return new Promise(function(_){S.dispatch({type:te.resetStart},_,I)})},ready:function(I){return m&&I({plugins:y,instance:w}),w.on(te.ready,function(_){I&&I(_),m=!0})},on:function(I,_){if(!I||!Ke(_))return!1;if(I===te.bootstrap)throw new Error(".on disabled for "+I);var j=/Start$|Start:/;if(I==="*"){var H=function(ae){return function(ue){return function(ie){return ie.type.match(j)&&_({payload:ie,instance:w,plugins:o}),ue(ie)}}},X=function(ae){return function(ue){return function(ie){return ie.type.match(j)||_({payload:ie,instance:w,plugins:o}),ue(ie)}}};return h(H,na),h(X,aa),function(){d(H,na),d(X,aa)}}var Z=I.match(j)?na:aa,fe=function(ae){return function(ue){return function(ie){return ie.type===I&&_({payload:ie,instance:w,plugins:o,abort:v}),ue(ie)}}};return h(fe,Z),function(){return d(fe,Z)}},once:function(I,_){if(!I||!Ke(_))return!1;if(I===te.bootstrap)throw new Error(".once disabled for "+I);var j=w.on(I,function(H){_({payload:H.payload,instance:w,plugins:o,abort:v}),j()});return j},getState:function(I){var _=S.getState();return I?hp(_,I):Object.assign({},_)},dispatch:function(I){var _=_t(I)?{type:I}:I;if(ra.includes(_.type))throw new Error("reserved action "+_.type);var j=ee({},_,{_:ee({originalAction:_.type},I._||{})});S.dispatch(j)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:a.getItem,setItem:function(I,_,j){S.dispatch({type:te.setItemStart,key:I,value:_,options:j})},removeItem:function(I,_){S.dispatch({type:te.removeItemStart,key:I,options:_})}},setAnonymousId:function(I,_){w.storage.setItem(Rt,I,_)},events:{core:ra,plugins:s}},R=n.middlewares.concat([function(I){return function(_){return function(j){return j.meta||(j.meta=Zp()),_(j)}}},p(na),fb(w,c,{all:l,plugins:s}),db(a),ob(w),cb(w),p(aa)]),A={context:Pb,user:sb(a),page:Ib,track:mb,plugins:pb(c),queue:yb},x=Ir,K=Ir;if(Ce&&t.debug){var G=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;G&&(x=G({trace:!0,traceLimit:25})),K=function(){return arguments.length===0?Vp():ze(typeof arguments[0])?Jp():Jp().apply(null,arguments)}}var re,L=(function(I){return Object.keys(I).reduce(function(_,j){return Eb.includes(j)||(_[j]=I[j]),_},{})})(t),M=n.pluginsArray.reduce(function(I,_){var j=_.name,H=_.config,X=_.loaded,Z=n.pluginEnabled[j];return I[j]={enabled:Z,initialized:!!Z&&!_.initialize,loaded:!!X({config:H}),config:H},I},{}),N={context:L,user:b,plugins:M},S=Pp((function(I){for(var _=Object.keys(I),j={},H=0;H<_.length;H++){var X=_[H];typeof I[X]===Tt&&(j[X]=I[X])}var Z,fe=Object.keys(j);try{(function(ae){Object.keys(ae).forEach(function(ue){var ie=ae[ue];if(typeof ie(void 0,{type:Vs})===yt||typeof ie(void 0,{type:nb})===yt)throw new Error(ln+" "+ue+" "+yt)})})(j)}catch(ae){Z=ae}return function(ae,ue){if(ae===void 0&&(ae={}),Z)throw Z;for(var ie=!1,Ae={},De=0;De<fe.length;De++){var He=fe[De],Ne=ae[He],it=(0,j[He])(Ne,ue);if(typeof it===yt){var At=ab(He,ue);throw new Error(At)}Ae[He]=it,ie=ie||it!==Ne}return ie?Ae:ae}})(ee({},A,e)),N,K(x(ib.apply(void 0,R))));S.dispatch=(re=S.dispatch,function(I,_,j){var H=ee({},I,{meta:Zp(I.meta,_,tc(j))});return re.apply(null,[H])});var O=Object.keys(o);S.dispatch({type:te.bootstrap,plugins:O,config:L,params:g,user:b,initialUser:r,persistedUser:P});var q=O.filter(function(I){return n.pluginEnabled[I]}),F=O.filter(function(I){return!n.pluginEnabled[I]});return S.dispatch({type:te.registerPlugins,plugins:O,enabled:n.pluginEnabled}),n.pluginsArray.map(function(I,_){var j=I.bootstrap,H=I.config,X=I.name;j&&Ke(j)&&j({instance:w,config:H,payload:I}),S.dispatch({type:te.registerPluginType(X),name:X,enabled:n.pluginEnabled[X],plugin:I}),n.pluginsArray.length===_+1&&S.dispatch({type:te.initializeStart,plugins:q,disabled:F})}),_b(function(I){S.dispatch({type:I?te.offline:te.online})}),(function(I,_,j){setInterval(function(){return Cp(I,_,j)},3e3)})(S,c,w),w}var na="before",aa="after",Xt="cookie",Qt=Qp(),Yp=ia,Rb=ia;function Xp(t){return Qt?ia(t,"",-1):br(t)}function Qp(){if(Qt!==void 0)return Qt;var t=Xt+Xt;try{ia(t,t),Qt=document.cookie.indexOf(t)!==-1,Xp(t)}catch{Qt=!1}return Qt}function ia(t,e,r,n,a,i){if(typeof window<"u"){var o=arguments.length>1;return Qt===!1&&(o?Zt(t,e):Jt(t)),o?document.cookie=t+"="+encodeURIComponent(e)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(a?"; domain="+a:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var wt="localStorage",Ob=Ws.bind(null,wt);Sr(wt,"getItem",Jt),Sr(wt,"setItem",Zt),Sr(wt,"removeItem",br);var bt="sessionStorage",Cb=Ws.bind(null,bt);Sr(bt,"getItem",Jt),Sr(bt,"setItem",Zt),Sr(bt,"removeItem",br);function _r(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(ze(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var Ab=Ob(),$b=Cb(),Ub=Qp();function er(t,e){if(t){var r=rc(e),n=!oc(r),a=nc(r)?_r(localStorage.getItem(t)):void 0;if(n&&!gr(a))return a;var i=ac(r)?_r(Yp(t)):void 0;if(n&&i)return i;var o=ic(r)?_r(sessionStorage.getItem(t)):void 0;if(n&&o)return o;var s=Jt(t);return n?s:{localStorage:a,sessionStorage:o,cookie:i,global:s}}}function oa(t,e,r){if(t&&!gr(e)){var n={},a=rc(r),i=JSON.stringify(e),o=!oc(a);return nc(a)&&(n[wt]=ca(wt,e,_r(localStorage.getItem(t))),localStorage.setItem(t,i),o)?n[wt]:ac(a)&&(n[Xt]=ca(Xt,e,_r(Yp(t))),Rb(t,i),o)?n[Xt]:ic(a)&&(n[bt]=ca(bt,e,_r(sessionStorage.getItem(t))),sessionStorage.setItem(t,i),o)?n[bt]:(n[Vt]=ca(Vt,e,Jt(t)),Zt(t,e),o?n[Vt]:n)}}function Lb(t,e){if(t){var r=rc(e),n=er(t,vp),a={};return!gr(n.localStorage)&&nc(r)&&(localStorage.removeItem(t),a[wt]=n.localStorage),!gr(n.cookie)&&ac(r)&&(Xp(t),a[Xt]=n.cookie),!gr(n.sessionStorage)&&ic(r)&&(sessionStorage.removeItem(t),a[bt]=n.sessionStorage),!gr(n.global)&&sa(r,Vt)&&(br(t),a[Vt]=n.global),a}}function rc(t){return t?_t(t)?t:t.storage:pp}function nc(t){return Ab&&sa(t,wt)}function ac(t){return Ub&&sa(t,Xt)}function ic(t){return $b&&sa(t,bt)}function oc(t){return t===vp||t==="all"}function sa(t,e){return t===pp||t===e||oc(t)}function ca(t,e,r){return{location:t,current:e,previous:r}}var qb={setItem:oa,getItem:er,removeItem:Lb};function Nb(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ev(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function tv(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ev(Object(r),!0).forEach(function(n){Nb(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ev(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function jb(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:qb};return Tb(tv(tv({},e),t))}function xb(t){if(typeof window>"u")return;const{addEventListener:e,history:r,location:n}=window;let a=n.pathname;e("popstate",()=>t(n.pathname)),["push","replace"].map(i=>{const o=`${i}State`;if(o!=="pushState"&&o!=="replaceState")return;const s=r[o];r[o]=function(...u){const l=u[2]?.toString()||"",c=Mb(l);return a!==c&&(a=c,setTimeout(()=>t(l),0)),s.apply(r,u)}})}function Db(t,e){const r=t.indexOf(e);return r>-1?t.slice(0,r):t}function Mb(t){return["#","?"].forEach(e=>t=Db(t,e)),t}function Fb(){xb(()=>{St.page()})}var sc="up",cc="down";function Kb(t){if(t===void 0&&(t={}),!Ce)return Gs;var e=nv(),r=uc(),n=rv(),a=ua(n,e),i=ua(r,e),o=[],s=[],u=[],l=n,c=a,f=i,h=Object.keys(t);if(!h.length)return Gs;var d=h.map(function(v){return Number(v)}),p=rb(function(){var v=nv(),g=(function(L,M){return M.map(function(N){return N===100?L-5:L*(N/100)})})(v,d),P=uc(),b=rv(),y=ua(b,v),m=ua(P,v);if(c=y>c?y:c,f=m<f?m:f,!(o.length>=d.length)){var w=l===b,R=sc;w?R="initial":l<=b&&(R=cc);var A=g,x=d;(R===sc||w)&&(A=g.slice().reverse(),x=d.slice().reverse());var K=x.reduce(function(L,M,N){var S=A[N];return u.includes(M)&&b<=S&&(u=u.filter(function(O){return O!==M}),L.singleFunction=M),R===cc&&!o.includes(M)&&b>=S&&M>i?(s.push(M),L.callbacks=L.callbacks.concat(M),L):R===sc&&!o.includes(M)&&b<=S&&M<=y?(L.foundFunc=[M],L):(w&&b>=S&&L.foundFunc.length===0&&(L.foundFunc=[M]),!s.includes(M)&&b>=S&&(s.push(M),L.singleFunction?u.push(M):L.singleFunction=M),L)},{foundFunc:[],singleFunction:null,callbacks:[],direction:R});if(l=b,R===cc&&K.callbacks&&K.callbacks.forEach(function(L){Ke(t[L])&&(t[L]({trigger:L,direction:R,scrollMin:f,scrollMax:c,range:[f,c]}),o.push(L))}),K.singleFunction){var G=K.singleFunction,re=K.direction;Ke(t[G])&&t[G]({trigger:G,direction:re,scrollMin:f,scrollMax:c,range:[f,c]}),o.push(G)}}},500);return window.addEventListener("scroll",p),function(){return window.removeEventListener("scroll",p)}}function uc(){return Ce?document.body.scrollTop||document.documentElement.scrollTop:0}function zb(){return Ce?window.innerHeight||document.documentElement.clientHeight:0}function rv(){return Math.round(uc()+zb())}function nv(){if(!Ce)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function ua(t,e){return Math.round(t/e*100)}var lc="Event",av=lc+"Listener";function Hb(t){return function(e,r,n,a){var i=n||Gs,o=a||!1;if(!Ce)return i;var s=la(r),u=la(e,!0);if(!u.length)throw new Error("noElements");if(!s.length)throw new Error("no"+lc);var l=[];return(function c(f){f&&(l=[]);for(var h=f?"add"+av:"remove"+av,d=0;d<u.length;d++){var p=u[d];l[d]=f?o&&o.once?Bb(i):i:l[d]||i;for(var v=0;v<s.length;v++)p[h]?p["on"+s[v]]=f?l[d]:null:p[h](s[v],l[d],o)}return c.bind(null,!f)})(t)}}function la(t,e){if(_t(t))return e?la(document.querySelectorAll(t)):(r=t).split(r.indexOf(",")>-1?",":" ").map(function(o){return o.trim()});var r;if(NodeList.prototype.isPrototypeOf(t)){for(var n=[],a=t.length>>>0;a--;)n[a]=t[a];return n}var i=Yw(t);return e?i.map(function(o){return _t(o)?la(o,!0):o}).flat():i}function Bb(t,e){var r;return function(){return t&&(r=t.apply(this,arguments),t=null),r}}var fc=Hb(lc);function iv(t,e){return Ce&&Ke(window[t])?(r=window[t],n=e,(a=window)===void 0&&(a=null),Ke(r)?function(){r.apply(a,arguments),n.apply(a,arguments)}:n):window[t]=e;var r,n,a}iv.bind(null,"onerror"),iv.bind(null,"onload");var ov=typeof window>"u",sv="hidden";function Gb(t){if(ov)return!1;var e=Wb(),r="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),n=function(){return t(!!document[e])},a=function(){return document.addEventListener(r,n)};return a(),function(){return document.removeEventListener(r,n),a}}function Wb(){var t=["webkit","moz","ms","o"];return ov||sv in document?sv:t.reduce(function(e,r){var n=r+"Hidden";return!e&&n in document?n:e},null)}var Vb=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Jb(t,e){e===void 0&&(e={});var r=(function(o,s){var u=this,l=!1;return function(c){l||(o.call(u,c),l=!0,setTimeout(function(){return l=!1},s))}})(t,e.throttle||1e4),n=[];function a(){var o=Gb(function(s){s||r({type:"tabVisible"})});return n=[o].concat(Vb.map(function(s){return fc(document,s,r)})).concat(fc(window,"load",r)).concat(fc(window,"scroll",r,{capture:!0,passive:!0})),i}function i(){n.map(function(o){return o()})}return a(),function(){return i(),a}}function Zb(t){var e,r,n=t.onIdle,a=t.onWakeUp,i=t.onHeartbeat,o=t.timeout,s=o,u=t.throttle,l=u===void 0?2e3:u,c=!1,f=!1,h=new Date,d=function(){return clearTimeout(e)};function p(g){d(),i&&!c&&i(hn(h),g),a&&c&&(c=!1,a(hn(r),g),h=new Date),e=setTimeout(function(){c=!0,n&&(r=new Date,n(hn(h),g))},s)}var v=Jb(p,{throttle:l});return{disable:function(){f=!0,c=!1,d();var g=v();return function(){return f=!1,h=new Date,p({type:"load"}),g()}},getStatus:function(){return{isIdle:c,isDisabled:f,active:c?0:hn(h,f),idle:c?hn(r,f):0}}}}function hn(t,e){return e?0:Math.round((new Date-t)/1e3)}const cv=5e3;class Yb{element;isInViewport=!1;isAwake=!1;isFlushing;observer;lastEventAt=Date.now();registeredView=!1;viewCallback;activeDurationCallback;idleDurationCallback;scrollCallback;constructor(e){this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(r=>{r.forEach(n=>{this.handleInViewPort(n.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Zb({onIdle:r=>this.handleAwake(!1,r),onWakeUp:r=>this.handleAwake(!0,r),timeout:cv}),Kb({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,r=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-r*cv:Date.now(),this.isInViewport&&this.trackAwake(e,r)}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,r){!e&&this.activeDurationCallback&&this.activeDurationCallback(r,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(r,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}function uv(t){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}function Xb(t,e){e=e||{};var r,n,a=[],i=e.max||1/0;function o(){clearInterval(r),t(a.splice(0,i)),s()}function s(){r=setInterval(o,e.interval||1e4)}return s(),{flush:o,push:function(u){return n=a.push(u),n>=i&&o(),n},size:function(){return a.length},end:function(u){u&&o(),clearInterval(r)}}}const lv="sesamy_session_id";function Qb(){let t=sessionStorage.getItem(lv);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(lv,t)),t}let fv=!1,fa,da,dc;function dv(t){return JSON.stringify(t.map(e=>{const{campaign:r,...n}=e.properties||{};return{anonymousId:e.anonymousId,userId:e.userId,type:e.type,properties:n,clientId:dc,requestId:Math.random().toString(36).slice(2,9),sessionId:Qb(),timestamp:new Date().toISOString(),version:rn,event:e.event,context:{...e.context,page:{url:window.location.href,title:document.title,referrer:document.referrer,itemSrc:ge("sesamy:item-src"),publisherContentId:ge("sesamy:publisher-content-id")},campaign:r,locale:navigator.language,library:Fs,userAgent:navigator.userAgent,clientId:dc}}}))}const hv=Xb(async t=>{if(t.length>0){const e=dv(t);fv?navigator.sendBeacon(da,e):(await fetch(da,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function hc(t){if(t.anonymousId)if(t.properties?.flushing){const e={...t};delete e.properties.flushing,navigator.sendBeacon(da,dv([e]))}else hv.push(t)}function eS(){return fv=!0,hv.flush()}function tS(t,e,r){fa=e,da=`${nt("logs",r)}/events`,dc=t}const rS={name:"custom-analytics-plugin",page:({payload:t})=>{if(!fa)return;const{properties:e,anonymousId:r,userId:n,event:a}=t;hc({anonymousId:r,userId:n,properties:e,event:a,type:"page"})},track:({payload:t})=>{if(!fa)return;const{properties:e,anonymousId:r,userId:n,event:a}=t;hc({anonymousId:r,userId:n,properties:e,event:a,type:"track"})},identify:({payload:t})=>{if(!fa)return;const{properties:e,anonymousId:r,userId:n}=t;hc({anonymousId:r,userId:n,properties:e,type:"identify"})}},pv=["source","medium","campaign","term","content"],Ct="utm_",nS=1800*1e3;function vv(t){return t?Date.now()-parseInt(t,10)>nS:!0}function mv(){const t=document.referrer||"";if(!t)return;const e=er(`${Ct}set_at`);(vv(e)||!er(`${Ct}referrer`))&&oa(`${Ct}referrer`,t)}function aS(){const t=()=>{const r={};for(const a of pv){const i=er(`${Ct}${a}`);i&&(r[`utm_${a}`]=i)}const n=er(`${Ct}referrer`);return n&&(r.utm_referrer=n),r};return{name:"attribution-tracking",initialize(){mv()},campaign({payload:r}){const n=r?.campaign||{},a=er(`${Ct}set_at`);if(Object.keys(n).length>0&&vv(a)){for(const o of pv){const s=n[o];s&&oa(`${Ct}${o}`,s)}oa(`${Ct}set_at`,String(Date.now()))}mv()},page({payload:r}){return r.properties.campaign=t(),r},track({payload:r}){return r.properties.campaign=t(),r},getStoredCampaignData:t}}const iS=aS(),gv=new Map,yv=new Map;function oS({clientId:t,enabled:e=!0,environment:r}){tS(t,e,r),e&&(window.addEventListener("beforeunload",()=>{yv.forEach((n,a)=>{n.bind(a)()}),eS()}),window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&gv.forEach((n,a)=>{n.bind(a)()})}),Fb(),uv(()=>{const n=new Yb({element:document.body,viewCallback:()=>{St.page()},activeDurationCallback:(a,i,o)=>{St.track("activeDuration",{duration:a,durationStart:o,flushing:i})},idleDurationCallback:(a,i,o)=>{St.track("idleDuration",{duration:a,durationStart:o,flushing:i})},scrollCallback:a=>{St.track("scroll",{scroll:a.scrollMax})}});yv.set(document.body,()=>{n.flush()}),gv.set(document.body,()=>{n.handleVisibilityChange()})}),window.addEventListener(Ge.AUTHENTICATED,async n=>{const a=n;await St.identify(a.detail.sub)}),window.addEventListener(Ge.LOGOUT,async()=>{await St.track("logout",{}),await St.reset()}))}const St=jb({app:Fs,version:rn,plugins:[iS,rS]});function wv(t,e){St.track(t,e)}const sS=["AdHeader","AdContainer","AD_Top","homead","ad-lead"];function bv(){return new Promise(t=>{const e=sS.map(r=>{const n=document.createElement("div");return n.innerHTML=" ",n.id=r,n.style.position="absolute",document.body.appendChild(n),n});window.setTimeout(()=>{const r=!e.every(n=>document.querySelector(`#${n.id}`)?.offsetParent);e.forEach(n=>n.remove()),t(r)},100)})}function Sv(){const t=navigator.userAgent.toLowerCase(),e=[{name:"Facebook",regex:/fbav|fban/i},{name:"LinkedIn",regex:/linkedin/i},{name:"Instagram",regex:/instagram/i},{name:"Gmail",regex:/gmail/i},{name:"Twitter",regex:/twitter/i},{name:"WeChat",regex:/micromessenger/i},{name:"Line",regex:/line/i},{name:"Snapchat",regex:/snapchat/i},{name:"Pinterest",regex:/pinterest/i},{name:"Kakao",regex:/kakaotalk/i},{name:"Skype",regex:/skype/i},{name:"WhatsApp",regex:/whatsapp/i}];for(const r of e)if(r.regex.test(t))return{isInAppBrowser:!0,browserName:r.name};return/; wv\)/.test(t)?{isInAppBrowser:!0,browserName:"Unknown In-App Browser"}:{isInAppBrowser:!1,browserName:null}}function cS(t,e,r=!1){const n={name:t,data:e},a=new CustomEvent(t,{detail:n,cancelable:r,bubbles:!0});wv(`event:${t}`,{...e,timestamp:new Date().toISOString()});const i=window.dispatchEvent(a);return r&&!i?{canceled:!0,message:n.cancellationMessage}:{canceled:!1}}function uS(t,e){t.cancelable&&(t.detail.cancellationMessage=e,t.preventDefault())}const lS=["sesamy","__sesamy","__anon_id","auth0","a0","_legacy_auth0"],fS=["access_token","id_token","refresh_token","token"];function pc(t){const e=t.split(".");return e.length===3?`${e[0]}.${e[1]}.[REDACTED]`:t}function Iv(t){const e=t.toLowerCase();return fS.some(r=>e.includes(r))}function Pv(t){const e=t.split(".");return e.length===3&&e.every(r=>r.length>0)}function Ev(t){const e=[];for(let r=0;r<t.length;r++){const n=t.key(r);if(!n)continue;if(lS.some(i=>n.toLowerCase().startsWith(i.toLowerCase()))){let i=t.getItem(n)||"",o=!1;(Iv(n)||Pv(i))&&(i=pc(i),o=!0);try{const s=JSON.parse(i);if(typeof s=="object"&&s!==null){const u=vc(s);u.wasRedacted&&(i=JSON.stringify(u.value),o=!0)}}catch{}e.push({key:n,value:i,redacted:o})}}return e}function vc(t){if(t==null)return{value:t,wasRedacted:!1};if(typeof t=="string")return Pv(t)?{value:pc(t),wasRedacted:!0}:{value:t,wasRedacted:!1};if(Array.isArray(t)){let e=!1;return{value:t.map(n=>{const a=vc(n);return a.wasRedacted&&(e=!0),a.value}),wasRedacted:e}}if(typeof t=="object"){let e=!1;const r={};for(const[n,a]of Object.entries(t))if(Iv(n)&&typeof a=="string")r[n]=pc(a),e=!0;else{const i=vc(a);i.wasRedacted&&(e=!0),r[n]=i.value}return{value:r,wasRedacted:e}}return{value:t,wasRedacted:!1}}function dS(){const t=navigator;return{userAgent:t.userAgent,platform:t.platform,language:t.language,languages:[...t.languages||[]],cookiesEnabled:t.cookieEnabled,onLine:t.onLine,hardwareConcurrency:t.hardwareConcurrency,deviceMemory:t.deviceMemory,maxTouchPoints:t.maxTouchPoints,vendor:t.vendor,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,screenWidth:screen.width,screenHeight:screen.height,pixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset()}}async function hS(){await Ch();const[t]=await Promise.all([bv()]),e=Sv();return{adBlockEnabled:t,incognitoMode:Nn()??!1,inAppBrowser:e.isInAppBrowser}}async function kv(t){const e=[],r={timestamp:new Date().toISOString(),sdkVersion:rn,clientId:t.clientId,fallbackId:t.fallbackId};r.pageUrl=window.location.href,r.pageTitle=document.title;try{r.browser=dS()}catch(a){e.push(`Browser info collection failed: ${a.message}`)}try{r.detection=await hS()}catch(a){e.push(`Detection collection failed: ${a.message}`)}try{r.localStorage=Ev(localStorage)}catch(a){e.push(`LocalStorage collection failed: ${a.message}`)}try{r.sessionStorage=Ev(sessionStorage)}catch(a){e.push(`SessionStorage collection failed: ${a.message}`)}if(await Et()){try{const a=await mt(!1);if(a){const i=a.split(".");if(i.length>=2){const o=JSON.parse(atob(i[1]));r.userId=o.sub}}}catch(a){e.push(`User ID extraction failed: ${a.message}`)}if(t.getProfile)try{r.profile=await t.getProfile()||void 0}catch(a){e.push(`Profile collection failed: ${a.message}`)}if(t.getEntitlements)try{r.entitlements=await t.getEntitlements()}catch(a){e.push(`Entitlements collection failed: ${a.message}`)}if(t.getContracts)try{r.contracts=await t.getContracts()}catch(a){e.push(`Contracts collection failed: ${a.message}`)}if(t.getTags)try{r.tags=await t.getTags()}catch(a){e.push(`Tags collection failed: ${a.message}`)}if(t.getTallies)try{r.tallies=await t.getTallies()}catch(a){e.push(`Tallies collection failed: ${a.message}`)}}return e.length>0&&(r.errors=e),r}async function pS(t,e,r){const a=`${nt("api2",e)}/diagnostics`,i={"Content-Type":"application/json"};if(await Et())try{const s=await mt(!1);s&&(i.Authorization=`Bearer ${s}`)}catch{}if(!i.Authorization&&r){const s=localStorage.getItem("__anon_id")?.replace(/"/g,"")||"",u=btoa(`${r}|${s}:`);i.Authorization=`Basic ${u}`}const o=await fetch(a,{method:"POST",headers:i,body:JSON.stringify(t)});if(!o.ok){const s=await o.text();throw new Error(`Failed to submit diagnostics: ${s}`)}return o.json()}const _v="user-diagnostics",Tv="diagnostics-id",vS=`
|
|
37
37
|
.sesamy-diagnostics-modal {
|
|
38
38
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
@@ -153,4 +153,4 @@ CAUSE: `+d.stack,w.response=y,w.status=y.status,w.url=f,y.type==="opaque")throw
|
|
|
153
153
|
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), white);
|
|
154
154
|
pointer-events: none;
|
|
155
155
|
}
|
|
156
|
-
`,document.head.appendChild(i)}async function IS(t){try{const e=await fetch(t);return e.ok?await e.text():(console.error(`Failed to fetch content from ${t}: ${e.statusText}`),null)}catch(e){return console.error(`Error fetching content from ${t}:`,e),null}}async function mc(t){if(t.contentType==="selector"&&t.content){const e=document.querySelector(t.content);if(e)return e.innerHTML;console.warn(`Source element for selector '${t.content}' not found`)}else if(t.contentType==="url"&&t.content){const e=await IS(t.content);if(e)return e;console.warn(`Failed to fetch content from URL '${t.content}'`)}else if(t.content)return t.content;return""}async function PS(t,e){const r=e.insertionPoint||"inside",n=await mc(e);switch(r){case"before":t.insertAdjacentHTML("beforebegin",n);break;case"after":t.insertAdjacentHTML("afterend",n);break;case"inside":default:t.innerHTML+=n;break}}async function ES(t,e){const r=await mc(e);t.innerHTML=r}async function kS(t,e){const r=await mc(e);t.innerHTML=r.replace("${content}",t.innerHTML)}async function _S({enabled:t=!1,rules:e}){t&&uv(async()=>{const r=await Et(),n=window.location.href;for(const a of e){const i=document.querySelectorAll(a.selector);if(!(a.path&&!new RegExp(a.path).test(n)))for(const o of i){const s=o;if(!(a.authenticated!==void 0&&a.authenticated!==r))switch(a.transform){case"insert":await PS(s,a);break;case"replace":await ES(s,a);break;case"remove":o.remove();break;case"wrap":await kS(s,a);break;case"gradient":SS(s,a);break;default:console.warn(`Unknown transform type: ${a.transform}`)}}}})}const Ov="access_token";function TS(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get(Ov);if(e){$s(e);const r=new URL(window.location.href);t.delete(Ov),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Cv="sesamy-refresh",Av="force-refetch-entitlements";function RS(){const t=new URLSearchParams(window.location.search),e=t.get(Av),r=t.get(Cv);if(e!==null||r!==null){const n=new URL(window.location.href);t.delete(Av),t.delete(Cv),n.search=t.toString(),gt(),window.history.replaceState(null,"",n)}}function OS(t){if(!t||typeof t!="string")throw new Error("Invalid token: token must be a non-empty string");const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT format: token must have exactly 3 parts separated by dots");const[,r]=e;if(!r)throw new Error("Invalid JWT format: payload is empty");let n;try{n=atob(r)}catch{throw new Error("Invalid JWT format: payload is not valid base64")}try{return JSON.parse(n)}catch{throw new Error("Invalid JWT format: payload is not valid JSON")}}function CS(){const
|
|
156
|
+
`,document.head.appendChild(i)}async function IS(t){try{const e=await fetch(t);return e.ok?await e.text():(console.error(`Failed to fetch content from ${t}: ${e.statusText}`),null)}catch(e){return console.error(`Error fetching content from ${t}:`,e),null}}async function mc(t){if(t.contentType==="selector"&&t.content){const e=document.querySelector(t.content);if(e)return e.innerHTML;console.warn(`Source element for selector '${t.content}' not found`)}else if(t.contentType==="url"&&t.content){const e=await IS(t.content);if(e)return e;console.warn(`Failed to fetch content from URL '${t.content}'`)}else if(t.content)return t.content;return""}async function PS(t,e){const r=e.insertionPoint||"inside",n=await mc(e);switch(r){case"before":t.insertAdjacentHTML("beforebegin",n);break;case"after":t.insertAdjacentHTML("afterend",n);break;case"inside":default:t.innerHTML+=n;break}}async function ES(t,e){const r=await mc(e);t.innerHTML=r}async function kS(t,e){const r=await mc(e);t.innerHTML=r.replace("${content}",t.innerHTML)}async function _S({enabled:t=!1,rules:e}){t&&uv(async()=>{const r=await Et(),n=window.location.href;for(const a of e){const i=document.querySelectorAll(a.selector);if(!(a.path&&!new RegExp(a.path).test(n)))for(const o of i){const s=o;if(!(a.authenticated!==void 0&&a.authenticated!==r))switch(a.transform){case"insert":await PS(s,a);break;case"replace":await ES(s,a);break;case"remove":o.remove();break;case"wrap":await kS(s,a);break;case"gradient":SS(s,a);break;default:console.warn(`Unknown transform type: ${a.transform}`)}}}})}const Ov="access_token";function TS(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get(Ov);if(e){$s(e);const r=new URL(window.location.href);t.delete(Ov),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Cv="sesamy-refresh",Av="force-refetch-entitlements";function RS(){const t=new URLSearchParams(window.location.search),e=t.get(Av),r=t.get(Cv);if(e!==null||r!==null){const n=new URL(window.location.href);t.delete(Av),t.delete(Cv),n.search=t.toString(),gt(),window.history.replaceState(null,"",n)}}function OS(t){if(!t||typeof t!="string")throw new Error("Invalid token: token must be a non-empty string");const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT format: token must have exactly 3 parts separated by dots");const[,r]=e;if(!r)throw new Error("Invalid JWT format: payload is empty");let n;try{n=atob(r)}catch{throw new Error("Invalid JWT format: payload is not valid base64")}try{return JSON.parse(n)}catch{throw new Error("Invalid JWT format: payload is not valid JSON")}}function CS(t,e){const r=new Date(t.exp*1e3);return{id:"",title:t.p?.toString(),sku:t.s?.toString(),purchaseOption:t.p?.toString(),publisherContentId:t.pid?.toString(),url:t.url?.toString(),token:e,type:"article",hasAccess:!0,expiresAt:r.toISOString(),createdAt:new Date(t.iat*1e3).toISOString(),updatedAt:new Date(t.iat*1e3).toISOString()}}function AS(t,e){const r=new Date(t.exp*1e3),n=t.meta;return{id:t.tid?.toString()||"",title:n?.purchaseOption?.toString()||t.tier?.toString(),sku:t.tier?.toString(),purchaseOption:n?.purchaseOption?.toString(),publisherContentId:t.contentId?.toString(),url:t.url?.toString(),token:e,type:"article",hasAccess:!0,expiresAt:r.toISOString(),createdAt:new Date(t.iat*1e3).toISOString(),updatedAt:new Date(t.iat*1e3).toISOString()}}function $S(t){return t.v===1&&typeof t.tier=="string"&&typeof t.contentId=="string"}function US(){const t=new URLSearchParams(window.location.search),e=t.get("sesamy_token")||t.get("sesamy-token")||t.get("token");if(!e)return;try{const n=OS(e),a=$S(n)?AS(n,e):CS(n,e);gw(a)}catch(n){B(`Failed to extract signed link ${n}`)}const r=new URL(window.location.href);r.searchParams.delete("ss"),r.searchParams.delete("se"),r.searchParams.delete("sp"),r.searchParams.delete("so"),r.searchParams.delete("token"),r.searchParams.delete("sesamy-token"),r.searchParams.delete("sesamy_token"),window.history.replaceState(null,"",r)}const $v="sesamy-user";async function LS(){const e=new URLSearchParams(window.location.search).get($v)?.toLowerCase();if(!e)return;const r=await _y();r?.email!==e?(B(`Current user does not match sesamy user: ${r?.email} !== ${e}`),gt(),Hn({authorizationParams:{login_hint:e}})):B(`Current user matches sesamy user: ${r?.email} === ${e}`);const n=new URL(window.location.href);n.searchParams.delete($v),window.history.replaceState(null,"",n)}const Uv="sesamy-purchase";function qS(){const t=new URLSearchParams(window.location.search),e=t.get(Uv);if(e!==null){const r=new URL(window.location.href);t.delete(Uv),r.search=t.toString(),B(`Purchase ${e}`),Nt(Ge.PURCHASE,{itemSrc:e}),gt(),window.history.replaceState(null,"",r)}}const Lv="sesamy-login",NS="sesamy_login";async function jS(){const t=new URLSearchParams(window.location.search);if(!(t.get(Lv)||t.get(NS)))return;await Et()||Hn();const n=new URL(window.location.href);n.searchParams.delete(Lv),window.history.replaceState(null,"",n)}const qv="sesamy-debug";async function xS(){const e=new URLSearchParams(window.location.search).get(qv)?.toLowerCase();if(!e)return;wg(e==="true");const r=new URL(window.location.href);r.searchParams.delete(qv),window.history.replaceState(null,"",r)}function DS(){if(!document.referrer.length)return;const t=new URL(document.referrer);if(!(t.hostname===window.location.hostname||t.hostname.includes("sesamy")))return document.referrer}async function MS(t){if(!zt())return;const e=new URLSearchParams(window.location.search),r={utmSource:e.get("utm_source")??void 0,utmMedium:e.get("utm_medium")??void 0,utmCampaign:e.get("utm_campaign")??void 0,utmTerm:e.get("utm_term")??void 0,utmContent:e.get("utm_content")??void 0,ref:e.get("ref")??void 0,referrer:DS()},[n]=t.content.list();n?.url&&(r.itemSrc=n.url,r.publisherContentId=n.id),Yh(r)}function FS(){const t=new URLSearchParams(window.location.search);let e=!1;try{e=!!window.opener&&window.opener.location.origin===window.location.origin}catch{e=!1}const r=sessionStorage.getItem(Rh)==="true",n=t.has("code")||t.has("error")||t.has("state");!e||r||(sessionStorage.setItem(Rh,"true"),n||(B("Reloading page to get query params in incognito browser"),window.location.reload()))}async function KS(t){const e=a=>i=>{i.preventDefault();try{a()}catch(o){console.error("Error handling click:",o)}},r=(a,i)=>{try{document.querySelectorAll(a).forEach(s=>{s.addEventListener("click",e(i))})}catch(o){console.error(`Error attaching event handlers (selector: ${a}):`,o)}};r('[sesamy-link="login"]',()=>t.auth.loginWithRedirect()),r('[sesamy-link="logout"]',()=>t.auth.logout());const n=await t.generateLink({target:"account"});n&&r('[sesamy-link="account"]',()=>{window.location.href=n})}async function zS(t){const e=await t.auth.isAuthenticated();try{document.querySelectorAll(`[sesamy-visibility="${e?"not-logged-in":"logged-in"}"]`).forEach(a=>{a instanceof HTMLElement&&(a.style.display="none")}),document.querySelectorAll(`[sesamy-visibility="${e?"logged-in":"not-logged-in"}"]`).forEach(a=>{a instanceof HTMLElement&&(a.style.display="")})}catch(r){console.error("Error handling visibility:",r)}}async function HS(t){const e=ge("sesamy:locked-content-redirect-url");if(!e)return;const[r]=t.content.list();if(!r)return;await t.entitlements.hasAccess(r.url||"",r.pass?.split(",")||[])||(location.href=e)}xe.isInitialized=!1;async function Nv(t,e){B(`Init with config: ${JSON.stringify(t)}`);try{FS(),oS({clientId:t.clientId,environment:t.environment,...t.analytics}),await ky({clientId:t.clientId,organization:t.organization,environment:t.environment,...t.auth}),Pw(t,e),t.transform&&await _S(t.transform),Ch(),xS(),gS({clientId:t.clientId||t.vendorId,environment:t.environment,getProfile:()=>e.profile.get(),getEntitlements:()=>e.entitlements.list(),getContracts:()=>e.contracts.list(),getTags:()=>e.tags.list(),getTallies:()=>e.tallies.list()}),MS(e),TS(),RS(),US(),await jS(),await LS(),qS(),await zS(e),await KS(e),await HS(e),xe.isInitialized=!0,Nt(Ge.READY,{})}catch(r){B(`Failed to init ${r.message}`)}}async function jv(t){B("Initializing Sesamy");const e=t.api?.namespace||"sesamy";if(zt()&&e in window)return B("Sesamy already initialized. This is likely due to a duplicate import"),xe.isInitialized=!0,window[e];const r=wS({clientId:t.clientId,vendorId:t.vendorId,environment:t.environment,...t.api});return zt()?(t.awaitAllServices?await Nv(t,r):Nv(t,r),r):(xe.isInitialized=!0,r)}if(zt()){const t=document.getElementById("sesamy-js");if(t?.textContent)try{const e=JSON.parse(t.textContent);jv(e)}catch(e){console.error("Failed to parse config",e)}}return xe.Events=Ge,xe.clearMetadataCache=Tw,xe.getAllLdJson=kw,xe.getAllMetaTags=an,xe.getContentConfig=Iw,xe.getContentMetadata=up,xe.getLdJson=sn,xe.init=jv,Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"}),xe})({});
|
package/dist/sesamy-js.mjs
CHANGED
|
@@ -6614,7 +6614,7 @@ function nv(t) {
|
|
|
6614
6614
|
localStorage.setItem(Rs, JSON.stringify({ value: r }));
|
|
6615
6615
|
}
|
|
6616
6616
|
}
|
|
6617
|
-
const hc = "@sesamy/sesamy-js", un = "1.
|
|
6617
|
+
const hc = "@sesamy/sesamy-js", un = "1.87.0", av = "sesamyFlags";
|
|
6618
6618
|
async function iv(t) {
|
|
6619
6619
|
try {
|
|
6620
6620
|
localStorage.setItem(av, JSON.stringify(t));
|
|
@@ -6701,7 +6701,7 @@ function pc() {
|
|
|
6701
6701
|
return !(n.userAgentContains && !r.includes(n.userAgentContains));
|
|
6702
6702
|
});
|
|
6703
6703
|
}
|
|
6704
|
-
function
|
|
6704
|
+
function tI() {
|
|
6705
6705
|
return pc();
|
|
6706
6706
|
}
|
|
6707
6707
|
function bw(t, e) {
|
|
@@ -6772,7 +6772,7 @@ function mn(t) {
|
|
|
6772
6772
|
const e = pv(), r = (n) => !t || n["@type"] === t || Array.isArray(n["@type"]) && n["@type"].includes(t);
|
|
6773
6773
|
return e.find(r) || null;
|
|
6774
6774
|
}
|
|
6775
|
-
function
|
|
6775
|
+
function rI(t) {
|
|
6776
6776
|
const e = pv(), r = (n) => !t || n["@type"] === t || Array.isArray(n["@type"]) && n["@type"].includes(t);
|
|
6777
6777
|
return e.filter(r);
|
|
6778
6778
|
}
|
|
@@ -6852,7 +6852,7 @@ function Pw() {
|
|
|
6852
6852
|
};
|
|
6853
6853
|
return Br = lv(n), Br;
|
|
6854
6854
|
}
|
|
6855
|
-
function
|
|
6855
|
+
function nI() {
|
|
6856
6856
|
Br = null;
|
|
6857
6857
|
}
|
|
6858
6858
|
function vc({
|
|
@@ -9559,36 +9559,58 @@ function kS(t) {
|
|
|
9559
9559
|
throw new Error("Invalid JWT format: payload is not valid JSON");
|
|
9560
9560
|
}
|
|
9561
9561
|
}
|
|
9562
|
-
function _S() {
|
|
9563
|
-
const
|
|
9562
|
+
function _S(t, e) {
|
|
9563
|
+
const r = new Date(t.exp * 1e3);
|
|
9564
|
+
return {
|
|
9565
|
+
id: "",
|
|
9566
|
+
title: t.p?.toString(),
|
|
9567
|
+
sku: t.s?.toString(),
|
|
9568
|
+
purchaseOption: t.p?.toString(),
|
|
9569
|
+
publisherContentId: t.pid?.toString(),
|
|
9570
|
+
url: t.url?.toString(),
|
|
9571
|
+
token: e,
|
|
9572
|
+
type: "article",
|
|
9573
|
+
hasAccess: !0,
|
|
9574
|
+
expiresAt: r.toISOString(),
|
|
9575
|
+
createdAt: new Date(t.iat * 1e3).toISOString(),
|
|
9576
|
+
updatedAt: new Date(t.iat * 1e3).toISOString()
|
|
9577
|
+
};
|
|
9578
|
+
}
|
|
9579
|
+
function TS(t, e) {
|
|
9580
|
+
const r = new Date(t.exp * 1e3), n = t.meta;
|
|
9581
|
+
return {
|
|
9582
|
+
id: t.tid?.toString() || "",
|
|
9583
|
+
title: n?.purchaseOption?.toString() || t.tier?.toString(),
|
|
9584
|
+
sku: t.tier?.toString(),
|
|
9585
|
+
purchaseOption: n?.purchaseOption?.toString(),
|
|
9586
|
+
publisherContentId: t.contentId?.toString(),
|
|
9587
|
+
url: t.url?.toString(),
|
|
9588
|
+
token: e,
|
|
9589
|
+
type: "article",
|
|
9590
|
+
hasAccess: !0,
|
|
9591
|
+
expiresAt: r.toISOString(),
|
|
9592
|
+
createdAt: new Date(t.iat * 1e3).toISOString(),
|
|
9593
|
+
updatedAt: new Date(t.iat * 1e3).toISOString()
|
|
9594
|
+
};
|
|
9595
|
+
}
|
|
9596
|
+
function RS(t) {
|
|
9597
|
+
return t.v === 1 && typeof t.tier == "string" && typeof t.contentId == "string";
|
|
9598
|
+
}
|
|
9599
|
+
function OS() {
|
|
9600
|
+
const t = new URLSearchParams(window.location.search), e = t.get("sesamy_token") || t.get("sesamy-token") || t.get("token");
|
|
9564
9601
|
if (!e)
|
|
9565
9602
|
return;
|
|
9566
9603
|
try {
|
|
9567
|
-
const n = kS(e), a =
|
|
9568
|
-
|
|
9569
|
-
// This is not part of the signed link
|
|
9570
|
-
title: n.p?.toString(),
|
|
9571
|
-
sku: n.s?.toString(),
|
|
9572
|
-
purchaseOption: n.p?.toString(),
|
|
9573
|
-
publisherContentId: n.pid?.toString(),
|
|
9574
|
-
url: n.url?.toString(),
|
|
9575
|
-
token: e,
|
|
9576
|
-
type: "article",
|
|
9577
|
-
hasAccess: !0,
|
|
9578
|
-
// Signed links grant access
|
|
9579
|
-
expiresAt: a.toISOString(),
|
|
9580
|
-
createdAt: new Date(n.iat).toISOString(),
|
|
9581
|
-
updatedAt: new Date(n.iat).toISOString()
|
|
9582
|
-
};
|
|
9583
|
-
vw(i);
|
|
9604
|
+
const n = kS(e), a = RS(n) ? TS(n, e) : _S(n, e);
|
|
9605
|
+
vw(a);
|
|
9584
9606
|
} catch (n) {
|
|
9585
9607
|
G(`Failed to extract signed link ${n}`);
|
|
9586
9608
|
}
|
|
9587
9609
|
const r = new URL(window.location.href);
|
|
9588
|
-
r.searchParams.delete("ss"), r.searchParams.delete("se"), r.searchParams.delete("sp"), r.searchParams.delete("so"), r.searchParams.delete("token"), r.searchParams.delete("sesamy-token"), window.history.replaceState(null, "", r);
|
|
9610
|
+
r.searchParams.delete("ss"), r.searchParams.delete("se"), r.searchParams.delete("sp"), r.searchParams.delete("so"), r.searchParams.delete("token"), r.searchParams.delete("sesamy-token"), r.searchParams.delete("sesamy_token"), window.history.replaceState(null, "", r);
|
|
9589
9611
|
}
|
|
9590
9612
|
const Oh = "sesamy-user";
|
|
9591
|
-
async function
|
|
9613
|
+
async function CS() {
|
|
9592
9614
|
const e = new URLSearchParams(window.location.search).get(Oh)?.toLowerCase();
|
|
9593
9615
|
if (!e)
|
|
9594
9616
|
return;
|
|
@@ -9598,24 +9620,24 @@ async function TS() {
|
|
|
9598
9620
|
n.searchParams.delete(Oh), window.history.replaceState(null, "", n);
|
|
9599
9621
|
}
|
|
9600
9622
|
const Ch = "sesamy-purchase";
|
|
9601
|
-
function
|
|
9623
|
+
function AS() {
|
|
9602
9624
|
const t = new URLSearchParams(window.location.search), e = t.get(Ch);
|
|
9603
9625
|
if (e !== null) {
|
|
9604
9626
|
const r = new URL(window.location.href);
|
|
9605
9627
|
t.delete(Ch), r.search = t.toString(), G(`Purchase ${e}`), Zt(Je.PURCHASE, { itemSrc: e }), mt(), window.history.replaceState(null, "", r);
|
|
9606
9628
|
}
|
|
9607
9629
|
}
|
|
9608
|
-
const Ah = "sesamy-login",
|
|
9609
|
-
async function
|
|
9630
|
+
const Ah = "sesamy-login", $S = "sesamy_login";
|
|
9631
|
+
async function US() {
|
|
9610
9632
|
const t = new URLSearchParams(window.location.search);
|
|
9611
|
-
if (!(t.get(Ah) || t.get(
|
|
9633
|
+
if (!(t.get(Ah) || t.get($S)))
|
|
9612
9634
|
return;
|
|
9613
9635
|
await Ot() || oa();
|
|
9614
9636
|
const n = new URL(window.location.href);
|
|
9615
9637
|
n.searchParams.delete(Ah), window.history.replaceState(null, "", n);
|
|
9616
9638
|
}
|
|
9617
9639
|
const $h = "sesamy-debug";
|
|
9618
|
-
async function
|
|
9640
|
+
async function LS() {
|
|
9619
9641
|
const e = new URLSearchParams(window.location.search).get($h)?.toLowerCase();
|
|
9620
9642
|
if (!e)
|
|
9621
9643
|
return;
|
|
@@ -9623,14 +9645,14 @@ async function AS() {
|
|
|
9623
9645
|
const r = new URL(window.location.href);
|
|
9624
9646
|
r.searchParams.delete($h), window.history.replaceState(null, "", r);
|
|
9625
9647
|
}
|
|
9626
|
-
function
|
|
9648
|
+
function qS() {
|
|
9627
9649
|
if (!document.referrer.length)
|
|
9628
9650
|
return;
|
|
9629
9651
|
const t = new URL(document.referrer);
|
|
9630
9652
|
if (!(t.hostname === window.location.hostname || t.hostname.includes("sesamy")))
|
|
9631
9653
|
return document.referrer;
|
|
9632
9654
|
}
|
|
9633
|
-
async function
|
|
9655
|
+
async function NS(t) {
|
|
9634
9656
|
if (!Yt())
|
|
9635
9657
|
return;
|
|
9636
9658
|
const e = new URLSearchParams(window.location.search), r = {
|
|
@@ -9640,11 +9662,11 @@ async function US(t) {
|
|
|
9640
9662
|
utmTerm: e.get("utm_term") ?? void 0,
|
|
9641
9663
|
utmContent: e.get("utm_content") ?? void 0,
|
|
9642
9664
|
ref: e.get("ref") ?? void 0,
|
|
9643
|
-
referrer:
|
|
9665
|
+
referrer: qS()
|
|
9644
9666
|
}, [n] = t.content.list();
|
|
9645
9667
|
n?.url && (r.itemSrc = n.url, r.publisherContentId = n.id), nv(r);
|
|
9646
9668
|
}
|
|
9647
|
-
function
|
|
9669
|
+
function xS() {
|
|
9648
9670
|
const t = new URLSearchParams(window.location.search);
|
|
9649
9671
|
let e = !1;
|
|
9650
9672
|
try {
|
|
@@ -9655,7 +9677,7 @@ function LS() {
|
|
|
9655
9677
|
const r = sessionStorage.getItem(Ld) === "true", n = t.has("code") || t.has("error") || t.has("state");
|
|
9656
9678
|
!e || r || (sessionStorage.setItem(Ld, "true"), n || (G("Reloading page to get query params in incognito browser"), window.location.reload()));
|
|
9657
9679
|
}
|
|
9658
|
-
async function
|
|
9680
|
+
async function jS(t) {
|
|
9659
9681
|
const e = (a) => (i) => {
|
|
9660
9682
|
i.preventDefault();
|
|
9661
9683
|
try {
|
|
@@ -9678,7 +9700,7 @@ async function qS(t) {
|
|
|
9678
9700
|
window.location.href = n;
|
|
9679
9701
|
});
|
|
9680
9702
|
}
|
|
9681
|
-
async function
|
|
9703
|
+
async function DS(t) {
|
|
9682
9704
|
const e = await t.auth.isAuthenticated();
|
|
9683
9705
|
try {
|
|
9684
9706
|
document.querySelectorAll(
|
|
@@ -9694,7 +9716,7 @@ async function NS(t) {
|
|
|
9694
9716
|
console.error("Error handling visibility:", r);
|
|
9695
9717
|
}
|
|
9696
9718
|
}
|
|
9697
|
-
async function
|
|
9719
|
+
async function MS(t) {
|
|
9698
9720
|
const e = ge("sesamy:locked-content-redirect-url");
|
|
9699
9721
|
if (!e)
|
|
9700
9722
|
return;
|
|
@@ -9707,7 +9729,7 @@ let zn = !1;
|
|
|
9707
9729
|
async function Uh(t, e) {
|
|
9708
9730
|
G(`Init with config: ${JSON.stringify(t)}`);
|
|
9709
9731
|
try {
|
|
9710
|
-
|
|
9732
|
+
xS(), rS({
|
|
9711
9733
|
clientId: t.clientId,
|
|
9712
9734
|
environment: t.environment,
|
|
9713
9735
|
// The default client id can be overridden by the config
|
|
@@ -9718,7 +9740,7 @@ async function Uh(t, e) {
|
|
|
9718
9740
|
environment: t.environment,
|
|
9719
9741
|
// The default client id can be overridden by the config
|
|
9720
9742
|
...t.auth
|
|
9721
|
-
}), bw(t, e), t.transform && await IS(t.transform), Bp(),
|
|
9743
|
+
}), bw(t, e), t.transform && await IS(t.transform), Bp(), LS(), hS({
|
|
9722
9744
|
clientId: t.clientId || t.vendorId,
|
|
9723
9745
|
environment: t.environment,
|
|
9724
9746
|
getProfile: () => e.profile.get(),
|
|
@@ -9726,12 +9748,12 @@ async function Uh(t, e) {
|
|
|
9726
9748
|
getContracts: () => e.contracts.list(),
|
|
9727
9749
|
getTags: () => e.tags.list(),
|
|
9728
9750
|
getTallies: () => e.tallies.list()
|
|
9729
|
-
}),
|
|
9751
|
+
}), NS(e), PS(), ES(), OS(), await US(), await CS(), AS(), await DS(e), await jS(e), await MS(e), zn = !0, Zt(Je.READY, {});
|
|
9730
9752
|
} catch (r) {
|
|
9731
9753
|
G(`Failed to init ${r.message}`);
|
|
9732
9754
|
}
|
|
9733
9755
|
}
|
|
9734
|
-
async function
|
|
9756
|
+
async function FS(t) {
|
|
9735
9757
|
G("Initializing Sesamy");
|
|
9736
9758
|
const e = t.api?.namespace || "sesamy";
|
|
9737
9759
|
if (Yt() && e in window)
|
|
@@ -9749,19 +9771,19 @@ if (Yt()) {
|
|
|
9749
9771
|
if (t?.textContent)
|
|
9750
9772
|
try {
|
|
9751
9773
|
const e = JSON.parse(t.textContent);
|
|
9752
|
-
|
|
9774
|
+
FS(e);
|
|
9753
9775
|
} catch (e) {
|
|
9754
9776
|
console.error("Failed to parse config", e);
|
|
9755
9777
|
}
|
|
9756
9778
|
}
|
|
9757
9779
|
export {
|
|
9758
9780
|
Je as Events,
|
|
9759
|
-
|
|
9760
|
-
|
|
9781
|
+
nI as clearMetadataCache,
|
|
9782
|
+
rI as getAllLdJson,
|
|
9761
9783
|
vn as getAllMetaTags,
|
|
9762
|
-
|
|
9784
|
+
tI as getContentConfig,
|
|
9763
9785
|
Pw as getContentMetadata,
|
|
9764
9786
|
mn as getLdJson,
|
|
9765
|
-
|
|
9787
|
+
FS as init,
|
|
9766
9788
|
zn as isInitialized
|
|
9767
9789
|
};
|