@entur-partner/app-shell 6.4.6 → 6.4.7
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/MenuProvider.d.ts +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2418 -2414
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c,1);let l=require(`@entur/alert`),u=require(`@entur/loader`),d=require(`@entur/tokens`),f=require(`@entur/typography`),p=require(`@entur-partner/common`),m=require(`@entur-partner/util`),h=require(`react/jsx-runtime`);var g=function(e,t){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},g(e,t)};function _(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);g(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},v.apply(this,arguments)};function ee(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function y(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function b(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function te(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function x(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}var S={timeoutInSeconds:60},ne=1e4,re=`memory`,ie={name:`auth0-spa-js`,version:`2.19.2`},ae=()=>Date.now(),C=`default`,w=class e extends Error{constructor(t,n){super(n),this.error=t,this.error_description=n,Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},oe=class e extends w{constructor(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;super(t,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,e.prototype)}},se=class e extends w{constructor(t,n,r,i){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;super(t,n),this.connection=r,this.state=i,this.appState=a,Object.setPrototypeOf(this,e.prototype)}},ce=class e extends w{constructor(){super(`timeout`,`Timeout`),Object.setPrototypeOf(this,e.prototype)}},le=class e extends ce{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},ue=class e extends w{constructor(t){super(`cancelled`,`Popup closed`),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},de=class e extends w{constructor(){super(`popup_open`,"Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,e.prototype)}},fe=class e extends w{constructor(t,n,r,i){super(t,n),this.mfa_token=r,this.mfa_requirements=i,Object.setPrototypeOf(this,e.prototype)}},pe=class e extends w{constructor(t,n){super(`missing_refresh_token`,`Missing Refresh Token (audience: '${ge(t,[`default`])}', scope: '${ge(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},me=class e extends w{constructor(t,n){super(`missing_scopes`,`Missing requested scopes after refresh (audience: '${ge(t,[`default`])}', missing scope: '${ge(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},he=class e extends w{constructor(t){super(`use_dpop_nonce`,`Server rejected DPoP proof: wrong nonce`),this.newDpopNonce=t,Object.setPrototypeOf(this,e.prototype)}};function ge(e){return e&&!(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).includes(e)?e:``}var _e=()=>window.crypto,ve=()=>{let e=``;for(;e.length<43;){let t=_e().getRandomValues(new Uint8Array(43-e.length));for(let n of t)e.length<43&&n<198&&(e+=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.`[n%66])}return e},ye=e=>btoa(e),be=[{key:`name`,type:[`string`]},{key:`version`,type:[`string`,`number`]},{key:`env`,type:[`object`]}],xe=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return Object.keys(e).reduce((n,r)=>{if(t&&r===`env`)return n;let i=be.find(e=>e.key===r);return i&&i.type.includes(typeof e[r])&&(n[r]=e[r]),n},{})},Se=e=>{var{clientId:t}=e,n=x(e,[`clientId`]);return new URLSearchParams((e=>Object.keys(e).filter(t=>e[t]!==void 0).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{}))(Object.assign({client_id:t},n))).toString()},Ce=async e=>await _e().subtle.digest({name:`SHA-256`},new TextEncoder().encode(e)),we=e=>(e=>decodeURIComponent(atob(e).split(``).map(e=>`%`+(`00`+e.charCodeAt(0).toString(16)).slice(-2)).join(``)))(e.replace(/_/g,`/`).replace(/-/g,`+`)),Te=e=>{let t=new Uint8Array(e);return(e=>{let t={"+":`-`,"/":`_`,"=":``};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))},Ee=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},De={},Oe={};Object.defineProperty(Oe,`__esModule`,{value:!0});var ke=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);r===void 0?n===void 0?e.locked.set(t,[]):e.locked.set(t,[n]):n!==void 0&&(r.unshift(n),e.locked.set(t,r))},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,r){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n())})},this.unlock=function(t){var n=e.locked.get(t);if(n!==void 0&&n.length!==0){var r=n.pop();e.locked.set(t,n),r!==void 0&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return e.instance===void 0&&(e.instance=new e),e.instance},e}();Oe.default=function(){return ke.getInstance()};var Ae=Ee&&Ee.__awaiter||function(e,t,n,r){return new(n||=Promise)(function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}c((r=r.apply(e,t||[])).next())})},je=Ee&&Ee.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw TypeError(`Generator is already executing.`);for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||a[0]!==6&&a[0]!==2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},Me=Ee;Object.defineProperty(De,`__esModule`,{value:!0});var Ne=Oe,Pe=`browser-tabs-lock-key`,Fe={key:function(e){return Ae(Me,void 0,void 0,function(){return je(this,function(e){throw Error(`Unsupported`)})})},getItem:function(e){return Ae(Me,void 0,void 0,function(){return je(this,function(e){throw Error(`Unsupported`)})})},clear:function(){return Ae(Me,void 0,void 0,function(){return je(this,function(e){return[2,window.localStorage.clear()]})})},removeItem:function(e){return Ae(Me,void 0,void 0,function(){return je(this,function(e){throw Error(`Unsupported`)})})},setItem:function(e,t){return Ae(Me,void 0,void 0,function(){return je(this,function(e){throw Error(`Unsupported`)})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function Ie(e){return new Promise(function(t){return setTimeout(t,e)})}function Le(e){for(var t=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`,n=``,r=0;r<e;r++)n+=t[Math.floor(61*Math.random())];return n}var Re=De.default=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+Le(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=t,e.waiters===void 0&&(e.waiters=[])}return e.prototype.acquireLock=function(t,n){return n===void 0&&(n=5e3),Ae(this,void 0,void 0,function(){var r,i,a,o,s,c,l;return je(this,function(u){switch(u.label){case 0:r=Date.now()+Le(4),i=Date.now()+n,a=Pe+`-`+t,o=this.storageHandler===void 0?Fe:this.storageHandler,u.label=1;case 1:return Date.now()<i?[4,Ie(30)]:[3,8];case 2:return u.sent(),o.getItemSync(a)===null?(s=this.id+`-`+t+`-`+r,[4,Ie(Math.floor(25*Math.random()))]):[3,5];case 3:return u.sent(),o.setItemSync(a,JSON.stringify({id:this.id,iat:r,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,Ie(30)];case 4:return u.sent(),(c=o.getItemSync(a))!==null&&(l=JSON.parse(c)).id===this.id&&l.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(a,r),[2,!0]):[3,7];case 5:return e.lockCorrector(this.storageHandler===void 0?Fe:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:u.sent(),u.label=7;case 7:return r=Date.now()+Le(4),[3,1];case 8:return[2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return Ae(this,void 0,void 0,function(){var n=this;return je(this,function(r){return setTimeout(function(){return Ae(n,void 0,void 0,function(){var n,r,i;return je(this,function(a){switch(a.label){case 0:return[4,Ne.default().lock(t)];case 1:return a.sent(),this.acquiredIatSet.has(t)?(n=this.storageHandler===void 0?Fe:this.storageHandler,(r=n.getItemSync(e))===null?(Ne.default().unlock(t),[2]):((i=JSON.parse(r)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(i)),Ne.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):(Ne.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return Ae(this,void 0,void 0,function(){return je(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var r=!1,i=Date.now(),a=!1;function o(){if(a||=(window.removeEventListener(`storage`,o),e.removeFromWaiting(o),clearTimeout(s),!0),!r){r=!0;var t=50-(Date.now()-i);t>0?setTimeout(n,t):n(null)}}window.addEventListener(`storage`,o),e.addToWaiting(o);var s=setTimeout(o,Math.max(0,t-Date.now()))})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),e.waiters!==void 0&&e.waiters.push(t)},e.removeFromWaiting=function(t){e.waiters!==void 0&&(e.waiters=e.waiters.filter(function(e){return e!==t}))},e.notifyWaiters=function(){e.waiters!==void 0&&e.waiters.slice().forEach(function(e){return e()})},e.prototype.releaseLock=function(e){return Ae(this,void 0,void 0,function(){return je(this,function(t){switch(t.label){case 0:return[4,this.releaseLock__private__(e)];case 1:return[2,t.sent()]}})})},e.prototype.releaseLock__private__=function(t){return Ae(this,void 0,void 0,function(){var n,r,i,a;return je(this,function(o){switch(o.label){case 0:return n=this.storageHandler===void 0?Fe:this.storageHandler,r=Pe+`-`+t,(i=n.getItemSync(r))===null?[2]:(a=JSON.parse(i)).id===this.id?[4,Ne.default().lock(a.iat)]:[3,2];case 1:o.sent(),this.acquiredIatSet.delete(a.iat),n.removeItemSync(r),Ne.default().unlock(a.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=t,i=[],a=0;;){var o=r.keySync(a);if(o===null)break;i.push(o),a++}for(var s=!1,c=0;c<i.length;c++){var l=i[c];if(l.includes(Pe)){var u=r.getItemSync(l);if(u!==null){var d=JSON.parse(u);(d.timeRefreshed===void 0&&d.timeAcquired<n||d.timeRefreshed!==void 0&&d.timeRefreshed<n)&&(r.removeItemSync(l),s=!0)}}}s&&e.notifyWaiters()},e.waiters=void 0,e}(),ze=class{async runWithLock(e,t,n){let r=new AbortController,i=setTimeout(()=>r.abort(),t);try{return await navigator.locks.request(e,{mode:`exclusive`,signal:r.signal},async e=>{if(clearTimeout(i),!e)throw Error(`Lock not available`);return await n()})}catch(e){throw clearTimeout(i),e?.name===`AbortError`?new ce:e}}},Be=class{constructor(){this.activeLocks=new Set,this.lock=new Re,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear()}}async runWithLock(e,t,n){let r=!1;for(let n=0;n<10&&!r;n++)r=await this.lock.acquireLock(e,t);if(!r)throw new ce;this.activeLocks.add(e),this.activeLocks.size===1&&typeof window<`u`&&window.addEventListener(`pagehide`,this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),this.activeLocks.size===0&&typeof window<`u`&&window.removeEventListener(`pagehide`,this.pagehideHandler)}}};function Ve(){return typeof navigator<`u`&&typeof(e=navigator.locks)?.request==`function`?new ze:new Be;var e}var He=null,Ue=new TextEncoder,We=new TextDecoder;function Ge(e){return typeof e==`string`?Ue.encode(e):We.decode(e)}function Ke(e){if(typeof e.modulusLength!=`number`||e.modulusLength<2048)throw new Ze(`${e.name} modulusLength must be at least 2048 bits`)}async function qe(e,t,n){if(!1===n.usages.includes(`sign`))throw TypeError(`private CryptoKey instances used for signing assertions must include "sign" in their "usages"`);let r=`${Ye(Ge(JSON.stringify(e)))}.${Ye(Ge(JSON.stringify(t)))}`;return`${r}.${Ye(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:`SHA-256`};case`RSA-PSS`:return Ke(e.algorithm),{name:e.algorithm.name,saltLength:32};case`RSASSA-PKCS1-v1_5`:return Ke(e.algorithm),{name:e.algorithm.name};case`Ed25519`:return{name:e.algorithm.name}}throw new Xe}(n),n,Ge(r)))}`}var Je;if(Uint8Array.prototype.toBase64)Je=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;Je=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Ye(e){return Je(e)}var Xe=class extends Error{constructor(e){var t;super(e??`operation not supported`),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}},Ze=class extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}};function Qe(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`PS256`;throw new Xe(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`RSASSA-PKCS1-v1_5`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`RS256`;throw new Xe(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`ECDSA`:return function(e){if(e.algorithm.namedCurve===`P-256`)return`ES256`;throw new Xe(`unsupported EcKeyAlgorithm namedCurve`)}(e);case`Ed25519`:return`Ed25519`;default:throw new Xe(`unsupported CryptoKey algorithm name`)}}function $e(e){return e instanceof CryptoKey}function et(e){return $e(e)&&e.type===`public`}async function tt(e,t,n,r,i,a){let o=e?.privateKey,s=e?.publicKey;if(!$e(c=o)||c.type!==`private`)throw TypeError(`"keypair.privateKey" must be a private CryptoKey`);var c;if(!et(s))throw TypeError(`"keypair.publicKey" must be a public CryptoKey`);if(!0!==s.extractable)throw TypeError(`"keypair.publicKey.extractable" must be true`);if(typeof t!=`string`)throw TypeError(`"htu" must be a string`);if(typeof n!=`string`)throw TypeError(`"htm" must be a string`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`"nonce" must be a string or undefined`);if(i!==void 0&&typeof i!=`string`)throw TypeError(`"accessToken" must be a string or undefined`);if(a!==void 0&&(typeof a!=`object`||!a||Array.isArray(a)))throw TypeError(`"additional" must be an object`);return qe({alg:Qe(o),typ:`dpop+jwt`,jwk:await nt(s)},Object.assign(Object.assign({},a),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:r,htu:t,ath:i?Ye(await crypto.subtle.digest(`SHA-256`,Ge(i))):void 0}),o)}async function nt(e){let{kty:t,e:n,n:r,x:i,y:a,crv:o}=await crypto.subtle.exportKey(`jwk`,e);return{kty:t,crv:o,e:n,n:r,x:i,y:a}}var rt=`dpop-nonce`,it=[`authorization_code`,`refresh_token`,`urn:ietf:params:oauth:grant-type:token-exchange`,`http://auth0.com/oauth/grant-type/mfa-oob`,`http://auth0.com/oauth/grant-type/mfa-otp`,`http://auth0.com/oauth/grant-type/mfa-recovery-code`];function at(){return async function(e,t){var n;let r;if(typeof e!=`string`||e.length===0)throw TypeError(`"alg" must be a non-empty string`);switch(e){case`PS256`:r={name:`RSA-PSS`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`RS256`:r={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`ES256`:r={name:`ECDSA`,namedCurve:`P-256`};break;case`Ed25519`:r={name:`Ed25519`};break;default:throw new Xe}return crypto.subtle.generateKey(r,(n=t?.extractable)!=null&&n,[`sign`,`verify`])}(`ES256`,{extractable:!1})}function ot(e){return async function(e){if(!et(e))throw TypeError(`"publicKey" must be a public CryptoKey`);if(!0!==e.extractable)throw TypeError(`"publicKey.extractable" must be true`);let t=await nt(e),n;switch(t.kty){case`EC`:n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case`OKP`:n={crv:t.crv,kty:t.kty,x:t.x};break;case`RSA`:n={e:t.e,kty:t.kty,n:t.n};break;default:throw new Xe(`unsupported JWK kty`)}return Ye(await crypto.subtle.digest({name:`SHA-256`},Ge(JSON.stringify(n))))}(e.publicKey)}function st(e){let{keyPair:t,url:n,method:r,nonce:i,accessToken:a}=e;return tt(t,function(e){let t=new URL(e);return t.search=``,t.hash=``,t.href}(n),r,i,a)}var ct=(e,t)=>new Promise(function(n,r){let i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?r(Error(e.data.error)):n(e.data),i.port1.close()},t.postMessage(e,[i.port2])}),lt=(e,t,n)=>{let r=new AbortController,i;return t.signal=r.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{i=setTimeout(()=>{r.abort(),t(Error(`Timeout when executing 'fetch'`))},n)})]).finally(()=>{clearTimeout(i)})},ut=async function(e,t,n,r,i,a){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:ne;return i?(async(e,t,n,r,i,a,o,s)=>ct({type:`refresh`,auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:r,useFormData:o,useMrrt:s},a))(e,t,n,r,o,i,a,arguments.length>7?arguments[7]:void 0):(async(e,t,n)=>{let r=await lt(e,t,n);return{ok:r.ok,json:await r.json(),headers:(i=r.headers,[...i].reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{}))};var i})(e,r,o)};async function dt(e,t,n,r,i,a,o,s,c,l){if(c){let t=await c.generateProof({url:e,method:i.method||`GET`,nonce:await c.getNonce()});i.headers=Object.assign(Object.assign({},i.headers),{dpop:t})}let u,d=null;for(let c=0;c<3;c++)try{u=await ut(e,n,r,i,a,o,t,s),d=null;break}catch(e){d=e}if(d)throw d;let f=u.json,{error:p,error_description:m}=f,h=x(f,[`error`,`error_description`]),{headers:g,ok:_}=u,v;if(c&&(v=g[rt],v&&await c.setNonce(v)),!_){let u=m||`HTTP error. Unable to fetch ${e}`;if(p===`mfa_required`)throw new fe(p,u,h.mfa_token,h.mfa_requirements);if(p===`missing_refresh_token`)throw new pe(n,r);if(p===`use_dpop_nonce`){if(!c||!v||l)throw new he(v);return dt(e,t,n,r,i,a,o,s,c,!0)}throw new w(p||`request_error`,u)}return h}async function ft(e,t){var{baseUrl:n,timeout:r,audience:i,scope:a,auth0Client:o,useFormData:s,useMrrt:c,dpop:l}=e,u=x(e,[`baseUrl`,`timeout`,`audience`,`scope`,`auth0Client`,`useFormData`,`useMrrt`,`dpop`]);let d=u.grant_type===`urn:ietf:params:oauth:grant-type:token-exchange`,f=u.grant_type===`refresh_token`&&c,p=Object.assign(Object.assign(Object.assign(Object.assign({},u),d&&i&&{audience:i}),d&&a&&{scope:a}),f&&{audience:i,scope:a}),m=s?Se(p):JSON.stringify(p),h=(g=u.grant_type,it.includes(g));var g;return await dt(`${n}/oauth/token`,r,i||C,a,{method:`POST`,body:m,headers:{"Content-Type":s?`application/x-www-form-urlencoded`:`application/json`,"Auth0-Client":btoa(JSON.stringify(xe(o||ie)))}},t,s,c,h?l:void 0)}var pt=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(r=t.filter(Boolean).join(` `).trim().split(/\s+/),Array.from(new Set(r))).join(` `);var r},mt=(e,t,n)=>{let r;return n&&(r=e[n]),r||=e[C],pt(r,t)},ht=`@@auth0spajs@@`,gt=`@@user@@`,_t=class e{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ht,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join(`::`)}static fromKey(t){let[n,r,i,a]=t.split(`::`);return new e({clientId:r,scope:a,audience:i},n)}static fromCacheEntry(t){let{scope:n,audience:r,client_id:i}=t;return new e({scope:n,audience:r,clientId:i})}},vt=class{set(e,t){localStorage.setItem(e,JSON.stringify(t))}get(e){let t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(ht))}},yt=class{constructor(){this.enclosedCache=function(){let e={};return{set(t,n){e[t]=n},get(t){let n=e[t];if(n)return n},remove(t){delete e[t]},allKeys:()=>Object.keys(e)}}()}},bt=class{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||ae}async setIdToken(e,t,n){let r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await this.keyManifest?.add(r)}async getIdToken(e){let t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){let t=await this.get(e);return!t||!t.id_token||!t.decodedToken?void 0:{id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return{id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3?arguments[3]:void 0,i=await this.cache.get(e.toKey()),a=e;if(!i){let t=await this.getCacheKeys();if(!t)return;let o=this.matchExistingCacheKey(e,t);if(o&&(i=await this.cache.get(o),a=_t.fromKey(o)),!i&&n&&r!==`cache-only`)return this.getEntryWithRefreshToken(e,t)}if(!i)return;let o=await this.nowProvider(),s=Math.floor(o/1e3);return i.expiresAt-t<s?i.body.refresh_token?this.modifiedCachedEntry(i,a):(await this.cache.remove(a.toKey()),void await this.keyManifest?.remove(a.toKey())):i.body}async modifiedCachedEntry(e,t){let n={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},r={body:n,expiresAt:e.expiresAt};return await this.cache.set(t.toKey(),r),{refresh_token:n.refresh_token,audience:n.audience,scope:n.scope}}async set(e){let t=new _t({clientId:e.client_id,scope:e.scope,audience:e.audience}),n=await this.wrapCacheEntry(e);await this.cache.set(t.toKey(),n),await this.keyManifest?.add(t.toKey())}async remove(e,t,n){let r=new _t({clientId:e,scope:n,audience:t});await this.cache.remove(r.toKey())}async stripRefreshToken(e){let t=await this.getCacheKeys();if(t)for(let n of t){let t=await this.cache.get(n);t?.body?.refresh_token===e&&(delete t.body.refresh_token,await this.cache.set(n,t))}}async clear(e){let t=await this.getCacheKeys();t&&(await t.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t)},Promise.resolve()),await this.keyManifest?.clear())}async wrapCacheEntry(e){let t=await this.nowProvider();return{body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){return this.keyManifest?(await this.keyManifest.get())?.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new _t({clientId:e},ht,gt).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{let n=_t.fromKey(t),r=new Set(n.scope&&n.scope.split(` `)),i=e.scope?.split(` `)||[],a=n.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return n.prefix===ht&&n.clientId===e.clientId&&n.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){for(let n of t){let t=_t.fromKey(n);if(t.prefix===ht&&t.clientId===e.clientId){let e=await this.cache.get(n);if(e?.body?.refresh_token)return{refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}}}async getRefreshTokensByAudience(e,t){var n;let r=await this.getCacheKeys();if(!r)return[];let i=new Set;for(let a of r){let r=_t.fromKey(a);if(r.prefix===ht&&r.clientId===t&&r.audience===e){let e=await this.cache.get(a);(n=e?.body)!=null&&n.refresh_token&&i.add(e.body.refresh_token)}}return Array.from(i)}async updateEntry(e,t){let n=await this.getCacheKeys();if(n)for(let r of n){let n=await this.cache.get(r);n?.body?.refresh_token===e&&(n.body.refresh_token=t,await this.cache.set(r,n))}}},xt=class{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}},St=e=>typeof e==`number`,Ct=`iss.aud.exp.nbf.iat.jti.azp.nonce.auth_time.at_hash.c_hash.acr.amr.sub_jwk.cnf.sip_from_tag.sip_date.sip_callid.sip_cseq_num.sip_via_branch.orig.dest.mky.events.toe.txn.rph.sid.vot.vtm`.split(`.`),wt=e=>{if(!e.id_token)throw Error(`ID token is required but missing`);let t=(e=>{let t=e.split(`.`),[n,r,i]=t;if(t.length!==3||!n||!r||!i)throw Error(`ID token could not be decoded`);let a=JSON.parse(we(r)),o={__raw:e},s={};return Object.keys(a).forEach(e=>{o[e]=a[e],Ct.includes(e)||(s[e]=a[e])}),{encoded:{header:n,payload:r,signature:i},header:JSON.parse(we(n)),claims:o,user:s}})(e.id_token);if(!t.claims.iss)throw Error(`Issuer (iss) claim must be a string present in the ID token`);if(t.claims.iss!==e.iss)throw Error(`Issuer (iss) claim mismatch in the ID token; expected "${e.iss}", found "${t.claims.iss}"`);if(!t.user.sub)throw Error(`Subject (sub) claim must be a string present in the ID token`);if(t.header.alg!==`RS256`)throw Error(`Signature algorithm of "${t.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!t.claims.aud||typeof t.claims.aud!=`string`&&!Array.isArray(t.claims.aud))throw Error(`Audience (aud) claim must be a string or array of strings present in the ID token`);if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but was not one of "${t.claims.aud.join(`, `)}"`);if(t.claims.aud.length>1){if(!t.claims.azp)throw Error(`Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values`);if(t.claims.azp!==e.aud)throw Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${e.aud}", found "${t.claims.azp}"`)}}else if(t.claims.aud!==e.aud)throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but found "${t.claims.aud}"`);if(e.nonce){if(!t.claims.nonce)throw Error(`Nonce (nonce) claim must be a string present in the ID token`);if(t.claims.nonce!==e.nonce)throw Error(`Nonce (nonce) claim mismatch in the ID token; expected "${e.nonce}", found "${t.claims.nonce}"`)}if(e.max_age&&!St(t.claims.auth_time))throw Error(`Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified`);if(t.claims.exp==null||!St(t.claims.exp))throw Error(`Expiration Time (exp) claim must be a number present in the ID token`);if(!St(t.claims.iat))throw Error(`Issued At (iat) claim must be a number present in the ID token`);let n=e.leeway||60,r=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),r>i)throw Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(t.claims.nbf!=null&&St(t.claims.nbf)){let e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),r<e)throw Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${e}`)}if(t.claims.auth_time!=null&&St(t.claims.auth_time)){let i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),r>i)throw Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${i}`)}if(e.organization){let n=e.organization.trim();if(n.startsWith(`org_`)){let e=n;if(!t.claims.org_id)throw Error(`Organization ID (org_id) claim must be a string present in the ID token`);if(e!==t.claims.org_id)throw Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_id}"`)}else{let e=n.toLowerCase();if(!t.claims.org_name)throw Error(`Organization Name (org_name) claim must be a string present in the ID token`);if(e!==t.claims.org_name)throw Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_name}"`)}}return t},Tt=Ee&&Ee.__assign||function(){return Tt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Tt.apply(this,arguments)};function Et(e,t){if(!t)return``;var n=`; `+e;return!0===t?n:n+`=`+t}function Dt(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,`%28`).replace(/\)/g,`%29`)+`=`+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if(typeof e.expires==`number`){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return Et(`Expires`,e.expires?e.expires.toUTCString():``)+Et(`Domain`,e.domain)+Et(`Path`,e.path)+Et(`Secure`,e.secure)+Et(`SameSite`,e.sameSite)}(n)}function Ot(){return function(e){for(var t={},n=e?e.split(`; `):[],r=/(%[\dA-F]{2})+/gi,i=0;i<n.length;i++){var a=n[i].split(`=`),o=a.slice(1).join(`=`);o.charAt(0)===`"`&&(o=o.slice(1,-1));try{t[a[0].replace(r,decodeURIComponent)]=o.replace(r,decodeURIComponent)}catch{}}return t}(document.cookie)}var kt=function(e){return Ot()[e]};function At(e,t,n){document.cookie=Dt(e,t,Tt({path:`/`},n))}var jt=At,Mt=function(e,t){At(e,``,Tt(Tt({},t),{expires:-1}))},Nt={get(e){let t=kt(e);if(t!==void 0)return JSON.parse(t)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0,sameSite:`none`}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),jt(e,JSON.stringify(t),r)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Mt(e,n)}},Pt=`_legacy_`,Ft={get(e){return Nt.get(e)||Nt.get(`${Pt}${e}`)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),jt(`${Pt}${e}`,JSON.stringify(t),r),Nt.save(e,t,n)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Mt(e,n),Nt.remove(e,t),Nt.remove(`${Pt}${e}`,t)}},It={get(e){if(typeof sessionStorage>`u`)return;let t=sessionStorage.getItem(e);return t==null?void 0:JSON.parse(t)},save(e,t){sessionStorage.setItem(e,JSON.stringify(t))},remove(e){sessionStorage.removeItem(e)}},Lt;(function(e){e.Code=`code`,e.ConnectCode=`connect_code`})(Lt||={});function Rt(e,t,n){var r=t===void 0?null:t,i=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,a=n.length;i<a;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,n!==void 0&&n),a=i.indexOf(`
|
|
2
|
-
`,10)+1,o=i.substring(a)+(r?`//# sourceMappingURL=`+r:``),s=new Blob([o],{type:`application/javascript`});return URL.createObjectURL(s)}var zt,Bt,Vt,Ht,Ut=(zt=`Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHQpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOm99PXQ7cmV0dXJuIG5ldyBlKHIsbyl9fWNsYXNzIHQgZXh0ZW5kcyBle2NvbnN0cnVjdG9yKGUsbyl7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChyKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChyKG8pLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1vLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLHQucHJvdG90eXBlKX19ZnVuY3Rpb24gcihlKXtyZXR1cm4gZSYmIShhcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W10pLmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IG89ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIG8gaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxvKSYmdC5pbmRleE9mKG8pPDAmJihyW29dPWVbb10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgcz0wO2ZvcihvPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7czxvLmxlbmd0aDtzKyspdC5pbmRleE9mKG9bc10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLG9bc10pJiYocltvW3NdXT1lW29bc11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIodD0+dm9pZCAwIT09ZVt0XSkucmVkdWNlKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkse30pKShPYmplY3QuYXNzaWduKHtjbGllbnRfaWQ6dH0scikpKS50b1N0cmluZygpfTtsZXQgcz17fSxuPW51bGw7Y29uc3QgaT0oZSx0KT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQodCksYT0oZSx0KT0+dC5zdGFydHNXaXRoKCIiLmNvbmNhdChlLCJ8IikpLGM9ZT0+e09iamVjdC5lbnRyaWVzKHMpLmZvckVhY2godD0+e2xldFtyLG9dPXQ7bz09PWUmJmRlbGV0ZSBzW3JdfSl9LGw9ZT0+e2NvbnN0IHQ9bmV3IFVSTFNlYXJjaFBhcmFtcyhlKSxyPXt9O3JldHVybiB0LmZvckVhY2goKGUsdCk9PntyW3RdPWV9KSxyfSxmPWFzeW5jIGU9PntsZXQgcixuLHtkYXRhOnt0aW1lb3V0OmMsYXV0aDpmLGZldGNoVXJsOnUsZmV0Y2hPcHRpb25zOmgsdXNlRm9ybURhdGE6ZCx1c2VNcnJ0OnB9LHBvcnRzOltnXX09ZSx5PXt9O2NvbnN0e2F1ZGllbmNlOmIsc2NvcGU6T309Znx8e307dHJ5e2NvbnN0IGU9ZD9sKGguYm9keSk6SlNPTi5wYXJzZShoLmJvZHkpO2lmKCFlLnJlZnJlc2hfdG9rZW4mJiJyZWZyZXNoX3Rva2VuIj09PWUuZ3JhbnRfdHlwZSl7aWYobj0oKGUsdCk9PnNbaShlLHQpXSkoYixPKSwhbiYmcCl7Y29uc3QgZT1zLmxhdGVzdF9yZWZyZXNoX3Rva2VuLHQ9KChlLHQpPT4hIU9iamVjdC5rZXlzKHMpLmZpbmQocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBvPWEodCxyKSxzPXIuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpLG49ZS5zcGxpdCgiICIpLmV2ZXJ5KGU9PnMuaW5jbHVkZXMoZSkpO3JldHVybiBvJiZufX0pKShPLGIpO2UmJiF0JiYobj1lKX1pZighbil0aHJvdyBuZXcgdChiLE8pO2guYm9keT1kP28oT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LGUpLHtyZWZyZXNoX3Rva2VuOm59KSk6SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LGUpLHtyZWZyZXNoX3Rva2VuOm59KSl9bGV0IGYsdzsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYoZj1uZXcgQWJvcnRDb250cm9sbGVyLGguc2lnbmFsPWYuc2lnbmFsKTt0cnl7dz1hd2FpdCBQcm9taXNlLnJhY2UoWyhtPWMsbmV3IFByb21pc2UoZT0+c2V0VGltZW91dChlLG0pKSksZmV0Y2godSxPYmplY3QuYXNzaWduKHt9LGgpKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIGcucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCF3KXJldHVybiBmJiZmLmFib3J0KCksdm9pZCBnLnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO189dy5oZWFkZXJzLHk9Wy4uLl9dLnJlZHVjZSgoZSx0KT0+e2xldFtyLG9dPXQ7cmV0dXJuIGVbcl09byxlfSx7fSkscj1hd2FpdCB3Lmpzb24oKSxyLnJlZnJlc2hfdG9rZW4/KHAmJihzLmxhdGVzdF9yZWZyZXNoX3Rva2VuPXIucmVmcmVzaF90b2tlbixrPW4saj1yLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMocykuZm9yRWFjaChlPT57bGV0W3Qscl09ZTtyPT09ayYmKHNbdF09ail9KSksKChlLHQscik9PntzW2kodCxyKV09ZX0pKHIucmVmcmVzaF90b2tlbixiLE8pLGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBzW2koZSx0KV19KShiLE8pLGcucG9zdE1lc3NhZ2Uoe29rOncub2ssanNvbjpyLGhlYWRlcnM6eX0pfWNhdGNoKGUpe2cucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOnl9KX12YXIgayxqLF8sbX0sdT1hc3luYyBlPT57bGV0e2RhdGE6e3RpbWVvdXQ6dCxhdXRoOnIsZmV0Y2hVcmw6bixmZXRjaE9wdGlvbnM6aSx1c2VGb3JtRGF0YTpmfSxwb3J0czpbdV19PWU7Y29uc3R7YXVkaWVuY2U6aH09cnx8e307dHJ5e2NvbnN0IGU9KGU9Pntjb25zdCB0PW5ldyBTZXQ7cmV0dXJuIE9iamVjdC5lbnRyaWVzKHMpLmZvckVhY2gocj0+e2xldFtvLHNdPXI7YShlLG8pJiZ0LmFkZChzKX0pLEFycmF5LmZyb20odCl9KShoKTtpZigwPT09ZS5sZW5ndGgpcmV0dXJuIHZvaWQgdS5wb3N0TWVzc2FnZSh7b2s6ITB9KTtjb25zdCByPWY/bChpLmJvZHkpOkpTT04ucGFyc2UoaS5ib2R5KTtmb3IoY29uc3QgcyBvZiBlKXtjb25zdCBlPWY/byhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3Rva2VuOnN9KSk6SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjpzfSkpO2xldCBhLGwsaCxkOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihhPW5ldyBBYm9ydENvbnRyb2xsZXIsbD1hLnNpZ25hbCk7dHJ5e2Q9YXdhaXQgUHJvbWlzZS5yYWNlKFtuZXcgUHJvbWlzZShlPT57aD1zZXRUaW1lb3V0KGUsdCl9KSxmZXRjaChuLE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxpKSx7Ym9keTplLHNpZ25hbDpsfSkpXSkuZmluYWxseSgoKT0+Y2xlYXJUaW1lb3V0KGgpKX1jYXRjaChlKXtyZXR1cm4gdm9pZCB1LnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZClyZXR1cm4gYSYmYS5hYm9ydCgpLHZvaWQgdS5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZighZC5vayl7bGV0IGU7dHJ5e2NvbnN0e2Vycm9yX2Rlc2NyaXB0aW9uOnR9PUpTT04ucGFyc2UoYXdhaXQgZC50ZXh0KCkpO2U9dH1jYXRjaChlKXt9cmV0dXJuIHZvaWQgdS5wb3N0TWVzc2FnZSh7ZXJyb3I6ZXx8IkhUVFAgZXJyb3IgIi5jb25jYXQoZC5zdGF0dXMpfSl9YyhzKX11LnBvc3RNZXNzYWdlKHtvazohMH0pfWNhdGNoKGUpe3UucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZXx8IlVua25vd24gZXJyb3IgZHVyaW5nIHRva2VuIHJldm9jYXRpb24ifSl9fSxoPShlLHQpPT57aWYoIW4pcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChuKS5vcmlnaW4sbz1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiBvLm9yaWdpbj09PXImJm8ucGF0aG5hbWU9PT10fWNhdGNoKGUpe3JldHVybiExfX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZT0+e2NvbnN0e2RhdGE6dCxwb3J0czpyfT1lLFtvXT1yO2lmKCEoInR5cGUiaW4gdCl8fCJpbml0IiE9PXQudHlwZSlyZXR1cm4idHlwZSJpbiB0JiYiY2xlYXIiPT09dC50eXBlPyhzPXt9LHZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITB9KSkpOiJ0eXBlImluIHQmJiJyZXZva2UiPT09dC50eXBlP2godCwiL29hdXRoL3Jldm9rZSIpP3ZvaWQgdShlKTp2b2lkKG51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpOnZvaWQoImZldGNoVXJsImluIHQmJmgodCwiL29hdXRoL3Rva2VuIik/ZihlKTpudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjoiaW52YWxpZF9mZXRjaF91cmwiLGVycm9yX2Rlc2NyaXB0aW9uOiJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIn0saGVhZGVyczp7fX0pKTtpZihudWxsPT09bil0cnl7bmV3IFVSTCh0LmFsbG93ZWRCYXNlVXJsKSxuPXQuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX0pfSgpOwoK`,Bt=null,Vt=!1,function(e){return Ht||=Rt(zt,Bt,Vt),new Worker(Ht,e)}),Wt={},Gt=class{constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){let t=new Set((await this.cache.get(this.manifestKey))?.keys||[]);t.add(e),await this.cache.set(this.manifestKey,{keys:[...t]})}async remove(e){let t=await this.cache.get(this.manifestKey);if(t){let n=new Set(t.keys);return n.delete(e),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`${ht}::${e}`}},Kt=`auth0.is.authenticated`,qt={memory:()=>new yt().enclosedCache,localstorage:()=>new vt},Jt=e=>qt[e],Yt=e=>{let{openUrl:t,onRedirect:n}=e,r=x(e,[`openUrl`,`onRedirect`]);return Object.assign(Object.assign({},r),{openUrl:!1===t||t?t:n})},Xt=(e,t)=>{let n=t?.split(` `)||[];return(e?.split(` `)||[]).every(e=>n.includes(e))},Zt={NONCE:`nonce`,KEYPAIR:`keypair`},Qt=class{constructor(e){this.clientId=e}getVersion(){return 1}createDbHandle(){let e=window.indexedDB.open(`auth0-spa-js`,this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(Zt).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result)})}async getDbHandle(){return this.dbHandle||=await this.createDbHandle(),this.dbHandle}async executeDbRequest(e,t,n){let r=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})}buildKey(e){let t=e?`_${e}`:`auth0`;return`${this.clientId}::${t}`}setNonce(e,t){return this.save(Zt.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(Zt.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,`readwrite`,e=>e.put(n,t))}findNonce(e){return this.find(Zt.NONCE,this.buildKey(e))}findKeyPair(){return this.find(Zt.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,`readonly`,e=>e.get(t))}async deleteBy(e,t){(await this.executeDbRequest(e,`readonly`,e=>e.getAllKeys()))?.filter(t).map(t=>this.executeDbRequest(e,`readwrite`,e=>e.delete(t)))}deleteByClientId(e,t){return this.deleteBy(e,e=>typeof e==`string`&&e.startsWith(`${t}::`))}clearNonces(){return this.deleteByClientId(Zt.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(Zt.KEYPAIR,this.clientId)}},$t=class{constructor(e){this.storage=new Qt(e)}getNonce(e){return this.storage.findNonce(e)}setNonce(e,t){return this.storage.setNonce(e,t)}async getOrGenerateKeyPair(){let e=await this.storage.findKeyPair();return e||(e=await at(),await this.storage.setKeyPair(e)),e}async generateProof(e){let t=await this.getOrGenerateKeyPair();return st(Object.assign({keyPair:t},e))}async calculateThumbprint(){return ot(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}},en;(function(e){e.Bearer=`Bearer`,e.DPoP=`DPoP`})(en||={});var tn=class{constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||(typeof window>`u`?fetch:window.fetch.bind(window))})}isAbsoluteUrl(e){return/^(https?:)?\/\//i.test(e)}buildUrl(e,t){if(t){if(this.isAbsoluteUrl(t))return t;if(e)return`${e.replace(/\/?\/$/,``)}/${t.replace(/^\/+/,``)}`}throw TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(e){return this.config.getAccessToken?this.config.getAccessToken(e):this.hooks.getAccessToken(e)}extractUrl(e){return typeof e==`string`?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);let n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),r=e instanceof Request?new Request(n,e):n;return new Request(r,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:en.Bearer;e.headers.set(`authorization`,`${n} ${t}`)}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;let n=await this.hooks.getDpopNonce(),r=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set(`dpop`,r)}async prepareRequest(e,t){let n=await this.getAccessToken(t),r,i;typeof n==`string`?(r=this.config.dpopNonceId?en.DPoP:en.Bearer,i=n):(r=n.token_type,i=n.access_token),this.setAuthorizationHeader(e,i,r),r===en.DPoP&&await this.setDpopProofHeader(e,i)}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||``:typeof e.get==`function`?e.get(t)||``:e[t]||``}hasUseDpopNonceError(e){if(e.status!==401)return!1;let t=this.getHeader(e.headers,`www-authenticate`);return t.includes(`invalid_dpop_nonce`)||t.includes(`use_dpop_nonce`)}async handleResponse(e,t){let n=this.getHeader(e.headers,rt);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new he(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,r){let i=this.buildBaseRequest(e,t);await this.prepareRequest(i,r);let a=await this.config.fetch(i);return this.handleResponse(a,n)}fetchWithAuth(e,t,n){let r={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,Object.assign(Object.assign({},r),{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,r,n)}},nn=class{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t}async connectAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/connect`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async completeAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t)}catch(n){throw new rn({type:`invalid_json`,status:e.status,title:`Invalid JSON response`,detail:t||String(n)})}if(e.ok)return t;throw new rn(t)}},rn=class e extends Error{constructor(t){let{type:n,status:r,title:i,detail:a,validation_errors:o}=t;super(a),this.name=`MyAccountApiError`,this.type=n,this.status=r,this.title=i,this.detail=a,this.validation_errors=o,Object.setPrototypeOf(this,e.prototype)}},an={otp:{authenticatorTypes:[`otp`]},sms:{authenticatorTypes:[`oob`],oobChannels:[`sms`]},email:{authenticatorTypes:[`oob`],oobChannels:[`email`]},push:{authenticatorTypes:[`oob`],oobChannels:[`auth0`]},voice:{authenticatorTypes:[`oob`],oobChannels:[`voice`]}},on=`http://auth0.com/oauth/grant-type/mfa-otp`,sn=`http://auth0.com/oauth/grant-type/mfa-oob`,cn=`http://auth0.com/oauth/grant-type/mfa-recovery-code`;function ln(e,t){this.v=e,this.k=t}function T(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function un(e){return new ln(e,0)}function dn(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function E(e,t){return e.get(T(e,t))}function D(e,t,n){dn(e,t),t.set(e,n)}function O(e,t,n){return e.set(T(e,t),n),n}function k(e,t,n){return(t=function(e){var t=function(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return typeof t==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function A(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fn(Object(n),!0).forEach(function(t){k(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pn(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function mn(e){return function(){return new hn(e.apply(this,arguments))}}function hn(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof ln;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}var gn,_n,vn;hn.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},hn.prototype.next=function(e){return this._invoke(`next`,e)},hn.prototype.throw=function(e){return this._invoke(`throw`,e)},hn.prototype.return=function(e){return this._invoke(`return`,e)},(typeof navigator>`u`||(gn=navigator.userAgent)==null||(_n=gn.startsWith)==null||!_n.call(gn,`Mozilla/5.0 `))&&(vn=`oauth4webapi/v3.8.5`);function yn(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var bn=`ERR_INVALID_ARG_VALUE`,xn=`ERR_INVALID_ARG_TYPE`;function j(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var Sn=Symbol(),Cn=Symbol(),wn=Symbol(),Tn=Symbol(),En=Symbol(),Dn=Symbol(),On=new TextEncoder,kn=new TextDecoder;function An(e){return typeof e==`string`?On.encode(e):kn.decode(e)}var jn,Mn;if(Uint8Array.prototype.toBase64)jn=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;jn=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Nn(e){return typeof e==`string`?Mn(e):jn(e)}Mn=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:`base64url`})}catch(e){throw j(`The input to be decoded is not correctly encoded.`,bn,e)}}:e=>{try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`).replace(/\s/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch(e){throw j(`The input to be decoded is not correctly encoded.`,bn,e)}};var Pn=class extends Error{constructor(e,t){var n;super(e,t),k(this,`code`,void 0),this.name=this.constructor.name,this.code=Nr,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},Fn=class extends Error{constructor(e,t){var n;super(e,t),k(this,`code`,void 0),this.name=this.constructor.name,t!=null&&t.code&&(this.code=t?.code),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function M(e,t,n){return new Fn(e,{code:t,cause:n})}function In(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw j(`${t} must be a CryptoKey`,xn)}(e,t),e.type!==`private`)throw j(`${t} must be a private CryptoKey`,bn)}function Ln(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Rn(e){yn(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(vn&&!t.has(`user-agent`)&&t.set(`user-agent`,vn),t.has(`authorization`))throw j(`"options.headers" must not include the "authorization" header name`,bn);return t}function zn(e,t){if(t!==void 0){if(typeof t==`function`&&(t=t(e.href)),!(t instanceof AbortSignal))throw j(`"options.signal" must return or be an instance of AbortSignal`,xn);return t}}function Bn(e){return e.includes(`//`)?e.replace(`//`,`/`):e}async function Vn(e,t){return async function(e,t,n,r){if(!(e instanceof URL))throw j(`"${t}" must be an instance of URL`,xn);er(e,!0!==r?.[Sn]);let i=n(new URL(e.href)),a=Rn(r?.headers);return a.set(`accept`,`application/json`),(r?.[Tn]||fetch)(i.href,{body:void 0,headers:Object.fromEntries(a.entries()),method:`GET`,redirect:`manual`,signal:zn(i,r?.signal)})}(e,`issuerIdentifier`,e=>{switch(t?.algorithm){case void 0:case`oidc`:(function(e,t){e.pathname=Bn(`${e.pathname}/${t}`)})(e,`.well-known/openid-configuration`);break;case`oauth2`:(function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2];e.pathname===`/`?e.pathname=t:e.pathname=Bn(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,``)}`)})(e,`.well-known/oauth-authorization-server`);break;default:throw j(`"options.algorithm" must be "oidc" (default), or "oauth2"`,bn)}return e},t)}function Hn(e,t,n,r,i){try{if(typeof e!=`number`||!Number.isFinite(e))throw j(`${n} must be a number`,xn,i);if(e>0)return;if(t){if(e!==0)throw j(`${n} must be a non-negative number`,bn,i);return}throw j(`${n} must be a positive number`,bn,i)}catch(e){throw r?M(e.message,r,i):e}}function N(e,t,n,r){try{if(typeof e!=`string`)throw j(`${t} must be a string`,xn,r);if(e.length===0)throw j(`${t} must not be empty`,bn,r)}catch(e){throw n?M(e.message,n,r):e}}function Un(e){(function(e,t){if(hr(e)!==t)throw function(e){let t=`"response" content-type must be `;for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(r.length>2){let e=r.pop();t+=`${r.join(`, `)}, or ${e}`}else r.length===2?t+=`${r[0]} or ${r[1]}`:t+=r[0];return M(t,Ir,e)}(e,t)})(e,`application/json`)}function Wn(){return Nn(crypto.getRandomValues(new Uint8Array(32)))}function Gn(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`PS256`;case`SHA-384`:return`PS384`;case`SHA-512`:return`PS512`;default:throw new Pn(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`RSASSA-PKCS1-v1_5`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`RS256`;case`SHA-384`:return`RS384`;case`SHA-512`:return`RS512`;default:throw new Pn(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`ECDSA`:return function(e){switch(e.algorithm.namedCurve){case`P-256`:return`ES256`;case`P-384`:return`ES384`;case`P-521`:return`ES512`;default:throw new Pn(`unsupported EcKeyAlgorithm namedCurve`,{cause:e})}}(e);case`Ed25519`:case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return e.algorithm.name;case`EdDSA`:return`Ed25519`;default:throw new Pn(`unsupported CryptoKey algorithm name`,{cause:e})}}function Kn(e){let t=e?.[Cn];return typeof t==`number`&&Number.isFinite(t)?t:0}function qn(e){let t=e?.[wn];return typeof t==`number`&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function Jn(){return Math.floor(Date.now()/1e3)}function Yn(e){if(typeof e!=`object`||!e)throw j(`"as" must be an object`,xn);N(e.issuer,`"as.issuer"`)}function Xn(e){if(typeof e!=`object`||!e)throw j(`"client" must be an object`,xn);N(e.client_id,`"client.client_id"`)}function Zn(e){return N(e,`"clientSecret"`),(t,n,r,i)=>{r.set(`client_id`,n.client_id),r.set(`client_secret`,e)}}function Qn(e,t){let{key:n,kid:r}=(i=e)instanceof CryptoKey?{key:i}:i?.key instanceof CryptoKey?(i.kid!==void 0&&N(i.kid,`"kid"`),{key:i.key,kid:i.kid}):{};var i;return In(n,`"clientPrivateKey.key"`),async(e,i,a,o)=>{var s;let c={alg:Gn(n),kid:r},l=function(e,t){let n=Jn()+Kn(t);return{jti:Wn(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,i);t==null||(s=t[En])==null||s.call(t,c,l),a.set(`client_id`,i.client_id),a.set(`client_assertion_type`,`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`),a.set(`client_assertion`,await async function(e,t,n){if(!n.usages.includes(`sign`))throw j(`CryptoKey instances used for signing assertions must include "sign" in their "usages"`,bn);let r=`${Nn(An(JSON.stringify(e)))}.${Nn(An(JSON.stringify(t)))}`;return`${r}.${Nn(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:qr(e)};case`RSA-PSS`:switch(Kr(e),e.algorithm.hash.name){case`SHA-256`:case`SHA-384`:case`SHA-512`:return{name:e.algorithm.name,saltLength:parseInt(e.algorithm.hash.name.slice(-3),10)>>3};default:throw new Pn(`unsupported RSA-PSS hash name`,{cause:e})}case`RSASSA-PKCS1-v1_5`:return Kr(e),e.algorithm.name;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:case`Ed25519`:return e.algorithm.name}throw new Pn(`unsupported CryptoKey algorithm name`,{cause:e})}(n),n,An(r)))}`}(c,l,n))}}var $n=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function er(e,t){if(t&&e.protocol!==`https:`)throw M(`only requests to HTTPS are allowed`,Rr,e);if(e.protocol!==`https:`&&e.protocol!==`http:`)throw M(`only HTTP and HTTPS requests are allowed`,zr,e)}function tr(e,t,n,r){let i;if(typeof e!=`string`||!(i=$n(e)))throw M(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Ur:Wr,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return er(i,r),i}function nr(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?tr(e.mtls_endpoint_aliases[t],t,n,r):tr(e[t],t,n,r)}var rr=class extends Error{constructor(e,t){var n;super(e,t),k(this,`cause`,void 0),k(this,`code`,void 0),k(this,`error`,void 0),k(this,`status`,void 0),k(this,`error_description`,void 0),k(this,`response`,void 0),this.name=this.constructor.name,this.code=Mr,this.cause=t.cause,this.error=t.cause.error,this.status=t.response.status,this.error_description=t.cause.error_description,Object.defineProperty(this,`response`,{enumerable:!1,value:t.response}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},ir=class extends Error{constructor(e,t){var n;super(e,t),k(this,`cause`,void 0),k(this,`code`,void 0),k(this,`error`,void 0),k(this,`error_description`,void 0),this.name=this.constructor.name,this.code=Pr,this.cause=t.cause,this.error=t.cause.get(`error`),this.error_description=t.cause.get(`error_description`)??void 0,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},ar=class extends Error{constructor(e,t){var n;super(e,t),k(this,`cause`,void 0),k(this,`code`,void 0),k(this,`response`,void 0),k(this,`status`,void 0),this.name=this.constructor.name,this.code=jr,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,`response`,{enumerable:!1}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},or="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",sr=`(`+or+`)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"`,cr=`(`+or+")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)",lr=RegExp(`^[,\\s]*(`+or+`)`),ur=RegExp(`^[,\\s]*`+sr+`[,\\s]*(.*)`),dr=RegExp(`^[,\\s]*`+cr+`[,\\s]*(.*)`),fr=RegExp(`^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)`);async function pr(e,t,n){if(e.status!==t){let t;throw function(e){let t;if(t=function(e){if(!yn(e,Response))throw j(`"response" must be an instance of Response`,xn);let t=e.headers.get(`www-authenticate`);if(t===null)return;let n=[],r=t;for(;r;){let e=r.match(lr),t=e?.[1].toLowerCase();if(!t)return;let i=r.substring(e[0].length);if(i&&!i.match(/^[\s,]/))return;let a=i.match(/^\s+(.*)$/),o=!!a;r=a?a[1]:void 0;let s={},c;if(o)for(;r;){let t,n;if(e=r.match(ur)){if([,t,n,r]=e,n.includes(`\\`))try{n=JSON.parse(`"${n}"`)}catch{}s[t.toLowerCase()]=n}else{if(!(e=r.match(dr))){if(e=r.match(fr)){if(Object.keys(s).length)break;[,c,r]=e;break}return}[,t,n,r]=e,s[t.toLowerCase()]=n}}else r=i||void 0;let l={scheme:t,parameters:s};c&&(l.token68=c),n.push(l)}return n.length?n:void 0}(e))throw new ar(`server responded with a challenge in the WWW-Authenticate HTTP Header`,{cause:t,response:e})}(e),(t=await async function(e){if(e.status>399&&e.status<500){Gr(e),Un(e);try{let t=await e.clone().json();if(Ln(t)&&typeof t.error==`string`&&t.error.length)return t}catch{}}}(e))?(await e.body?.cancel(),new rr(`server responded with an error in the response body`,{cause:t,response:e})):M(`"response" is not a conform ${n} response (unexpected HTTP status code)`,Lr,e)}}function mr(e){if(!wr.has(e))throw j(`"options.DPoP" is not a valid DPoPHandle`,bn)}function hr(e){return e.headers.get(`content-type`)?.split(`;`)[0]}async function gr(e,t,n,r,i,a,o){return await n(e,t,i,a),a.set(`content-type`,`application/x-www-form-urlencoded;charset=UTF-8`),(o?.[Tn]||fetch)(r.href,{body:i,headers:Object.fromEntries(a.entries()),method:`POST`,redirect:`manual`,signal:zn(r,o?.signal)})}async function _r(e,t,n,r,i,a){var o;let s=nr(e,`token_endpoint`,t.use_mtls_endpoint_aliases,!0!==a?.[Sn]);i.set(`grant_type`,r);let c=Rn(a?.headers);c.set(`accept`,`application/json`),a?.DPoP!==void 0&&(mr(a.DPoP),await a.DPoP.addProof(s,c,`POST`));let l=await gr(e,t,n,s,i,c,a);return a==null||(o=a.DPoP)==null||o.cacheNonce(l,s),l}var vr=new WeakMap,yr=new WeakMap;function br(e){if(!e.id_token)return;let t=vr.get(e);if(!t)throw j(`"ref" was already garbage collected or did not resolve from the proper sources`,bn);return t}async function xr(e,t,n,r,i,a){if(Yn(e),Xn(t),!yn(n,Response))throw j(`"response" must be an instance of Response`,xn);await pr(n,200,`Token Endpoint`),Gr(n);let o=await ei(n);if(N(o.access_token,`"response" body "access_token" property`,P,{body:o}),N(o.token_type,`"response" body "token_type" property`,P,{body:o}),o.token_type=o.token_type.toLowerCase(),o.expires_in!==void 0){let e=typeof o.expires_in==`number`?o.expires_in:parseFloat(o.expires_in);Hn(e,!0,`"response" body "expires_in" property`,P,{body:o}),o.expires_in=e}if(o.refresh_token!==void 0&&N(o.refresh_token,`"response" body "refresh_token" property`,P,{body:o}),o.scope!==void 0&&typeof o.scope!=`string`)throw M(`"response" body "scope" property must be a string`,P,{body:o});if(o.id_token!==void 0){N(o.id_token,`"response" body "id_token" property`,P,{body:o});let a=[`aud`,`exp`,`iat`,`iss`,`sub`];!0===t.require_auth_time&&a.push(`auth_time`),t.default_max_age!==void 0&&(Hn(t.default_max_age,!0,`"client.default_max_age"`),a.push(`auth_time`)),r!=null&&r.length&&a.push(...r);let{claims:s,jwt:c}=await async function(e,t,n,r,i){let a,o,{0:s,1:c,length:l}=e.split(`.`);if(l===5){if(i===void 0)throw new Pn(`JWE decryption is not configured`,{cause:e});e=await i(e),{0:s,1:c,length:l}=e.split(`.`)}if(l!==3)throw M(`Invalid JWT`,P,e);try{a=JSON.parse(An(Nn(s)))}catch(e){throw M(`failed to parse JWT Header body as base64url encoded JSON`,Fr,e)}if(!Ln(a))throw M(`JWT Header must be a top level object`,P,e);if(t(a),a.crit!==void 0)throw new Pn(`no JWT "crit" header parameter extensions are supported`,{cause:{header:a}});try{o=JSON.parse(An(Nn(c)))}catch(e){throw M(`failed to parse JWT Payload body as base64url encoded JSON`,Fr,e)}if(!Ln(o))throw M(`JWT Payload must be a top level object`,P,e);let u=Jn()+n;if(o.exp!==void 0){if(typeof o.exp!=`number`)throw M(`unexpected JWT "exp" (expiration time) claim type`,P,{claims:o});if(o.exp<=u-r)throw M(`unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp`,Br,{claims:o,now:u,tolerance:r,claim:`exp`})}if(o.iat!==void 0&&typeof o.iat!=`number`)throw M(`unexpected JWT "iat" (issued at) claim type`,P,{claims:o});if(o.iss!==void 0&&typeof o.iss!=`string`)throw M(`unexpected JWT "iss" (issuer) claim type`,P,{claims:o});if(o.nbf!==void 0){if(typeof o.nbf!=`number`)throw M(`unexpected JWT "nbf" (not before) claim type`,P,{claims:o});if(o.nbf>u+r)throw M(`unexpected JWT "nbf" (not before) claim value`,Br,{claims:o,now:u,tolerance:r,claim:`nbf`})}if(o.aud!==void 0&&typeof o.aud!=`string`&&!Array.isArray(o.aud))throw M(`unexpected JWT "aud" (audience) claim type`,P,{claims:o});return{header:a,claims:o,jwt:e}}(o.id_token,Yr.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,`RS256`),Kn(t),qn(t),i).then(Dr.bind(void 0,a)).then(Cr.bind(void 0,e)).then(Sr.bind(void 0,t.client_id));if(Array.isArray(s.aud)&&s.aud.length!==1){if(s.azp===void 0)throw M(`ID Token "aud" (audience) claim includes additional untrusted audiences`,Vr,{claims:s,claim:`aud`});if(s.azp!==t.client_id)throw M(`unexpected ID Token "azp" (authorized party) claim value`,Vr,{expected:t.client_id,claims:s,claim:`azp`})}s.auth_time!==void 0&&Hn(s.auth_time,!0,`ID Token "auth_time" (authentication time)`,P,{claims:s}),yr.set(n,c),vr.set(o,s)}if(a?.[o.token_type]!==void 0)a[o.token_type](n,o);else if(o.token_type!==`dpop`&&o.token_type!==`bearer`)throw new Pn("unsupported `token_type` value",{cause:{body:o}});return o}function Sr(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw M(`unexpected JWT "aud" (audience) claim value`,Vr,{expected:e,claims:t.claims,claim:`aud`})}else if(t.claims.aud!==e)throw M(`unexpected JWT "aud" (audience) claim value`,Vr,{expected:e,claims:t.claims,claim:`aud`});return t}function Cr(e,t){let n=e[ni]?.call(e,t)??e.issuer;if(t.claims.iss!==n)throw M(`unexpected JWT "iss" (issuer) claim value`,Vr,{expected:n,claims:t.claims,claim:`iss`});return t}var wr=new WeakSet,Tr=Symbol(),Er={aud:`audience`,c_hash:`code hash`,client_id:`client id`,exp:`expiration time`,iat:`issued at`,iss:`issuer`,jti:`jwt id`,nonce:`nonce`,s_hash:`state hash`,sub:`subject`,ath:`access token hash`,htm:`http method`,htu:`http uri`,cnf:`confirmation`,auth_time:`authentication time`};function Dr(e,t){for(let n of e)if(t.claims[n]===void 0)throw M(`JWT "${n}" (${Er[n]}) claim missing`,P,{claims:t.claims});return t}var Or=Symbol(),kr=Symbol();async function Ar(e,t,n,r){return typeof r?.expectedNonce==`string`||typeof r?.maxAge==`number`||r!=null&&r.requireIdToken?async function(e,t,n,r,i,a,o){let s=[];switch(r){case void 0:r=Or;break;case Or:break;default:N(r,`"expectedNonce" argument`),s.push(`nonce`)}switch(i??=t.default_max_age,i){case void 0:i=kr;break;case kr:break;default:Hn(i,!0,`"maxAge" argument`),s.push(`auth_time`)}let c=await xr(e,t,n,s,a,o);N(c.id_token,`"response" body "id_token" property`,P,{body:c});let l=br(c);if(i!==kr){let e=Jn()+Kn(t),n=qn(t);if(l.auth_time+i<e-n)throw M(`too much time has elapsed since the last End-User authentication`,Br,{claims:l,now:e,tolerance:n,claim:`auth_time`})}if(r===Or){if(l.nonce!==void 0)throw M(`unexpected ID Token "nonce" claim value`,Vr,{expected:void 0,claims:l,claim:`nonce`})}else if(l.nonce!==r)throw M(`unexpected ID Token "nonce" claim value`,Vr,{expected:r,claims:l,claim:`nonce`});return c}(e,t,n,r.expectedNonce,r.maxAge,r[Dn],r.recognizedTokenTypes):async function(e,t,n,r,i){let a=await xr(e,t,n,void 0,r,i),o=br(a);if(o){if(t.default_max_age!==void 0){Hn(t.default_max_age,!0,`"client.default_max_age"`);let e=Jn()+Kn(t),n=qn(t);if(o.auth_time+t.default_max_age<e-n)throw M(`too much time has elapsed since the last End-User authentication`,Br,{claims:o,now:e,tolerance:n,claim:`auth_time`})}if(o.nonce!==void 0)throw M(`unexpected ID Token "nonce" claim value`,Vr,{expected:void 0,claims:o,claim:`nonce`})}return a}(e,t,n,r?.[Dn],r?.recognizedTokenTypes)}var jr=`OAUTH_WWW_AUTHENTICATE_CHALLENGE`,Mr=`OAUTH_RESPONSE_BODY_ERROR`,Nr=`OAUTH_UNSUPPORTED_OPERATION`,Pr=`OAUTH_AUTHORIZATION_RESPONSE_ERROR`,Fr=`OAUTH_PARSE_ERROR`,P=`OAUTH_INVALID_RESPONSE`,Ir=`OAUTH_RESPONSE_IS_NOT_JSON`,Lr=`OAUTH_RESPONSE_IS_NOT_CONFORM`,Rr=`OAUTH_HTTP_REQUEST_FORBIDDEN`,zr=`OAUTH_REQUEST_PROTOCOL_FORBIDDEN`,Br=`OAUTH_JWT_TIMESTAMP_CHECK_FAILED`,Vr=`OAUTH_JWT_CLAIM_COMPARISON_FAILED`,Hr=`OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED`,Ur=`OAUTH_MISSING_SERVER_METADATA`,Wr=`OAUTH_INVALID_SERVER_METADATA`;function Gr(e){if(e.bodyUsed)throw j(`"response" body has been used already`,bn)}function Kr(e){let{algorithm:t}=e;if(typeof t.modulusLength!=`number`||t.modulusLength<2048)throw new Pn(`unsupported ${t.name} modulusLength`,{cause:e})}function qr(e){let{algorithm:t}=e;switch(t.namedCurve){case`P-256`:return`SHA-256`;case`P-384`:return`SHA-384`;case`P-521`:return`SHA-512`;default:throw new Pn(`unsupported ECDSA namedCurve`,{cause:e})}}async function Jr(e){if(e.method!==`POST`)throw j(`form_post responses are expected to use the POST method`,bn,{cause:e});if(hr(e)!==`application/x-www-form-urlencoded`)throw j(`form_post responses are expected to use the application/x-www-form-urlencoded content-type`,bn,{cause:e});return async function(e){if(e.bodyUsed)throw j(`form_post Request instances must contain a readable body`,bn,{cause:e});return e.text()}(e)}function Yr(e,t,n,r){if(e===void 0)if(Array.isArray(t)){if(!t.includes(r.alg))throw M(`unexpected JWT "alg" header parameter`,P,{header:r,expected:t,reason:`authorization server metadata`})}else{if(n===void 0)throw M(`missing client or server configuration to verify used JWT "alg" header parameter`,void 0,{client:e,issuer:t,fallback:n});if(typeof n==`string`?r.alg!==n:typeof n==`function`?!n(r.alg):!n.includes(r.alg))throw M(`unexpected JWT "alg" header parameter`,P,{header:r,expected:n,reason:`default value`})}else if(typeof e==`string`?r.alg!==e:!e.includes(r.alg))throw M(`unexpected JWT "alg" header parameter`,P,{header:r,expected:e,reason:`client configuration`})}function Xr(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw M(`"${t}" parameter must be provided only once`,P);return n}var Zr=Symbol(),Qr=Symbol();function $r(e,t,n,r){if(Yn(e),Xn(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw j(`"parameters" must be an instance of URLSearchParams, or URL`,xn);if(Xr(n,`response`))throw M(`"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()`,P,{parameters:n});let i=Xr(n,`iss`),a=Xr(n,`state`);if(!i&&e.authorization_response_iss_parameter_supported)throw M(`response parameter "iss" (issuer) missing`,P,{parameters:n});if(i&&i!==e.issuer)throw M(`unexpected "iss" (issuer) response parameter value`,P,{expected:e.issuer,parameters:n});switch(r){case void 0:case Qr:if(a!==void 0)throw M(`unexpected "state" response parameter encountered`,P,{expected:void 0,parameters:n});break;case Zr:break;default:if(N(r,`"expectedState" argument`),a!==r)throw M(a===void 0?`response parameter "state" missing`:`unexpected "state" response parameter value`,P,{expected:r,parameters:n})}if(Xr(n,`error`))throw new ir(`authorization response from the server is an error`,{cause:n});let o=Xr(n,`id_token`),s=Xr(n,`token`);if(o!==void 0||s!==void 0)throw new Pn(`implicit and hybrid flows are not supported`);return c=new URLSearchParams(n),wr.add(c),c;var c}async function ei(e){let t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Un;try{t=await e.json()}catch(t){throw n(e),M(`failed to parse "response" body as JSON`,Fr,t)}if(!Ln(t))throw M(`"response" body must be a top level object`,P,{body:t});return t}var ti=Symbol(),ni=Symbol(),ri=new TextEncoder,ii=new TextDecoder;function ai(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>127)throw TypeError(`non-ASCII string encountered in encode()`);t[n]=r}return t}function oi(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function si(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:ii.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=ii.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return oi(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var ci=function(e){return TypeError(`CryptoKey does not support this operation, its ${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`algorithm.name`} must be ${e}`)},li=(e,t)=>e.name===t;function ui(e,t){var n;if((n=e.hash,parseInt(n.name.slice(4),10))!==t)throw ci(`SHA-${t}`,`algorithm.hash`)}function di(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!li(e.algorithm,`HMAC`))throw ci(`HMAC`);ui(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!li(e.algorithm,`RSASSA-PKCS1-v1_5`))throw ci(`RSASSA-PKCS1-v1_5`);ui(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!li(e.algorithm,`RSA-PSS`))throw ci(`RSA-PSS`);ui(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!li(e.algorithm,`Ed25519`))throw ci(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!li(e.algorithm,t))throw ci(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!li(e.algorithm,`ECDSA`))throw ci(`ECDSA`);let n=function(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}(t);if(e.algorithm.namedCurve!==n)throw ci(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}(function(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)})(e,n)}function fi(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if((r=r.filter(Boolean)).length>2){let t=r.pop();e+=`one of type ${r.join(`, `)}, or ${t}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==`function`&&t.name)e+=` Received function ${t.name}`;else if(typeof t==`object`&&t){var a;(a=t.constructor)!=null&&a.name&&(e+=` Received an instance of ${t.constructor.name}`)}return e}var pi=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return fi(`Key for the ${e} algorithm must be `,t,...r)},mi=class extends Error{constructor(e,t){var n;super(e,t),k(this,`code`,`ERR_JOSE_GENERIC`),this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};k(mi,`code`,`ERR_JOSE_GENERIC`);var hi=class extends mi{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),k(this,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`),k(this,`claim`,void 0),k(this,`reason`,void 0),k(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};k(hi,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`);var gi=class extends mi{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),k(this,`code`,`ERR_JWT_EXPIRED`),k(this,`claim`,void 0),k(this,`reason`,void 0),k(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};k(gi,`code`,`ERR_JWT_EXPIRED`);var _i=class extends mi{constructor(){super(...arguments),k(this,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`)}};k(_i,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`);var vi=class extends mi{constructor(){super(...arguments),k(this,`code`,`ERR_JOSE_NOT_SUPPORTED`)}};k(vi,`code`,`ERR_JOSE_NOT_SUPPORTED`),k(class extends mi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`decryption operation failed`,arguments.length>1?arguments[1]:void 0),k(this,`code`,`ERR_JWE_DECRYPTION_FAILED`)}},`code`,`ERR_JWE_DECRYPTION_FAILED`),k(class extends mi{constructor(){super(...arguments),k(this,`code`,`ERR_JWE_INVALID`)}},`code`,`ERR_JWE_INVALID`);var yi=class extends mi{constructor(){super(...arguments),k(this,`code`,`ERR_JWS_INVALID`)}};k(yi,`code`,`ERR_JWS_INVALID`);var bi=class extends mi{constructor(){super(...arguments),k(this,`code`,`ERR_JWT_INVALID`)}};k(bi,`code`,`ERR_JWT_INVALID`),k(class extends mi{constructor(){super(...arguments),k(this,`code`,`ERR_JWK_INVALID`)}},`code`,`ERR_JWK_INVALID`);var xi=class extends mi{constructor(){super(...arguments),k(this,`code`,`ERR_JWKS_INVALID`)}};k(xi,`code`,`ERR_JWKS_INVALID`);var Si=class extends mi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`no applicable key found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),k(this,`code`,`ERR_JWKS_NO_MATCHING_KEY`)}};k(Si,`code`,`ERR_JWKS_NO_MATCHING_KEY`);var Ci=class extends mi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`multiple matching keys found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),k(this,Symbol.asyncIterator,void 0),k(this,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`)}};k(Ci,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`);var wi=class extends mi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`request timed out`,arguments.length>1?arguments[1]:void 0),k(this,`code`,`ERR_JWKS_TIMEOUT`)}};k(wi,`code`,`ERR_JWKS_TIMEOUT`);var Ti=class extends mi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`signature verification failed`,arguments.length>1?arguments[1]:void 0),k(this,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`)}};k(Ti,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`);var Ei=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},Di=e=>e?.[Symbol.toStringTag]===`KeyObject`,Oi=e=>Ei(e)||Di(e);function ki(e,t,n){try{return si(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}function Ai(e){if(typeof(t=e)!=`object`||t===null||Object.prototype.toString.call(e)!==`[object Object]`)return!1;var t;if(Object.getPrototypeOf(e)===null)return!0;let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}var ji=e=>Ai(e)&&typeof e.kty==`string`;async function Mi(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return fi(`Key must be `,e,...n)}(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return di(t,e,n),t}async function Ni(e,t,n,r){let i=await Mi(e,t,`verify`);(function(e,t){if(e.startsWith(`RS`)||e.startsWith(`PS`)){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,i);let a=function(e,t){let n=`SHA-${e.slice(-3)}`;switch(e){case`HS256`:case`HS384`:case`HS512`:return{hash:n,name:`HMAC`};case`PS256`:case`PS384`:case`PS512`:return{hash:n,name:`RSA-PSS`,saltLength:parseInt(e.slice(-3),10)>>3};case`RS256`:case`RS384`:case`RS512`:return{hash:n,name:`RSASSA-PKCS1-v1_5`};case`ES256`:case`ES384`:case`ES512`:return{hash:n,name:`ECDSA`,namedCurve:t.namedCurve};case`Ed25519`:case`EdDSA`:return{name:`Ed25519`};case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return{name:e};default:throw new vi(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var Pi=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;async function Fi(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=function(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new vi(Pi)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new vi(Pi)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new vi(Pi)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new vi(Pi)}break;default:throw new vi(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}(e),r=A({},e);return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??(!e.d&&!e.priv),e.key_ops??n)}var Ii=`given KeyObject instance cannot be used for this algorithm`,Li,Ri=async function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];Li||=new WeakMap;let i=Li.get(e);if(i!=null&&i[n])return i[n];let a=await Fi(A(A({},t),{},{alg:n}));return r&&Object.freeze(e),i?i[n]=a:Li.set(e,{[n]:a}),a};async function zi(e,t){if(e instanceof Uint8Array||Ei(e))return e;if(Di(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return((e,t)=>{Li||=new WeakMap;let n=Li.get(e);if(n!=null&&n[t])return n[t];let r=e.type===`public`,i=!!r,a;if(e.asymmetricKeyType===`x25519`){switch(t){case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:break;default:throw TypeError(Ii)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(Ii);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}switch(e.asymmetricKeyType){case`ml-dsa-44`:case`ml-dsa-65`:case`ml-dsa-87`:if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(Ii);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`rsa`){let n;switch(t){case`RSA-OAEP`:n=`SHA-1`;break;case`RS256`:case`PS256`:case`RSA-OAEP-256`:n=`SHA-256`;break;case`RS384`:case`PS384`:case`RSA-OAEP-384`:n=`SHA-384`;break;case`RS512`:case`PS512`:case`RSA-OAEP-512`:n=`SHA-512`;break;default:throw TypeError(Ii)}if(t.startsWith(`RSA-OAEP`))return e.toCryptoKey({name:`RSA-OAEP`,hash:n},i,r?[`encrypt`]:[`decrypt`]);a=e.toCryptoKey({name:t.startsWith(`PS`)?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:n},i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`ec`){let n=new Map([[`prime256v1`,`P-256`],[`secp384r1`,`P-384`],[`secp521r1`,`P-521`]]).get(e.asymmetricKeyDetails?.namedCurve);if(!n)throw TypeError(Ii);let o={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};o[t]&&n===o[t]&&(a=e.toCryptoKey({name:`ECDSA`,namedCurve:n},i,[r?`verify`:`sign`])),t.startsWith(`ECDH-ES`)&&(a=e.toCryptoKey({name:`ECDH`,namedCurve:n},i,r?[]:[`deriveBits`]))}if(!a)throw TypeError(Ii);return n?n[t]=a:Li.set(e,{[t]:a}),a})(e,t)}catch(e){if(e instanceof TypeError)throw e}return Ri(e,e.export({format:`jwk`}),t)}if(ji(e))return e.k?si(e.k):Ri(e,e,t,!0);throw Error(`unreachable`)}var Bi=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},Vi=e=>{let t=e.data[e.pos++];if(128&t){let n=127&t,r=0;for(let t=0;t<n;t++)r=r<<8|e.data[e.pos++];return r}return t},Hi=(e,t,n)=>{if(e.data[e.pos++]!==t)throw Error(n)},Ui=(e,t)=>{let n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},Wi=e=>{let t=(e=>(Hi(e,6,`Expected algorithm OID`),Ui(e,Vi(e))))(e);if(Bi(t,[43,101,110]))return`X25519`;if(!Bi(t,[42,134,72,206,61,2,1]))throw Error(`Unsupported key algorithm`);Hi(e,6,`Expected curve OID`);let n=Ui(e,Vi(e));for(let{name:e,oid:t}of[{name:`P-256`,oid:[42,134,72,206,61,3,1,7]},{name:`P-384`,oid:[43,129,4,0,34]},{name:`P-521`,oid:[43,129,4,0,35]}])if(Bi(n,t))return e;throw Error(`Unsupported named curve`)},Gi=async(e,t,n,r)=>{let i,a,o=e===`spki`,s=()=>o?[`verify`]:[`sign`];switch(n){case`PS256`:case`PS384`:case`PS512`:i={name:`RSA-PSS`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RS256`:case`RS384`:case`RS512`:i={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:i={name:`RSA-OAEP`,hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=o?[`encrypt`,`wrapKey`]:[`decrypt`,`unwrapKey`];break;case`ES256`:case`ES384`:case`ES512`:i={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[n]},a=s();break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:try{let e=r.getNamedCurve(t);i=e===`X25519`?{name:`X25519`}:{name:`ECDH`,namedCurve:e}}catch{throw new vi(`Invalid or unsupported key format`)}a=o?[]:[`deriveBits`];break;case`Ed25519`:case`EdDSA`:i={name:`Ed25519`},a=s();break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:i={name:n},a=s();break;default:throw new vi(`Invalid or unsupported "alg" (Algorithm) value`)}return crypto.subtle.importKey(e,t,i,r?.extractable??!!o,a)},Ki=(e,t,n)=>{var r;let i=((e,t)=>oi(e.replace(t,``)))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),a=n;return t!=null&&(r=t.startsWith)!=null&&r.call(t,`ECDH-ES`)&&(a||={},a.getNamedCurve=e=>{let t={data:e,pos:0};return function(e){Hi(e,48,`Invalid PKCS#8 structure`),Vi(e),Hi(e,2,`Expected version field`);let t=Vi(e);e.pos+=t,Hi(e,48,`Expected algorithm identifier`),Vi(e),e.pos}(t),Wi(t)}),Gi(`pkcs8`,i,t,a)},qi=e=>e?.[Symbol.toStringTag],Ji=(e,t,n)=>{if(t.use!==void 0){let e;switch(n){case`sign`:case`verify`:e=`sig`;break;case`encrypt`:case`decrypt`:e=`enc`}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){var r,i;let a;switch(!0){case n===`sign`||n===`verify`:case e===`dir`:case e.includes(`CBC-HS`):a=n;break;case e.startsWith(`PBES2`):a=`deriveBits`;break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):a=!e.includes(`GCM`)&&e.endsWith(`KW`)?n===`encrypt`?`wrapKey`:`unwrapKey`:n;break;case n===`encrypt`&&e.startsWith(`RSA`):a=`wrapKey`;break;case n===`decrypt`:a=e.startsWith(`RSA`)?`unwrapKey`:`deriveBits`}if(a&&!1===((r=t.key_ops)==null||(i=r.includes)==null?void 0:i.call(r,a)))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${a}" when present`)}return!0};function Yi(e,t,n){switch(e.substring(0,2)){case`A1`:case`A2`:case`di`:case`HS`:case`PB`:((e,t,n)=>{if(!(t instanceof Uint8Array)){if(ji(t)){if((e=>e.kty===`oct`&&typeof e.k==`string`)(t)&&Ji(e,t,n))return;throw TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!Oi(t))throw TypeError(pi(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${qi(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,n);break;default:((e,t,n)=>{if(ji(t))switch(n){case`decrypt`:case`sign`:if((e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`))(t)&&Ji(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if((e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0)(t)&&Ji(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!Oi(t))throw TypeError(pi(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${qi(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${qi(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${qi(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${qi(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${qi(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,n)}}var Xi,Zi,Qi,$i;(typeof navigator>`u`||(Xi=navigator.userAgent)==null||(Zi=Xi.startsWith)==null||!Zi.call(Xi,`Mozilla/5.0 `))&&($i=`openid-client/v6.8.3`,Qi={"user-agent":$i});var ea=e=>ta.get(e),ta,na;function ra(e){return e===void 0?(na||=new WeakMap,(e,t,n,r)=>{let i;return(i=na.get(t))||(function(e,t){if(typeof e!=`string`)throw sa(`${t} must be a string`,oa);if(e.length===0)throw sa(`${t} must not be empty`,aa)}(t.client_secret,`"metadata.client_secret"`),i=Zn(t.client_secret),na.set(t,i)),i(e,t,n,r)}):Zn(e)}var ia=Tn,aa=`ERR_INVALID_ARG_VALUE`,oa=`ERR_INVALID_ARG_TYPE`;function sa(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function ca(e){return async function(e){return N(e,`codeVerifier`),Nn(await crypto.subtle.digest(`SHA-256`,An(e)))}(e)}function la(){return Wn()}var ua=class extends Error{constructor(e,t){var n;super(e,t),k(this,`code`,void 0),this.name=this.constructor.name,this.code=t?.code,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function da(e,t,n){return new ua(e,{cause:t,code:n})}function fa(e){if(e instanceof TypeError||e instanceof ua||e instanceof rr||e instanceof ir||e instanceof ar)throw e;if(e instanceof Fn)switch(e.code){case Rr:throw da(`only requests to HTTPS are allowed`,e,e.code);case zr:throw da(`only requests to HTTP or HTTPS are allowed`,e,e.code);case Lr:throw da(`unexpected HTTP response status code`,e.cause,e.code);case Ir:throw da(`unexpected response content-type`,e.cause,e.code);case Fr:throw da(`parsing error occured`,e,e.code);case P:throw da(`invalid response encountered`,e,e.code);case Vr:throw da(`unexpected JWT claim value encountered`,e,e.code);case Hr:throw da(`unexpected JSON attribute value encountered`,e,e.code);case Br:throw da(`JWT timestamp claim value failed validation`,e,e.code);default:throw da(e.message,e,e.code)}if(e instanceof Pn)throw da(`unsupported operation`,e,e.code);if(e instanceof DOMException)switch(e.name){case`OperationError`:throw da(`runtime operation error`,e,Nr);case`NotSupportedError`:throw da(`runtime unsupported operation`,e,Nr);case`TimeoutError`:throw da(`operation timed out`,e,`OAUTH_TIMEOUT`);case`AbortError`:throw da(`operation aborted`,e,`OAUTH_ABORT`)}throw new ua(`something went wrong`,{cause:e})}async function pa(e,t,n,r,i){let a=new ha(await async function(e,t){var n;if(!(e instanceof URL))throw sa(`"server" must be an instance of URL`,oa);let r=!e.href.includes(`/.well-known/`),i=t?.timeout??30,a=AbortSignal.timeout(1e3*i),o=await(r?Vn(e,{algorithm:t?.algorithm,[Tn]:t?.[ia],[Sn]:t==null||(n=t.execute)==null?void 0:n.includes(xa),signal:a,headers:new Headers(Qi)}):(t?.[ia]||fetch)((er(e,t==null||(s=t.execute)==null||!s.includes(xa)),e.href),{headers:Object.fromEntries(new Headers(A({accept:`application/json`},Qi)).entries()),body:void 0,method:`GET`,redirect:`manual`,signal:a})).then(e=>async function(e,t){let n=e;if(!(n instanceof URL)&&n!==ti)throw j(`"expectedIssuerIdentifier" must be an instance of URL`,xn);if(!yn(t,Response))throw j(`"response" must be an instance of Response`,xn);if(t.status!==200)throw M(`"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)`,Lr,t);Gr(t);let r=await ei(t);if(N(r.issuer,`"response" body "issuer" property`,P,{body:r}),n!==ti&&new URL(r.issuer).href!==n.href)throw M(`"response" body "issuer" property does not match the expected value`,Hr,{expected:n.href,body:r,attribute:`issuer`});return r}(ti,e)).catch(fa);var s;return r&&new URL(o.issuer).href!==e.href&&(function(e,t,n){return!(e.origin!==`https://login.microsoftonline.com`||n!=null&&n.algorithm&&n.algorithm!==`oidc`||(t[ma]=!0,0))}(e,o,t)||function(e,t){return!(!e.hostname.endsWith(`.b2clogin.com`)||t!=null&&t.algorithm&&t.algorithm!==`oidc`)}(e,t)||(()=>{throw new ua(`discovered metadata issuer does not match the expected issuer`,{code:Hr,cause:{expected:e.href,body:o,attribute:`issuer`}})})()),o}(e,i),t,n,r),o=ea(a);if(i!=null&&i[ia]&&(o.fetch=i[ia]),i!=null&&i.timeout&&(o.timeout=i.timeout),i!=null&&i.execute)for(let e of i.execute)e(a);return a}new TextDecoder;var ma=Symbol(),ha=class{constructor(e,t,n,r){if(typeof t!=`string`||!t.length)throw sa(`"clientId" must be a non-empty string`,oa);if(typeof n==`string`&&(n={client_secret:n}),n?.client_id!==void 0&&t!==n.client_id)throw sa(`"clientId" and "metadata.client_id" must be the same`,aa);let i=A(A({},structuredClone(n)),{},{client_id:t}),a;i[Cn]=n?.[Cn]??0,i[wn]=n?.[wn]??30,a=r||(typeof i.client_secret==`string`&&i.client_secret.length?ra(i.client_secret):(e,t,n,r)=>{n.set(`client_id`,t.client_id)});let o=Object.freeze(i),s=structuredClone(e);ma in e&&(s[ni]=t=>{let{claims:{tid:n}}=t;return e.issuer.replace(`{tenantid}`,n)});let c=Object.freeze(s);ta||=new WeakMap,ta.set(this,{__proto__:null,as:c,c:o,auth:a,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let e=structuredClone(ea(this).as);return function(e){Object.defineProperties(e,function(e){return{supportsPKCE:{__proto__:null,value(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`S256`;return!0===e.code_challenge_methods_supported?.includes(t)}}}}(e))}(e),e}clientMetadata(){return structuredClone(ea(this).c)}get timeout(){return ea(this).timeout}set timeout(e){ea(this).timeout=e}get[ia](){return ea(this).fetch}set[ia](e){ea(this).fetch=e}};function ga(e){Object.defineProperties(e,function(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return br(this)}catch{return}}}}}(e))}async function _a(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3],i=e.headers.get(`retry-after`)?.trim();if(i===void 0)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else{let e=new Date(i);if(Number.isFinite(e.getTime())){let t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3))}}if(r&&!Number.isFinite(a))throw new Fn(`invalid Retry-After header value`,{cause:e});a>t&&await va(a-t,n)}function va(e,t){return new Promise((n,r)=>{let i=e=>{try{t.throwIfAborted()}catch(e){r(e);return}if(e<=0)return void n();let a=Math.min(e,5);setTimeout(()=>i(e-a),1e3*a)};i(e)})}async function ya(e,t){Da(e);let{as:n,c:r,auth:i,fetch:a,tlsOnly:o,timeout:s}=ea(e);return async function(e,t,n,r,i){Yn(e),Xn(t);let a=nr(e,`backchannel_authentication_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[Sn]),o=new URLSearchParams(r);o.set(`client_id`,t.client_id);let s=Rn(i?.headers);return s.set(`accept`,`application/json`),gr(e,t,n,a,o,s,i)}(n,r,i,t,{[Tn]:a,[Sn]:!o,headers:new Headers(Qi),signal:Oa(s)}).then(e=>async function(e,t,n){if(Yn(e),Xn(t),!yn(n,Response))throw j(`"response" must be an instance of Response`,xn);await pr(n,200,`Backchannel Authentication Endpoint`),Gr(n);let r=await ei(n);N(r.auth_req_id,`"response" body "auth_req_id" property`,P,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Hn(i,!0,`"response" body "expires_in" property`,P,{body:r}),r.expires_in=i,r.interval!==void 0&&Hn(r.interval,!1,`"response" body "interval" property`,P,{body:r}),r}(n,r,e)).catch(fa)}async function ba(e,t,n,r){Da(e),n=new URLSearchParams(n);let i=t.interval??5,a=r?.signal??AbortSignal.timeout(1e3*t.expires_in);try{await va(i,a)}catch(e){fa(e)}let{as:o,c:s,auth:c,fetch:l,tlsOnly:u,nonRepudiation:d,timeout:f,decrypt:p}=ea(e),m=(i,o)=>ba(e,A(A({},t),{},{interval:i}),n,A(A({},r),{},{signal:a,flag:o})),h=await async function(e,t,n,r,i){Yn(e),Xn(t),N(r,`"authReqId"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`auth_req_id`,r),_r(e,t,n,`urn:openid:params:grant-type:ciba`,a,i)}(o,s,c,t.auth_req_id,{[Tn]:l,[Sn]:!u,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(Qi),signal:a.aborted?a:Oa(f)}).catch(fa);if(h.status===503&&h.headers.has(`retry-after`))return await _a(h,i,a,!0),await h.body?.cancel(),m(i);let g=async function(e,t,n,r){return xr(e,t,n,void 0,r?.[Dn],r?.recognizedTokenTypes)}(o,s,h,{[Dn]:p}),_;try{_=await g}catch(e){if(ka(e,r))return m(i,Aa);if(e instanceof rr)switch(e.error){case`slow_down`:i+=5;case`authorization_pending`:return await _a(e.response,i,a),m(i)}fa(e)}return _.id_token&&await d?.(h),ga(_),_}function xa(e){ea(e).tlsOnly=!1}async function Sa(e,t,n,r,i){if(Da(e),!(i?.flag===Aa||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}(t,`Request`)))throw sa(`"currentUrl" must be an instance of URL, or Request`,oa);let a,o,{as:s,c,auth:l,fetch:u,tlsOnly:d,jarm:f,hybrid:p,nonRepudiation:m,timeout:h,decrypt:g,implicit:_}=ea(e);if(i?.flag===Aa)a=i.authResponse,o=i.redirectUri;else{if(!(t instanceof URL)){let e=t;switch(t=new URL(t.url),e.method){case`GET`:break;case`POST`:let n=new URLSearchParams(await Jr(e));if(p)t.hash=n.toString();else for(let[e,r]of n.entries())t.searchParams.append(e,r);break;default:throw sa(`unexpected Request HTTP method`,aa)}}switch(o=function(e){return(e=new URL(e)).search=``,e.hash=``,e.href}(t),!0){case!!f:a=await f(t,n?.expectedState);break;case!!p:a=await p(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!_:throw TypeError(`authorizationCodeGrant() cannot be used by response_type=id_token clients`);default:try{a=$r(s,c,t.searchParams,n?.expectedState)}catch(e){fa(e)}}}let v=await async function(e,t,n,r,i,a,o){if(Yn(e),Xn(t),!wr.has(r))throw j(`"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()`,bn);N(i,`"redirectUri"`);let s=Xr(r,`code`);if(!s)throw M(`no authorization code in "callbackParameters"`,P);let c=new URLSearchParams(o?.additionalParameters);return c.set(`redirect_uri`,i),c.set(`code`,s),a!==Tr&&(N(a,`"codeVerifier"`),c.set(`code_verifier`,a)),_r(e,t,n,`authorization_code`,c,o)}(s,c,l,a,o,n?.pkceCodeVerifier||Tr,{additionalParameters:r,[Tn]:u,[Sn]:!d,DPoP:i?.DPoP,headers:new Headers(Qi),signal:Oa(h)}).catch(fa);typeof n?.expectedNonce!=`string`&&typeof n?.maxAge!=`number`||(n.idTokenExpected=!0);let ee=Ar(s,c,v,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[Dn]:g}),y;try{y=await ee}catch(t){if(ka(t,i))return Sa(e,void 0,n,r,A(A({},i),{},{flag:Aa,authResponse:a,redirectUri:o}));fa(t)}return y.id_token&&await m?.(v),ga(y),y}async function Ca(e,t,n,r){Da(e),n=new URLSearchParams(n);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,nonRepudiation:l,timeout:u,decrypt:d}=ea(e),f=await async function(e,t,n,r,i){Yn(e),Xn(t),N(r,`"refreshToken"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`refresh_token`,r),_r(e,t,n,`refresh_token`,a,i)}(i,a,o,t,{[Tn]:s,[Sn]:!c,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(Qi),signal:Oa(u)}).catch(fa),p=async function(e,t,n,r){return xr(e,t,n,void 0,r?.[Dn],r?.recognizedTokenTypes)}(i,a,f,{[Dn]:d}),m;try{m=await p}catch(i){if(ka(i,r))return Ca(e,t,n,A(A({},r),{},{flag:Aa}));fa(i)}return m.id_token&&await l?.(f),ga(m),m}async function wa(e,t,n){Da(e),t=new URLSearchParams(t);let{as:r,c:i,auth:a,fetch:o,tlsOnly:s,timeout:c}=ea(e),l=async function(e,t,n,r){return xr(e,t,n,void 0,r?.[Dn],r?.recognizedTokenTypes)}(r,i,await async function(e,t,n,r,i){return Yn(e),Xn(t),_r(e,t,n,`client_credentials`,new URLSearchParams(r),i)}(r,i,a,t,{[Tn]:o,[Sn]:!s,DPoP:n?.DPoP,headers:new Headers(Qi),signal:Oa(c)}).catch(fa)),u;try{u=await l}catch(r){if(ka(r,n))return wa(e,t,A(A({},n),{},{flag:Aa}));fa(r)}return ga(u),u}function Ta(e,t){Da(e);let{as:n,c:r,tlsOnly:i,hybrid:a,jarm:o,implicit:s}=ea(e),c=nr(n,`authorization_endpoint`,!1,i);if((t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id),!t.has(`request_uri`)&&!t.has(`request`)){if(t.has(`response_type`)||t.set(`response_type`,a?`code id_token`:s?`id_token`:`code`),s&&!t.has(`nonce`))throw sa(`response_type=id_token clients must provide a nonce parameter in their authorization request parameters`,aa);o&&t.set(`response_mode`,`jwt`)}for(let[e,n]of t.entries())c.searchParams.append(e,n);return c}async function Ea(e,t,n){Da(e);let r=Ta(e,t),{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l}=ea(e),u=async function(e,t,n){if(Yn(e),Xn(t),!yn(n,Response))throw j(`"response" must be an instance of Response`,xn);await pr(n,201,`Pushed Authorization Request Endpoint`),Gr(n);let r=await ei(n);N(r.request_uri,`"response" body "request_uri" property`,P,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Hn(i,!0,`"response" body "expires_in" property`,P,{body:r}),r.expires_in=i,r}(i,a,await async function(e,t,n,r,i){var a;Yn(e),Xn(t);let o=nr(e,`pushed_authorization_request_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[Sn]),s=new URLSearchParams(r);s.set(`client_id`,t.client_id);let c=Rn(i?.headers);c.set(`accept`,`application/json`),i?.DPoP!==void 0&&(mr(i.DPoP),await i.DPoP.addProof(o,c,`POST`));let l=await gr(e,t,n,o,s,c,i);return i==null||(a=i.DPoP)==null||a.cacheNonce(l,o),l}(i,a,o,r.searchParams,{[Tn]:s,[Sn]:!c,DPoP:n?.DPoP,headers:new Headers(Qi),signal:Oa(l)}).catch(fa)),d;try{d=await u}catch(r){if(ka(r,n))return Ea(e,t,A(A({},n),{},{flag:Aa}));fa(r)}return Ta(e,{request_uri:d.request_uri})}function Da(e){if(!(e instanceof ha))throw sa(`"config" must be an instance of Configuration`,oa);if(Object.getPrototypeOf(e)!==ha.prototype)throw sa(`subclassing Configuration is not allowed`,aa)}function Oa(e){return e?AbortSignal.timeout(1e3*e):void 0}function ka(e,t){return!(t==null||!t.DPoP||t.flag===Aa)&&function(e){if(e instanceof ar){let{0:t,length:n}=e.cause;return n===1&&t.scheme===`dpop`&&t.parameters.error===`use_dpop_nonce`}return e instanceof rr&&e.error===`use_dpop_nonce`}(e)}Object.freeze(ha.prototype);var Aa=Symbol();async function ja(e,t,n,r){Da(e);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l,decrypt:u}=ea(e),d=await async function(e,t,n,r,i,a){return Yn(e),Xn(t),N(r,`"grantType"`),_r(e,t,n,r,new URLSearchParams(i),a)}(i,a,o,t,new URLSearchParams(n),{[Tn]:s,[Sn]:!c,DPoP:r?.DPoP,headers:new Headers(Qi),signal:Oa(l)}).then(e=>{let n;return t===`urn:ietf:params:oauth:grant-type:token-exchange`&&(n={n_a:()=>{}}),async function(e,t,n,r){return xr(e,t,n,void 0,r?.[Dn],r?.recognizedTokenTypes)}(i,a,e,{[Dn]:u,recognizedTokenTypes:n})}).catch(fa);return ga(d),d}async function Ma(e,t,n){if(!Ai(e))throw new yi(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new yi(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new yi(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new yi(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new yi(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!Ai(e.header))throw new yi(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=si(e.protected);r=JSON.parse(ii.decode(t))}catch{throw new yi(`JWS Protected Header is invalid`)}if(!function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.filter(Boolean);if(r.length===0||r.length===1)return!0;let i;for(let e of r){let t=Object.keys(e);if(i&&i.size!==0)for(let e of t){if(i.has(e))return!1;i.add(e)}else i=new Set(t)}return!0}(r,e.header))throw new yi(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i=A(A({},r),e.header),a=function(e,t,n,r,i){if(i.crit!==void 0&&r?.crit===void 0)throw new e(`"crit" (Critical) Header Parameter MUST be integrity protected`);if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(e=>typeof e!=`string`||e.length===0))throw new e(`"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present`);let a;a=n===void 0?t:new Map([...Object.entries(n),...t.entries()]);for(let t of r.crit){if(!a.has(t))throw new vi(`Extension Header Parameter "${t}" is not recognized`);if(i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&r[t]===void 0)throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(r.crit)}(yi,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new yi(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new yi(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&function(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some(e=>typeof e!=`string`)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new _i(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new yi(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new yi(`JWS Payload must be a string or an Uint8Array instance`);let l=!1;typeof t==`function`&&(t=await t(r,e),l=!0),Yi(s,t,`verify`);let u=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.reduce((e,t)=>{let{length:n}=t;return e+n},0),i=new Uint8Array(r),a=0;for(let e of t)i.set(e,a),a+=e.length;return i}(e.protected===void 0?new Uint8Array:ai(e.protected),ai(`.`),typeof e.payload==`string`?o?ai(e.payload):ri.encode(e.payload):e.payload),d=ki(e.signature,`signature`,yi),f=await zi(t,s);if(!await Ni(s,f,d,u))throw new Ti;let p;p=o?ki(e.payload,`payload`,yi):typeof e.payload==`string`?ri.encode(e.payload):e.payload;let m={payload:p};return e.protected!==void 0&&(m.protectedHeader=r),e.header!==void 0&&(m.unprotectedHeader=e.header),l?A(A({},m),{},{key:f}):m}var Na=86400,Pa=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Fa(e){let t=Pa.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r;switch(t[3].toLowerCase()){case`sec`:case`secs`:case`second`:case`seconds`:case`s`:r=Math.round(n);break;case`minute`:case`minutes`:case`min`:case`mins`:case`m`:r=Math.round(60*n);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:r=Math.round(3600*n);break;case`day`:case`days`:case`d`:r=Math.round(n*Na);break;case`week`:case`weeks`:case`w`:r=Math.round(604800*n);break;default:r=Math.round(31557600*n)}return t[1]===`-`||t[4]===`ago`?-r:r}var Ia=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`;function La(e,t){let n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};try{n=JSON.parse(ii.decode(t))}catch{}if(!Ai(n))throw new bi(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=r;if(i&&(typeof e.typ!=`string`||Ia(e.typ)!==Ia(i)))throw new hi(`unexpected "typ" JWT header value`,n,`typ`,`check_failed`);let{requiredClaims:a=[],issuer:o,subject:s,audience:c,maxTokenAge:l}=r,u=[...a];l!==void 0&&u.push(`iat`),c!==void 0&&u.push(`aud`),s!==void 0&&u.push(`sub`),o!==void 0&&u.push(`iss`);for(let e of new Set(u.reverse()))if(!(e in n))throw new hi(`missing required "${e}" claim`,n,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(n.iss))throw new hi(`unexpected "iss" claim value`,n,`iss`,`check_failed`);if(s&&n.sub!==s)throw new hi(`unexpected "sub" claim value`,n,`sub`,`check_failed`);if(c&&(d=n.aud,f=typeof c==`string`?[c]:c,!(typeof d==`string`?f.includes(d):Array.isArray(d)&&f.some(Set.prototype.has.bind(new Set(d))))))throw new hi(`unexpected "aud" claim value`,n,`aud`,`check_failed`);var d,f;let p;switch(typeof r.clockTolerance){case`string`:p=Fa(r.clockTolerance);break;case`number`:p=r.clockTolerance;break;case`undefined`:p=0;break;default:throw TypeError(`Invalid clockTolerance option type`)}let{currentDate:m}=r,h=(g=m||new Date,Math.floor(g.getTime()/1e3));var g;if((n.iat!==void 0||l)&&typeof n.iat!=`number`)throw new hi(`"iat" claim must be a number`,n,`iat`,`invalid`);if(n.nbf!==void 0){if(typeof n.nbf!=`number`)throw new hi(`"nbf" claim must be a number`,n,`nbf`,`invalid`);if(n.nbf>h+p)throw new hi(`"nbf" claim timestamp check failed`,n,`nbf`,`check_failed`)}if(n.exp!==void 0){if(typeof n.exp!=`number`)throw new hi(`"exp" claim must be a number`,n,`exp`,`invalid`);if(n.exp<=h-p)throw new gi(`"exp" claim timestamp check failed`,n,`exp`,`check_failed`)}if(l){let e=h-n.iat;if(e-p>(typeof l==`number`?l:Fa(l)))throw new gi(`"iat" claim timestamp check failed (too far in the past)`,n,`iat`,`check_failed`);if(e<0-p)throw new hi(`"iat" claim timestamp check failed (it should be in the past)`,n,`iat`,`check_failed`)}return n}async function Ra(e,t,n){var r;let i=await async function(e,t,n){if(e instanceof Uint8Array&&(e=ii.decode(e)),typeof e!=`string`)throw new yi(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new yi(`Invalid Compact JWS`);let s=await Ma({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return typeof t==`function`?A(A({},c),{},{key:s.key}):c}(e,t,n);if((r=i.protectedHeader.crit)!=null&&r.includes(`b64`)&&!1===i.protectedHeader.b64)throw new bi(`JWTs MUST NOT use unencoded payload`);let a={payload:La(i.protectedHeader,i.payload,n),protectedHeader:i.protectedHeader};return typeof t==`function`?A(A({},a),{},{key:i.key}):a}function za(e){return Ai(e)}var Ba,Va,Ha=new WeakMap,Ua=new WeakMap,Wa=class{constructor(e){if(D(this,Ha,void 0),D(this,Ua,new WeakMap),!function(e){return e&&typeof e==`object`&&Array.isArray(e.keys)&&e.keys.every(za)}(e))throw new xi(`JSON Web Key Set malformed`);O(Ha,this,structuredClone(e))}jwks(){return E(Ha,this)}async getKey(e,t){let{alg:n,kid:r}=A(A({},e),t?.header),i=function(e){switch(typeof e==`string`&&e.slice(0,2)){case`RS`:case`PS`:return`RSA`;case`ES`:return`EC`;case`Ed`:return`OKP`;case`ML`:return`AKP`;default:throw new vi(`Unsupported "alg" value for a JSON Web Key Set`)}}(n),a=E(Ha,this).keys.filter(e=>{let t=i===e.kty;if(t&&typeof r==`string`&&(t=r===e.kid),!t||typeof e.alg!=`string`&&i!==`AKP`||(t=n===e.alg),t&&typeof e.use==`string`&&(t=e.use===`sig`),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes(`verify`)),t)switch(n){case`ES256`:t=e.crv===`P-256`;break;case`ES384`:t=e.crv===`P-384`;break;case`ES512`:t=e.crv===`P-521`;break;case`Ed25519`:case`EdDSA`:t=e.crv===`Ed25519`}return t}),{0:o,length:s}=a;if(s===0)throw new Si;if(s!==1){let e=new Ci,t=E(Ua,this);throw e[Symbol.asyncIterator]=mn(function*(){for(let e of a)try{yield yield un(Ga(t,e,n))}catch{}}),e}return Ga(E(Ua,this),o,n)}};async function Ga(e,t,n){let r=e.get(t)||e.set(t,{}).get(t);if(r[n]===void 0){let e=await async function(e,t,n){if(!Ai(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return si(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new vi(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return Fi(A(A({},e),{},{alg:t,ext:r}));case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return Fi(A(A({},e),{},{ext:r}));case`EC`:case`OKP`:return Fi(A(A({},e),{},{alg:t,ext:r}));default:throw new vi(`Unsupported "kty" (Key Type) Parameter value`)}}(A(A({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||e.type!==`public`)throw new xi(`JSON Web Key Set members must be public keys`);r[n]=e}return r[n]}function Ka(e){let t=new Wa(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}var qa;(typeof navigator>`u`||(Ba=navigator.userAgent)==null||(Va=Ba.startsWith)==null||!Va.call(Ba,`Mozilla/5.0 `))&&(qa=`jose/v6.2.2`);var Ja=Symbol(),Ya=Symbol(),Xa=new WeakMap,Za=new WeakMap,Qa=new WeakMap,$a=new WeakMap,eo=new WeakMap,to=new WeakMap,no=new WeakMap,ro=new WeakMap,io=new WeakMap,ao=new WeakMap,oo=class{constructor(e,t){if(D(this,Xa,void 0),D(this,Za,void 0),D(this,Qa,void 0),D(this,$a,void 0),D(this,eo,void 0),D(this,to,void 0),D(this,no,void 0),D(this,ro,void 0),D(this,io,void 0),D(this,ao,void 0),!(e instanceof URL))throw TypeError(`url must be an instance of URL`);var n,r;O(Xa,this,new URL(e.href)),O(Za,this,typeof t?.timeoutDuration==`number`?t?.timeoutDuration:5e3),O(Qa,this,typeof t?.cooldownDuration==`number`?t?.cooldownDuration:3e4),O($a,this,typeof t?.cacheMaxAge==`number`?t?.cacheMaxAge:6e5),O(no,this,new Headers(t?.headers)),qa&&!E(no,this).has(`User-Agent`)&&E(no,this).set(`User-Agent`,qa),E(no,this).has(`accept`)||(E(no,this).set(`accept`,`application/json`),E(no,this).append(`accept`,`application/jwk-set+json`)),O(ro,this,t?.[Ja]),t?.[Ya]!==void 0&&(O(ao,this,t?.[Ya]),n=t?.[Ya],r=E($a,this),typeof n==`object`&&n&&`uat`in n&&typeof n.uat==`number`&&!(Date.now()-n.uat>=r)&&`jwks`in n&&Ai(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,Ai)&&(O(eo,this,E(ao,this).uat),O(io,this,Ka(E(ao,this).jwks))))}pendingFetch(){return!!E(to,this)}coolingDown(){return typeof E(eo,this)==`number`&&Date.now()<E(eo,this)+E(Qa,this)}fresh(){return typeof E(eo,this)==`number`&&Date.now()<E(eo,this)+E($a,this)}jwks(){return E(io,this)?.jwks()}async getKey(e,t){E(io,this)&&this.fresh()||await this.reload();try{return await E(io,this).call(this,e,t)}catch(n){if(n instanceof Si&&!1===this.coolingDown())return await this.reload(),E(io,this).call(this,e,t);throw n}}async reload(){E(to,this)&&(typeof WebSocketPair<`u`||typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`||typeof EdgeRuntime<`u`&&EdgeRuntime===`vercel`)&&O(to,this,void 0),E(to,this)||O(to,this,async function(e,t,n){let r=await(arguments.length>3&&arguments[3]!==void 0?arguments[3]:fetch)(e,{method:`GET`,signal:n,redirect:`manual`,headers:t}).catch(e=>{throw e.name===`TimeoutError`?new wi:e});if(r.status!==200)throw new mi(`Expected 200 OK from the JSON Web Key Set HTTP response`);try{return await r.json()}catch{throw new mi(`Failed to parse the JSON Web Key Set HTTP response as JSON`)}}(E(Xa,this).href,E(no,this),AbortSignal.timeout(E(Za,this)),E(ro,this)).then(e=>{O(io,this,Ka(e)),E(ao,this)&&(E(ao,this).uat=Date.now(),E(ao,this).jwks=e),O(eo,this,Date.now()),O(to,this,void 0)}).catch(e=>{throw O(to,this,void 0),e})),await E(to,this)}},so=[`mfaToken`],co=[`mfaToken`],lo,uo,fo,po,mo,ho,go,_o,vo,F,yo,bo,xo,So,Co,I,wo=class extends Error{constructor(e,t){super(t),k(this,`code`,void 0),this.name=`NotSupportedError`,this.code=e}},To=class extends Error{constructor(e,t,n){super(t),k(this,`cause`,void 0),k(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},Eo=class extends To{constructor(e,t){super(`token_by_code_error`,e,t),this.name=`TokenByCodeError`}},Do=class extends To{constructor(e,t){super(`token_by_client_credentials_error`,e,t),this.name=`TokenByClientCredentialsError`}},Oo=class extends To{constructor(e,t){super(`token_by_refresh_token_error`,e,t),this.name=`TokenByRefreshTokenError`}},ko=class extends To{constructor(e,t){super(`token_by_password_error`,e,t),this.name=`TokenByPasswordError`}},Ao=class extends To{constructor(e,t){super(`token_for_connection_error`,e,t),this.name=`TokenForConnectionErrorCode`}},jo=class extends To{constructor(e,t){super(`token_exchange_error`,e,t),this.name=`TokenExchangeError`}},Mo=class extends Error{constructor(e){super(e),k(this,`code`,`verify_logout_token_error`),this.name=`VerifyLogoutTokenError`}},No=class extends To{constructor(e){super(`backchannel_authentication_error`,`There was an error when trying to use Client-Initiated Backchannel Authentication.`,e),k(this,`code`,`backchannel_authentication_error`),this.name=`BackchannelAuthenticationError`}},Po=class extends To{constructor(e){super(`build_authorization_url_error`,`There was an error when trying to build the authorization URL.`,e),this.name=`BuildAuthorizationUrlError`}},Fo=class extends To{constructor(e){super(`build_link_user_url_error`,`There was an error when trying to build the Link User URL.`,e),this.name=`BuildLinkUserUrlError`}},Io=class extends To{constructor(e){super(`build_unlink_user_url_error`,`There was an error when trying to build the Unlink User URL.`,e),this.name=`BuildUnlinkUserUrlError`}},Lo=class extends Error{constructor(){super(`The client secret or client assertion signing key must be provided.`),k(this,`code`,`missing_client_auth_error`),this.name=`MissingClientAuthError`}};function Ro(e){return Object.entries(e).filter(e=>{let[,t]=e;return t!==void 0}).reduce((e,t)=>A(A({},e),{},{[t[0]]:t[1]}),{})}var zo=class extends Error{constructor(e,t,n){super(t),k(this,`cause`,void 0),k(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},Bo=class extends zo{constructor(e,t){super(`mfa_list_authenticators_error`,e,t),this.name=`MfaListAuthenticatorsError`}},Vo=class extends zo{constructor(e,t){super(`mfa_enrollment_error`,e,t),this.name=`MfaEnrollmentError`}},Ho=class extends zo{constructor(e,t){super(`mfa_delete_authenticator_error`,e,t),this.name=`MfaDeleteAuthenticatorError`}},Uo=class extends zo{constructor(e,t){super(`mfa_challenge_error`,e,t),this.name=`MfaChallengeError`}};function Wo(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var Go=(lo=new WeakMap,uo=new WeakMap,fo=new WeakMap,class{constructor(e){D(this,lo,void 0),D(this,uo,void 0),D(this,fo,void 0),O(lo,this,`https://${e.domain}`),O(uo,this,e.clientId),O(fo,this,e.customFetch??function(){return fetch(...arguments)})}async listAuthenticators(e){let t=`${E(lo,this)}/mfa/authenticators`,{mfaToken:n}=e,r=await E(fo,this).call(this,t,{method:`GET`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!r.ok){let e=await r.json();throw new Bo(e.error_description||`Failed to list authenticators`,e)}return(await r.json()).map(Wo)}async enrollAuthenticator(e){let t=`${E(lo,this)}/mfa/associate`,{mfaToken:n}=e,r=pn(e,so),i={authenticator_types:r.authenticatorTypes};`oobChannels`in r&&(i.oob_channels=r.oobChannels),`phoneNumber`in r&&r.phoneNumber&&(i.phone_number=r.phoneNumber),`email`in r&&r.email&&(i.email=r.email);let a=await E(fo,this).call(this,t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new Vo(e.error_description||`Failed to enroll authenticator`,e)}return function(e){if(e.authenticator_type===`otp`)return{authenticatorType:`otp`,secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if(e.authenticator_type===`oob`)return{authenticatorType:`oob`,oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes};throw Error(`Unexpected authenticator type: ${e.authenticator_type}`)}(await a.json())}async deleteAuthenticator(e){let{authenticatorId:t,mfaToken:n}=e,r=`${E(lo,this)}/mfa/authenticators/${encodeURIComponent(t)}`,i=await E(fo,this).call(this,r,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!i.ok){let e=await i.json();throw new Ho(e.error_description||`Failed to delete authenticator`,e)}}async challengeAuthenticator(e){let t=`${E(lo,this)}/mfa/challenge`,{mfaToken:n}=e,r=pn(e,co),i={mfa_token:n,client_id:E(uo,this),challenge_type:r.challengeType};r.authenticatorId&&(i.authenticator_id=r.authenticatorId);let a=await E(fo,this).call(this,t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new Uo(e.error_description||`Failed to challenge authenticator`,e)}return function(e){let t={challengeType:e.challenge_type};return e.oob_code!==void 0&&(t.oobCode=e.oob_code),e.binding_method!==void 0&&(t.bindingMethod=e.binding_method),t}(await a.json())}}),Ko=class e{constructor(e,t,n,r,i,a,o){k(this,`accessToken`,void 0),k(this,`idToken`,void 0),k(this,`refreshToken`,void 0),k(this,`expiresAt`,void 0),k(this,`scope`,void 0),k(this,`claims`,void 0),k(this,`authorizationDetails`,void 0),k(this,`tokenType`,void 0),k(this,`issuedTokenType`,void 0),this.accessToken=e,this.idToken=n,this.refreshToken=r,this.expiresAt=t,this.scope=i,this.claims=a,this.authorizationDetails=o}static fromTokenEndpointResponse(t){let n=t.id_token?t.claims():void 0,r=new e(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return r.tokenType=t.token_type,r.issuedTokenType=t.issued_token_type,r}},qo=(po=new WeakMap,mo=new WeakMap,ho=new WeakMap,class{constructor(e,t){D(this,po,new Map),D(this,mo,void 0),D(this,ho,void 0),O(ho,this,Math.max(1,Math.floor(e))),O(mo,this,Math.max(0,Math.floor(t)))}get(e){let t=E(po,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return E(po,this).delete(e),E(po,this).set(e,t),t.value;E(po,this).delete(e)}}set(e,t){for(E(po,this).has(e)&&E(po,this).delete(e),E(po,this).set(e,{value:t,expiresAt:Date.now()+E(mo,this)});E(po,this).size>E(ho,this);){let e=E(po,this).keys().next().value;if(e===void 0)break;E(po,this).delete(e)}}}),Jo=new Map;function Yo(e){return{ttlMs:1e3*(typeof e?.ttl==`number`?e.ttl:600),maxEntries:typeof e?.maxEntries==`number`&&e.maxEntries>0?e.maxEntries:100}}var Xo=class{static createDiscoveryCache(e){let t=(n=e.maxEntries,r=e.ttlMs,`${n}:${r}`);var n,r;let i=(a=t,Jo.get(a));var a;return i||(i=new qo(e.maxEntries,e.ttlMs),Jo.set(t,i)),i}static createJwksCache(){return{}}},Zo=`openid profile email offline_access`,Qo=Object.freeze(new Set([`grant_type`,`client_id`,`client_secret`,`client_assertion`,`client_assertion_type`,`subject_token`,`subject_token_type`,`requested_token_type`,`actor_token`,`actor_token_type`,`audience`,`aud`,`resource`,`resources`,`resource_indicator`,`scope`,`connection`,`login_hint`,`organization`,`assertion`]));function $o(e){if(e==null)throw new jo(`subject_token is required`);if(typeof e!=`string`)throw new jo(`subject_token must be a string`);if(e.trim().length===0)throw new jo(`subject_token cannot be blank or whitespace`);if(e!==e.trim())throw new jo(`subject_token must not include leading or trailing whitespace`);if(/^bearer\s+/i.test(e))throw new jo(`subject_token must not include the 'Bearer ' prefix`)}function es(e,t){if(t){for(let[n,r]of Object.entries(t))if(!Qo.has(n))if(Array.isArray(r)){if(r.length>20)throw new jo(`Parameter '${n}' exceeds maximum array size of 20`);r.forEach(t=>{e.append(n,t)})}else e.append(n,r)}}var ts=`urn:ietf:params:oauth:token-type:access_token`,ns=(go=new WeakMap,_o=new WeakMap,vo=new WeakMap,F=new WeakMap,yo=new WeakMap,bo=new WeakMap,xo=new WeakMap,So=new WeakMap,Co=new WeakMap,I=new WeakSet,class{constructor(e){var t;if(function(e,t){dn(e,t),t.add(e)}(this,I),D(this,go,void 0),D(this,_o,void 0),D(this,vo,void 0),D(this,F,void 0),D(this,yo,void 0),D(this,bo,void 0),D(this,xo,void 0),D(this,So,void 0),D(this,Co,void 0),k(this,`mfa`,void 0),O(F,this,e),e.useMtls&&!e.customFetch)throw new wo(`mtls_without_custom_fetch_not_supported`,`Using mTLS without a custom fetch implementation is not supported`);O(yo,this,function(e,t){if(!1===t.enabled)return e;let n={name:t.name,version:t.version},r=btoa(JSON.stringify(n));return async(t,n)=>{let i=t instanceof Request?new Headers(t.headers):new Headers;return n!=null&&n.headers&&new Headers(n.headers).forEach((e,t)=>{i.set(t,e)}),i.set(`Auth0-Client`,r),e(t,A(A({},n),{},{headers:i}))}}(e.customFetch??function(){return fetch(...arguments)},!1===(t=e.telemetry)?.enabled?t:{enabled:!0,name:t?.name??`@auth0/auth0-auth-js`,version:t?.version??`1.6.0`}));let n=Yo(e.discoveryCache);O(xo,this,Xo.createDiscoveryCache(n)),O(So,this,new Map),O(Co,this,Xo.createJwksCache()),this.mfa=new Go({domain:E(F,this).domain,clientId:E(F,this).clientId,customFetch:E(yo,this)})}async getServerMetadata(){let{serverMetadata:e}=await T(I,this,as).call(this);return e}async buildAuthorizationUrl(e){let{serverMetadata:t}=await T(I,this,as).call(this);if(e!=null&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new wo(`par_not_supported_error`,`The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par`);try{return await T(I,this,ls).call(this,e)}catch(e){throw new Po(e)}}async buildLinkUserUrl(e){try{let t=await T(I,this,ls).call(this,{authorizationParams:A(A({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:`openid link_account offline_access`,id_token_hint:e.idToken})});return{linkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new Fo(e)}}async buildUnlinkUserUrl(e){try{let t=await T(I,this,ls).call(this,{authorizationParams:A(A({},e.authorizationParams),{},{requested_connection:e.connection,scope:`openid unlink_account`,id_token_hint:e.idToken})});return{unlinkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new Io(e)}}async backchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await T(I,this,as).call(this),r=Ro(A(A({},E(F,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(A(A({scope:Zo},r),{},{client_id:E(F,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await ba(t,await ya(t,i));return Ko.fromTokenEndpointResponse(e)}catch(e){throw new No(e)}}async initiateBackchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await T(I,this,as).call(this),r=Ro(A(A({},E(F,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(A(A({scope:Zo},r),{},{client_id:E(F,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await ya(t,i);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new No(e)}}async backchannelAuthenticationGrant(e){let{authReqId:t}=e,{configuration:n}=await T(I,this,as).call(this),r=new URLSearchParams({auth_req_id:t});try{let e=await ja(n,`urn:openid:params:grant-type:ciba`,r);return Ko.fromTokenEndpointResponse(e)}catch(e){throw new No(e)}}async getTokenForConnection(e){if(e.refreshToken&&e.accessToken)throw new Ao(`Either a refresh or access token should be specified, but not both.`);let t=e.accessToken??e.refreshToken;if(!t)throw new Ao(`Either a refresh or access token must be specified.`);try{return await this.exchangeToken({connection:e.connection,subjectToken:t,subjectTokenType:e.accessToken?ts:`urn:ietf:params:oauth:token-type:refresh_token`,loginHint:e.loginHint})}catch(e){throw e instanceof jo?new Ao(e.message,e.cause):e}}async exchangeToken(e){return`connection`in e?T(I,this,os).call(this,e):T(I,this,ss).call(this,e)}async getTokenByCode(e,t){let{configuration:n}=await T(I,this,as).call(this);try{let r=await Sa(n,e,{pkceCodeVerifier:t.codeVerifier});return Ko.fromTokenEndpointResponse(r)}catch(e){throw new Eo(`There was an error while trying to request a token.`,e)}}async getTokenByRefreshToken(e){let{configuration:t}=await T(I,this,as).call(this),n=new URLSearchParams;e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope);try{let r=await Ca(t,e.refreshToken,n);return Ko.fromTokenEndpointResponse(r)}catch(e){throw new Oo(`The access token has expired and there was an error while trying to refresh it.`,e)}}async getTokenByPassword(e){let{configuration:t}=await T(I,this,as).call(this),n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.realm&&n.append(`realm`,e.realm);let r=t;if(e.auth0ForwardedFor){let n=await T(I,this,cs).call(this);r=new ha(t.serverMetadata(),E(F,this).clientId,E(F,this).clientSecret,n),r[ia]=(t,n)=>E(yo,this).call(this,t,A(A({},n),{},{headers:A(A({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}try{let e=await ja(r,`password`,n);return Ko.fromTokenEndpointResponse(e)}catch(e){throw new ko(`There was an error while trying to request a token.`,e)}}async getTokenByClientCredentials(e){let{configuration:t}=await T(I,this,as).call(this);try{let n=new URLSearchParams({audience:e.audience});e.organization&&n.append(`organization`,e.organization);let r=await wa(t,n);return Ko.fromTokenEndpointResponse(r)}catch(e){throw new Do(`There was an error while trying to request a token.`,e)}}async buildLogoutUrl(e){let{configuration:t,serverMetadata:n}=await T(I,this,as).call(this);if(!n.end_session_endpoint){let t=new URL(`https://${E(F,this).domain}/v2/logout`);return t.searchParams.set(`returnTo`,e.returnTo),t.searchParams.set(`client_id`,E(F,this).clientId),t}return function(e,t){Da(e);let{as:n,c:r,tlsOnly:i}=ea(e),a=nr(n,`end_session_endpoint`,!1,i);(t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id);for(let[e,n]of t.entries())a.searchParams.append(e,n);return a}(t,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){let{serverMetadata:t}=await T(I,this,as).call(this),n=Yo(E(F,this).discoveryCache),r=t.jwks_uri;E(bo,this)||O(bo,this,function(e,t){let n=new oo(e,t),r=async(e,t)=>n.getKey(e,t);return Object.defineProperties(r,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),r}(new URL(r),{cacheMaxAge:n.ttlMs,[Ja]:E(yo,this),[Ya]:E(Co,this)}));let{payload:i}=await Ra(e.logoutToken,E(bo,this),{issuer:t.issuer,audience:E(F,this).clientId,algorithms:[`RS256`],requiredClaims:[`iat`]});if(!(`sid`in i)&&!(`sub`in i))throw new Mo(`either "sid" or "sub" (or both) claims must be present`);if(`sid`in i&&typeof i.sid!=`string`)throw new Mo(`"sid" claim must be a string`);if(`sub`in i&&typeof i.sub!=`string`)throw new Mo(`"sub" claim must be a string`);if(`nonce`in i)throw new Mo(`"nonce" claim is prohibited`);if(!(`events`in i))throw new Mo(`"events" claim is missing`);if(typeof i.events!=`object`||i.events===null)throw new Mo(`"events" claim must be an object`);if(!(`http://schemas.openid.net/event/backchannel-logout`in i.events))throw new Mo(`"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim`);if(typeof i.events[`http://schemas.openid.net/event/backchannel-logout`]!=`object`)throw new Mo(`"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object`);return{sid:i.sid,sub:i.sub}}});function rs(){return`${E(F,this).domain.toLowerCase()}|mtls:${E(F,this).useMtls?`1`:`0`}`}async function is(e){let t=await T(I,this,cs).call(this),n=new ha(e,E(F,this).clientId,E(F,this).clientSecret,t);return n[ia]=E(yo,this),n}async function as(){if(E(go,this)&&E(_o,this))return{configuration:E(go,this),serverMetadata:E(_o,this)};let e=T(I,this,rs).call(this),t=E(xo,this).get(e);if(t)return O(_o,this,t.serverMetadata),O(go,this,await T(I,this,is).call(this,t.serverMetadata)),{configuration:E(go,this),serverMetadata:E(_o,this)};let n=E(So,this).get(e);if(n){let e=await n;return O(_o,this,e.serverMetadata),O(go,this,await T(I,this,is).call(this,e.serverMetadata)),{configuration:E(go,this),serverMetadata:E(_o,this)}}let r=(async()=>{let t=await T(I,this,cs).call(this),n=await pa(new URL(`https://${E(F,this).domain}`),E(F,this).clientId,{use_mtls_endpoint_aliases:E(F,this).useMtls},t,{[ia]:E(yo,this)}),r=n.serverMetadata();return E(xo,this).set(e,{serverMetadata:r}),{configuration:n,serverMetadata:r}})(),i=r.then(e=>{let{serverMetadata:t}=e;return{serverMetadata:t}});i.catch(()=>{}),E(So,this).set(e,i);try{let{configuration:e,serverMetadata:t}=await r;O(go,this,e),O(_o,this,t),E(go,this)[ia]=E(yo,this)}finally{E(So,this).delete(e)}return{configuration:E(go,this),serverMetadata:E(_o,this)}}async function os(e){let{configuration:t}=await T(I,this,as).call(this);if(`audience`in e||`resource`in e)throw new jo(`audience and resource parameters are not supported for Token Vault exchanges`);$o(e.subjectToken);let n=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType??ts,requested_token_type:e.requestedTokenType??`http://auth0.com/oauth/token-type/federated-connection-access-token`});e.loginHint&&n.append(`login_hint`,e.loginHint),e.scope&&n.append(`scope`,e.scope),es(n,e.extra);try{let e=await ja(t,`urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token`,n);return Ko.fromTokenEndpointResponse(e)}catch(t){throw new jo(`Failed to exchange token for connection '${e.connection}'.`,t)}}async function ss(e){let{configuration:t}=await T(I,this,as).call(this);$o(e.subjectToken);let n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.requestedTokenType&&n.append(`requested_token_type`,e.requestedTokenType),e.organization&&n.append(`organization`,e.organization),es(n,e.extra);try{let e=await ja(t,`urn:ietf:params:oauth:grant-type:token-exchange`,n);return Ko.fromTokenEndpointResponse(e)}catch(t){throw new jo(`Failed to exchange token of type '${e.subjectTokenType}'${e.audience?` for audience '${e.audience}'`:``}.`,t)}}async function cs(){return E(vo,this)||O(vo,this,(async()=>{if(!E(F,this).clientSecret&&!E(F,this).clientAssertionSigningKey&&!E(F,this).useMtls)throw new Lo;if(E(F,this).useMtls)return(e,t,n,r)=>{n.set(`client_id`,t.client_id)};let e=E(F,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await async function(e,t,n){if(typeof e!=`string`||e.indexOf(`-----BEGIN PRIVATE KEY-----`)!==0)throw TypeError(`"pkcs8" must be PKCS#8 formatted string`);return Ki(e,t,n)}(e,E(F,this).clientAssertionSigningAlg||`RS256`)),e?function(e,t){return Qn(e,t)}(e):ra(E(F,this).clientSecret)})().catch(e=>{throw O(vo,this,void 0),e})),E(vo,this)}async function ls(e){let{configuration:t}=await T(I,this,as).call(this),n=la(),r=await ca(n),i=Ro(A(A({},E(F,this).authorizationParams),e?.authorizationParams)),a=new URLSearchParams(A(A({scope:Zo},i),{},{client_id:E(F,this).clientId,code_challenge:r,code_challenge_method:`S256`}));return{authorizationUrl:e!=null&&e.pushedAuthorizationRequests?await Ea(t,a):await Ta(t,a),codeVerifier:n}}var us=class e extends w{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},ds=class e extends us{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},fs=class e extends us{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},ps=class e extends us{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},ms=class e extends us{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},hs=class e extends us{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},gs=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:6e5;this.contexts=new Map,this.ttlMs=e}set(e,t){this.cleanup(),this.contexts.set(e,Object.assign(Object.assign({},t),{createdAt:Date.now()}))}get(e){let t=this.contexts.get(e);if(t){if(!(Date.now()-t.createdAt>this.ttlMs))return t;this.contexts.delete(e)}}remove(e){this.contexts.delete(e)}cleanup(){let e=Date.now();for(let[t,n]of this.contexts)e-n.createdAt>this.ttlMs&&this.contexts.delete(t)}get size(){return this.contexts.size}},_s=class{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new gs}setMFAAuthDetails(e,t,n,r){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:r})}async getAuthenticators(e){let t=this.contextManager.get(e);if(!t?.mfaRequirements?.challenge||t.mfaRequirements.challenge.length===0)throw new ds(`invalid_request`,`challengeType is required and must contain at least one challenge type, please check mfa_required error payload`);let n=t.mfaRequirements.challenge.map(e=>e.type);try{return(await this.authJsMfaClient.listAuthenticators({mfaToken:e})).filter(e=>!!e.type&&n.includes(e.type))}catch(e){throw e instanceof Bo?new ds(e.cause?.error,e.message):e}}async enroll(e){let t=function(e){let t=an[e.factorType];return Object.assign(Object.assign(Object.assign({mfaToken:e.mfaToken,authenticatorTypes:t.authenticatorTypes},t.oobChannels&&{oobChannels:t.oobChannels}),`phoneNumber`in e&&{phoneNumber:e.phoneNumber}),`email`in e&&{email:e.email})}(e);try{return await this.authJsMfaClient.enrollAuthenticator(t)}catch(e){throw e instanceof Vo?new fs(e.cause?.error,e.message):e}}async challenge(e){try{let t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){throw e instanceof Uo?new ps(e.cause?.error,e.message):e}}async getEnrollmentFactors(e){let t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new hs(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);return t.mfaRequirements.enroll&&t.mfaRequirements.enroll.length!==0?t.mfaRequirements.enroll:[]}async verify(e){let t=this.contextManager.get(e.mfaToken);if(!t)throw new ms(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);let n=function(e){return`otp`in e&&e.otp?on:`oobCode`in e&&e.oobCode?sn:`recoveryCode`in e&&e.recoveryCode?cn:void 0}(e);if(!n)throw new ms(`invalid_request`,`Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.`);let r=t.scope,i=t.audience;try{let t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:r,audience:i,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof fe)this.setMFAAuthDetails(e.mfa_token,r,i,e.mfa_requirements);else if(e instanceof ms)throw new ms(e.error,e.error_description);throw e}}},vs=class{constructor(e){let t,n;if(this.userCache=new yt().enclosedCache,this.defaultOptions={authorizationParams:{scope:`openid profile email`},useRefreshTokensFallback:!1,useFormData:!0},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<`u`&&(()=>{if(!_e())throw Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(_e().subtle===void 0)throw Error(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c,1);let l=require(`@entur/alert`),u=require(`@entur/loader`),d=require(`@entur/tokens`),f=require(`@entur/typography`),p=require(`@entur-partner/common`),m=require(`@entur-partner/util`),h=require(`react/jsx-runtime`),g=require(`@entur-partner/micro-frontend`);var _=function(e,t){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},_(e,t)};function v(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},y.apply(this,arguments)};function ee(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function b(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function te(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function ne(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function x(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}var re={timeoutInSeconds:60},ie=1e4,ae=`memory`,oe={name:`auth0-spa-js`,version:`2.19.2`},se=()=>Date.now(),S=`default`,C=class e extends Error{constructor(t,n){super(n),this.error=t,this.error_description=n,Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},ce=class e extends C{constructor(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;super(t,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,e.prototype)}},le=class e extends C{constructor(t,n,r,i){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;super(t,n),this.connection=r,this.state=i,this.appState=a,Object.setPrototypeOf(this,e.prototype)}},ue=class e extends C{constructor(){super(`timeout`,`Timeout`),Object.setPrototypeOf(this,e.prototype)}},de=class e extends ue{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},fe=class e extends C{constructor(t){super(`cancelled`,`Popup closed`),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},pe=class e extends C{constructor(){super(`popup_open`,"Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,e.prototype)}},me=class e extends C{constructor(t,n,r,i){super(t,n),this.mfa_token=r,this.mfa_requirements=i,Object.setPrototypeOf(this,e.prototype)}},he=class e extends C{constructor(t,n){super(`missing_refresh_token`,`Missing Refresh Token (audience: '${ve(t,[`default`])}', scope: '${ve(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},ge=class e extends C{constructor(t,n){super(`missing_scopes`,`Missing requested scopes after refresh (audience: '${ve(t,[`default`])}', missing scope: '${ve(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},_e=class e extends C{constructor(t){super(`use_dpop_nonce`,`Server rejected DPoP proof: wrong nonce`),this.newDpopNonce=t,Object.setPrototypeOf(this,e.prototype)}};function ve(e){return e&&!(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).includes(e)?e:``}var ye=()=>window.crypto,be=()=>{let e=``;for(;e.length<43;){let t=ye().getRandomValues(new Uint8Array(43-e.length));for(let n of t)e.length<43&&n<198&&(e+=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.`[n%66])}return e},xe=e=>btoa(e),Se=[{key:`name`,type:[`string`]},{key:`version`,type:[`string`,`number`]},{key:`env`,type:[`object`]}],Ce=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return Object.keys(e).reduce((n,r)=>{if(t&&r===`env`)return n;let i=Se.find(e=>e.key===r);return i&&i.type.includes(typeof e[r])&&(n[r]=e[r]),n},{})},we=e=>{var{clientId:t}=e,n=x(e,[`clientId`]);return new URLSearchParams((e=>Object.keys(e).filter(t=>e[t]!==void 0).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{}))(Object.assign({client_id:t},n))).toString()},Te=async e=>await ye().subtle.digest({name:`SHA-256`},new TextEncoder().encode(e)),Ee=e=>(e=>decodeURIComponent(atob(e).split(``).map(e=>`%`+(`00`+e.charCodeAt(0).toString(16)).slice(-2)).join(``)))(e.replace(/_/g,`/`).replace(/-/g,`+`)),De=e=>{let t=new Uint8Array(e);return(e=>{let t={"+":`-`,"/":`_`,"=":``};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))},Oe=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},ke={},Ae={};Object.defineProperty(Ae,`__esModule`,{value:!0});var je=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);r===void 0?n===void 0?e.locked.set(t,[]):e.locked.set(t,[n]):n!==void 0&&(r.unshift(n),e.locked.set(t,r))},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,r){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n())})},this.unlock=function(t){var n=e.locked.get(t);if(n!==void 0&&n.length!==0){var r=n.pop();e.locked.set(t,n),r!==void 0&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return e.instance===void 0&&(e.instance=new e),e.instance},e}();Ae.default=function(){return je.getInstance()};var Me=Oe&&Oe.__awaiter||function(e,t,n,r){return new(n||=Promise)(function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}c((r=r.apply(e,t||[])).next())})},Ne=Oe&&Oe.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw TypeError(`Generator is already executing.`);for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||a[0]!==6&&a[0]!==2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},Pe=Oe;Object.defineProperty(ke,`__esModule`,{value:!0});var Fe=Ae,Ie=`browser-tabs-lock-key`,Le={key:function(e){return Me(Pe,void 0,void 0,function(){return Ne(this,function(e){throw Error(`Unsupported`)})})},getItem:function(e){return Me(Pe,void 0,void 0,function(){return Ne(this,function(e){throw Error(`Unsupported`)})})},clear:function(){return Me(Pe,void 0,void 0,function(){return Ne(this,function(e){return[2,window.localStorage.clear()]})})},removeItem:function(e){return Me(Pe,void 0,void 0,function(){return Ne(this,function(e){throw Error(`Unsupported`)})})},setItem:function(e,t){return Me(Pe,void 0,void 0,function(){return Ne(this,function(e){throw Error(`Unsupported`)})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function Re(e){return new Promise(function(t){return setTimeout(t,e)})}function ze(e){for(var t=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`,n=``,r=0;r<e;r++)n+=t[Math.floor(61*Math.random())];return n}var Be=ke.default=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+ze(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=t,e.waiters===void 0&&(e.waiters=[])}return e.prototype.acquireLock=function(t,n){return n===void 0&&(n=5e3),Me(this,void 0,void 0,function(){var r,i,a,o,s,c,l;return Ne(this,function(u){switch(u.label){case 0:r=Date.now()+ze(4),i=Date.now()+n,a=Ie+`-`+t,o=this.storageHandler===void 0?Le:this.storageHandler,u.label=1;case 1:return Date.now()<i?[4,Re(30)]:[3,8];case 2:return u.sent(),o.getItemSync(a)===null?(s=this.id+`-`+t+`-`+r,[4,Re(Math.floor(25*Math.random()))]):[3,5];case 3:return u.sent(),o.setItemSync(a,JSON.stringify({id:this.id,iat:r,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,Re(30)];case 4:return u.sent(),(c=o.getItemSync(a))!==null&&(l=JSON.parse(c)).id===this.id&&l.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(a,r),[2,!0]):[3,7];case 5:return e.lockCorrector(this.storageHandler===void 0?Le:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:u.sent(),u.label=7;case 7:return r=Date.now()+ze(4),[3,1];case 8:return[2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return Me(this,void 0,void 0,function(){var n=this;return Ne(this,function(r){return setTimeout(function(){return Me(n,void 0,void 0,function(){var n,r,i;return Ne(this,function(a){switch(a.label){case 0:return[4,Fe.default().lock(t)];case 1:return a.sent(),this.acquiredIatSet.has(t)?(n=this.storageHandler===void 0?Le:this.storageHandler,(r=n.getItemSync(e))===null?(Fe.default().unlock(t),[2]):((i=JSON.parse(r)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(i)),Fe.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):(Fe.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return Me(this,void 0,void 0,function(){return Ne(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var r=!1,i=Date.now(),a=!1;function o(){if(a||=(window.removeEventListener(`storage`,o),e.removeFromWaiting(o),clearTimeout(s),!0),!r){r=!0;var t=50-(Date.now()-i);t>0?setTimeout(n,t):n(null)}}window.addEventListener(`storage`,o),e.addToWaiting(o);var s=setTimeout(o,Math.max(0,t-Date.now()))})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),e.waiters!==void 0&&e.waiters.push(t)},e.removeFromWaiting=function(t){e.waiters!==void 0&&(e.waiters=e.waiters.filter(function(e){return e!==t}))},e.notifyWaiters=function(){e.waiters!==void 0&&e.waiters.slice().forEach(function(e){return e()})},e.prototype.releaseLock=function(e){return Me(this,void 0,void 0,function(){return Ne(this,function(t){switch(t.label){case 0:return[4,this.releaseLock__private__(e)];case 1:return[2,t.sent()]}})})},e.prototype.releaseLock__private__=function(t){return Me(this,void 0,void 0,function(){var n,r,i,a;return Ne(this,function(o){switch(o.label){case 0:return n=this.storageHandler===void 0?Le:this.storageHandler,r=Ie+`-`+t,(i=n.getItemSync(r))===null?[2]:(a=JSON.parse(i)).id===this.id?[4,Fe.default().lock(a.iat)]:[3,2];case 1:o.sent(),this.acquiredIatSet.delete(a.iat),n.removeItemSync(r),Fe.default().unlock(a.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=t,i=[],a=0;;){var o=r.keySync(a);if(o===null)break;i.push(o),a++}for(var s=!1,c=0;c<i.length;c++){var l=i[c];if(l.includes(Ie)){var u=r.getItemSync(l);if(u!==null){var d=JSON.parse(u);(d.timeRefreshed===void 0&&d.timeAcquired<n||d.timeRefreshed!==void 0&&d.timeRefreshed<n)&&(r.removeItemSync(l),s=!0)}}}s&&e.notifyWaiters()},e.waiters=void 0,e}(),Ve=class{async runWithLock(e,t,n){let r=new AbortController,i=setTimeout(()=>r.abort(),t);try{return await navigator.locks.request(e,{mode:`exclusive`,signal:r.signal},async e=>{if(clearTimeout(i),!e)throw Error(`Lock not available`);return await n()})}catch(e){throw clearTimeout(i),e?.name===`AbortError`?new ue:e}}},He=class{constructor(){this.activeLocks=new Set,this.lock=new Be,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear()}}async runWithLock(e,t,n){let r=!1;for(let n=0;n<10&&!r;n++)r=await this.lock.acquireLock(e,t);if(!r)throw new ue;this.activeLocks.add(e),this.activeLocks.size===1&&typeof window<`u`&&window.addEventListener(`pagehide`,this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),this.activeLocks.size===0&&typeof window<`u`&&window.removeEventListener(`pagehide`,this.pagehideHandler)}}};function Ue(){return typeof navigator<`u`&&typeof(e=navigator.locks)?.request==`function`?new Ve:new He;var e}var We=null,Ge=new TextEncoder,Ke=new TextDecoder;function qe(e){return typeof e==`string`?Ge.encode(e):Ke.decode(e)}function Je(e){if(typeof e.modulusLength!=`number`||e.modulusLength<2048)throw new $e(`${e.name} modulusLength must be at least 2048 bits`)}async function Ye(e,t,n){if(!1===n.usages.includes(`sign`))throw TypeError(`private CryptoKey instances used for signing assertions must include "sign" in their "usages"`);let r=`${Ze(qe(JSON.stringify(e)))}.${Ze(qe(JSON.stringify(t)))}`;return`${r}.${Ze(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:`SHA-256`};case`RSA-PSS`:return Je(e.algorithm),{name:e.algorithm.name,saltLength:32};case`RSASSA-PKCS1-v1_5`:return Je(e.algorithm),{name:e.algorithm.name};case`Ed25519`:return{name:e.algorithm.name}}throw new Qe}(n),n,qe(r)))}`}var Xe;if(Uint8Array.prototype.toBase64)Xe=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;Xe=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Ze(e){return Xe(e)}var Qe=class extends Error{constructor(e){var t;super(e??`operation not supported`),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}},$e=class extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}};function et(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`PS256`;throw new Qe(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`RSASSA-PKCS1-v1_5`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`RS256`;throw new Qe(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`ECDSA`:return function(e){if(e.algorithm.namedCurve===`P-256`)return`ES256`;throw new Qe(`unsupported EcKeyAlgorithm namedCurve`)}(e);case`Ed25519`:return`Ed25519`;default:throw new Qe(`unsupported CryptoKey algorithm name`)}}function tt(e){return e instanceof CryptoKey}function nt(e){return tt(e)&&e.type===`public`}async function rt(e,t,n,r,i,a){let o=e?.privateKey,s=e?.publicKey;if(!tt(c=o)||c.type!==`private`)throw TypeError(`"keypair.privateKey" must be a private CryptoKey`);var c;if(!nt(s))throw TypeError(`"keypair.publicKey" must be a public CryptoKey`);if(!0!==s.extractable)throw TypeError(`"keypair.publicKey.extractable" must be true`);if(typeof t!=`string`)throw TypeError(`"htu" must be a string`);if(typeof n!=`string`)throw TypeError(`"htm" must be a string`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`"nonce" must be a string or undefined`);if(i!==void 0&&typeof i!=`string`)throw TypeError(`"accessToken" must be a string or undefined`);if(a!==void 0&&(typeof a!=`object`||!a||Array.isArray(a)))throw TypeError(`"additional" must be an object`);return Ye({alg:et(o),typ:`dpop+jwt`,jwk:await it(s)},Object.assign(Object.assign({},a),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:r,htu:t,ath:i?Ze(await crypto.subtle.digest(`SHA-256`,qe(i))):void 0}),o)}async function it(e){let{kty:t,e:n,n:r,x:i,y:a,crv:o}=await crypto.subtle.exportKey(`jwk`,e);return{kty:t,crv:o,e:n,n:r,x:i,y:a}}var at=`dpop-nonce`,ot=[`authorization_code`,`refresh_token`,`urn:ietf:params:oauth:grant-type:token-exchange`,`http://auth0.com/oauth/grant-type/mfa-oob`,`http://auth0.com/oauth/grant-type/mfa-otp`,`http://auth0.com/oauth/grant-type/mfa-recovery-code`];function st(){return async function(e,t){var n;let r;if(typeof e!=`string`||e.length===0)throw TypeError(`"alg" must be a non-empty string`);switch(e){case`PS256`:r={name:`RSA-PSS`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`RS256`:r={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`ES256`:r={name:`ECDSA`,namedCurve:`P-256`};break;case`Ed25519`:r={name:`Ed25519`};break;default:throw new Qe}return crypto.subtle.generateKey(r,(n=t?.extractable)!=null&&n,[`sign`,`verify`])}(`ES256`,{extractable:!1})}function ct(e){return async function(e){if(!nt(e))throw TypeError(`"publicKey" must be a public CryptoKey`);if(!0!==e.extractable)throw TypeError(`"publicKey.extractable" must be true`);let t=await it(e),n;switch(t.kty){case`EC`:n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case`OKP`:n={crv:t.crv,kty:t.kty,x:t.x};break;case`RSA`:n={e:t.e,kty:t.kty,n:t.n};break;default:throw new Qe(`unsupported JWK kty`)}return Ze(await crypto.subtle.digest({name:`SHA-256`},qe(JSON.stringify(n))))}(e.publicKey)}function lt(e){let{keyPair:t,url:n,method:r,nonce:i,accessToken:a}=e;return rt(t,function(e){let t=new URL(e);return t.search=``,t.hash=``,t.href}(n),r,i,a)}var ut=(e,t)=>new Promise(function(n,r){let i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?r(Error(e.data.error)):n(e.data),i.port1.close()},t.postMessage(e,[i.port2])}),dt=(e,t,n)=>{let r=new AbortController,i;return t.signal=r.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{i=setTimeout(()=>{r.abort(),t(Error(`Timeout when executing 'fetch'`))},n)})]).finally(()=>{clearTimeout(i)})},ft=async function(e,t,n,r,i,a){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:ie;return i?(async(e,t,n,r,i,a,o,s)=>ut({type:`refresh`,auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:r,useFormData:o,useMrrt:s},a))(e,t,n,r,o,i,a,arguments.length>7?arguments[7]:void 0):(async(e,t,n)=>{let r=await dt(e,t,n);return{ok:r.ok,json:await r.json(),headers:(i=r.headers,[...i].reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{}))};var i})(e,r,o)};async function pt(e,t,n,r,i,a,o,s,c,l){if(c){let t=await c.generateProof({url:e,method:i.method||`GET`,nonce:await c.getNonce()});i.headers=Object.assign(Object.assign({},i.headers),{dpop:t})}let u,d=null;for(let c=0;c<3;c++)try{u=await ft(e,n,r,i,a,o,t,s),d=null;break}catch(e){d=e}if(d)throw d;let f=u.json,{error:p,error_description:m}=f,h=x(f,[`error`,`error_description`]),{headers:g,ok:_}=u,v;if(c&&(v=g[at],v&&await c.setNonce(v)),!_){let u=m||`HTTP error. Unable to fetch ${e}`;if(p===`mfa_required`)throw new me(p,u,h.mfa_token,h.mfa_requirements);if(p===`missing_refresh_token`)throw new he(n,r);if(p===`use_dpop_nonce`){if(!c||!v||l)throw new _e(v);return pt(e,t,n,r,i,a,o,s,c,!0)}throw new C(p||`request_error`,u)}return h}async function mt(e,t){var{baseUrl:n,timeout:r,audience:i,scope:a,auth0Client:o,useFormData:s,useMrrt:c,dpop:l}=e,u=x(e,[`baseUrl`,`timeout`,`audience`,`scope`,`auth0Client`,`useFormData`,`useMrrt`,`dpop`]);let d=u.grant_type===`urn:ietf:params:oauth:grant-type:token-exchange`,f=u.grant_type===`refresh_token`&&c,p=Object.assign(Object.assign(Object.assign(Object.assign({},u),d&&i&&{audience:i}),d&&a&&{scope:a}),f&&{audience:i,scope:a}),m=s?we(p):JSON.stringify(p),h=(g=u.grant_type,ot.includes(g));var g;return await pt(`${n}/oauth/token`,r,i||S,a,{method:`POST`,body:m,headers:{"Content-Type":s?`application/x-www-form-urlencoded`:`application/json`,"Auth0-Client":btoa(JSON.stringify(Ce(o||oe)))}},t,s,c,h?l:void 0)}var ht=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(r=t.filter(Boolean).join(` `).trim().split(/\s+/),Array.from(new Set(r))).join(` `);var r},gt=(e,t,n)=>{let r;return n&&(r=e[n]),r||=e[S],ht(r,t)},_t=`@@auth0spajs@@`,vt=`@@user@@`,yt=class e{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:_t,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join(`::`)}static fromKey(t){let[n,r,i,a]=t.split(`::`);return new e({clientId:r,scope:a,audience:i},n)}static fromCacheEntry(t){let{scope:n,audience:r,client_id:i}=t;return new e({scope:n,audience:r,clientId:i})}},bt=class{set(e,t){localStorage.setItem(e,JSON.stringify(t))}get(e){let t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(_t))}},xt=class{constructor(){this.enclosedCache=function(){let e={};return{set(t,n){e[t]=n},get(t){let n=e[t];if(n)return n},remove(t){delete e[t]},allKeys:()=>Object.keys(e)}}()}},St=class{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||se}async setIdToken(e,t,n){let r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await this.keyManifest?.add(r)}async getIdToken(e){let t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){let t=await this.get(e);return!t||!t.id_token||!t.decodedToken?void 0:{id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return{id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3?arguments[3]:void 0,i=await this.cache.get(e.toKey()),a=e;if(!i){let t=await this.getCacheKeys();if(!t)return;let o=this.matchExistingCacheKey(e,t);if(o&&(i=await this.cache.get(o),a=yt.fromKey(o)),!i&&n&&r!==`cache-only`)return this.getEntryWithRefreshToken(e,t)}if(!i)return;let o=await this.nowProvider(),s=Math.floor(o/1e3);return i.expiresAt-t<s?i.body.refresh_token?this.modifiedCachedEntry(i,a):(await this.cache.remove(a.toKey()),void await this.keyManifest?.remove(a.toKey())):i.body}async modifiedCachedEntry(e,t){let n={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},r={body:n,expiresAt:e.expiresAt};return await this.cache.set(t.toKey(),r),{refresh_token:n.refresh_token,audience:n.audience,scope:n.scope}}async set(e){let t=new yt({clientId:e.client_id,scope:e.scope,audience:e.audience}),n=await this.wrapCacheEntry(e);await this.cache.set(t.toKey(),n),await this.keyManifest?.add(t.toKey())}async remove(e,t,n){let r=new yt({clientId:e,scope:n,audience:t});await this.cache.remove(r.toKey())}async stripRefreshToken(e){let t=await this.getCacheKeys();if(t)for(let n of t){let t=await this.cache.get(n);t?.body?.refresh_token===e&&(delete t.body.refresh_token,await this.cache.set(n,t))}}async clear(e){let t=await this.getCacheKeys();t&&(await t.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t)},Promise.resolve()),await this.keyManifest?.clear())}async wrapCacheEntry(e){let t=await this.nowProvider();return{body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){return this.keyManifest?(await this.keyManifest.get())?.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new yt({clientId:e},_t,vt).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{let n=yt.fromKey(t),r=new Set(n.scope&&n.scope.split(` `)),i=e.scope?.split(` `)||[],a=n.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return n.prefix===_t&&n.clientId===e.clientId&&n.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){for(let n of t){let t=yt.fromKey(n);if(t.prefix===_t&&t.clientId===e.clientId){let e=await this.cache.get(n);if(e?.body?.refresh_token)return{refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}}}async getRefreshTokensByAudience(e,t){var n;let r=await this.getCacheKeys();if(!r)return[];let i=new Set;for(let a of r){let r=yt.fromKey(a);if(r.prefix===_t&&r.clientId===t&&r.audience===e){let e=await this.cache.get(a);(n=e?.body)!=null&&n.refresh_token&&i.add(e.body.refresh_token)}}return Array.from(i)}async updateEntry(e,t){let n=await this.getCacheKeys();if(n)for(let r of n){let n=await this.cache.get(r);n?.body?.refresh_token===e&&(n.body.refresh_token=t,await this.cache.set(r,n))}}},Ct=class{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}},wt=e=>typeof e==`number`,Tt=`iss.aud.exp.nbf.iat.jti.azp.nonce.auth_time.at_hash.c_hash.acr.amr.sub_jwk.cnf.sip_from_tag.sip_date.sip_callid.sip_cseq_num.sip_via_branch.orig.dest.mky.events.toe.txn.rph.sid.vot.vtm`.split(`.`),Et=e=>{if(!e.id_token)throw Error(`ID token is required but missing`);let t=(e=>{let t=e.split(`.`),[n,r,i]=t;if(t.length!==3||!n||!r||!i)throw Error(`ID token could not be decoded`);let a=JSON.parse(Ee(r)),o={__raw:e},s={};return Object.keys(a).forEach(e=>{o[e]=a[e],Tt.includes(e)||(s[e]=a[e])}),{encoded:{header:n,payload:r,signature:i},header:JSON.parse(Ee(n)),claims:o,user:s}})(e.id_token);if(!t.claims.iss)throw Error(`Issuer (iss) claim must be a string present in the ID token`);if(t.claims.iss!==e.iss)throw Error(`Issuer (iss) claim mismatch in the ID token; expected "${e.iss}", found "${t.claims.iss}"`);if(!t.user.sub)throw Error(`Subject (sub) claim must be a string present in the ID token`);if(t.header.alg!==`RS256`)throw Error(`Signature algorithm of "${t.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!t.claims.aud||typeof t.claims.aud!=`string`&&!Array.isArray(t.claims.aud))throw Error(`Audience (aud) claim must be a string or array of strings present in the ID token`);if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but was not one of "${t.claims.aud.join(`, `)}"`);if(t.claims.aud.length>1){if(!t.claims.azp)throw Error(`Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values`);if(t.claims.azp!==e.aud)throw Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${e.aud}", found "${t.claims.azp}"`)}}else if(t.claims.aud!==e.aud)throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but found "${t.claims.aud}"`);if(e.nonce){if(!t.claims.nonce)throw Error(`Nonce (nonce) claim must be a string present in the ID token`);if(t.claims.nonce!==e.nonce)throw Error(`Nonce (nonce) claim mismatch in the ID token; expected "${e.nonce}", found "${t.claims.nonce}"`)}if(e.max_age&&!wt(t.claims.auth_time))throw Error(`Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified`);if(t.claims.exp==null||!wt(t.claims.exp))throw Error(`Expiration Time (exp) claim must be a number present in the ID token`);if(!wt(t.claims.iat))throw Error(`Issued At (iat) claim must be a number present in the ID token`);let n=e.leeway||60,r=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),r>i)throw Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(t.claims.nbf!=null&&wt(t.claims.nbf)){let e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),r<e)throw Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${e}`)}if(t.claims.auth_time!=null&&wt(t.claims.auth_time)){let i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),r>i)throw Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${i}`)}if(e.organization){let n=e.organization.trim();if(n.startsWith(`org_`)){let e=n;if(!t.claims.org_id)throw Error(`Organization ID (org_id) claim must be a string present in the ID token`);if(e!==t.claims.org_id)throw Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_id}"`)}else{let e=n.toLowerCase();if(!t.claims.org_name)throw Error(`Organization Name (org_name) claim must be a string present in the ID token`);if(e!==t.claims.org_name)throw Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_name}"`)}}return t},Dt=Oe&&Oe.__assign||function(){return Dt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Dt.apply(this,arguments)};function Ot(e,t){if(!t)return``;var n=`; `+e;return!0===t?n:n+`=`+t}function kt(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,`%28`).replace(/\)/g,`%29`)+`=`+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if(typeof e.expires==`number`){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return Ot(`Expires`,e.expires?e.expires.toUTCString():``)+Ot(`Domain`,e.domain)+Ot(`Path`,e.path)+Ot(`Secure`,e.secure)+Ot(`SameSite`,e.sameSite)}(n)}function At(){return function(e){for(var t={},n=e?e.split(`; `):[],r=/(%[\dA-F]{2})+/gi,i=0;i<n.length;i++){var a=n[i].split(`=`),o=a.slice(1).join(`=`);o.charAt(0)===`"`&&(o=o.slice(1,-1));try{t[a[0].replace(r,decodeURIComponent)]=o.replace(r,decodeURIComponent)}catch{}}return t}(document.cookie)}var jt=function(e){return At()[e]};function Mt(e,t,n){document.cookie=kt(e,t,Dt({path:`/`},n))}var Nt=Mt,Pt=function(e,t){Mt(e,``,Dt(Dt({},t),{expires:-1}))},Ft={get(e){let t=jt(e);if(t!==void 0)return JSON.parse(t)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0,sameSite:`none`}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Nt(e,JSON.stringify(t),r)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Pt(e,n)}},It=`_legacy_`,Lt={get(e){return Ft.get(e)||Ft.get(`${It}${e}`)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Nt(`${It}${e}`,JSON.stringify(t),r),Ft.save(e,t,n)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Pt(e,n),Ft.remove(e,t),Ft.remove(`${It}${e}`,t)}},Rt={get(e){if(typeof sessionStorage>`u`)return;let t=sessionStorage.getItem(e);return t==null?void 0:JSON.parse(t)},save(e,t){sessionStorage.setItem(e,JSON.stringify(t))},remove(e){sessionStorage.removeItem(e)}},zt;(function(e){e.Code=`code`,e.ConnectCode=`connect_code`})(zt||={});function Bt(e,t,n){var r=t===void 0?null:t,i=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,a=n.length;i<a;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,n!==void 0&&n),a=i.indexOf(`
|
|
2
|
+
`,10)+1,o=i.substring(a)+(r?`//# sourceMappingURL=`+r:``),s=new Blob([o],{type:`application/javascript`});return URL.createObjectURL(s)}var Vt,Ht,Ut,Wt,Gt=(Vt=`Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHQpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOm99PXQ7cmV0dXJuIG5ldyBlKHIsbyl9fWNsYXNzIHQgZXh0ZW5kcyBle2NvbnN0cnVjdG9yKGUsbyl7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChyKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChyKG8pLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1vLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLHQucHJvdG90eXBlKX19ZnVuY3Rpb24gcihlKXtyZXR1cm4gZSYmIShhcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W10pLmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IG89ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIG8gaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxvKSYmdC5pbmRleE9mKG8pPDAmJihyW29dPWVbb10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgcz0wO2ZvcihvPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7czxvLmxlbmd0aDtzKyspdC5pbmRleE9mKG9bc10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLG9bc10pJiYocltvW3NdXT1lW29bc11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIodD0+dm9pZCAwIT09ZVt0XSkucmVkdWNlKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkse30pKShPYmplY3QuYXNzaWduKHtjbGllbnRfaWQ6dH0scikpKS50b1N0cmluZygpfTtsZXQgcz17fSxuPW51bGw7Y29uc3QgaT0oZSx0KT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQodCksYT0oZSx0KT0+dC5zdGFydHNXaXRoKCIiLmNvbmNhdChlLCJ8IikpLGM9ZT0+e09iamVjdC5lbnRyaWVzKHMpLmZvckVhY2godD0+e2xldFtyLG9dPXQ7bz09PWUmJmRlbGV0ZSBzW3JdfSl9LGw9ZT0+e2NvbnN0IHQ9bmV3IFVSTFNlYXJjaFBhcmFtcyhlKSxyPXt9O3JldHVybiB0LmZvckVhY2goKGUsdCk9PntyW3RdPWV9KSxyfSxmPWFzeW5jIGU9PntsZXQgcixuLHtkYXRhOnt0aW1lb3V0OmMsYXV0aDpmLGZldGNoVXJsOnUsZmV0Y2hPcHRpb25zOmgsdXNlRm9ybURhdGE6ZCx1c2VNcnJ0OnB9LHBvcnRzOltnXX09ZSx5PXt9O2NvbnN0e2F1ZGllbmNlOmIsc2NvcGU6T309Znx8e307dHJ5e2NvbnN0IGU9ZD9sKGguYm9keSk6SlNPTi5wYXJzZShoLmJvZHkpO2lmKCFlLnJlZnJlc2hfdG9rZW4mJiJyZWZyZXNoX3Rva2VuIj09PWUuZ3JhbnRfdHlwZSl7aWYobj0oKGUsdCk9PnNbaShlLHQpXSkoYixPKSwhbiYmcCl7Y29uc3QgZT1zLmxhdGVzdF9yZWZyZXNoX3Rva2VuLHQ9KChlLHQpPT4hIU9iamVjdC5rZXlzKHMpLmZpbmQocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBvPWEodCxyKSxzPXIuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpLG49ZS5zcGxpdCgiICIpLmV2ZXJ5KGU9PnMuaW5jbHVkZXMoZSkpO3JldHVybiBvJiZufX0pKShPLGIpO2UmJiF0JiYobj1lKX1pZighbil0aHJvdyBuZXcgdChiLE8pO2guYm9keT1kP28oT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LGUpLHtyZWZyZXNoX3Rva2VuOm59KSk6SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LGUpLHtyZWZyZXNoX3Rva2VuOm59KSl9bGV0IGYsdzsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYoZj1uZXcgQWJvcnRDb250cm9sbGVyLGguc2lnbmFsPWYuc2lnbmFsKTt0cnl7dz1hd2FpdCBQcm9taXNlLnJhY2UoWyhtPWMsbmV3IFByb21pc2UoZT0+c2V0VGltZW91dChlLG0pKSksZmV0Y2godSxPYmplY3QuYXNzaWduKHt9LGgpKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIGcucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCF3KXJldHVybiBmJiZmLmFib3J0KCksdm9pZCBnLnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO189dy5oZWFkZXJzLHk9Wy4uLl9dLnJlZHVjZSgoZSx0KT0+e2xldFtyLG9dPXQ7cmV0dXJuIGVbcl09byxlfSx7fSkscj1hd2FpdCB3Lmpzb24oKSxyLnJlZnJlc2hfdG9rZW4/KHAmJihzLmxhdGVzdF9yZWZyZXNoX3Rva2VuPXIucmVmcmVzaF90b2tlbixrPW4saj1yLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMocykuZm9yRWFjaChlPT57bGV0W3Qscl09ZTtyPT09ayYmKHNbdF09ail9KSksKChlLHQscik9PntzW2kodCxyKV09ZX0pKHIucmVmcmVzaF90b2tlbixiLE8pLGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBzW2koZSx0KV19KShiLE8pLGcucG9zdE1lc3NhZ2Uoe29rOncub2ssanNvbjpyLGhlYWRlcnM6eX0pfWNhdGNoKGUpe2cucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOnl9KX12YXIgayxqLF8sbX0sdT1hc3luYyBlPT57bGV0e2RhdGE6e3RpbWVvdXQ6dCxhdXRoOnIsZmV0Y2hVcmw6bixmZXRjaE9wdGlvbnM6aSx1c2VGb3JtRGF0YTpmfSxwb3J0czpbdV19PWU7Y29uc3R7YXVkaWVuY2U6aH09cnx8e307dHJ5e2NvbnN0IGU9KGU9Pntjb25zdCB0PW5ldyBTZXQ7cmV0dXJuIE9iamVjdC5lbnRyaWVzKHMpLmZvckVhY2gocj0+e2xldFtvLHNdPXI7YShlLG8pJiZ0LmFkZChzKX0pLEFycmF5LmZyb20odCl9KShoKTtpZigwPT09ZS5sZW5ndGgpcmV0dXJuIHZvaWQgdS5wb3N0TWVzc2FnZSh7b2s6ITB9KTtjb25zdCByPWY/bChpLmJvZHkpOkpTT04ucGFyc2UoaS5ib2R5KTtmb3IoY29uc3QgcyBvZiBlKXtjb25zdCBlPWY/byhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3Rva2VuOnN9KSk6SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjpzfSkpO2xldCBhLGwsaCxkOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihhPW5ldyBBYm9ydENvbnRyb2xsZXIsbD1hLnNpZ25hbCk7dHJ5e2Q9YXdhaXQgUHJvbWlzZS5yYWNlKFtuZXcgUHJvbWlzZShlPT57aD1zZXRUaW1lb3V0KGUsdCl9KSxmZXRjaChuLE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxpKSx7Ym9keTplLHNpZ25hbDpsfSkpXSkuZmluYWxseSgoKT0+Y2xlYXJUaW1lb3V0KGgpKX1jYXRjaChlKXtyZXR1cm4gdm9pZCB1LnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZClyZXR1cm4gYSYmYS5hYm9ydCgpLHZvaWQgdS5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZighZC5vayl7bGV0IGU7dHJ5e2NvbnN0e2Vycm9yX2Rlc2NyaXB0aW9uOnR9PUpTT04ucGFyc2UoYXdhaXQgZC50ZXh0KCkpO2U9dH1jYXRjaChlKXt9cmV0dXJuIHZvaWQgdS5wb3N0TWVzc2FnZSh7ZXJyb3I6ZXx8IkhUVFAgZXJyb3IgIi5jb25jYXQoZC5zdGF0dXMpfSl9YyhzKX11LnBvc3RNZXNzYWdlKHtvazohMH0pfWNhdGNoKGUpe3UucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZXx8IlVua25vd24gZXJyb3IgZHVyaW5nIHRva2VuIHJldm9jYXRpb24ifSl9fSxoPShlLHQpPT57aWYoIW4pcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChuKS5vcmlnaW4sbz1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiBvLm9yaWdpbj09PXImJm8ucGF0aG5hbWU9PT10fWNhdGNoKGUpe3JldHVybiExfX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZT0+e2NvbnN0e2RhdGE6dCxwb3J0czpyfT1lLFtvXT1yO2lmKCEoInR5cGUiaW4gdCl8fCJpbml0IiE9PXQudHlwZSlyZXR1cm4idHlwZSJpbiB0JiYiY2xlYXIiPT09dC50eXBlPyhzPXt9LHZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITB9KSkpOiJ0eXBlImluIHQmJiJyZXZva2UiPT09dC50eXBlP2godCwiL29hdXRoL3Jldm9rZSIpP3ZvaWQgdShlKTp2b2lkKG51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpOnZvaWQoImZldGNoVXJsImluIHQmJmgodCwiL29hdXRoL3Rva2VuIik/ZihlKTpudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjoiaW52YWxpZF9mZXRjaF91cmwiLGVycm9yX2Rlc2NyaXB0aW9uOiJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIn0saGVhZGVyczp7fX0pKTtpZihudWxsPT09bil0cnl7bmV3IFVSTCh0LmFsbG93ZWRCYXNlVXJsKSxuPXQuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX0pfSgpOwoK`,Ht=null,Ut=!1,function(e){return Wt||=Bt(Vt,Ht,Ut),new Worker(Wt,e)}),Kt={},qt=class{constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){let t=new Set((await this.cache.get(this.manifestKey))?.keys||[]);t.add(e),await this.cache.set(this.manifestKey,{keys:[...t]})}async remove(e){let t=await this.cache.get(this.manifestKey);if(t){let n=new Set(t.keys);return n.delete(e),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`${_t}::${e}`}},Jt=`auth0.is.authenticated`,Yt={memory:()=>new xt().enclosedCache,localstorage:()=>new bt},Xt=e=>Yt[e],Zt=e=>{let{openUrl:t,onRedirect:n}=e,r=x(e,[`openUrl`,`onRedirect`]);return Object.assign(Object.assign({},r),{openUrl:!1===t||t?t:n})},Qt=(e,t)=>{let n=t?.split(` `)||[];return(e?.split(` `)||[]).every(e=>n.includes(e))},$t={NONCE:`nonce`,KEYPAIR:`keypair`},en=class{constructor(e){this.clientId=e}getVersion(){return 1}createDbHandle(){let e=window.indexedDB.open(`auth0-spa-js`,this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values($t).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result)})}async getDbHandle(){return this.dbHandle||=await this.createDbHandle(),this.dbHandle}async executeDbRequest(e,t,n){let r=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})}buildKey(e){let t=e?`_${e}`:`auth0`;return`${this.clientId}::${t}`}setNonce(e,t){return this.save($t.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save($t.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,`readwrite`,e=>e.put(n,t))}findNonce(e){return this.find($t.NONCE,this.buildKey(e))}findKeyPair(){return this.find($t.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,`readonly`,e=>e.get(t))}async deleteBy(e,t){(await this.executeDbRequest(e,`readonly`,e=>e.getAllKeys()))?.filter(t).map(t=>this.executeDbRequest(e,`readwrite`,e=>e.delete(t)))}deleteByClientId(e,t){return this.deleteBy(e,e=>typeof e==`string`&&e.startsWith(`${t}::`))}clearNonces(){return this.deleteByClientId($t.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId($t.KEYPAIR,this.clientId)}},tn=class{constructor(e){this.storage=new en(e)}getNonce(e){return this.storage.findNonce(e)}setNonce(e,t){return this.storage.setNonce(e,t)}async getOrGenerateKeyPair(){let e=await this.storage.findKeyPair();return e||(e=await st(),await this.storage.setKeyPair(e)),e}async generateProof(e){let t=await this.getOrGenerateKeyPair();return lt(Object.assign({keyPair:t},e))}async calculateThumbprint(){return ct(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}},nn;(function(e){e.Bearer=`Bearer`,e.DPoP=`DPoP`})(nn||={});var rn=class{constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||(typeof window>`u`?fetch:window.fetch.bind(window))})}isAbsoluteUrl(e){return/^(https?:)?\/\//i.test(e)}buildUrl(e,t){if(t){if(this.isAbsoluteUrl(t))return t;if(e)return`${e.replace(/\/?\/$/,``)}/${t.replace(/^\/+/,``)}`}throw TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(e){return this.config.getAccessToken?this.config.getAccessToken(e):this.hooks.getAccessToken(e)}extractUrl(e){return typeof e==`string`?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);let n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),r=e instanceof Request?new Request(n,e):n;return new Request(r,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:nn.Bearer;e.headers.set(`authorization`,`${n} ${t}`)}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;let n=await this.hooks.getDpopNonce(),r=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set(`dpop`,r)}async prepareRequest(e,t){let n=await this.getAccessToken(t),r,i;typeof n==`string`?(r=this.config.dpopNonceId?nn.DPoP:nn.Bearer,i=n):(r=n.token_type,i=n.access_token),this.setAuthorizationHeader(e,i,r),r===nn.DPoP&&await this.setDpopProofHeader(e,i)}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||``:typeof e.get==`function`?e.get(t)||``:e[t]||``}hasUseDpopNonceError(e){if(e.status!==401)return!1;let t=this.getHeader(e.headers,`www-authenticate`);return t.includes(`invalid_dpop_nonce`)||t.includes(`use_dpop_nonce`)}async handleResponse(e,t){let n=this.getHeader(e.headers,at);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new _e(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,r){let i=this.buildBaseRequest(e,t);await this.prepareRequest(i,r);let a=await this.config.fetch(i);return this.handleResponse(a,n)}fetchWithAuth(e,t,n){let r={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,Object.assign(Object.assign({},r),{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,r,n)}},an=class{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t}async connectAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/connect`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async completeAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t)}catch(n){throw new on({type:`invalid_json`,status:e.status,title:`Invalid JSON response`,detail:t||String(n)})}if(e.ok)return t;throw new on(t)}},on=class e extends Error{constructor(t){let{type:n,status:r,title:i,detail:a,validation_errors:o}=t;super(a),this.name=`MyAccountApiError`,this.type=n,this.status=r,this.title=i,this.detail=a,this.validation_errors=o,Object.setPrototypeOf(this,e.prototype)}},sn={otp:{authenticatorTypes:[`otp`]},sms:{authenticatorTypes:[`oob`],oobChannels:[`sms`]},email:{authenticatorTypes:[`oob`],oobChannels:[`email`]},push:{authenticatorTypes:[`oob`],oobChannels:[`auth0`]},voice:{authenticatorTypes:[`oob`],oobChannels:[`voice`]}},cn=`http://auth0.com/oauth/grant-type/mfa-otp`,ln=`http://auth0.com/oauth/grant-type/mfa-oob`,un=`http://auth0.com/oauth/grant-type/mfa-recovery-code`;function dn(e,t){this.v=e,this.k=t}function w(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function fn(e){return new dn(e,0)}function pn(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function T(e,t){return e.get(w(e,t))}function E(e,t,n){pn(e,t),t.set(e,n)}function D(e,t,n){return e.set(w(e,t),n),n}function O(e,t,n){return(t=function(e){var t=function(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return typeof t==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?mn(Object(n),!0).forEach(function(t){O(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function hn(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function gn(e){return function(){return new _n(e.apply(this,arguments))}}function _n(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof dn;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}var vn,yn,bn;_n.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},_n.prototype.next=function(e){return this._invoke(`next`,e)},_n.prototype.throw=function(e){return this._invoke(`throw`,e)},_n.prototype.return=function(e){return this._invoke(`return`,e)},(typeof navigator>`u`||(vn=navigator.userAgent)==null||(yn=vn.startsWith)==null||!yn.call(vn,`Mozilla/5.0 `))&&(bn=`oauth4webapi/v3.8.5`);function xn(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var Sn=`ERR_INVALID_ARG_VALUE`,Cn=`ERR_INVALID_ARG_TYPE`;function A(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var wn=Symbol(),Tn=Symbol(),En=Symbol(),Dn=Symbol(),On=Symbol(),kn=Symbol(),An=new TextEncoder,jn=new TextDecoder;function Mn(e){return typeof e==`string`?An.encode(e):jn.decode(e)}var Nn,Pn;if(Uint8Array.prototype.toBase64)Nn=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;Nn=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Fn(e){return typeof e==`string`?Pn(e):Nn(e)}Pn=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:`base64url`})}catch(e){throw A(`The input to be decoded is not correctly encoded.`,Sn,e)}}:e=>{try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`).replace(/\s/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch(e){throw A(`The input to be decoded is not correctly encoded.`,Sn,e)}};var In=class extends Error{constructor(e,t){var n;super(e,t),O(this,`code`,void 0),this.name=this.constructor.name,this.code=Fr,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},Ln=class extends Error{constructor(e,t){var n;super(e,t),O(this,`code`,void 0),this.name=this.constructor.name,t!=null&&t.code&&(this.code=t?.code),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function j(e,t,n){return new Ln(e,{code:t,cause:n})}function Rn(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw A(`${t} must be a CryptoKey`,Cn)}(e,t),e.type!==`private`)throw A(`${t} must be a private CryptoKey`,Sn)}function zn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bn(e){xn(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(bn&&!t.has(`user-agent`)&&t.set(`user-agent`,bn),t.has(`authorization`))throw A(`"options.headers" must not include the "authorization" header name`,Sn);return t}function Vn(e,t){if(t!==void 0){if(typeof t==`function`&&(t=t(e.href)),!(t instanceof AbortSignal))throw A(`"options.signal" must return or be an instance of AbortSignal`,Cn);return t}}function Hn(e){return e.includes(`//`)?e.replace(`//`,`/`):e}async function Un(e,t){return async function(e,t,n,r){if(!(e instanceof URL))throw A(`"${t}" must be an instance of URL`,Cn);nr(e,!0!==r?.[wn]);let i=n(new URL(e.href)),a=Bn(r?.headers);return a.set(`accept`,`application/json`),(r?.[Dn]||fetch)(i.href,{body:void 0,headers:Object.fromEntries(a.entries()),method:`GET`,redirect:`manual`,signal:Vn(i,r?.signal)})}(e,`issuerIdentifier`,e=>{switch(t?.algorithm){case void 0:case`oidc`:(function(e,t){e.pathname=Hn(`${e.pathname}/${t}`)})(e,`.well-known/openid-configuration`);break;case`oauth2`:(function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2];e.pathname===`/`?e.pathname=t:e.pathname=Hn(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,``)}`)})(e,`.well-known/oauth-authorization-server`);break;default:throw A(`"options.algorithm" must be "oidc" (default), or "oauth2"`,Sn)}return e},t)}function Wn(e,t,n,r,i){try{if(typeof e!=`number`||!Number.isFinite(e))throw A(`${n} must be a number`,Cn,i);if(e>0)return;if(t){if(e!==0)throw A(`${n} must be a non-negative number`,Sn,i);return}throw A(`${n} must be a positive number`,Sn,i)}catch(e){throw r?j(e.message,r,i):e}}function M(e,t,n,r){try{if(typeof e!=`string`)throw A(`${t} must be a string`,Cn,r);if(e.length===0)throw A(`${t} must not be empty`,Sn,r)}catch(e){throw n?j(e.message,n,r):e}}function Gn(e){(function(e,t){if(_r(e)!==t)throw function(e){let t=`"response" content-type must be `;for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(r.length>2){let e=r.pop();t+=`${r.join(`, `)}, or ${e}`}else r.length===2?t+=`${r[0]} or ${r[1]}`:t+=r[0];return j(t,Rr,e)}(e,t)})(e,`application/json`)}function Kn(){return Fn(crypto.getRandomValues(new Uint8Array(32)))}function qn(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`PS256`;case`SHA-384`:return`PS384`;case`SHA-512`:return`PS512`;default:throw new In(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`RSASSA-PKCS1-v1_5`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`RS256`;case`SHA-384`:return`RS384`;case`SHA-512`:return`RS512`;default:throw new In(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`ECDSA`:return function(e){switch(e.algorithm.namedCurve){case`P-256`:return`ES256`;case`P-384`:return`ES384`;case`P-521`:return`ES512`;default:throw new In(`unsupported EcKeyAlgorithm namedCurve`,{cause:e})}}(e);case`Ed25519`:case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return e.algorithm.name;case`EdDSA`:return`Ed25519`;default:throw new In(`unsupported CryptoKey algorithm name`,{cause:e})}}function Jn(e){let t=e?.[Tn];return typeof t==`number`&&Number.isFinite(t)?t:0}function Yn(e){let t=e?.[En];return typeof t==`number`&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function Xn(){return Math.floor(Date.now()/1e3)}function Zn(e){if(typeof e!=`object`||!e)throw A(`"as" must be an object`,Cn);M(e.issuer,`"as.issuer"`)}function Qn(e){if(typeof e!=`object`||!e)throw A(`"client" must be an object`,Cn);M(e.client_id,`"client.client_id"`)}function $n(e){return M(e,`"clientSecret"`),(t,n,r,i)=>{r.set(`client_id`,n.client_id),r.set(`client_secret`,e)}}function er(e,t){let{key:n,kid:r}=(i=e)instanceof CryptoKey?{key:i}:i?.key instanceof CryptoKey?(i.kid!==void 0&&M(i.kid,`"kid"`),{key:i.key,kid:i.kid}):{};var i;return Rn(n,`"clientPrivateKey.key"`),async(e,i,a,o)=>{var s;let c={alg:qn(n),kid:r},l=function(e,t){let n=Xn()+Jn(t);return{jti:Kn(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,i);t==null||(s=t[On])==null||s.call(t,c,l),a.set(`client_id`,i.client_id),a.set(`client_assertion_type`,`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`),a.set(`client_assertion`,await async function(e,t,n){if(!n.usages.includes(`sign`))throw A(`CryptoKey instances used for signing assertions must include "sign" in their "usages"`,Sn);let r=`${Fn(Mn(JSON.stringify(e)))}.${Fn(Mn(JSON.stringify(t)))}`;return`${r}.${Fn(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:Yr(e)};case`RSA-PSS`:switch(Jr(e),e.algorithm.hash.name){case`SHA-256`:case`SHA-384`:case`SHA-512`:return{name:e.algorithm.name,saltLength:parseInt(e.algorithm.hash.name.slice(-3),10)>>3};default:throw new In(`unsupported RSA-PSS hash name`,{cause:e})}case`RSASSA-PKCS1-v1_5`:return Jr(e),e.algorithm.name;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:case`Ed25519`:return e.algorithm.name}throw new In(`unsupported CryptoKey algorithm name`,{cause:e})}(n),n,Mn(r)))}`}(c,l,n))}}var tr=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function nr(e,t){if(t&&e.protocol!==`https:`)throw j(`only requests to HTTPS are allowed`,Br,e);if(e.protocol!==`https:`&&e.protocol!==`http:`)throw j(`only HTTP and HTTPS requests are allowed`,Vr,e)}function rr(e,t,n,r){let i;if(typeof e!=`string`||!(i=tr(e)))throw j(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Gr:Kr,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return nr(i,r),i}function ir(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?rr(e.mtls_endpoint_aliases[t],t,n,r):rr(e[t],t,n,r)}var ar=class extends Error{constructor(e,t){var n;super(e,t),O(this,`cause`,void 0),O(this,`code`,void 0),O(this,`error`,void 0),O(this,`status`,void 0),O(this,`error_description`,void 0),O(this,`response`,void 0),this.name=this.constructor.name,this.code=Pr,this.cause=t.cause,this.error=t.cause.error,this.status=t.response.status,this.error_description=t.cause.error_description,Object.defineProperty(this,`response`,{enumerable:!1,value:t.response}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},or=class extends Error{constructor(e,t){var n;super(e,t),O(this,`cause`,void 0),O(this,`code`,void 0),O(this,`error`,void 0),O(this,`error_description`,void 0),this.name=this.constructor.name,this.code=Ir,this.cause=t.cause,this.error=t.cause.get(`error`),this.error_description=t.cause.get(`error_description`)??void 0,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},sr=class extends Error{constructor(e,t){var n;super(e,t),O(this,`cause`,void 0),O(this,`code`,void 0),O(this,`response`,void 0),O(this,`status`,void 0),this.name=this.constructor.name,this.code=Nr,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,`response`,{enumerable:!1}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},cr="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",lr=`(`+cr+`)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"`,ur=`(`+cr+")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)",dr=RegExp(`^[,\\s]*(`+cr+`)`),fr=RegExp(`^[,\\s]*`+lr+`[,\\s]*(.*)`),pr=RegExp(`^[,\\s]*`+ur+`[,\\s]*(.*)`),mr=RegExp(`^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)`);async function hr(e,t,n){if(e.status!==t){let t;throw function(e){let t;if(t=function(e){if(!xn(e,Response))throw A(`"response" must be an instance of Response`,Cn);let t=e.headers.get(`www-authenticate`);if(t===null)return;let n=[],r=t;for(;r;){let e=r.match(dr),t=e?.[1].toLowerCase();if(!t)return;let i=r.substring(e[0].length);if(i&&!i.match(/^[\s,]/))return;let a=i.match(/^\s+(.*)$/),o=!!a;r=a?a[1]:void 0;let s={},c;if(o)for(;r;){let t,n;if(e=r.match(fr)){if([,t,n,r]=e,n.includes(`\\`))try{n=JSON.parse(`"${n}"`)}catch{}s[t.toLowerCase()]=n}else{if(!(e=r.match(pr))){if(e=r.match(mr)){if(Object.keys(s).length)break;[,c,r]=e;break}return}[,t,n,r]=e,s[t.toLowerCase()]=n}}else r=i||void 0;let l={scheme:t,parameters:s};c&&(l.token68=c),n.push(l)}return n.length?n:void 0}(e))throw new sr(`server responded with a challenge in the WWW-Authenticate HTTP Header`,{cause:t,response:e})}(e),(t=await async function(e){if(e.status>399&&e.status<500){qr(e),Gn(e);try{let t=await e.clone().json();if(zn(t)&&typeof t.error==`string`&&t.error.length)return t}catch{}}}(e))?(await e.body?.cancel(),new ar(`server responded with an error in the response body`,{cause:t,response:e})):j(`"response" is not a conform ${n} response (unexpected HTTP status code)`,zr,e)}}function gr(e){if(!Er.has(e))throw A(`"options.DPoP" is not a valid DPoPHandle`,Sn)}function _r(e){return e.headers.get(`content-type`)?.split(`;`)[0]}async function vr(e,t,n,r,i,a,o){return await n(e,t,i,a),a.set(`content-type`,`application/x-www-form-urlencoded;charset=UTF-8`),(o?.[Dn]||fetch)(r.href,{body:i,headers:Object.fromEntries(a.entries()),method:`POST`,redirect:`manual`,signal:Vn(r,o?.signal)})}async function yr(e,t,n,r,i,a){var o;let s=ir(e,`token_endpoint`,t.use_mtls_endpoint_aliases,!0!==a?.[wn]);i.set(`grant_type`,r);let c=Bn(a?.headers);c.set(`accept`,`application/json`),a?.DPoP!==void 0&&(gr(a.DPoP),await a.DPoP.addProof(s,c,`POST`));let l=await vr(e,t,n,s,i,c,a);return a==null||(o=a.DPoP)==null||o.cacheNonce(l,s),l}var br=new WeakMap,xr=new WeakMap;function Sr(e){if(!e.id_token)return;let t=br.get(e);if(!t)throw A(`"ref" was already garbage collected or did not resolve from the proper sources`,Sn);return t}async function Cr(e,t,n,r,i,a){if(Zn(e),Qn(t),!xn(n,Response))throw A(`"response" must be an instance of Response`,Cn);await hr(n,200,`Token Endpoint`),qr(n);let o=await ni(n);if(M(o.access_token,`"response" body "access_token" property`,N,{body:o}),M(o.token_type,`"response" body "token_type" property`,N,{body:o}),o.token_type=o.token_type.toLowerCase(),o.expires_in!==void 0){let e=typeof o.expires_in==`number`?o.expires_in:parseFloat(o.expires_in);Wn(e,!0,`"response" body "expires_in" property`,N,{body:o}),o.expires_in=e}if(o.refresh_token!==void 0&&M(o.refresh_token,`"response" body "refresh_token" property`,N,{body:o}),o.scope!==void 0&&typeof o.scope!=`string`)throw j(`"response" body "scope" property must be a string`,N,{body:o});if(o.id_token!==void 0){M(o.id_token,`"response" body "id_token" property`,N,{body:o});let a=[`aud`,`exp`,`iat`,`iss`,`sub`];!0===t.require_auth_time&&a.push(`auth_time`),t.default_max_age!==void 0&&(Wn(t.default_max_age,!0,`"client.default_max_age"`),a.push(`auth_time`)),r!=null&&r.length&&a.push(...r);let{claims:s,jwt:c}=await async function(e,t,n,r,i){let a,o,{0:s,1:c,length:l}=e.split(`.`);if(l===5){if(i===void 0)throw new In(`JWE decryption is not configured`,{cause:e});e=await i(e),{0:s,1:c,length:l}=e.split(`.`)}if(l!==3)throw j(`Invalid JWT`,N,e);try{a=JSON.parse(Mn(Fn(s)))}catch(e){throw j(`failed to parse JWT Header body as base64url encoded JSON`,Lr,e)}if(!zn(a))throw j(`JWT Header must be a top level object`,N,e);if(t(a),a.crit!==void 0)throw new In(`no JWT "crit" header parameter extensions are supported`,{cause:{header:a}});try{o=JSON.parse(Mn(Fn(c)))}catch(e){throw j(`failed to parse JWT Payload body as base64url encoded JSON`,Lr,e)}if(!zn(o))throw j(`JWT Payload must be a top level object`,N,e);let u=Xn()+n;if(o.exp!==void 0){if(typeof o.exp!=`number`)throw j(`unexpected JWT "exp" (expiration time) claim type`,N,{claims:o});if(o.exp<=u-r)throw j(`unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp`,Hr,{claims:o,now:u,tolerance:r,claim:`exp`})}if(o.iat!==void 0&&typeof o.iat!=`number`)throw j(`unexpected JWT "iat" (issued at) claim type`,N,{claims:o});if(o.iss!==void 0&&typeof o.iss!=`string`)throw j(`unexpected JWT "iss" (issuer) claim type`,N,{claims:o});if(o.nbf!==void 0){if(typeof o.nbf!=`number`)throw j(`unexpected JWT "nbf" (not before) claim type`,N,{claims:o});if(o.nbf>u+r)throw j(`unexpected JWT "nbf" (not before) claim value`,Hr,{claims:o,now:u,tolerance:r,claim:`nbf`})}if(o.aud!==void 0&&typeof o.aud!=`string`&&!Array.isArray(o.aud))throw j(`unexpected JWT "aud" (audience) claim type`,N,{claims:o});return{header:a,claims:o,jwt:e}}(o.id_token,Zr.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,`RS256`),Jn(t),Yn(t),i).then(kr.bind(void 0,a)).then(Tr.bind(void 0,e)).then(wr.bind(void 0,t.client_id));if(Array.isArray(s.aud)&&s.aud.length!==1){if(s.azp===void 0)throw j(`ID Token "aud" (audience) claim includes additional untrusted audiences`,Ur,{claims:s,claim:`aud`});if(s.azp!==t.client_id)throw j(`unexpected ID Token "azp" (authorized party) claim value`,Ur,{expected:t.client_id,claims:s,claim:`azp`})}s.auth_time!==void 0&&Wn(s.auth_time,!0,`ID Token "auth_time" (authentication time)`,N,{claims:s}),xr.set(n,c),br.set(o,s)}if(a?.[o.token_type]!==void 0)a[o.token_type](n,o);else if(o.token_type!==`dpop`&&o.token_type!==`bearer`)throw new In("unsupported `token_type` value",{cause:{body:o}});return o}function wr(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw j(`unexpected JWT "aud" (audience) claim value`,Ur,{expected:e,claims:t.claims,claim:`aud`})}else if(t.claims.aud!==e)throw j(`unexpected JWT "aud" (audience) claim value`,Ur,{expected:e,claims:t.claims,claim:`aud`});return t}function Tr(e,t){let n=e[ii]?.call(e,t)??e.issuer;if(t.claims.iss!==n)throw j(`unexpected JWT "iss" (issuer) claim value`,Ur,{expected:n,claims:t.claims,claim:`iss`});return t}var Er=new WeakSet,Dr=Symbol(),Or={aud:`audience`,c_hash:`code hash`,client_id:`client id`,exp:`expiration time`,iat:`issued at`,iss:`issuer`,jti:`jwt id`,nonce:`nonce`,s_hash:`state hash`,sub:`subject`,ath:`access token hash`,htm:`http method`,htu:`http uri`,cnf:`confirmation`,auth_time:`authentication time`};function kr(e,t){for(let n of e)if(t.claims[n]===void 0)throw j(`JWT "${n}" (${Or[n]}) claim missing`,N,{claims:t.claims});return t}var Ar=Symbol(),jr=Symbol();async function Mr(e,t,n,r){return typeof r?.expectedNonce==`string`||typeof r?.maxAge==`number`||r!=null&&r.requireIdToken?async function(e,t,n,r,i,a,o){let s=[];switch(r){case void 0:r=Ar;break;case Ar:break;default:M(r,`"expectedNonce" argument`),s.push(`nonce`)}switch(i??=t.default_max_age,i){case void 0:i=jr;break;case jr:break;default:Wn(i,!0,`"maxAge" argument`),s.push(`auth_time`)}let c=await Cr(e,t,n,s,a,o);M(c.id_token,`"response" body "id_token" property`,N,{body:c});let l=Sr(c);if(i!==jr){let e=Xn()+Jn(t),n=Yn(t);if(l.auth_time+i<e-n)throw j(`too much time has elapsed since the last End-User authentication`,Hr,{claims:l,now:e,tolerance:n,claim:`auth_time`})}if(r===Ar){if(l.nonce!==void 0)throw j(`unexpected ID Token "nonce" claim value`,Ur,{expected:void 0,claims:l,claim:`nonce`})}else if(l.nonce!==r)throw j(`unexpected ID Token "nonce" claim value`,Ur,{expected:r,claims:l,claim:`nonce`});return c}(e,t,n,r.expectedNonce,r.maxAge,r[kn],r.recognizedTokenTypes):async function(e,t,n,r,i){let a=await Cr(e,t,n,void 0,r,i),o=Sr(a);if(o){if(t.default_max_age!==void 0){Wn(t.default_max_age,!0,`"client.default_max_age"`);let e=Xn()+Jn(t),n=Yn(t);if(o.auth_time+t.default_max_age<e-n)throw j(`too much time has elapsed since the last End-User authentication`,Hr,{claims:o,now:e,tolerance:n,claim:`auth_time`})}if(o.nonce!==void 0)throw j(`unexpected ID Token "nonce" claim value`,Ur,{expected:void 0,claims:o,claim:`nonce`})}return a}(e,t,n,r?.[kn],r?.recognizedTokenTypes)}var Nr=`OAUTH_WWW_AUTHENTICATE_CHALLENGE`,Pr=`OAUTH_RESPONSE_BODY_ERROR`,Fr=`OAUTH_UNSUPPORTED_OPERATION`,Ir=`OAUTH_AUTHORIZATION_RESPONSE_ERROR`,Lr=`OAUTH_PARSE_ERROR`,N=`OAUTH_INVALID_RESPONSE`,Rr=`OAUTH_RESPONSE_IS_NOT_JSON`,zr=`OAUTH_RESPONSE_IS_NOT_CONFORM`,Br=`OAUTH_HTTP_REQUEST_FORBIDDEN`,Vr=`OAUTH_REQUEST_PROTOCOL_FORBIDDEN`,Hr=`OAUTH_JWT_TIMESTAMP_CHECK_FAILED`,Ur=`OAUTH_JWT_CLAIM_COMPARISON_FAILED`,Wr=`OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED`,Gr=`OAUTH_MISSING_SERVER_METADATA`,Kr=`OAUTH_INVALID_SERVER_METADATA`;function qr(e){if(e.bodyUsed)throw A(`"response" body has been used already`,Sn)}function Jr(e){let{algorithm:t}=e;if(typeof t.modulusLength!=`number`||t.modulusLength<2048)throw new In(`unsupported ${t.name} modulusLength`,{cause:e})}function Yr(e){let{algorithm:t}=e;switch(t.namedCurve){case`P-256`:return`SHA-256`;case`P-384`:return`SHA-384`;case`P-521`:return`SHA-512`;default:throw new In(`unsupported ECDSA namedCurve`,{cause:e})}}async function Xr(e){if(e.method!==`POST`)throw A(`form_post responses are expected to use the POST method`,Sn,{cause:e});if(_r(e)!==`application/x-www-form-urlencoded`)throw A(`form_post responses are expected to use the application/x-www-form-urlencoded content-type`,Sn,{cause:e});return async function(e){if(e.bodyUsed)throw A(`form_post Request instances must contain a readable body`,Sn,{cause:e});return e.text()}(e)}function Zr(e,t,n,r){if(e===void 0)if(Array.isArray(t)){if(!t.includes(r.alg))throw j(`unexpected JWT "alg" header parameter`,N,{header:r,expected:t,reason:`authorization server metadata`})}else{if(n===void 0)throw j(`missing client or server configuration to verify used JWT "alg" header parameter`,void 0,{client:e,issuer:t,fallback:n});if(typeof n==`string`?r.alg!==n:typeof n==`function`?!n(r.alg):!n.includes(r.alg))throw j(`unexpected JWT "alg" header parameter`,N,{header:r,expected:n,reason:`default value`})}else if(typeof e==`string`?r.alg!==e:!e.includes(r.alg))throw j(`unexpected JWT "alg" header parameter`,N,{header:r,expected:e,reason:`client configuration`})}function Qr(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw j(`"${t}" parameter must be provided only once`,N);return n}var $r=Symbol(),ei=Symbol();function ti(e,t,n,r){if(Zn(e),Qn(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw A(`"parameters" must be an instance of URLSearchParams, or URL`,Cn);if(Qr(n,`response`))throw j(`"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()`,N,{parameters:n});let i=Qr(n,`iss`),a=Qr(n,`state`);if(!i&&e.authorization_response_iss_parameter_supported)throw j(`response parameter "iss" (issuer) missing`,N,{parameters:n});if(i&&i!==e.issuer)throw j(`unexpected "iss" (issuer) response parameter value`,N,{expected:e.issuer,parameters:n});switch(r){case void 0:case ei:if(a!==void 0)throw j(`unexpected "state" response parameter encountered`,N,{expected:void 0,parameters:n});break;case $r:break;default:if(M(r,`"expectedState" argument`),a!==r)throw j(a===void 0?`response parameter "state" missing`:`unexpected "state" response parameter value`,N,{expected:r,parameters:n})}if(Qr(n,`error`))throw new or(`authorization response from the server is an error`,{cause:n});let o=Qr(n,`id_token`),s=Qr(n,`token`);if(o!==void 0||s!==void 0)throw new In(`implicit and hybrid flows are not supported`);return c=new URLSearchParams(n),Er.add(c),c;var c}async function ni(e){let t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Gn;try{t=await e.json()}catch(t){throw n(e),j(`failed to parse "response" body as JSON`,Lr,t)}if(!zn(t))throw j(`"response" body must be a top level object`,N,{body:t});return t}var ri=Symbol(),ii=Symbol(),ai=new TextEncoder,oi=new TextDecoder;function si(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>127)throw TypeError(`non-ASCII string encountered in encode()`);t[n]=r}return t}function ci(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function li(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:oi.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=oi.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return ci(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var ui=function(e){return TypeError(`CryptoKey does not support this operation, its ${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`algorithm.name`} must be ${e}`)},di=(e,t)=>e.name===t;function fi(e,t){var n;if((n=e.hash,parseInt(n.name.slice(4),10))!==t)throw ui(`SHA-${t}`,`algorithm.hash`)}function pi(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!di(e.algorithm,`HMAC`))throw ui(`HMAC`);fi(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!di(e.algorithm,`RSASSA-PKCS1-v1_5`))throw ui(`RSASSA-PKCS1-v1_5`);fi(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!di(e.algorithm,`RSA-PSS`))throw ui(`RSA-PSS`);fi(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!di(e.algorithm,`Ed25519`))throw ui(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!di(e.algorithm,t))throw ui(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!di(e.algorithm,`ECDSA`))throw ui(`ECDSA`);let n=function(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}(t);if(e.algorithm.namedCurve!==n)throw ui(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}(function(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)})(e,n)}function mi(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if((r=r.filter(Boolean)).length>2){let t=r.pop();e+=`one of type ${r.join(`, `)}, or ${t}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==`function`&&t.name)e+=` Received function ${t.name}`;else if(typeof t==`object`&&t){var a;(a=t.constructor)!=null&&a.name&&(e+=` Received an instance of ${t.constructor.name}`)}return e}var hi=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return mi(`Key for the ${e} algorithm must be `,t,...r)},gi=class extends Error{constructor(e,t){var n;super(e,t),O(this,`code`,`ERR_JOSE_GENERIC`),this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};O(gi,`code`,`ERR_JOSE_GENERIC`);var _i=class extends gi{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),O(this,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`),O(this,`claim`,void 0),O(this,`reason`,void 0),O(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};O(_i,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`);var vi=class extends gi{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),O(this,`code`,`ERR_JWT_EXPIRED`),O(this,`claim`,void 0),O(this,`reason`,void 0),O(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};O(vi,`code`,`ERR_JWT_EXPIRED`);var yi=class extends gi{constructor(){super(...arguments),O(this,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`)}};O(yi,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`);var bi=class extends gi{constructor(){super(...arguments),O(this,`code`,`ERR_JOSE_NOT_SUPPORTED`)}};O(bi,`code`,`ERR_JOSE_NOT_SUPPORTED`),O(class extends gi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`decryption operation failed`,arguments.length>1?arguments[1]:void 0),O(this,`code`,`ERR_JWE_DECRYPTION_FAILED`)}},`code`,`ERR_JWE_DECRYPTION_FAILED`),O(class extends gi{constructor(){super(...arguments),O(this,`code`,`ERR_JWE_INVALID`)}},`code`,`ERR_JWE_INVALID`);var xi=class extends gi{constructor(){super(...arguments),O(this,`code`,`ERR_JWS_INVALID`)}};O(xi,`code`,`ERR_JWS_INVALID`);var Si=class extends gi{constructor(){super(...arguments),O(this,`code`,`ERR_JWT_INVALID`)}};O(Si,`code`,`ERR_JWT_INVALID`),O(class extends gi{constructor(){super(...arguments),O(this,`code`,`ERR_JWK_INVALID`)}},`code`,`ERR_JWK_INVALID`);var Ci=class extends gi{constructor(){super(...arguments),O(this,`code`,`ERR_JWKS_INVALID`)}};O(Ci,`code`,`ERR_JWKS_INVALID`);var wi=class extends gi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`no applicable key found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),O(this,`code`,`ERR_JWKS_NO_MATCHING_KEY`)}};O(wi,`code`,`ERR_JWKS_NO_MATCHING_KEY`);var Ti=class extends gi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`multiple matching keys found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),O(this,Symbol.asyncIterator,void 0),O(this,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`)}};O(Ti,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`);var Ei=class extends gi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`request timed out`,arguments.length>1?arguments[1]:void 0),O(this,`code`,`ERR_JWKS_TIMEOUT`)}};O(Ei,`code`,`ERR_JWKS_TIMEOUT`);var Di=class extends gi{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`signature verification failed`,arguments.length>1?arguments[1]:void 0),O(this,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`)}};O(Di,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`);var Oi=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},ki=e=>e?.[Symbol.toStringTag]===`KeyObject`,Ai=e=>Oi(e)||ki(e);function ji(e,t,n){try{return li(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}function Mi(e){if(typeof(t=e)!=`object`||t===null||Object.prototype.toString.call(e)!==`[object Object]`)return!1;var t;if(Object.getPrototypeOf(e)===null)return!0;let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}var Ni=e=>Mi(e)&&typeof e.kty==`string`;async function Pi(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return mi(`Key must be `,e,...n)}(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return pi(t,e,n),t}async function Fi(e,t,n,r){let i=await Pi(e,t,`verify`);(function(e,t){if(e.startsWith(`RS`)||e.startsWith(`PS`)){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,i);let a=function(e,t){let n=`SHA-${e.slice(-3)}`;switch(e){case`HS256`:case`HS384`:case`HS512`:return{hash:n,name:`HMAC`};case`PS256`:case`PS384`:case`PS512`:return{hash:n,name:`RSA-PSS`,saltLength:parseInt(e.slice(-3),10)>>3};case`RS256`:case`RS384`:case`RS512`:return{hash:n,name:`RSASSA-PKCS1-v1_5`};case`ES256`:case`ES384`:case`ES512`:return{hash:n,name:`ECDSA`,namedCurve:t.namedCurve};case`Ed25519`:case`EdDSA`:return{name:`Ed25519`};case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return{name:e};default:throw new bi(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var Ii=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;async function Li(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=function(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new bi(Ii)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new bi(Ii)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new bi(Ii)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new bi(Ii)}break;default:throw new bi(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}(e),r=k({},e);return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??(!e.d&&!e.priv),e.key_ops??n)}var Ri=`given KeyObject instance cannot be used for this algorithm`,zi,Bi=async function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];zi||=new WeakMap;let i=zi.get(e);if(i!=null&&i[n])return i[n];let a=await Li(k(k({},t),{},{alg:n}));return r&&Object.freeze(e),i?i[n]=a:zi.set(e,{[n]:a}),a};async function Vi(e,t){if(e instanceof Uint8Array||Oi(e))return e;if(ki(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return((e,t)=>{zi||=new WeakMap;let n=zi.get(e);if(n!=null&&n[t])return n[t];let r=e.type===`public`,i=!!r,a;if(e.asymmetricKeyType===`x25519`){switch(t){case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:break;default:throw TypeError(Ri)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(Ri);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}switch(e.asymmetricKeyType){case`ml-dsa-44`:case`ml-dsa-65`:case`ml-dsa-87`:if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(Ri);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`rsa`){let n;switch(t){case`RSA-OAEP`:n=`SHA-1`;break;case`RS256`:case`PS256`:case`RSA-OAEP-256`:n=`SHA-256`;break;case`RS384`:case`PS384`:case`RSA-OAEP-384`:n=`SHA-384`;break;case`RS512`:case`PS512`:case`RSA-OAEP-512`:n=`SHA-512`;break;default:throw TypeError(Ri)}if(t.startsWith(`RSA-OAEP`))return e.toCryptoKey({name:`RSA-OAEP`,hash:n},i,r?[`encrypt`]:[`decrypt`]);a=e.toCryptoKey({name:t.startsWith(`PS`)?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:n},i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`ec`){let n=new Map([[`prime256v1`,`P-256`],[`secp384r1`,`P-384`],[`secp521r1`,`P-521`]]).get(e.asymmetricKeyDetails?.namedCurve);if(!n)throw TypeError(Ri);let o={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};o[t]&&n===o[t]&&(a=e.toCryptoKey({name:`ECDSA`,namedCurve:n},i,[r?`verify`:`sign`])),t.startsWith(`ECDH-ES`)&&(a=e.toCryptoKey({name:`ECDH`,namedCurve:n},i,r?[]:[`deriveBits`]))}if(!a)throw TypeError(Ri);return n?n[t]=a:zi.set(e,{[t]:a}),a})(e,t)}catch(e){if(e instanceof TypeError)throw e}return Bi(e,e.export({format:`jwk`}),t)}if(Ni(e))return e.k?li(e.k):Bi(e,e,t,!0);throw Error(`unreachable`)}var Hi=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},Ui=e=>{let t=e.data[e.pos++];if(128&t){let n=127&t,r=0;for(let t=0;t<n;t++)r=r<<8|e.data[e.pos++];return r}return t},Wi=(e,t,n)=>{if(e.data[e.pos++]!==t)throw Error(n)},Gi=(e,t)=>{let n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},Ki=e=>{let t=(e=>(Wi(e,6,`Expected algorithm OID`),Gi(e,Ui(e))))(e);if(Hi(t,[43,101,110]))return`X25519`;if(!Hi(t,[42,134,72,206,61,2,1]))throw Error(`Unsupported key algorithm`);Wi(e,6,`Expected curve OID`);let n=Gi(e,Ui(e));for(let{name:e,oid:t}of[{name:`P-256`,oid:[42,134,72,206,61,3,1,7]},{name:`P-384`,oid:[43,129,4,0,34]},{name:`P-521`,oid:[43,129,4,0,35]}])if(Hi(n,t))return e;throw Error(`Unsupported named curve`)},qi=async(e,t,n,r)=>{let i,a,o=e===`spki`,s=()=>o?[`verify`]:[`sign`];switch(n){case`PS256`:case`PS384`:case`PS512`:i={name:`RSA-PSS`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RS256`:case`RS384`:case`RS512`:i={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:i={name:`RSA-OAEP`,hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=o?[`encrypt`,`wrapKey`]:[`decrypt`,`unwrapKey`];break;case`ES256`:case`ES384`:case`ES512`:i={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[n]},a=s();break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:try{let e=r.getNamedCurve(t);i=e===`X25519`?{name:`X25519`}:{name:`ECDH`,namedCurve:e}}catch{throw new bi(`Invalid or unsupported key format`)}a=o?[]:[`deriveBits`];break;case`Ed25519`:case`EdDSA`:i={name:`Ed25519`},a=s();break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:i={name:n},a=s();break;default:throw new bi(`Invalid or unsupported "alg" (Algorithm) value`)}return crypto.subtle.importKey(e,t,i,r?.extractable??!!o,a)},Ji=(e,t,n)=>{var r;let i=((e,t)=>ci(e.replace(t,``)))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),a=n;return t!=null&&(r=t.startsWith)!=null&&r.call(t,`ECDH-ES`)&&(a||={},a.getNamedCurve=e=>{let t={data:e,pos:0};return function(e){Wi(e,48,`Invalid PKCS#8 structure`),Ui(e),Wi(e,2,`Expected version field`);let t=Ui(e);e.pos+=t,Wi(e,48,`Expected algorithm identifier`),Ui(e),e.pos}(t),Ki(t)}),qi(`pkcs8`,i,t,a)},Yi=e=>e?.[Symbol.toStringTag],Xi=(e,t,n)=>{if(t.use!==void 0){let e;switch(n){case`sign`:case`verify`:e=`sig`;break;case`encrypt`:case`decrypt`:e=`enc`}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){var r,i;let a;switch(!0){case n===`sign`||n===`verify`:case e===`dir`:case e.includes(`CBC-HS`):a=n;break;case e.startsWith(`PBES2`):a=`deriveBits`;break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):a=!e.includes(`GCM`)&&e.endsWith(`KW`)?n===`encrypt`?`wrapKey`:`unwrapKey`:n;break;case n===`encrypt`&&e.startsWith(`RSA`):a=`wrapKey`;break;case n===`decrypt`:a=e.startsWith(`RSA`)?`unwrapKey`:`deriveBits`}if(a&&!1===((r=t.key_ops)==null||(i=r.includes)==null?void 0:i.call(r,a)))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${a}" when present`)}return!0};function Zi(e,t,n){switch(e.substring(0,2)){case`A1`:case`A2`:case`di`:case`HS`:case`PB`:((e,t,n)=>{if(!(t instanceof Uint8Array)){if(Ni(t)){if((e=>e.kty===`oct`&&typeof e.k==`string`)(t)&&Xi(e,t,n))return;throw TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!Ai(t))throw TypeError(hi(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${Yi(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,n);break;default:((e,t,n)=>{if(Ni(t))switch(n){case`decrypt`:case`sign`:if((e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`))(t)&&Xi(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if((e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0)(t)&&Xi(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!Ai(t))throw TypeError(hi(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${Yi(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${Yi(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${Yi(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${Yi(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${Yi(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,n)}}var Qi,$i,ea,ta;(typeof navigator>`u`||(Qi=navigator.userAgent)==null||($i=Qi.startsWith)==null||!$i.call(Qi,`Mozilla/5.0 `))&&(ta=`openid-client/v6.8.3`,ea={"user-agent":ta});var na=e=>ra.get(e),ra,ia;function aa(e){return e===void 0?(ia||=new WeakMap,(e,t,n,r)=>{let i;return(i=ia.get(t))||(function(e,t){if(typeof e!=`string`)throw la(`${t} must be a string`,ca);if(e.length===0)throw la(`${t} must not be empty`,sa)}(t.client_secret,`"metadata.client_secret"`),i=$n(t.client_secret),ia.set(t,i)),i(e,t,n,r)}):$n(e)}var oa=Dn,sa=`ERR_INVALID_ARG_VALUE`,ca=`ERR_INVALID_ARG_TYPE`;function la(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function ua(e){return async function(e){return M(e,`codeVerifier`),Fn(await crypto.subtle.digest(`SHA-256`,Mn(e)))}(e)}function da(){return Kn()}var fa=class extends Error{constructor(e,t){var n;super(e,t),O(this,`code`,void 0),this.name=this.constructor.name,this.code=t?.code,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function pa(e,t,n){return new fa(e,{cause:t,code:n})}function ma(e){if(e instanceof TypeError||e instanceof fa||e instanceof ar||e instanceof or||e instanceof sr)throw e;if(e instanceof Ln)switch(e.code){case Br:throw pa(`only requests to HTTPS are allowed`,e,e.code);case Vr:throw pa(`only requests to HTTP or HTTPS are allowed`,e,e.code);case zr:throw pa(`unexpected HTTP response status code`,e.cause,e.code);case Rr:throw pa(`unexpected response content-type`,e.cause,e.code);case Lr:throw pa(`parsing error occured`,e,e.code);case N:throw pa(`invalid response encountered`,e,e.code);case Ur:throw pa(`unexpected JWT claim value encountered`,e,e.code);case Wr:throw pa(`unexpected JSON attribute value encountered`,e,e.code);case Hr:throw pa(`JWT timestamp claim value failed validation`,e,e.code);default:throw pa(e.message,e,e.code)}if(e instanceof In)throw pa(`unsupported operation`,e,e.code);if(e instanceof DOMException)switch(e.name){case`OperationError`:throw pa(`runtime operation error`,e,Fr);case`NotSupportedError`:throw pa(`runtime unsupported operation`,e,Fr);case`TimeoutError`:throw pa(`operation timed out`,e,`OAUTH_TIMEOUT`);case`AbortError`:throw pa(`operation aborted`,e,`OAUTH_ABORT`)}throw new fa(`something went wrong`,{cause:e})}async function ha(e,t,n,r,i){let a=new _a(await async function(e,t){var n;if(!(e instanceof URL))throw la(`"server" must be an instance of URL`,ca);let r=!e.href.includes(`/.well-known/`),i=t?.timeout??30,a=AbortSignal.timeout(1e3*i),o=await(r?Un(e,{algorithm:t?.algorithm,[Dn]:t?.[oa],[wn]:t==null||(n=t.execute)==null?void 0:n.includes(Ca),signal:a,headers:new Headers(ea)}):(t?.[oa]||fetch)((nr(e,t==null||(s=t.execute)==null||!s.includes(Ca)),e.href),{headers:Object.fromEntries(new Headers(k({accept:`application/json`},ea)).entries()),body:void 0,method:`GET`,redirect:`manual`,signal:a})).then(e=>async function(e,t){let n=e;if(!(n instanceof URL)&&n!==ri)throw A(`"expectedIssuerIdentifier" must be an instance of URL`,Cn);if(!xn(t,Response))throw A(`"response" must be an instance of Response`,Cn);if(t.status!==200)throw j(`"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)`,zr,t);qr(t);let r=await ni(t);if(M(r.issuer,`"response" body "issuer" property`,N,{body:r}),n!==ri&&new URL(r.issuer).href!==n.href)throw j(`"response" body "issuer" property does not match the expected value`,Wr,{expected:n.href,body:r,attribute:`issuer`});return r}(ri,e)).catch(ma);var s;return r&&new URL(o.issuer).href!==e.href&&(function(e,t,n){return!(e.origin!==`https://login.microsoftonline.com`||n!=null&&n.algorithm&&n.algorithm!==`oidc`||(t[ga]=!0,0))}(e,o,t)||function(e,t){return!(!e.hostname.endsWith(`.b2clogin.com`)||t!=null&&t.algorithm&&t.algorithm!==`oidc`)}(e,t)||(()=>{throw new fa(`discovered metadata issuer does not match the expected issuer`,{code:Wr,cause:{expected:e.href,body:o,attribute:`issuer`}})})()),o}(e,i),t,n,r),o=na(a);if(i!=null&&i[oa]&&(o.fetch=i[oa]),i!=null&&i.timeout&&(o.timeout=i.timeout),i!=null&&i.execute)for(let e of i.execute)e(a);return a}new TextDecoder;var ga=Symbol(),_a=class{constructor(e,t,n,r){if(typeof t!=`string`||!t.length)throw la(`"clientId" must be a non-empty string`,ca);if(typeof n==`string`&&(n={client_secret:n}),n?.client_id!==void 0&&t!==n.client_id)throw la(`"clientId" and "metadata.client_id" must be the same`,sa);let i=k(k({},structuredClone(n)),{},{client_id:t}),a;i[Tn]=n?.[Tn]??0,i[En]=n?.[En]??30,a=r||(typeof i.client_secret==`string`&&i.client_secret.length?aa(i.client_secret):(e,t,n,r)=>{n.set(`client_id`,t.client_id)});let o=Object.freeze(i),s=structuredClone(e);ga in e&&(s[ii]=t=>{let{claims:{tid:n}}=t;return e.issuer.replace(`{tenantid}`,n)});let c=Object.freeze(s);ra||=new WeakMap,ra.set(this,{__proto__:null,as:c,c:o,auth:a,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let e=structuredClone(na(this).as);return function(e){Object.defineProperties(e,function(e){return{supportsPKCE:{__proto__:null,value(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`S256`;return!0===e.code_challenge_methods_supported?.includes(t)}}}}(e))}(e),e}clientMetadata(){return structuredClone(na(this).c)}get timeout(){return na(this).timeout}set timeout(e){na(this).timeout=e}get[oa](){return na(this).fetch}set[oa](e){na(this).fetch=e}};function va(e){Object.defineProperties(e,function(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return Sr(this)}catch{return}}}}}(e))}async function ya(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3],i=e.headers.get(`retry-after`)?.trim();if(i===void 0)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else{let e=new Date(i);if(Number.isFinite(e.getTime())){let t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3))}}if(r&&!Number.isFinite(a))throw new Ln(`invalid Retry-After header value`,{cause:e});a>t&&await ba(a-t,n)}function ba(e,t){return new Promise((n,r)=>{let i=e=>{try{t.throwIfAborted()}catch(e){r(e);return}if(e<=0)return void n();let a=Math.min(e,5);setTimeout(()=>i(e-a),1e3*a)};i(e)})}async function xa(e,t){ka(e);let{as:n,c:r,auth:i,fetch:a,tlsOnly:o,timeout:s}=na(e);return async function(e,t,n,r,i){Zn(e),Qn(t);let a=ir(e,`backchannel_authentication_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[wn]),o=new URLSearchParams(r);o.set(`client_id`,t.client_id);let s=Bn(i?.headers);return s.set(`accept`,`application/json`),vr(e,t,n,a,o,s,i)}(n,r,i,t,{[Dn]:a,[wn]:!o,headers:new Headers(ea),signal:Aa(s)}).then(e=>async function(e,t,n){if(Zn(e),Qn(t),!xn(n,Response))throw A(`"response" must be an instance of Response`,Cn);await hr(n,200,`Backchannel Authentication Endpoint`),qr(n);let r=await ni(n);M(r.auth_req_id,`"response" body "auth_req_id" property`,N,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Wn(i,!0,`"response" body "expires_in" property`,N,{body:r}),r.expires_in=i,r.interval!==void 0&&Wn(r.interval,!1,`"response" body "interval" property`,N,{body:r}),r}(n,r,e)).catch(ma)}async function Sa(e,t,n,r){ka(e),n=new URLSearchParams(n);let i=t.interval??5,a=r?.signal??AbortSignal.timeout(1e3*t.expires_in);try{await ba(i,a)}catch(e){ma(e)}let{as:o,c:s,auth:c,fetch:l,tlsOnly:u,nonRepudiation:d,timeout:f,decrypt:p}=na(e),m=(i,o)=>Sa(e,k(k({},t),{},{interval:i}),n,k(k({},r),{},{signal:a,flag:o})),h=await async function(e,t,n,r,i){Zn(e),Qn(t),M(r,`"authReqId"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`auth_req_id`,r),yr(e,t,n,`urn:openid:params:grant-type:ciba`,a,i)}(o,s,c,t.auth_req_id,{[Dn]:l,[wn]:!u,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(ea),signal:a.aborted?a:Aa(f)}).catch(ma);if(h.status===503&&h.headers.has(`retry-after`))return await ya(h,i,a,!0),await h.body?.cancel(),m(i);let g=async function(e,t,n,r){return Cr(e,t,n,void 0,r?.[kn],r?.recognizedTokenTypes)}(o,s,h,{[kn]:p}),_;try{_=await g}catch(e){if(ja(e,r))return m(i,Ma);if(e instanceof ar)switch(e.error){case`slow_down`:i+=5;case`authorization_pending`:return await ya(e.response,i,a),m(i)}ma(e)}return _.id_token&&await d?.(h),va(_),_}function Ca(e){na(e).tlsOnly=!1}async function wa(e,t,n,r,i){if(ka(e),!(i?.flag===Ma||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}(t,`Request`)))throw la(`"currentUrl" must be an instance of URL, or Request`,ca);let a,o,{as:s,c,auth:l,fetch:u,tlsOnly:d,jarm:f,hybrid:p,nonRepudiation:m,timeout:h,decrypt:g,implicit:_}=na(e);if(i?.flag===Ma)a=i.authResponse,o=i.redirectUri;else{if(!(t instanceof URL)){let e=t;switch(t=new URL(t.url),e.method){case`GET`:break;case`POST`:let n=new URLSearchParams(await Xr(e));if(p)t.hash=n.toString();else for(let[e,r]of n.entries())t.searchParams.append(e,r);break;default:throw la(`unexpected Request HTTP method`,sa)}}switch(o=function(e){return(e=new URL(e)).search=``,e.hash=``,e.href}(t),!0){case!!f:a=await f(t,n?.expectedState);break;case!!p:a=await p(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!_:throw TypeError(`authorizationCodeGrant() cannot be used by response_type=id_token clients`);default:try{a=ti(s,c,t.searchParams,n?.expectedState)}catch(e){ma(e)}}}let v=await async function(e,t,n,r,i,a,o){if(Zn(e),Qn(t),!Er.has(r))throw A(`"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()`,Sn);M(i,`"redirectUri"`);let s=Qr(r,`code`);if(!s)throw j(`no authorization code in "callbackParameters"`,N);let c=new URLSearchParams(o?.additionalParameters);return c.set(`redirect_uri`,i),c.set(`code`,s),a!==Dr&&(M(a,`"codeVerifier"`),c.set(`code_verifier`,a)),yr(e,t,n,`authorization_code`,c,o)}(s,c,l,a,o,n?.pkceCodeVerifier||Dr,{additionalParameters:r,[Dn]:u,[wn]:!d,DPoP:i?.DPoP,headers:new Headers(ea),signal:Aa(h)}).catch(ma);typeof n?.expectedNonce!=`string`&&typeof n?.maxAge!=`number`||(n.idTokenExpected=!0);let y=Mr(s,c,v,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[kn]:g}),ee;try{ee=await y}catch(t){if(ja(t,i))return wa(e,void 0,n,r,k(k({},i),{},{flag:Ma,authResponse:a,redirectUri:o}));ma(t)}return ee.id_token&&await m?.(v),va(ee),ee}async function Ta(e,t,n,r){ka(e),n=new URLSearchParams(n);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,nonRepudiation:l,timeout:u,decrypt:d}=na(e),f=await async function(e,t,n,r,i){Zn(e),Qn(t),M(r,`"refreshToken"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`refresh_token`,r),yr(e,t,n,`refresh_token`,a,i)}(i,a,o,t,{[Dn]:s,[wn]:!c,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(ea),signal:Aa(u)}).catch(ma),p=async function(e,t,n,r){return Cr(e,t,n,void 0,r?.[kn],r?.recognizedTokenTypes)}(i,a,f,{[kn]:d}),m;try{m=await p}catch(i){if(ja(i,r))return Ta(e,t,n,k(k({},r),{},{flag:Ma}));ma(i)}return m.id_token&&await l?.(f),va(m),m}async function Ea(e,t,n){ka(e),t=new URLSearchParams(t);let{as:r,c:i,auth:a,fetch:o,tlsOnly:s,timeout:c}=na(e),l=async function(e,t,n,r){return Cr(e,t,n,void 0,r?.[kn],r?.recognizedTokenTypes)}(r,i,await async function(e,t,n,r,i){return Zn(e),Qn(t),yr(e,t,n,`client_credentials`,new URLSearchParams(r),i)}(r,i,a,t,{[Dn]:o,[wn]:!s,DPoP:n?.DPoP,headers:new Headers(ea),signal:Aa(c)}).catch(ma)),u;try{u=await l}catch(r){if(ja(r,n))return Ea(e,t,k(k({},n),{},{flag:Ma}));ma(r)}return va(u),u}function Da(e,t){ka(e);let{as:n,c:r,tlsOnly:i,hybrid:a,jarm:o,implicit:s}=na(e),c=ir(n,`authorization_endpoint`,!1,i);if((t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id),!t.has(`request_uri`)&&!t.has(`request`)){if(t.has(`response_type`)||t.set(`response_type`,a?`code id_token`:s?`id_token`:`code`),s&&!t.has(`nonce`))throw la(`response_type=id_token clients must provide a nonce parameter in their authorization request parameters`,sa);o&&t.set(`response_mode`,`jwt`)}for(let[e,n]of t.entries())c.searchParams.append(e,n);return c}async function Oa(e,t,n){ka(e);let r=Da(e,t),{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l}=na(e),u=async function(e,t,n){if(Zn(e),Qn(t),!xn(n,Response))throw A(`"response" must be an instance of Response`,Cn);await hr(n,201,`Pushed Authorization Request Endpoint`),qr(n);let r=await ni(n);M(r.request_uri,`"response" body "request_uri" property`,N,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Wn(i,!0,`"response" body "expires_in" property`,N,{body:r}),r.expires_in=i,r}(i,a,await async function(e,t,n,r,i){var a;Zn(e),Qn(t);let o=ir(e,`pushed_authorization_request_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[wn]),s=new URLSearchParams(r);s.set(`client_id`,t.client_id);let c=Bn(i?.headers);c.set(`accept`,`application/json`),i?.DPoP!==void 0&&(gr(i.DPoP),await i.DPoP.addProof(o,c,`POST`));let l=await vr(e,t,n,o,s,c,i);return i==null||(a=i.DPoP)==null||a.cacheNonce(l,o),l}(i,a,o,r.searchParams,{[Dn]:s,[wn]:!c,DPoP:n?.DPoP,headers:new Headers(ea),signal:Aa(l)}).catch(ma)),d;try{d=await u}catch(r){if(ja(r,n))return Oa(e,t,k(k({},n),{},{flag:Ma}));ma(r)}return Da(e,{request_uri:d.request_uri})}function ka(e){if(!(e instanceof _a))throw la(`"config" must be an instance of Configuration`,ca);if(Object.getPrototypeOf(e)!==_a.prototype)throw la(`subclassing Configuration is not allowed`,sa)}function Aa(e){return e?AbortSignal.timeout(1e3*e):void 0}function ja(e,t){return!(t==null||!t.DPoP||t.flag===Ma)&&function(e){if(e instanceof sr){let{0:t,length:n}=e.cause;return n===1&&t.scheme===`dpop`&&t.parameters.error===`use_dpop_nonce`}return e instanceof ar&&e.error===`use_dpop_nonce`}(e)}Object.freeze(_a.prototype);var Ma=Symbol();async function Na(e,t,n,r){ka(e);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l,decrypt:u}=na(e),d=await async function(e,t,n,r,i,a){return Zn(e),Qn(t),M(r,`"grantType"`),yr(e,t,n,r,new URLSearchParams(i),a)}(i,a,o,t,new URLSearchParams(n),{[Dn]:s,[wn]:!c,DPoP:r?.DPoP,headers:new Headers(ea),signal:Aa(l)}).then(e=>{let n;return t===`urn:ietf:params:oauth:grant-type:token-exchange`&&(n={n_a:()=>{}}),async function(e,t,n,r){return Cr(e,t,n,void 0,r?.[kn],r?.recognizedTokenTypes)}(i,a,e,{[kn]:u,recognizedTokenTypes:n})}).catch(ma);return va(d),d}async function Pa(e,t,n){if(!Mi(e))throw new xi(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new xi(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new xi(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new xi(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new xi(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!Mi(e.header))throw new xi(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=li(e.protected);r=JSON.parse(oi.decode(t))}catch{throw new xi(`JWS Protected Header is invalid`)}if(!function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.filter(Boolean);if(r.length===0||r.length===1)return!0;let i;for(let e of r){let t=Object.keys(e);if(i&&i.size!==0)for(let e of t){if(i.has(e))return!1;i.add(e)}else i=new Set(t)}return!0}(r,e.header))throw new xi(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i=k(k({},r),e.header),a=function(e,t,n,r,i){if(i.crit!==void 0&&r?.crit===void 0)throw new e(`"crit" (Critical) Header Parameter MUST be integrity protected`);if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(e=>typeof e!=`string`||e.length===0))throw new e(`"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present`);let a;a=n===void 0?t:new Map([...Object.entries(n),...t.entries()]);for(let t of r.crit){if(!a.has(t))throw new bi(`Extension Header Parameter "${t}" is not recognized`);if(i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&r[t]===void 0)throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(r.crit)}(xi,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new xi(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new xi(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&function(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some(e=>typeof e!=`string`)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new yi(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new xi(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new xi(`JWS Payload must be a string or an Uint8Array instance`);let l=!1;typeof t==`function`&&(t=await t(r,e),l=!0),Zi(s,t,`verify`);let u=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.reduce((e,t)=>{let{length:n}=t;return e+n},0),i=new Uint8Array(r),a=0;for(let e of t)i.set(e,a),a+=e.length;return i}(e.protected===void 0?new Uint8Array:si(e.protected),si(`.`),typeof e.payload==`string`?o?si(e.payload):ai.encode(e.payload):e.payload),d=ji(e.signature,`signature`,xi),f=await Vi(t,s);if(!await Fi(s,f,d,u))throw new Di;let p;p=o?ji(e.payload,`payload`,xi):typeof e.payload==`string`?ai.encode(e.payload):e.payload;let m={payload:p};return e.protected!==void 0&&(m.protectedHeader=r),e.header!==void 0&&(m.unprotectedHeader=e.header),l?k(k({},m),{},{key:f}):m}var Fa=86400,Ia=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function La(e){let t=Ia.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r;switch(t[3].toLowerCase()){case`sec`:case`secs`:case`second`:case`seconds`:case`s`:r=Math.round(n);break;case`minute`:case`minutes`:case`min`:case`mins`:case`m`:r=Math.round(60*n);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:r=Math.round(3600*n);break;case`day`:case`days`:case`d`:r=Math.round(n*Fa);break;case`week`:case`weeks`:case`w`:r=Math.round(604800*n);break;default:r=Math.round(31557600*n)}return t[1]===`-`||t[4]===`ago`?-r:r}var Ra=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`;function za(e,t){let n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};try{n=JSON.parse(oi.decode(t))}catch{}if(!Mi(n))throw new Si(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=r;if(i&&(typeof e.typ!=`string`||Ra(e.typ)!==Ra(i)))throw new _i(`unexpected "typ" JWT header value`,n,`typ`,`check_failed`);let{requiredClaims:a=[],issuer:o,subject:s,audience:c,maxTokenAge:l}=r,u=[...a];l!==void 0&&u.push(`iat`),c!==void 0&&u.push(`aud`),s!==void 0&&u.push(`sub`),o!==void 0&&u.push(`iss`);for(let e of new Set(u.reverse()))if(!(e in n))throw new _i(`missing required "${e}" claim`,n,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(n.iss))throw new _i(`unexpected "iss" claim value`,n,`iss`,`check_failed`);if(s&&n.sub!==s)throw new _i(`unexpected "sub" claim value`,n,`sub`,`check_failed`);if(c&&(d=n.aud,f=typeof c==`string`?[c]:c,!(typeof d==`string`?f.includes(d):Array.isArray(d)&&f.some(Set.prototype.has.bind(new Set(d))))))throw new _i(`unexpected "aud" claim value`,n,`aud`,`check_failed`);var d,f;let p;switch(typeof r.clockTolerance){case`string`:p=La(r.clockTolerance);break;case`number`:p=r.clockTolerance;break;case`undefined`:p=0;break;default:throw TypeError(`Invalid clockTolerance option type`)}let{currentDate:m}=r,h=(g=m||new Date,Math.floor(g.getTime()/1e3));var g;if((n.iat!==void 0||l)&&typeof n.iat!=`number`)throw new _i(`"iat" claim must be a number`,n,`iat`,`invalid`);if(n.nbf!==void 0){if(typeof n.nbf!=`number`)throw new _i(`"nbf" claim must be a number`,n,`nbf`,`invalid`);if(n.nbf>h+p)throw new _i(`"nbf" claim timestamp check failed`,n,`nbf`,`check_failed`)}if(n.exp!==void 0){if(typeof n.exp!=`number`)throw new _i(`"exp" claim must be a number`,n,`exp`,`invalid`);if(n.exp<=h-p)throw new vi(`"exp" claim timestamp check failed`,n,`exp`,`check_failed`)}if(l){let e=h-n.iat;if(e-p>(typeof l==`number`?l:La(l)))throw new vi(`"iat" claim timestamp check failed (too far in the past)`,n,`iat`,`check_failed`);if(e<0-p)throw new _i(`"iat" claim timestamp check failed (it should be in the past)`,n,`iat`,`check_failed`)}return n}async function Ba(e,t,n){var r;let i=await async function(e,t,n){if(e instanceof Uint8Array&&(e=oi.decode(e)),typeof e!=`string`)throw new xi(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new xi(`Invalid Compact JWS`);let s=await Pa({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return typeof t==`function`?k(k({},c),{},{key:s.key}):c}(e,t,n);if((r=i.protectedHeader.crit)!=null&&r.includes(`b64`)&&!1===i.protectedHeader.b64)throw new Si(`JWTs MUST NOT use unencoded payload`);let a={payload:za(i.protectedHeader,i.payload,n),protectedHeader:i.protectedHeader};return typeof t==`function`?k(k({},a),{},{key:i.key}):a}function Va(e){return Mi(e)}var Ha,Ua,Wa=new WeakMap,Ga=new WeakMap,Ka=class{constructor(e){if(E(this,Wa,void 0),E(this,Ga,new WeakMap),!function(e){return e&&typeof e==`object`&&Array.isArray(e.keys)&&e.keys.every(Va)}(e))throw new Ci(`JSON Web Key Set malformed`);D(Wa,this,structuredClone(e))}jwks(){return T(Wa,this)}async getKey(e,t){let{alg:n,kid:r}=k(k({},e),t?.header),i=function(e){switch(typeof e==`string`&&e.slice(0,2)){case`RS`:case`PS`:return`RSA`;case`ES`:return`EC`;case`Ed`:return`OKP`;case`ML`:return`AKP`;default:throw new bi(`Unsupported "alg" value for a JSON Web Key Set`)}}(n),a=T(Wa,this).keys.filter(e=>{let t=i===e.kty;if(t&&typeof r==`string`&&(t=r===e.kid),!t||typeof e.alg!=`string`&&i!==`AKP`||(t=n===e.alg),t&&typeof e.use==`string`&&(t=e.use===`sig`),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes(`verify`)),t)switch(n){case`ES256`:t=e.crv===`P-256`;break;case`ES384`:t=e.crv===`P-384`;break;case`ES512`:t=e.crv===`P-521`;break;case`Ed25519`:case`EdDSA`:t=e.crv===`Ed25519`}return t}),{0:o,length:s}=a;if(s===0)throw new wi;if(s!==1){let e=new Ti,t=T(Ga,this);throw e[Symbol.asyncIterator]=gn(function*(){for(let e of a)try{yield yield fn(qa(t,e,n))}catch{}}),e}return qa(T(Ga,this),o,n)}};async function qa(e,t,n){let r=e.get(t)||e.set(t,{}).get(t);if(r[n]===void 0){let e=await async function(e,t,n){if(!Mi(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return li(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new bi(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return Li(k(k({},e),{},{alg:t,ext:r}));case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return Li(k(k({},e),{},{ext:r}));case`EC`:case`OKP`:return Li(k(k({},e),{},{alg:t,ext:r}));default:throw new bi(`Unsupported "kty" (Key Type) Parameter value`)}}(k(k({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||e.type!==`public`)throw new Ci(`JSON Web Key Set members must be public keys`);r[n]=e}return r[n]}function Ja(e){let t=new Ka(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}var Ya;(typeof navigator>`u`||(Ha=navigator.userAgent)==null||(Ua=Ha.startsWith)==null||!Ua.call(Ha,`Mozilla/5.0 `))&&(Ya=`jose/v6.2.2`);var Xa=Symbol(),Za=Symbol(),Qa=new WeakMap,$a=new WeakMap,eo=new WeakMap,to=new WeakMap,no=new WeakMap,ro=new WeakMap,io=new WeakMap,ao=new WeakMap,oo=new WeakMap,so=new WeakMap,co=class{constructor(e,t){if(E(this,Qa,void 0),E(this,$a,void 0),E(this,eo,void 0),E(this,to,void 0),E(this,no,void 0),E(this,ro,void 0),E(this,io,void 0),E(this,ao,void 0),E(this,oo,void 0),E(this,so,void 0),!(e instanceof URL))throw TypeError(`url must be an instance of URL`);var n,r;D(Qa,this,new URL(e.href)),D($a,this,typeof t?.timeoutDuration==`number`?t?.timeoutDuration:5e3),D(eo,this,typeof t?.cooldownDuration==`number`?t?.cooldownDuration:3e4),D(to,this,typeof t?.cacheMaxAge==`number`?t?.cacheMaxAge:6e5),D(io,this,new Headers(t?.headers)),Ya&&!T(io,this).has(`User-Agent`)&&T(io,this).set(`User-Agent`,Ya),T(io,this).has(`accept`)||(T(io,this).set(`accept`,`application/json`),T(io,this).append(`accept`,`application/jwk-set+json`)),D(ao,this,t?.[Xa]),t?.[Za]!==void 0&&(D(so,this,t?.[Za]),n=t?.[Za],r=T(to,this),typeof n==`object`&&n&&`uat`in n&&typeof n.uat==`number`&&!(Date.now()-n.uat>=r)&&`jwks`in n&&Mi(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,Mi)&&(D(no,this,T(so,this).uat),D(oo,this,Ja(T(so,this).jwks))))}pendingFetch(){return!!T(ro,this)}coolingDown(){return typeof T(no,this)==`number`&&Date.now()<T(no,this)+T(eo,this)}fresh(){return typeof T(no,this)==`number`&&Date.now()<T(no,this)+T(to,this)}jwks(){return T(oo,this)?.jwks()}async getKey(e,t){T(oo,this)&&this.fresh()||await this.reload();try{return await T(oo,this).call(this,e,t)}catch(n){if(n instanceof wi&&!1===this.coolingDown())return await this.reload(),T(oo,this).call(this,e,t);throw n}}async reload(){T(ro,this)&&(typeof WebSocketPair<`u`||typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`||typeof EdgeRuntime<`u`&&EdgeRuntime===`vercel`)&&D(ro,this,void 0),T(ro,this)||D(ro,this,async function(e,t,n){let r=await(arguments.length>3&&arguments[3]!==void 0?arguments[3]:fetch)(e,{method:`GET`,signal:n,redirect:`manual`,headers:t}).catch(e=>{throw e.name===`TimeoutError`?new Ei:e});if(r.status!==200)throw new gi(`Expected 200 OK from the JSON Web Key Set HTTP response`);try{return await r.json()}catch{throw new gi(`Failed to parse the JSON Web Key Set HTTP response as JSON`)}}(T(Qa,this).href,T(io,this),AbortSignal.timeout(T($a,this)),T(ao,this)).then(e=>{D(oo,this,Ja(e)),T(so,this)&&(T(so,this).uat=Date.now(),T(so,this).jwks=e),D(no,this,Date.now()),D(ro,this,void 0)}).catch(e=>{throw D(ro,this,void 0),e})),await T(ro,this)}},lo=[`mfaToken`],uo=[`mfaToken`],fo,po,mo,ho,go,_o,vo,yo,bo,P,xo,So,Co,wo,To,F,Eo=class extends Error{constructor(e,t){super(t),O(this,`code`,void 0),this.name=`NotSupportedError`,this.code=e}},Do=class extends Error{constructor(e,t,n){super(t),O(this,`cause`,void 0),O(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},Oo=class extends Do{constructor(e,t){super(`token_by_code_error`,e,t),this.name=`TokenByCodeError`}},ko=class extends Do{constructor(e,t){super(`token_by_client_credentials_error`,e,t),this.name=`TokenByClientCredentialsError`}},Ao=class extends Do{constructor(e,t){super(`token_by_refresh_token_error`,e,t),this.name=`TokenByRefreshTokenError`}},jo=class extends Do{constructor(e,t){super(`token_by_password_error`,e,t),this.name=`TokenByPasswordError`}},Mo=class extends Do{constructor(e,t){super(`token_for_connection_error`,e,t),this.name=`TokenForConnectionErrorCode`}},No=class extends Do{constructor(e,t){super(`token_exchange_error`,e,t),this.name=`TokenExchangeError`}},Po=class extends Error{constructor(e){super(e),O(this,`code`,`verify_logout_token_error`),this.name=`VerifyLogoutTokenError`}},Fo=class extends Do{constructor(e){super(`backchannel_authentication_error`,`There was an error when trying to use Client-Initiated Backchannel Authentication.`,e),O(this,`code`,`backchannel_authentication_error`),this.name=`BackchannelAuthenticationError`}},Io=class extends Do{constructor(e){super(`build_authorization_url_error`,`There was an error when trying to build the authorization URL.`,e),this.name=`BuildAuthorizationUrlError`}},Lo=class extends Do{constructor(e){super(`build_link_user_url_error`,`There was an error when trying to build the Link User URL.`,e),this.name=`BuildLinkUserUrlError`}},Ro=class extends Do{constructor(e){super(`build_unlink_user_url_error`,`There was an error when trying to build the Unlink User URL.`,e),this.name=`BuildUnlinkUserUrlError`}},zo=class extends Error{constructor(){super(`The client secret or client assertion signing key must be provided.`),O(this,`code`,`missing_client_auth_error`),this.name=`MissingClientAuthError`}};function Bo(e){return Object.entries(e).filter(e=>{let[,t]=e;return t!==void 0}).reduce((e,t)=>k(k({},e),{},{[t[0]]:t[1]}),{})}var Vo=class extends Error{constructor(e,t,n){super(t),O(this,`cause`,void 0),O(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},Ho=class extends Vo{constructor(e,t){super(`mfa_list_authenticators_error`,e,t),this.name=`MfaListAuthenticatorsError`}},Uo=class extends Vo{constructor(e,t){super(`mfa_enrollment_error`,e,t),this.name=`MfaEnrollmentError`}},Wo=class extends Vo{constructor(e,t){super(`mfa_delete_authenticator_error`,e,t),this.name=`MfaDeleteAuthenticatorError`}},Go=class extends Vo{constructor(e,t){super(`mfa_challenge_error`,e,t),this.name=`MfaChallengeError`}};function Ko(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var qo=(fo=new WeakMap,po=new WeakMap,mo=new WeakMap,class{constructor(e){E(this,fo,void 0),E(this,po,void 0),E(this,mo,void 0),D(fo,this,`https://${e.domain}`),D(po,this,e.clientId),D(mo,this,e.customFetch??function(){return fetch(...arguments)})}async listAuthenticators(e){let t=`${T(fo,this)}/mfa/authenticators`,{mfaToken:n}=e,r=await T(mo,this).call(this,t,{method:`GET`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!r.ok){let e=await r.json();throw new Ho(e.error_description||`Failed to list authenticators`,e)}return(await r.json()).map(Ko)}async enrollAuthenticator(e){let t=`${T(fo,this)}/mfa/associate`,{mfaToken:n}=e,r=hn(e,lo),i={authenticator_types:r.authenticatorTypes};`oobChannels`in r&&(i.oob_channels=r.oobChannels),`phoneNumber`in r&&r.phoneNumber&&(i.phone_number=r.phoneNumber),`email`in r&&r.email&&(i.email=r.email);let a=await T(mo,this).call(this,t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new Uo(e.error_description||`Failed to enroll authenticator`,e)}return function(e){if(e.authenticator_type===`otp`)return{authenticatorType:`otp`,secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if(e.authenticator_type===`oob`)return{authenticatorType:`oob`,oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes};throw Error(`Unexpected authenticator type: ${e.authenticator_type}`)}(await a.json())}async deleteAuthenticator(e){let{authenticatorId:t,mfaToken:n}=e,r=`${T(fo,this)}/mfa/authenticators/${encodeURIComponent(t)}`,i=await T(mo,this).call(this,r,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!i.ok){let e=await i.json();throw new Wo(e.error_description||`Failed to delete authenticator`,e)}}async challengeAuthenticator(e){let t=`${T(fo,this)}/mfa/challenge`,{mfaToken:n}=e,r=hn(e,uo),i={mfa_token:n,client_id:T(po,this),challenge_type:r.challengeType};r.authenticatorId&&(i.authenticator_id=r.authenticatorId);let a=await T(mo,this).call(this,t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new Go(e.error_description||`Failed to challenge authenticator`,e)}return function(e){let t={challengeType:e.challenge_type};return e.oob_code!==void 0&&(t.oobCode=e.oob_code),e.binding_method!==void 0&&(t.bindingMethod=e.binding_method),t}(await a.json())}}),Jo=class e{constructor(e,t,n,r,i,a,o){O(this,`accessToken`,void 0),O(this,`idToken`,void 0),O(this,`refreshToken`,void 0),O(this,`expiresAt`,void 0),O(this,`scope`,void 0),O(this,`claims`,void 0),O(this,`authorizationDetails`,void 0),O(this,`tokenType`,void 0),O(this,`issuedTokenType`,void 0),this.accessToken=e,this.idToken=n,this.refreshToken=r,this.expiresAt=t,this.scope=i,this.claims=a,this.authorizationDetails=o}static fromTokenEndpointResponse(t){let n=t.id_token?t.claims():void 0,r=new e(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return r.tokenType=t.token_type,r.issuedTokenType=t.issued_token_type,r}},Yo=(ho=new WeakMap,go=new WeakMap,_o=new WeakMap,class{constructor(e,t){E(this,ho,new Map),E(this,go,void 0),E(this,_o,void 0),D(_o,this,Math.max(1,Math.floor(e))),D(go,this,Math.max(0,Math.floor(t)))}get(e){let t=T(ho,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return T(ho,this).delete(e),T(ho,this).set(e,t),t.value;T(ho,this).delete(e)}}set(e,t){for(T(ho,this).has(e)&&T(ho,this).delete(e),T(ho,this).set(e,{value:t,expiresAt:Date.now()+T(go,this)});T(ho,this).size>T(_o,this);){let e=T(ho,this).keys().next().value;if(e===void 0)break;T(ho,this).delete(e)}}}),Xo=new Map;function Zo(e){return{ttlMs:1e3*(typeof e?.ttl==`number`?e.ttl:600),maxEntries:typeof e?.maxEntries==`number`&&e.maxEntries>0?e.maxEntries:100}}var Qo=class{static createDiscoveryCache(e){let t=(n=e.maxEntries,r=e.ttlMs,`${n}:${r}`);var n,r;let i=(a=t,Xo.get(a));var a;return i||(i=new Yo(e.maxEntries,e.ttlMs),Xo.set(t,i)),i}static createJwksCache(){return{}}},$o=`openid profile email offline_access`,es=Object.freeze(new Set([`grant_type`,`client_id`,`client_secret`,`client_assertion`,`client_assertion_type`,`subject_token`,`subject_token_type`,`requested_token_type`,`actor_token`,`actor_token_type`,`audience`,`aud`,`resource`,`resources`,`resource_indicator`,`scope`,`connection`,`login_hint`,`organization`,`assertion`]));function ts(e){if(e==null)throw new No(`subject_token is required`);if(typeof e!=`string`)throw new No(`subject_token must be a string`);if(e.trim().length===0)throw new No(`subject_token cannot be blank or whitespace`);if(e!==e.trim())throw new No(`subject_token must not include leading or trailing whitespace`);if(/^bearer\s+/i.test(e))throw new No(`subject_token must not include the 'Bearer ' prefix`)}function ns(e,t){if(t){for(let[n,r]of Object.entries(t))if(!es.has(n))if(Array.isArray(r)){if(r.length>20)throw new No(`Parameter '${n}' exceeds maximum array size of 20`);r.forEach(t=>{e.append(n,t)})}else e.append(n,r)}}var rs=`urn:ietf:params:oauth:token-type:access_token`,is=(vo=new WeakMap,yo=new WeakMap,bo=new WeakMap,P=new WeakMap,xo=new WeakMap,So=new WeakMap,Co=new WeakMap,wo=new WeakMap,To=new WeakMap,F=new WeakSet,class{constructor(e){var t;if(function(e,t){pn(e,t),t.add(e)}(this,F),E(this,vo,void 0),E(this,yo,void 0),E(this,bo,void 0),E(this,P,void 0),E(this,xo,void 0),E(this,So,void 0),E(this,Co,void 0),E(this,wo,void 0),E(this,To,void 0),O(this,`mfa`,void 0),D(P,this,e),e.useMtls&&!e.customFetch)throw new Eo(`mtls_without_custom_fetch_not_supported`,`Using mTLS without a custom fetch implementation is not supported`);D(xo,this,function(e,t){if(!1===t.enabled)return e;let n={name:t.name,version:t.version},r=btoa(JSON.stringify(n));return async(t,n)=>{let i=t instanceof Request?new Headers(t.headers):new Headers;return n!=null&&n.headers&&new Headers(n.headers).forEach((e,t)=>{i.set(t,e)}),i.set(`Auth0-Client`,r),e(t,k(k({},n),{},{headers:i}))}}(e.customFetch??function(){return fetch(...arguments)},!1===(t=e.telemetry)?.enabled?t:{enabled:!0,name:t?.name??`@auth0/auth0-auth-js`,version:t?.version??`1.6.0`}));let n=Zo(e.discoveryCache);D(Co,this,Qo.createDiscoveryCache(n)),D(wo,this,new Map),D(To,this,Qo.createJwksCache()),this.mfa=new qo({domain:T(P,this).domain,clientId:T(P,this).clientId,customFetch:T(xo,this)})}async getServerMetadata(){let{serverMetadata:e}=await w(F,this,ss).call(this);return e}async buildAuthorizationUrl(e){let{serverMetadata:t}=await w(F,this,ss).call(this);if(e!=null&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new Eo(`par_not_supported_error`,`The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par`);try{return await w(F,this,ds).call(this,e)}catch(e){throw new Io(e)}}async buildLinkUserUrl(e){try{let t=await w(F,this,ds).call(this,{authorizationParams:k(k({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:`openid link_account offline_access`,id_token_hint:e.idToken})});return{linkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new Lo(e)}}async buildUnlinkUserUrl(e){try{let t=await w(F,this,ds).call(this,{authorizationParams:k(k({},e.authorizationParams),{},{requested_connection:e.connection,scope:`openid unlink_account`,id_token_hint:e.idToken})});return{unlinkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new Ro(e)}}async backchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await w(F,this,ss).call(this),r=Bo(k(k({},T(P,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(k(k({scope:$o},r),{},{client_id:T(P,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await Sa(t,await xa(t,i));return Jo.fromTokenEndpointResponse(e)}catch(e){throw new Fo(e)}}async initiateBackchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await w(F,this,ss).call(this),r=Bo(k(k({},T(P,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(k(k({scope:$o},r),{},{client_id:T(P,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await xa(t,i);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new Fo(e)}}async backchannelAuthenticationGrant(e){let{authReqId:t}=e,{configuration:n}=await w(F,this,ss).call(this),r=new URLSearchParams({auth_req_id:t});try{let e=await Na(n,`urn:openid:params:grant-type:ciba`,r);return Jo.fromTokenEndpointResponse(e)}catch(e){throw new Fo(e)}}async getTokenForConnection(e){if(e.refreshToken&&e.accessToken)throw new Mo(`Either a refresh or access token should be specified, but not both.`);let t=e.accessToken??e.refreshToken;if(!t)throw new Mo(`Either a refresh or access token must be specified.`);try{return await this.exchangeToken({connection:e.connection,subjectToken:t,subjectTokenType:e.accessToken?rs:`urn:ietf:params:oauth:token-type:refresh_token`,loginHint:e.loginHint})}catch(e){throw e instanceof No?new Mo(e.message,e.cause):e}}async exchangeToken(e){return`connection`in e?w(F,this,cs).call(this,e):w(F,this,ls).call(this,e)}async getTokenByCode(e,t){let{configuration:n}=await w(F,this,ss).call(this);try{let r=await wa(n,e,{pkceCodeVerifier:t.codeVerifier});return Jo.fromTokenEndpointResponse(r)}catch(e){throw new Oo(`There was an error while trying to request a token.`,e)}}async getTokenByRefreshToken(e){let{configuration:t}=await w(F,this,ss).call(this),n=new URLSearchParams;e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope);try{let r=await Ta(t,e.refreshToken,n);return Jo.fromTokenEndpointResponse(r)}catch(e){throw new Ao(`The access token has expired and there was an error while trying to refresh it.`,e)}}async getTokenByPassword(e){let{configuration:t}=await w(F,this,ss).call(this),n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.realm&&n.append(`realm`,e.realm);let r=t;if(e.auth0ForwardedFor){let n=await w(F,this,us).call(this);r=new _a(t.serverMetadata(),T(P,this).clientId,T(P,this).clientSecret,n),r[oa]=(t,n)=>T(xo,this).call(this,t,k(k({},n),{},{headers:k(k({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}try{let e=await Na(r,`password`,n);return Jo.fromTokenEndpointResponse(e)}catch(e){throw new jo(`There was an error while trying to request a token.`,e)}}async getTokenByClientCredentials(e){let{configuration:t}=await w(F,this,ss).call(this);try{let n=new URLSearchParams({audience:e.audience});e.organization&&n.append(`organization`,e.organization);let r=await Ea(t,n);return Jo.fromTokenEndpointResponse(r)}catch(e){throw new ko(`There was an error while trying to request a token.`,e)}}async buildLogoutUrl(e){let{configuration:t,serverMetadata:n}=await w(F,this,ss).call(this);if(!n.end_session_endpoint){let t=new URL(`https://${T(P,this).domain}/v2/logout`);return t.searchParams.set(`returnTo`,e.returnTo),t.searchParams.set(`client_id`,T(P,this).clientId),t}return function(e,t){ka(e);let{as:n,c:r,tlsOnly:i}=na(e),a=ir(n,`end_session_endpoint`,!1,i);(t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id);for(let[e,n]of t.entries())a.searchParams.append(e,n);return a}(t,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){let{serverMetadata:t}=await w(F,this,ss).call(this),n=Zo(T(P,this).discoveryCache),r=t.jwks_uri;T(So,this)||D(So,this,function(e,t){let n=new co(e,t),r=async(e,t)=>n.getKey(e,t);return Object.defineProperties(r,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),r}(new URL(r),{cacheMaxAge:n.ttlMs,[Xa]:T(xo,this),[Za]:T(To,this)}));let{payload:i}=await Ba(e.logoutToken,T(So,this),{issuer:t.issuer,audience:T(P,this).clientId,algorithms:[`RS256`],requiredClaims:[`iat`]});if(!(`sid`in i)&&!(`sub`in i))throw new Po(`either "sid" or "sub" (or both) claims must be present`);if(`sid`in i&&typeof i.sid!=`string`)throw new Po(`"sid" claim must be a string`);if(`sub`in i&&typeof i.sub!=`string`)throw new Po(`"sub" claim must be a string`);if(`nonce`in i)throw new Po(`"nonce" claim is prohibited`);if(!(`events`in i))throw new Po(`"events" claim is missing`);if(typeof i.events!=`object`||i.events===null)throw new Po(`"events" claim must be an object`);if(!(`http://schemas.openid.net/event/backchannel-logout`in i.events))throw new Po(`"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim`);if(typeof i.events[`http://schemas.openid.net/event/backchannel-logout`]!=`object`)throw new Po(`"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object`);return{sid:i.sid,sub:i.sub}}});function as(){return`${T(P,this).domain.toLowerCase()}|mtls:${T(P,this).useMtls?`1`:`0`}`}async function os(e){let t=await w(F,this,us).call(this),n=new _a(e,T(P,this).clientId,T(P,this).clientSecret,t);return n[oa]=T(xo,this),n}async function ss(){if(T(vo,this)&&T(yo,this))return{configuration:T(vo,this),serverMetadata:T(yo,this)};let e=w(F,this,as).call(this),t=T(Co,this).get(e);if(t)return D(yo,this,t.serverMetadata),D(vo,this,await w(F,this,os).call(this,t.serverMetadata)),{configuration:T(vo,this),serverMetadata:T(yo,this)};let n=T(wo,this).get(e);if(n){let e=await n;return D(yo,this,e.serverMetadata),D(vo,this,await w(F,this,os).call(this,e.serverMetadata)),{configuration:T(vo,this),serverMetadata:T(yo,this)}}let r=(async()=>{let t=await w(F,this,us).call(this),n=await ha(new URL(`https://${T(P,this).domain}`),T(P,this).clientId,{use_mtls_endpoint_aliases:T(P,this).useMtls},t,{[oa]:T(xo,this)}),r=n.serverMetadata();return T(Co,this).set(e,{serverMetadata:r}),{configuration:n,serverMetadata:r}})(),i=r.then(e=>{let{serverMetadata:t}=e;return{serverMetadata:t}});i.catch(()=>{}),T(wo,this).set(e,i);try{let{configuration:e,serverMetadata:t}=await r;D(vo,this,e),D(yo,this,t),T(vo,this)[oa]=T(xo,this)}finally{T(wo,this).delete(e)}return{configuration:T(vo,this),serverMetadata:T(yo,this)}}async function cs(e){let{configuration:t}=await w(F,this,ss).call(this);if(`audience`in e||`resource`in e)throw new No(`audience and resource parameters are not supported for Token Vault exchanges`);ts(e.subjectToken);let n=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType??rs,requested_token_type:e.requestedTokenType??`http://auth0.com/oauth/token-type/federated-connection-access-token`});e.loginHint&&n.append(`login_hint`,e.loginHint),e.scope&&n.append(`scope`,e.scope),ns(n,e.extra);try{let e=await Na(t,`urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token`,n);return Jo.fromTokenEndpointResponse(e)}catch(t){throw new No(`Failed to exchange token for connection '${e.connection}'.`,t)}}async function ls(e){let{configuration:t}=await w(F,this,ss).call(this);ts(e.subjectToken);let n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.requestedTokenType&&n.append(`requested_token_type`,e.requestedTokenType),e.organization&&n.append(`organization`,e.organization),ns(n,e.extra);try{let e=await Na(t,`urn:ietf:params:oauth:grant-type:token-exchange`,n);return Jo.fromTokenEndpointResponse(e)}catch(t){throw new No(`Failed to exchange token of type '${e.subjectTokenType}'${e.audience?` for audience '${e.audience}'`:``}.`,t)}}async function us(){return T(bo,this)||D(bo,this,(async()=>{if(!T(P,this).clientSecret&&!T(P,this).clientAssertionSigningKey&&!T(P,this).useMtls)throw new zo;if(T(P,this).useMtls)return(e,t,n,r)=>{n.set(`client_id`,t.client_id)};let e=T(P,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await async function(e,t,n){if(typeof e!=`string`||e.indexOf(`-----BEGIN PRIVATE KEY-----`)!==0)throw TypeError(`"pkcs8" must be PKCS#8 formatted string`);return Ji(e,t,n)}(e,T(P,this).clientAssertionSigningAlg||`RS256`)),e?function(e,t){return er(e,t)}(e):aa(T(P,this).clientSecret)})().catch(e=>{throw D(bo,this,void 0),e})),T(bo,this)}async function ds(e){let{configuration:t}=await w(F,this,ss).call(this),n=da(),r=await ua(n),i=Bo(k(k({},T(P,this).authorizationParams),e?.authorizationParams)),a=new URLSearchParams(k(k({scope:$o},i),{},{client_id:T(P,this).clientId,code_challenge:r,code_challenge_method:`S256`}));return{authorizationUrl:e!=null&&e.pushedAuthorizationRequests?await Oa(t,a):await Da(t,a),codeVerifier:n}}var fs=class e extends C{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},ps=class e extends fs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},ms=class e extends fs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},hs=class e extends fs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},gs=class e extends fs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},_s=class e extends fs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},vs=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:6e5;this.contexts=new Map,this.ttlMs=e}set(e,t){this.cleanup(),this.contexts.set(e,Object.assign(Object.assign({},t),{createdAt:Date.now()}))}get(e){let t=this.contexts.get(e);if(t){if(!(Date.now()-t.createdAt>this.ttlMs))return t;this.contexts.delete(e)}}remove(e){this.contexts.delete(e)}cleanup(){let e=Date.now();for(let[t,n]of this.contexts)e-n.createdAt>this.ttlMs&&this.contexts.delete(t)}get size(){return this.contexts.size}},ys=class{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new vs}setMFAAuthDetails(e,t,n,r){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:r})}async getAuthenticators(e){let t=this.contextManager.get(e);if(!t?.mfaRequirements?.challenge||t.mfaRequirements.challenge.length===0)throw new ps(`invalid_request`,`challengeType is required and must contain at least one challenge type, please check mfa_required error payload`);let n=t.mfaRequirements.challenge.map(e=>e.type);try{return(await this.authJsMfaClient.listAuthenticators({mfaToken:e})).filter(e=>!!e.type&&n.includes(e.type))}catch(e){throw e instanceof Ho?new ps(e.cause?.error,e.message):e}}async enroll(e){let t=function(e){let t=sn[e.factorType];return Object.assign(Object.assign(Object.assign({mfaToken:e.mfaToken,authenticatorTypes:t.authenticatorTypes},t.oobChannels&&{oobChannels:t.oobChannels}),`phoneNumber`in e&&{phoneNumber:e.phoneNumber}),`email`in e&&{email:e.email})}(e);try{return await this.authJsMfaClient.enrollAuthenticator(t)}catch(e){throw e instanceof Uo?new ms(e.cause?.error,e.message):e}}async challenge(e){try{let t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){throw e instanceof Go?new hs(e.cause?.error,e.message):e}}async getEnrollmentFactors(e){let t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new _s(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);return t.mfaRequirements.enroll&&t.mfaRequirements.enroll.length!==0?t.mfaRequirements.enroll:[]}async verify(e){let t=this.contextManager.get(e.mfaToken);if(!t)throw new gs(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);let n=function(e){return`otp`in e&&e.otp?cn:`oobCode`in e&&e.oobCode?ln:`recoveryCode`in e&&e.recoveryCode?un:void 0}(e);if(!n)throw new gs(`invalid_request`,`Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.`);let r=t.scope,i=t.audience;try{let t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:r,audience:i,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof me)this.setMFAAuthDetails(e.mfa_token,r,i,e.mfa_requirements);else if(e instanceof gs)throw new gs(e.error,e.error_description);throw e}}},bs=class{constructor(e){let t,n;if(this.userCache=new xt().enclosedCache,this.defaultOptions={authorizationParams:{scope:`openid profile email`},useRefreshTokensFallback:!1,useFormData:!0},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<`u`&&(()=>{if(!ye())throw Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(ye().subtle===void 0)throw Error(`
|
|
3
3
|
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
4
|
-
`)})(),this.lockManager=(He||=Ve(),He),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)n=e.cache;else{if(t=e.cacheLocation||re,!Jt(t))throw Error(`Invalid cache location "${t}"`);n=Jt(t)()}var r;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:ne,this.cookieStorage=!1===e.legacySameSiteCookie?Nt:Ft,this.orgHintCookieName=(r=this.options.clientId,`auth0.${r}.organization_hint`),this.isAuthenticatedCookieName=(e=>`auth0.${e}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;let i=e.useCookiesForTransactions?this.cookieStorage:It;var a;this.scope=function(e,t){var n=[...arguments].slice(2);if(typeof e!=`object`)return{[C]:pt(t,e,...n)};let r={[C]:pt(t,...n)};return Object.keys(e).forEach(i=>{let a=e[i];r[i]=pt(t,a,...n)}),r}(this.options.authorizationParams.scope,`openid`,this.options.useRefreshTokens?`offline_access`:``),this.transactionManager=new xt(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||ae,this.cacheManager=new bt(n,n.allKeys?void 0:new Gt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new $t(this.options.clientId):void 0,this.domainUrl=(a=this.options.domain,/^https?:\/\//.test(a)?a:`https://${a}`),this.tokenIssuer=((e,t)=>e?e.startsWith(`https://`)?e:`https://${e}/`:`${t}/`)(this.options.issuer,this.domainUrl);let o=`${this.domainUrl}/me/`,s=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:`__auth0_my_account_api__`}),{getAccessToken:()=>this.getTokenSilently({authorizationParams:{scope:`create:me:connected_accounts`,audience:o},detailedResponse:!0})}));this.myAccountApi=new nn(s,o),this.authJsClient=new ns({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new _s(this.authJsClient.mfa,this),typeof window<`u`&&window.Worker&&this.options.useRefreshTokens&&t===re&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new Ut,this.worker.postMessage({type:`init`,allowedBaseUrl:this.domainUrl}))}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){let t=xe(this.options.auth0Client||ie,!0),n=encodeURIComponent(btoa(JSON.stringify(t)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${Se(e)}`)}async _verifyIdToken(e,t,n){let r=await this.nowProvider();return wt({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i==`string`?parseInt(i,10)||void 0:i),now:r});var i}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{let t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},``,t.toString()))}catch{}}_applySessionTransferToken(e){let t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;let n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),Object.assign(Object.assign({},e),{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){let r=ye(ve()),i=ye(ve()),a=ve(),o=Te(await Ce(a)),s=await this.dpop?.calculateThumbprint(),c=((e,t,n,r,i,a,o,s,c)=>Object.assign(Object.assign(Object.assign({client_id:e.clientId},e.authorizationParams),n),{scope:mt(t,n.scope,n.audience),response_type:`code`,response_mode:s||`query`,state:r,nonce:i,redirect_uri:o||e.authorizationParams.redirect_uri,code_challenge:a,code_challenge_method:`S256`,dpop_jkt:c}))(this.options,this.scope,e,r,i,o,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,t?.response_mode,s),l=this._authorizeUrl(c);return{nonce:i,code_verifier:a,scope:c.scope,audience:c.audience||C,redirect_uri:c.redirect_uri,state:r,url:l}}async loginWithPopup(e,t){if(e||={},!(t||={}).popup&&(t.popup=(e=>{let t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,`auth0:authorize:popup`,`left=${t},top=${n},width=400,height=600,resizable,scrollbars=yes,status=1`)})(``),!t.popup))throw new de;let n=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(n,{response_mode:`web_message`},window.location.origin);t.popup.location.href=r.url;let i=await((e,t)=>new Promise((n,r)=>{let i,a=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(a),clearTimeout(o),window.removeEventListener(`message`,i,!1),r(new ue(e.popup)))},1e3),o=setTimeout(()=>{clearInterval(a),r(new le(e.popup)),window.removeEventListener(`message`,i,!1)},1e3*(e.timeoutInSeconds||60));i=function(s){if(s.origin===t&&s.data&&s.data.type===`authorization_response`){if(clearTimeout(o),clearInterval(a),window.removeEventListener(`message`,i,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return r(w.fromPayload(s.data.response));n(s.data.response)}},window.addEventListener(`message`,i)}))(Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new w(`state_mismatch`,`Invalid state`);let a=e.authorizationParams?.organization||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:`authorization_code`,code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a})}async getUser(){return(await this._getIdTokenFromCache())?.decodedToken?.user}async getIdTokenClaims(){return(await this._getIdTokenFromCache())?.decodedToken?.claims}async loginWithRedirect(){let e=Yt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),{openUrl:t,fragment:n,appState:r}=e,i=x(e,[`openUrl`,`fragment`,`appState`]),a=i.authorizationParams?.organization||this.options.authorizationParams.organization,o=this._applySessionTransferToken(i.authorizationParams||{}),s=await this._prepareAuthorizeUrl(o),{url:c}=s,l=x(s,[`url`]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},l),{appState:r,response_type:Lt.Code}),a&&{organization:a}));let u=n?`${c}#${n}`:c;t?await t(u):window.location.assign(u)}async handleRedirectCallback(){let e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.location.href).split(`?`).slice(1);if(e.length===0)throw Error(`There are no query params available for parsing.`);let t=this.transactionManager.get();if(!t)throw new w(`missing_transaction`,`Invalid state`);this.transactionManager.remove();let n=(e=>{e.indexOf(`#`)>-1&&(e=e.substring(0,e.indexOf(`#`)));let t=new URLSearchParams(e);return{state:t.get(`state`),code:t.get(`code`)||void 0,connect_code:t.get(`connect_code`)||void 0,error:t.get(`error`)||void 0,error_description:t.get(`error_description`)||void 0}})(e.join(``));return t.response_type===Lt.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){let{code:n,state:r,error:i,error_description:a}=e;if(i)throw new oe(i,a||i,r,t.appState);if(!t.code_verifier||t.state&&t.state!==r)throw new w(`state_mismatch`,`Invalid state`);let o=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(Object.assign({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:`authorization_code`,code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:o}),{appState:t.appState,response_type:Lt.Code}}async _handleConnectAccountRedirectCallback(e,t){let{connect_code:n,state:r,error:i,error_description:a}=e;if(i)throw new se(i,a||i,t.connection,r,t.appState);if(!n)throw new w(`missing_connect_code`,`Missing connect code`);if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===r))throw new w(`state_mismatch`,`Invalid state`);let o=await this.myAccountApi.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier});return Object.assign(Object.assign({},o),{appState:t.appState,response_type:Lt.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(Kt))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(Kt)}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Object.assign(Object.assign({cacheMode:`on`},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:mt(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})}),n=await((e,t)=>{let n=Wt[t];return n||(n=e().finally(()=>{delete Wt[t],n=null}),Wt[t]=n),n})(()=>this._getTokenSilently(t),`${this.options.clientId}::${t.authorizationParams.audience}::${t.authorizationParams.scope}`);return e.detailedResponse?n:n?.access_token}async _getTokenSilently(e){let{cacheMode:t}=e,n=x(e,[`cacheMode`]);if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||C,clientId:this.options.clientId,cacheMode:t});if(e)return e}if(t===`cache-only`)return;let r=(i=this.options.clientId,a=n.authorizationParams.audience||`default`,`auth0.lock.getTokenSilently.${i}.${a}`);var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||C,clientId:this.options.clientId});if(e)return e}let{id_token:e,token_type:r,access_token:i,oauthTokenScope:a,expires_in:o}=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n);return Object.assign(Object.assign({id_token:e,token_type:r,access_token:i},a?{scope:a}:null),{expires_in:o})})}catch(e){if(this._isInteractiveError(e)&&this.options.interactiveErrorHandler===`popup`)return await this._handleInteractiveErrorWithPopup(n);throw e}}_isInteractiveError(e){return e instanceof fe||e instanceof w&&this._isIframeMfaError(e)}_isIframeMfaError(e){return e.error===`login_required`&&e.error_description===`Multifactor authentication required`}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});let t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||C,clientId:this.options.clientId});if(!t)throw new w(`interactive_handler_cache_miss`,`Token not found in cache after interactive authentication`);return t}catch(e){throw e}}async getTokenWithPopup(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:mt(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})});return t=Object.assign(Object.assign({},S),t),await this.loginWithPopup(n,t),(await this.cacheManager.get(new _t({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||C,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId===null?delete e.clientId:e.clientId=e.clientId||this.options.clientId;let t=e.logoutParams||{},{federated:n}=t,r=x(t,[`federated`]),i=n?`&federated`:``;return this._url(`/v2/logout?${Se(Object.assign({clientId:e.clientId},r))}`)+i}async revokeRefreshToken(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.options.useRefreshTokens)return;let t=e.audience||this.options.authorizationParams.audience||C,n=await this.cacheManager.getRefreshTokensByAudience(t,this.options.clientId);await async function(e,t){let{baseUrl:n,timeout:r,auth0Client:i,useFormData:a,refreshTokens:o,audience:s,client_id:c,onRefreshTokenRevoked:l}=e,u=r||ne,d=`refresh_token`,f=`${n}/oauth/revoke`,p={"Content-Type":a?`application/x-www-form-urlencoded`:`application/json`,"Auth0-Client":btoa(JSON.stringify(xe(i||ie)))};if(t){let e={client_id:c,token_type_hint:d},n=a?Se(e):JSON.stringify(e);try{return await ct({type:`revoke`,timeout:u,fetchUrl:f,fetchOptions:{method:`POST`,body:n,headers:p},useFormData:a,auth:{audience:s??C}},t)}catch(e){throw new w(`revoke_error`,e.message)}}for(let e of o){let t={client_id:c,token_type_hint:d,token:e},n=await lt(f,{method:`POST`,body:a?Se(t):JSON.stringify(t),headers:p},u);if(!n.ok){let e,t;try{({error:e,error_description:t}=JSON.parse(await n.text()))}catch{}throw new w(e||`revoke_error`,t||`HTTP error ${n.status}`)}await l?.(e)}}({baseUrl:this.domainUrl,timeout:this.httpTimeoutMs,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,client_id:this.options.clientId,refreshTokens:n,audience:t,onRefreshTokenRevoked:e=>this.cacheManager.stripRefreshToken(e)},this.worker)}async logout(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Yt(e),{openUrl:n}=t,r=x(t,[`openUrl`]);if(e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(gt),await this.dpop?.clear(),this.worker)try{await ct({type:`clear`},this.worker)}catch{}let i=this._buildLogoutUrl(r);n?await n(i):!1!==n&&window.location.assign(i)}async _getTokenFromIFrame(e){let t=(n=this.options.clientId,`auth0.lock.getTokenFromIFrame.${n}`);var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{let t=Object.assign(Object.assign({},e.authorizationParams),{prompt:`none`}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);let{url:r,state:i,nonce:a,code_verifier:o,redirect_uri:s,scope:c,audience:l}=await this._prepareAuthorizeUrl(t,{response_mode:`web_message`},window.location.origin);if(window.crossOriginIsolated)throw new w(`login_required`,`The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.`);let u=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,d;try{d=new URL(this.domainUrl).origin}catch{d=this.domainUrl}let f=await function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:60;return new Promise((r,i)=>{let a=window.document.createElement(`iframe`);a.setAttribute(`width`,`0`),a.setAttribute(`height`,`0`),a.style.display=`none`;let o=()=>{window.document.body.contains(a)&&(window.document.body.removeChild(a),window.removeEventListener(`message`,s,!1))},s,c=setTimeout(()=>{i(new ce),o()},1e3*n);s=function(e){if(e.origin!=t||!e.data||e.data.type!==`authorization_response`)return;let n=e.source;n&&n.close(),e.data.response.error?i(w.fromPayload(e.data.response)):r(e.data.response),clearTimeout(c),window.removeEventListener(`message`,s,!1),setTimeout(o,2e3)},window.addEventListener(`message`,s,!1),window.document.body.appendChild(a),a.setAttribute(`src`,e)})}(r,d,u);if(i!==f.state)throw new w(`state_mismatch`,`Invalid state`);let p=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:o,code:f.code,grant_type:`authorization_code`,redirect_uri:s,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return Object.assign(Object.assign({},p),{scope:c,oauthTokenScope:p.scope,audience:l})})}catch(e){throw e.error===`login_required`&&(e instanceof w&&this._isIframeMfaError(e)&&this.options.interactiveErrorHandler===`popup`||this.logout({openUrl:!1})),e}}async _getTokenUsingRefreshToken(e){let t=await this.cacheManager.get(new _t({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||C,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(t&&t.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new pe(e.authorizationParams.audience||C,e.authorizationParams.scope)}let n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof e.timeoutInSeconds==`number`?1e3*e.timeoutInSeconds:null,i=((e,t,n,r)=>{if(e&&n&&r){if(t.audience!==n)return t.scope;let e=r.split(` `),i=t.scope?.split(` `)||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?r:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,t?.audience,t?.scope);try{let l=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:`refresh_token`,refresh_token:t&&t.refresh_token,redirect_uri:n}),r&&{timeout:r}),{scopesToRequest:i});if(l.refresh_token&&t!=null&&t.refresh_token&&await this.cacheManager.updateEntry(t.refresh_token,l.refresh_token),this.options.useMrrt&&(a=t?.audience,o=t?.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,(a!==s||!Xt(c,o))&&!Xt(i,l.scope))){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope);let t=((e,t)=>{let n=e?.split(` `)||[],r=t?.split(` `)||[];return n.filter(e=>r.indexOf(e)==-1).join(`,`)})(i,l.scope);throw new me(e.authorizationParams.audience||`default`,t)}return Object.assign(Object.assign({},l),{scope:e.authorizationParams.scope,oauthTokenScope:l.scope,audience:e.authorizationParams.audience||C})}catch(t){if(t.message){if(t.message.includes(`user is blocked`))throw await this.logout({openUrl:!1}),t;if((t.message.includes(`Missing Refresh Token`)||t.message.includes(`invalid refresh token`))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t instanceof fe&&this.mfa.setMFAAuthDetails(t.mfa_token,e.authorizationParams?.scope,e.authorizationParams?.audience,t.mfa_requirements),t}var a,o,s,c}async _saveEntryInCache(e){let{id_token:t,decodedToken:n}=e,r=x(e,[`id_token`,`decodedToken`]);this.userCache.set(gt,{id_token:t,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(r)}async _getIdTokenFromCache(){let e=this.options.authorizationParams.audience||C,t=this.scope[e],n=await this.cacheManager.getIdToken(new _t({clientId:this.options.clientId,audience:e,scope:t})),r=this.userCache.get(gt);return n&&n.id_token===r?.id_token?r:(this.userCache.set(gt,n),n)}async _getEntryFromCache(e){let{scope:t,audience:n,clientId:r,cacheMode:i}=e,a=await this.cacheManager.get(new _t({scope:t,audience:n,clientId:r}),60,this.options.useMrrt,i);if(a&&a.access_token){let{token_type:e,access_token:t,oauthTokenScope:n,expires_in:r}=a,i=await this._getIdTokenFromCache();return i&&Object.assign(Object.assign({id_token:i.id_token,token_type:e||`Bearer`,access_token:t},n?{scope:n}:null),{expires_in:r})}}async _requestToken(e,t){var n;let{nonceIn:r,organization:i,scopesToRequest:a}=t||{},o=await ft(Object.assign(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop},e),{scope:a||e.scope}),this.worker),s=await this._verifyIdToken(o.id_token,r,i);if(e.grant_type===`authorization_code`){let e=await this._getIdTokenFromCache();(n=e?.decodedToken?.claims)!=null&&n.sub&&e.decodedToken.claims.sub!==s.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(gt))}return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:s,scope:e.scope,audience:e.audience||C}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||s.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:s})}async loginWithCustomTokenExchange(e){return this._requestToken(Object.assign(Object.assign({},e),{grant_type:`urn:ietf:params:oauth:grant-type:token-exchange`,subject_token:e.subject_token,subject_token_type:e.subject_token_type,scope:mt(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization}))}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(e){return this._assertDpop(this.dpop),this.dpop.getNonce(e)}setDpopNonce(e,t){return this._assertDpop(this.dpop),this.dpop.setNonce(e,t)}generateDpopProof(e){return this._assertDpop(this.dpop),this.dpop.generateProof(e)}createFetcher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new tn(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>this.getTokenSilently({authorizationParams:{scope:(e?.scope)?.join(` `),audience:e?.audience},detailedResponse:!0}),getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){let{openUrl:t,appState:n,connection:r,scopes:i,authorization_params:a,redirectUri:o=this.options.authorizationParams.redirect_uri||window.location.origin}=e;if(!r)throw Error(`connection is required`);let s=ye(ve()),c=ve(),l=Te(await Ce(c)),{connect_uri:u,connect_params:d,auth_session:f}=await this.myAccountApi.connectAccount({connection:r,scopes:i,redirect_uri:o,state:s,code_challenge:l,code_challenge_method:`S256`,authorization_params:a});this.transactionManager.create({state:s,code_verifier:c,auth_session:f,redirect_uri:o,appState:n,connection:r,response_type:Lt.ConnectCode});let p=new URL(u);p.searchParams.set(`ticket`,d.ticket),t?await t(p.toString()):window.location.assign(p)}async _requestTokenForMfa(e,t){let{mfaToken:n}=e,r=x(e,[`mfaToken`]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:n}),t)}},ys={isAuthenticated:!1,isLoading:!0,error:void 0,user:void 0},L=function(){throw Error(`You forgot to wrap your component in <Auth0Provider>.`)},bs=v(v({},ys),{buildAuthorizeUrl:L,buildLogoutUrl:L,getAccessTokenSilently:L,getAccessTokenWithPopup:L,getIdTokenClaims:L,loginWithCustomTokenExchange:L,exchangeToken:L,loginWithRedirect:L,loginWithPopup:L,connectAccountWithRedirect:L,logout:L,handleRedirectCallback:L,getDpopNonce:L,setDpopNonce:L,generateDpopProof:L,createFetcher:L,getConfiguration:L,mfa:{getAuthenticators:L,enroll:L,challenge:L,verify:L,getEnrollmentFactors:L}}),xs=(0,c.createContext)(bs),Ss=function(e){_(t,e);function t(n,r){var i=e.call(this,r??n)||this;return i.error=n,i.error_description=r,Object.setPrototypeOf(i,t.prototype),i}return t}(Error),Cs=/[?&](?:connect_)?code=[^&]+/,ws=/[?&]state=[^&]+/,Ts=/[?&]error=[^&]+/,Es=function(e){return e===void 0&&(e=window.location.search),(Cs.test(e)||Ts.test(e))&&ws.test(e)},Ds=function(e){return function(t){if(t instanceof Error)return t;if(typeof t==`object`&&t&&`error`in t&&typeof t.error==`string`){if(`error_description`in t&&typeof t.error_description==`string`){var n=t;return new Ss(n.error,n.error_description)}return new Ss(t.error)}return Error(e)}},Os=Ds(`Login failed`),ks=Ds(`Get access token failed`),As=function(e){e?.redirectUri&&(console.warn("Using `redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `redirectUri` will be no longer supported in a future version"),e.authorizationParams=e.authorizationParams??{},e.authorizationParams.redirect_uri=e.redirectUri,delete e.redirectUri),e?.authorizationParams?.redirectUri&&(console.warn("Using `authorizationParams.redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `authorizationParams.redirectUri` will be removed in a future version"),e.authorizationParams.redirect_uri=e.authorizationParams.redirectUri,delete e.authorizationParams.redirectUri)},js=function(e,t){switch(t.type){case`LOGIN_POPUP_STARTED`:return v(v({},e),{isLoading:!0});case`LOGIN_POPUP_COMPLETE`:case`INITIALISED`:return v(v({},e),{isAuthenticated:!!t.user,user:t.user,isLoading:!1,error:void 0});case`HANDLE_REDIRECT_COMPLETE`:case`GET_ACCESS_TOKEN_COMPLETE`:return e.user===t.user?e:v(v({},e),{isAuthenticated:!!t.user,user:t.user});case`LOGOUT`:return v(v({},e),{isAuthenticated:!1,user:void 0});case`ERROR`:return v(v({},e),{isLoading:!1,error:t.error})}},Ms=function(e){return As(e),v(v({},e),{auth0Client:{name:`auth0-react`,version:`2.16.2`}})},Ns=function(e){window.history.replaceState({},document.title,e.returnTo??window.location.pathname)},Ps=function(e){var t=e,n=t.children,r=t.skipRedirectCallback,i=t.onRedirectCallback,a=i===void 0?Ns:i,o=t.context,s=o===void 0?xs:o,l=t.client,u=ee(t,[`children`,`skipRedirectCallback`,`onRedirectCallback`,`context`,`client`]);l&&(u.domain||u.clientId)&&console.warn("Auth0Provider: the `client` prop takes precedence over `domain`/`clientId` and other configuration options. Remove `domain`, `clientId`, and any other Auth0Client configuration props when using the `client` prop.");var d=(0,c.useState)(function(){return l??new vs(Ms(u))})[0],f=(0,c.useReducer)(js,ys),p=f[0],m=f[1],h=(0,c.useRef)(!1),g=(0,c.useCallback)(function(e){return m({type:`ERROR`,error:e}),e},[]);(0,c.useEffect)(function(){h.current||(h.current=!0,(function(){return y(void 0,void 0,void 0,function(){var e,t,n,i,o,s,c;return b(this,function(l){switch(l.label){case 0:return l.trys.push([0,7,,8]),e=void 0,Es()&&!r?[4,d.handleRedirectCallback()]:[3,3];case 1:return t=l.sent(),n=t.appState,i=n===void 0?{}:n,o=t.response_type,s=ee(t,[`appState`,`response_type`]),[4,d.getUser()];case 2:return e=l.sent(),i.response_type=o,o===Lt.ConnectCode&&(i.connectedAccount=s),a(i,e),[3,6];case 3:return[4,d.checkSession()];case 4:return l.sent(),[4,d.getUser()];case 5:e=l.sent(),l.label=6;case 6:return m({type:`INITIALISED`,user:e}),[3,8];case 7:return c=l.sent(),g(Os(c)),[3,8];case 8:return[2]}})})})())},[d,a,r,g]);var _=(0,c.useCallback)(function(e){return As(e),d.loginWithRedirect(e)},[d]),x=(0,c.useCallback)(function(e,t){return y(void 0,void 0,void 0,function(){var n,r;return b(this,function(i){switch(i.label){case 0:m({type:`LOGIN_POPUP_STARTED`}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,d.loginWithPopup(e,t)];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),g(Os(n)),[2];case 4:return[4,d.getUser()];case 5:return r=i.sent(),m({type:`LOGIN_POPUP_COMPLETE`,user:r}),[2]}})})},[d,g]),S=(0,c.useCallback)(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return y(void 0,te([],e,!0),void 0,function(e){return e===void 0&&(e={}),b(this,function(t){switch(t.label){case 0:return[4,d.logout(e)];case 1:return t.sent(),(e.openUrl||e.openUrl===!1)&&m({type:`LOGOUT`}),[2]}})})},[d]),ne=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r,i;return b(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,d.getTokenSilently(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),ks(n);case 3:return r=m,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[d]),re=(0,c.useCallback)(function(e,t){return y(void 0,void 0,void 0,function(){var n,r,i,a;return b(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,3,5]),[4,d.getTokenWithPopup(e,t)];case 1:return n=o.sent(),[3,5];case 2:throw r=o.sent(),ks(r);case 3:return i=m,a={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return i.apply(void 0,[(a.user=o.sent(),a)]),[7];case 5:return[2,n]}})})},[d]),ie=(0,c.useCallback)(function(e){return d.connectAccountWithRedirect(e)},[d]),ae=(0,c.useCallback)(function(){return d.getIdTokenClaims()},[d]),C=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r,i;return b(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,d.loginWithCustomTokenExchange(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),ks(n);case 3:return r=m,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[d]),w=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){return b(this,function(t){return[2,C(e)]})})},[C]),oe=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r;return b(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,5]),[4,d.handleRedirectCallback(e)];case 1:return[2,i.sent()];case 2:throw t=i.sent(),ks(t);case 3:return n=m,r={type:`HANDLE_REDIRECT_COMPLETE`},[4,d.getUser()];case 4:return n.apply(void 0,[(r.user=i.sent(),r)]),[7];case 5:return[2]}})})},[d]),se=(0,c.useCallback)(function(e){return d.getDpopNonce(e)},[d]),ce=(0,c.useCallback)(function(e,t){return d.setDpopNonce(e,t)},[d]),le=(0,c.useCallback)(function(e){return d.generateDpopProof(e)},[d]),ue=(0,c.useCallback)(function(e){return d.createFetcher(e)},[d]),de=(0,c.useCallback)(function(){return d.getConfiguration()},[d]),fe=(0,c.useMemo)(function(){return d.mfa},[d]),pe=(0,c.useMemo)(function(){return v(v({},p),{getAccessTokenSilently:ne,getAccessTokenWithPopup:re,getIdTokenClaims:ae,loginWithCustomTokenExchange:C,exchangeToken:w,loginWithRedirect:_,loginWithPopup:x,connectAccountWithRedirect:ie,logout:S,handleRedirectCallback:oe,getDpopNonce:se,setDpopNonce:ce,generateDpopProof:le,createFetcher:ue,getConfiguration:de,mfa:fe})},[p,ne,re,ae,C,w,_,x,ie,S,oe,se,ce,le,ue,de,fe]);return c.default.createElement(s.Provider,{value:pe},n)},Fs=function(e){return e===void 0&&(e=xs),(0,c.useContext)(e)},Is=({environment:e})=>(0,h.jsx)(`div`,{className:`epp-environment-banner`,style:{position:`fixed`,zIndex:9999,top:0,left:0,right:0,width:`100vw`,height:`16px`,backgroundColor:(0,p.getColorForEnvironment)(e)}});function Ls(e){let{protocol:t,hostname:n,port:r}=window.location;return e({logoutParams:{returnTo:`${t}//${n}:${r}`}})}var Rs=({children:e,decorateUser:t,getReturnPath:n})=>{let[r,i]=(0,c.useState)(void 0),{user:a,getAccessTokenSilently:o,loginWithRedirect:s,logout:p,isLoading:g,isAuthenticated:_,error:v}=Fs();return(0,c.useEffect)(()=>{_&&(async()=>{try{i(await t(a,await o()))}catch(e){console.error(`Error fetching user data:`,e)}})()},[t,o,_,a]),!g&&!_?(s({appState:{returnTo:n()}}),(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Redirecting to login page`})):g||!r?(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Authenticating`}):v?(process.env.NODE_ENV!==`production`&&console.error(v),(0,h.jsxs)(l.BannerAlertBox,{variant:`error`,title:`Authentication failed`,style:{maxWidth:`600px`,margin:`0 auto`},children:[(0,h.jsxs)(f.Paragraph,{children:[`Something went wrong while trying to authenticate you. If the problem persists you should contact`,` `,(0,h.jsx)(f.Link,{href:`mailto:support@entur.org`,children:`support@entur.org`}),` to get it resolved.`]}),(0,h.jsxs)(f.Paragraph,{children:[`Authentication failed with: `,(0,h.jsx)(f.CodeText,{children:v?.toString()})]})]})):((0,m.assertIsDefined)(r),(0,h.jsx)(h.Fragment,{children:e({user:r,logout:()=>Ls(p),getToken:o})}))},zs=({children:e,audience:t,domain:n,clientId:r,decorateUser:i,environment:a,redirectUri:o,navigate:s})=>(0,h.jsx)(Ps,{domain:n,clientId:r,authorizationParams:{redirect_uri:o??window.location.origin,audience:t},onRedirectCallback:e=>{let t=e?.returnTo,n=o||t||`/`;s?s(n,{replace:!0}):window.history.replaceState({},``,n)},children:(0,h.jsx)(Rs,{decorateUser:i,getReturnPath:()=>`${window.location.pathname}${window.location.search}${window.location.hash}`,children:t=>(0,h.jsxs)(h.Fragment,{children:[a&&a!==p.Environment.Production&&(0,h.jsx)(Is,{environment:a}),e(t)]})})}),Bs=`EP::activeOrgId`,Vs={get:()=>localStorage.getItem(Bs),set:e=>localStorage.setItem(Bs,e)},Hs=`EP::locale`,Us={get:()=>localStorage.getItem(Hs),set:e=>localStorage.setItem(Hs,e)},Ws=`ucData`,Gs={get:()=>localStorage.getItem(Ws)},Ks={Usercentrics:`Usercentrics Consent Management Platform`,PostHog:`PostHog.com`,Sentry:`Sentry`},qs={Usercentrics:{consentGiven:!1},PostHog:{consentGiven:!1},Sentry:{consentGiven:!1}},Js=e=>e.map(e=>{let t=Object.entries(Ks).find(t=>t[1]===e.name)?.[0];if((0,m.assertIsDefined)(t,`Service name ${e.name} not found in SERVICE_NAMES`),typeof e.consent==`boolean`){let n=e.consent;return{[t]:{consentGiven:n}}}else if(typeof e.consent==`object`&&`given`in e.consent){let n=e.consent.given;return{[t]:{consentGiven:n}}}return{[t]:{consentGiven:!1}}}).reduce((e,t)=>({...e,...t}),qs),Ys=(0,c.createContext)(qs),Xs=()=>(0,c.useContext)(Ys),Zs=({children:e})=>{let[t,n]=(0,c.useState)(qs);return(0,c.useEffect)(()=>{if(typeof window>`u`)return;let e=Gs.get();if(e){let t=JSON.parse(e);n(Js(Object.values(t.consent.services)))}},[]),(0,c.useEffect)(()=>{let e=async e=>{typeof window>`u`||n(Js(Object.values(e.detail.services)))};return window.addEventListener(`UC_CONSENT`,e),()=>window.removeEventListener(`UC_CONSENT`,e)},[]),(0,h.jsx)(Ys.Provider,{value:t,children:e})},Qs=(0,c.createContext)(void 0),$s=e=>{let[t,n]=(0,c.useState)(e);return(0,c.useEffect)(()=>{Us.set(t)},[t]),[t,n]},ec=()=>{let e=(0,c.useContext)(Qs);return(0,m.assertIsDefined)(e),e},tc=({children:e,language:t})=>{let[n,r]=$s(t);return(0,h.jsx)(Qs.Provider,{value:{language:n,setLanguage:r},children:e})},nc=(0,c.createContext)({addItems:()=>{},getItemsForPath:()=>[],getMFNavigate:()=>void 0,setMFNavigate:()=>{},getItemGroupsPerPath:()=>({})}),rc=e=>(0,c.useContext)(nc).getItemsForPath(e),ic=()=>(0,c.useContext)(nc),ac=e=>{let{getMFNavigate:t}=ic();return t(e)},oc=({children:e})=>{let[t,n]=(0,c.useState)({}),[r,i]=(0,c.useState)({}),a=(0,c.useCallback)((e,t)=>{n(n=>({...n,[t]:e}))},[]);return(0,h.jsx)(nc.Provider,{value:{addItems:a,getItemGroupsPerPath:()=>t,getItemsForPath:e=>t[e]??[],getMFNavigate:e=>r[e],setMFNavigate:(e,t)=>i(n=>({...n,[e]:t}))},children:e})};function sc(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var cc=({navigate:e,children:t,onClick:n,target:r,...i})=>(0,h.jsx)(`a`,{onClick:t=>{try{n&&n(t)}catch(e){throw t.preventDefault(),e}!t.defaultPrevented&&t.button===0&&(!r||r===`_self`)&&!sc(t)&&(t.preventDefault(),e())},target:r,...i,children:t}),lc=(0,c.createContext)(void 0),uc=()=>{let e=(0,c.useContext)(lc);return(0,m.assertIsDefined)(e),e},dc=()=>{let e=(0,c.useContext)(lc);return(0,m.assertIsDefined)(e),e.organisationId},fc=e=>{let[t,n]=(0,c.useState)(Number(e));return(0,c.useEffect)(()=>{Vs.set(t.toString())},[t]),[t,n]},pc=({children:e,organisationId:t})=>{let[n,r]=fc(t);return(0,h.jsx)(lc.Provider,{value:{organisationId:n,setOrganisationId:r},children:e})},mc=class extends Error{constructor(...e){super(...e),this.message=`Failed fetching organisations`}},hc=({getToken:e,getOrganisations:t,selectedOrganisationId:n,onChange:r,...i})=>{let[a,o]=(0,c.useState)([]),{language:s}=ec(),[l,d]=(0,c.useState)(`LOADING`);switch((0,c.useEffect)(()=>{(async()=>{let n=await e(),r;r=typeof t==`string`?await fetch(t,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`}}).then(e=>e.json()):await t(n),o(r),d(`SUCCESS`)})().catch(e=>{process.env.NODE_ENV===`development`&&console.error(e),d(`ERROR`)})},[t,e]),l){case`LOADING`:return(0,h.jsx)(`div`,{className:`eds-contrast`,children:(0,h.jsx)(u.SkeletonRectangle,{style:{height:`2.4rem`}})});case`SUCCESS`:return(0,h.jsx)(p.OrganisationDropDown,{label:s===`nb`||s===`nb-NO`?`Organisasjon`:`Organisation`,selectedOrganisationId:n,organisations:a,onChange:r,...i});case`ERROR`:throw new mc;default:return null}},R=typeof window<`u`?window:void 0,gc=typeof globalThis<`u`?globalThis:R;typeof self>`u`&&(gc.self=gc),typeof File>`u`&&(gc.File=function(){});var _c=gc?.navigator,z=gc?.document,vc=gc?.location,yc=gc?.fetch,bc=gc!=null&&gc.XMLHttpRequest&&`withCredentials`in new gc.XMLHttpRequest?gc.XMLHttpRequest:void 0,xc=gc?.AbortController,Sc=gc?.CompressionStream,Cc=_c?.userAgent,B=R??{},wc=`1.369.5`,Tc={DEBUG:!1,LIB_VERSION:wc,LIB_NAME:`web`,JS_SDK_VERSION:wc};function Ec(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Dc(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ec(a,r,i,o,s,`next`,e)}function s(e){Ec(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(null,arguments)}function Oc(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function kc(){return(kc=Dc((function*(e,t,n){t===void 0&&(t=!0);try{var r=new Blob([e],{type:`text/plain`}).stream().pipeThrough(new CompressionStream(`gzip`));return yield new Response(r).blob()}catch(e){if(n!=null&&n.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}}))).apply(this,arguments)}var Ac=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`],jc=`amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterest,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),Mc=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return jc.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))};function H(e,t){return e.indexOf(t)!==-1}var Nc=function(e){return e.trim()},Pc=function(e){return e.replace(/^\$/,``)},Fc=Object.prototype,Ic=Fc.hasOwnProperty,Lc=Fc.toString,U=Array.isArray||function(e){return Lc.call(e)===`[object Array]`},Rc=e=>typeof e==`function`,zc=e=>e===Object(e)&&!U(e),Bc=e=>{if(zc(e)){for(var t in e)if(Ic.call(e,t))return!1;return!0}return!1},W=e=>e===void 0,G=e=>Lc.call(e)==`[object String]`,Vc=e=>G(e)&&e.trim().length===0,Hc=e=>e===null,K=e=>W(e)||Hc(e),Uc=e=>Lc.call(e)==`[object Number]`&&e==e,Wc=e=>Uc(e)&&e>0,Gc=e=>Lc.call(e)===`[object Boolean]`,Kc=e=>e instanceof FormData,qc=e=>H(Ac,e);function Jc(e){return typeof e!=`object`||!e}function Yc(e,t){return{}.toString.call(e)===`[object `+t+`]`}function Xc(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var Zc=[!0,`true`,1,`1`,`yes`],Qc=e=>H(Zc,e),$c=[!1,`false`,0,`0`,`no`];function el(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Uc(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),el(i||n,t,n,r))}var tl=class{constructor(e){this.Pt={},this.Dt=e.Dt,this.jt=el(e.bucketSize,0,100,e.qt),this.$t=el(e.refillRate,0,this.jt,e.qt),this.Vt=el(e.refillInterval,0,864e5,e.qt)}Ht(e,t){var n=Math.floor((t-e.lastAccess)/this.Vt);n>0&&(e.tokens=Math.min(e.tokens+n*this.$t,this.jt),e.lastAccess+=n*this.Vt)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.Pt[r];return i?this.Ht(i,n):this.Pt[r]=i={tokens:this.jt,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.Dt)==null||t.call(this,e)),i.tokens===0)}stop(){this.Pt={}}},nl,rl,il,al=`Mobile`,ol=`iOS`,sl=`Android`,cl=`Tablet`,ll=sl+` `+cl,ul=`iPad`,dl=`Apple`,fl=dl+` Watch`,pl=`Safari`,ml=`BlackBerry`,hl=`Samsung`,gl=hl+`Browser`,_l=hl+` Internet`,vl=`Chrome`,yl=vl+` OS`,bl=vl+` `+ol,xl=`Internet Explorer`,Sl=xl+` `+al,Cl=`Opera`,wl=Cl+` Mini`,Tl=`Edge`,El=`Microsoft `+Tl,Dl=`Firefox`,Ol=Dl+` `+ol,kl=`Nintendo`,Al=`PlayStation`,jl=`Xbox`,Ml=sl+` `+al,Nl=al+` `+pl,Pl=`Windows`,Fl=Pl+` Phone`,Il=`Nokia`,Ll=`Ouya`,Rl=`Generic`,zl=Rl+` `+al.toLowerCase(),Bl=Rl+` `+cl.toLowerCase(),Vl=`Konqueror`,Hl=`(\\d+(\\.\\d+)?)`,Ul=RegExp(`Version/`+Hl),Wl=new RegExp(jl,`i`),Gl=RegExp(Al+` \\w+`,`i`),Kl=RegExp(kl+` \\w+`,`i`),ql=RegExp(ml+`|PlayBook|BB10`,`i`),Jl={"NT3.51":`NT 3.11`,"NT4.0":`NT 4.0`,"5.0":`2000`,5.1:`XP`,5.2:`XP`,"6.0":`Vista`,6.1:`7`,6.2:`8`,6.3:`8.1`,6.4:`10`,"10.0":`10`},Yl=function(e,t){return t||=``,H(e,` OPR/`)&&H(e,`Mini`)?wl:H(e,` OPR/`)?Cl:ql.test(e)?ml:H(e,`IE`+al)||H(e,`WPDesktop`)?Sl:H(e,gl)?_l:H(e,Tl)||H(e,`Edg/`)?El:H(e,`FBIOS`)?`Facebook `+al:H(e,`UCWEB`)||H(e,`UCBrowser`)?`UC Browser`:H(e,`CriOS`)?bl:H(e,`CrMo`)||H(e,vl)?vl:H(e,sl)&&H(e,pl)?Ml:H(e,`FxiOS`)?Ol:H(e.toLowerCase(),Vl.toLowerCase())?Vl:((e,t)=>t&&H(t,dl)||function(e){return H(e,pl)&&!H(e,vl)&&!H(e,sl)}(e))(e,t)?H(e,al)?Nl:pl:H(e,Dl)?Dl:H(e,`MSIE`)||H(e,`Trident/`)?xl:H(e,`Gecko`)?Dl:``},Xl={[Sl]:[RegExp(`rv:`+Hl)],[El]:[RegExp(Tl+`?\\/`+Hl)],[vl]:[RegExp(`(`+vl+`|CrMo)\\/`+Hl)],[bl]:[RegExp(`CriOS\\/`+Hl)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+Hl)],[pl]:[Ul],[Nl]:[Ul],[Cl]:[RegExp(`(Opera|OPR)\\/`+Hl)],[Dl]:[RegExp(Dl+`\\/`+Hl)],[Ol]:[RegExp(`FxiOS\\/`+Hl)],[Vl]:[RegExp(`Konqueror[:/]?`+Hl,`i`)],[ml]:[RegExp(ml+` `+Hl),Ul],[Ml]:[RegExp(`android\\s`+Hl,`i`)],[_l]:[RegExp(gl+`\\/`+Hl)],[xl]:[RegExp(`(rv:|MSIE )`+Hl)],Mozilla:[RegExp(`rv:`+Hl)]},Zl=function(e,t){var n=Xl[Yl(e,t)];if(W(n))return null;for(var r=0;n.length>r;r++){var i=e.match(n[r]);if(i)return parseFloat(i[i.length-2])}return null},Ql=[[RegExp(jl+`; `+jl+` (.*?)[);]`,`i`),e=>[jl,e&&e[1]||``]],[new RegExp(kl,`i`),[kl,``]],[new RegExp(Al,`i`),[Al,``]],[ql,[ml,``]],[new RegExp(Pl,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Fl,``];if(new RegExp(al).test(t)&&!/IEMobile\b/.test(t))return[Pl+` `+al,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=Jl[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[Pl,r]}return[Pl,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[ol,[e[3],e[4],e[5]||`0`].join(`.`)]:[ol,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=W(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+sl+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+sl+`)`,`i`),e=>e&&e[2]?[sl,[e[2],e[3],e[4]||`0`].join(`.`)]:[sl,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[yl,``]],[/Linux|debian/i,[`Linux`,``]]],$l=function(e){return Kl.test(e)?kl:Gl.test(e)?Al:Wl.test(e)?jl:new RegExp(Ll,`i`).test(e)?Ll:RegExp(`(`+Fl+`|WPDesktop)`,`i`).test(e)?Fl:/iPad/.test(e)?ul:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?fl:ql.test(e)?ml:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Il,`i`).test(e)?Il:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(al).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?sl:ll:RegExp(`(pda|`+al+`)`,`i`).test(e)?zl:new RegExp(cl,`i`).test(e)&&!RegExp(cl+` pc`,`i`).test(e)?Bl:``},eu=e=>e instanceof Error;function tu(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return il&&n.length===rl||(rl=n.length,il=n.reduce(((n,r)=>{nl||={};var i=nl[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,nl[r]=[s,c];break}}return n}),{})),il}}var nu=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return Dc((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&U(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),V({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Dc((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,V({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:tu(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return V({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},ru=`?`;function iu(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?ru:n,in_app:!0};return W(r)||(a.lineno=r),W(i)||(a.colno=i),a}var au=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?ru:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},ou=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,su=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,cu=/\((\S*)(?::(\d+))(?::(\d+))\)/,lu=(e,t)=>{var n=ou.exec(e);if(n){var[,r,i,a]=n;return iu(t,r,ru,+i,+a)}var o=su.exec(e);if(o){if(o[2]&&o[2].indexOf(`eval`)===0){var s=cu.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}var[c,l]=au(o[1]||ru,o[2]);return iu(t,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},uu=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,du=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,fu=(e,t)=>{var n=uu.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=du.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||ru;return[a,i]=au(a,i),iu(t,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},pu=/\(error: (.*)\)/,mu=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=G(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){var t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?t+`: `+e.message:t}isDOMException(e){return Yc(e,`DOMException`)}isDOMError(e){return Yc(e,`DOMError`)}},hu=class{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},gu=class{constructor(){}match(e){return Yc(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},_u=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,vu=class{match(e){return typeof e==`string`}coerce(e,t){var[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(_u);return r&&(t=r[1],n=r[2]),[t,n]}},yu=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function bu(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var xu=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return Xc(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+bu(e)}isSeverityLevel(e){return G(e)&&!Vc(e)&&yu.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(eu(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Su=class{match(e){return Xc(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+bu(e),stack:t.syntheticException?.stack,synthetic:!0}}},Cu=class{match(e){return Jc(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},wu=class{match(e){return Yc(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Xc(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return Jc(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},Tu=function(e,t){var{debugEnabled:n}=t===void 0?{}:t,r={C(t){if(R&&(Tc.DEBUG||B.POSTHOG_DEBUG||n)&&!W(R.console)&&R.console){for(var r=(`__rrweb_original__`in R.console[t])?R.console[t].__rrweb_original__:R.console[t],i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];r(e,...a)}},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`error`,...t)},critical(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];console.error(e,...n)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling `+e)},createLogger:(t,n)=>Tu(e+` `+t,n)};return r},q=Tu(`[PostHog.js]`),J=q.createLogger,Eu=J(`[ExternalScriptsLoader]`),Du=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Eu.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var r=z?.querySelectorAll(`script`);if(r){for(var i,a=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener(`load`,(t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)})),e.onerror=e=>n(e),{v:void 0})}},o=0;r.length>o;o++)if(i=a())return i.v}var s=()=>{if(!z)return n(`document not found`);var r=z.createElement(`script`);if(r.type=`text/javascript`,r.crossOrigin=`anonymous`,r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)},r.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)z.head.appendChild(r);else{var i,a=z.querySelectorAll(`body > script`);a.length>0?(i=a[0].parentNode)==null||i.insertBefore(r,a[0]):z.body.appendChild(r)}};z!=null&&z.body?s():z?.addEventListener(`DOMContentLoaded`,s)};B.__PosthogExtensions__=B.__PosthogExtensions__||{},B.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r;if(e.config.__preview_external_dependency_versioned_paths)r=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`);else{var i=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var a=3e5;i=i+`&t=`+Math.floor(Date.now()/a)*a}r=e.requestRouter.endpointFor(`assets`,i)}Du(e,r,n)}else Du(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},B.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{Du(e,e.requestRouter.endpointFor(`api`,t),n)};var Ou=`$people_distinct_id`,ku=`$device_id`,Au=`__alias`,ju=`__timers`,Mu=`$autocapture_disabled_server_side`,Nu=`$heatmaps_enabled_server_side`,Pu=`$exception_capture_enabled_server_side`,Fu=`$error_tracking_suppression_rules`,Iu=`$error_tracking_capture_extension_exceptions`,Lu=`$web_vitals_enabled_server_side`,Ru=`$dead_clicks_enabled_server_side`,zu=`$product_tours_enabled_server_side`,Bu=`$web_vitals_allowed_metrics`,Vu=`$session_recording_remote_config`,Hu=`$sesid`,Uu=`$session_is_sampled`,Wu=`$enabled_feature_flags`,Gu=`$early_access_features`,Ku=`$feature_flag_details`,qu=`$feature_flag_payloads`,Ju=`$override_feature_flag_payloads`,Yu=`$stored_person_properties`,Xu=`$stored_group_properties`,Zu=`$surveys`,Qu=`ph_product_tours`,$u=`$flag_call_reported`,ed=`$flag_call_reported_session_id`,td=`$feature_flag_errors`,nd=`$feature_flag_evaluated_at`,rd=`$user_state`,id=`$client_session_props`,ad=`$capture_rate_limit`,od=`$initial_campaign_params`,sd=`$initial_referrer_info`,cd=`$initial_person_info`,ld=`$epp`,ud=`__POSTHOG_TOOLBAR__`,dd=`$posthog_cookieless`,fd=[Ou,Au,`__cmpns`,ju,`$session_recording_enabled_server_side`,Nu,Hu,Wu,Fu,rd,Gu,Ku,Xu,Yu,Zu,$u,ed,td,nd,id,ad,od,sd,ld,cd,Qu,`$product_tours_activated`,zu,Vu,Ju],pd=`PostHog loadExternalDependency extension not found.`,md=`on_reject`,hd=`always`,gd=`anonymous`,_d=`identified`,vd=`identified_only`,yd=`visibilitychange`,bd=`beforeunload`,xd=`$pageview`,Sd=`$pageleave`,Cd=`$identify`,wd=`$groupidentify`;function Td(e,t){U(e)&&e.forEach(t)}function Y(e,t){if(!K(e))if(U(e))e.forEach(t);else if(Kc(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)Ic.call(e,n)&&t(e[n],n)}var X=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function Ed(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Dd=function(e){try{return e()}catch{return}},Od=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){q.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),q.critical(e)}}},kd=function(e){var t={};return Y(e,(function(e,n){(G(e)&&e.length>0||Uc(e))&&(t[n]=e)})),t},Ad=[`herokuapp.com`,`vercel.app`,`netlify.app`];function jd(e){var t=e?.hostname;if(!G(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of Ad)if(n===r)return!1;return!0}function Md(e,t,n,r){var{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function Nd(e){return e.name===`ph_toolbar_internal`}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Uc(e)&&isFinite(e)&&Math.floor(e)===e});var Pd=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},Fd=class{constructor(){this.I=0,this.S=0,this.k=new Rd}generate(){var e=this.generateOrAbort();if(W(e)){this.I=0;var t=this.generateOrAbort();if(W(t))throw Error(`Could not generate UUID after timestamp reset`);return t}return e}generateOrAbort(){var e=Date.now();if(e>this.I)this.I=e,this.A();else{if(this.I>=e+1e4)return;this.S++,this.S>4398046511103&&(this.I++,this.A())}return Pd.fromFieldsV7(this.I,Math.trunc(this.S/2**30),this.S&2**30-1,this.k.nextUint32())}A(){this.S=1024*this.k.nextUint32()+(1023&this.k.nextUint32())}},Id,Ld=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};R&&!W(R.crypto)&&crypto.getRandomValues&&(Ld=e=>crypto.getRandomValues(e));var Rd=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(Ld(this.T),this.N=0),this.T[this.N++]}},zd=()=>Bd().toString(),Bd=()=>(Id||=new Fd).generate(),Vd=``,Hd=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Ud={Ut:()=>!!z,Yt(e){q.error(`cookieStore error: `+e)},Gt(e){if(z){try{for(var t=e+`=`,n=z.cookie.split(`;`).filter((e=>e.length)),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==` `;)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},Wt(e){var t;try{t=JSON.parse(Ud.Gt(e))||{}}catch{}return t},Xt(e,t,n,r,i){if(z)try{var a=``,o=``,s=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=z),Vd)return Vd;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+zd();!Vd&&r--;){var a=n.slice(r).join(`.`),o=i+`=1;domain=.`+a+`;path=/`;t.cookie=o+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=o+`;max-age=0`,Vd=a)}return Vd}(e);if(!n){var r=(e=>{var t=e.match(Hd);return t?t[0]:``})(e);r!==n&&q.info(`Warning: cookie subdomain discovery mismatch`,r,n),n=r}return n?`; domain=.`+n:``}return``}(z.location.hostname,r);if(n){var c=new Date;c.setTime(c.getTime()+864e5*n),a=`; expires=`+c.toUTCString()}i&&(o=`; secure`);var l=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return l.length>3686.4&&q.warn(`cookieStore warning: large cookie, len=`+l.length),z.cookie=l,l}catch{return}},Jt(e,t){if(z!=null&&z.cookie)try{Ud.Xt(e,``,-1,t)}catch{return}}},Wd=null,Z={Ut(){if(!Hc(Wd))return Wd;var e=!0;if(W(R))e=!1;else try{var t=`__mplssupport__`;Z.Xt(t,`xyz`),Z.Gt(t)!==`"xyz"`&&(e=!1),Z.Jt(t)}catch{e=!1}return e||q.error(`localStorage unsupported; falling back to cookie store`),Wd=e,e},Yt(e){q.error(`localStorage error: `+e)},Gt(e){try{return R?.localStorage.getItem(e)}catch(e){Z.Yt(e)}return null},Wt(e){try{return JSON.parse(Z.Gt(e))||{}}catch{}return null},Xt(e,t){try{R?.localStorage.setItem(e,JSON.stringify(t))}catch(e){Z.Yt(e)}},Jt(e){try{R?.localStorage.removeItem(e)}catch(e){Z.Yt(e)}}},Gd=[ku,`distinct_id`,Hu,Uu,ld,cd,rd],Kd={},qd={Ut:()=>!0,Yt(e){q.error(`memoryStorage error: `+e)},Gt:e=>Kd[e]||null,Wt:e=>Kd[e]||null,Xt(e,t){Kd[e]=t},Jt(e){delete Kd[e]}},Jd=null,Yd={Ut(){if(!Hc(Jd))return Jd;if(Jd=!0,W(R))Jd=!1;else try{var e=`__support__`;Yd.Xt(e,`xyz`),Yd.Gt(e)!==`"xyz"`&&(Jd=!1),Yd.Jt(e)}catch{Jd=!1}return Jd},Yt(e){q.error(`sessionStorage error: `,e)},Gt(e){try{return R?.sessionStorage.getItem(e)}catch(e){Yd.Yt(e)}return null},Wt(e){try{return JSON.parse(Yd.Gt(e))||null}catch{}return null},Xt(e,t){try{R?.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Yd.Yt(e)}},Jt(e){try{R?.sessionStorage.removeItem(e)}catch(e){Yd.Yt(e)}}},Xd=class{constructor(e){this._instance=e}get Rt(){return this._instance.config}get consent(){return this.Kt()?0:this.Qt}isOptedOut(){return this.Rt.cookieless_mode===hd||this.isRejected()||this.consent===-1&&this.Rt.cookieless_mode===md}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Rt.opt_out_capturing_by_default}optInOut(e){this.ti.Xt(this.ei,+!!e,this.Rt.cookie_expiration,this.Rt.cross_subdomain_cookie,this.Rt.secure_cookie)}reset(){this.ti.Jt(this.ei,this.Rt.cross_subdomain_cookie)}get ei(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get Qt(){var e=this.ti.Gt(this.ei);return Qc(e)?1:H($c,e)?0:-1}get ti(){var e=this.Rt.opt_out_capturing_persistence_type,t=e===`localStorage`?Z:Ud;if(!this.ii||this.ii!==t){this.ii=t;var n=e===`localStorage`?Ud:Z;n.Gt(this.ei)&&(this.ii.Gt(this.ei)||this.optInOut(Qc(n.Gt(this.ei))),n.Jt(this.ei,this.Rt.cross_subdomain_cookie))}return this.ii}Kt(){return!!this.Rt.respect_dnt&&[_c?.doNotTrack,_c?.msDoNotTrack,B.doNotTrack].some((e=>Qc(e)))}},Zd=J(`[Dead Clicks]`),Qd=()=>!0,$d=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Ru)),r=e.instance.config.capture_dead_clicks;return Gc(r)?r:!!zc(r)||n},ef=class{get lazyLoadedDeadClicksAutocapture(){return this.ri}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){`captureDeadClicks`in e&&(this.instance.persistence&&this.instance.persistence.register({[Ru]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.ni((()=>{this.si()})):this.stop()}ni(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?Zd.error(`failed to load script`,t):e()}))}si(){var e;if(z){if(!this.ri&&(e=B.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=zc(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.ri=B.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ri.start(z),Zd.info(`starting...`)}}else Zd.error("`document` not found. Cannot start.")}stop(){this.ri&&(this.ri.stop(),this.ri=void 0,Zd.info(`stopping...`))}},tf=J(`[SegmentIntegration]`),nf=`posthog-js`;function rf(e,t){var{organization:n,projectId:r,prefix:i,severityAllowList:a=[`error`],sendExceptionsToPostHog:o=!0}=t===void 0?{}:t;return t=>{if(a!==`*`&&!a.includes(t.level)||!e.__loaded)return t;t.tags||={};var s=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var c,l=t.exception?.values||[],u=l.map((e=>V({},e,{stacktrace:e.stacktrace?V({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>V({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:l[0]?.value||t.message,$exception_type:l[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:l[0]?.value||t.message,$sentry_exception_type:l[0]?.type,$sentry_tags:t.tags};return n&&r&&(d.$sentry_url=(i||`https://sentry.io/organizations/`)+n+`/issues/?project=`+r+`&query=`+t.event_id),o&&((c=e.exceptions)==null||c.sendExceptionEvent(d)),t}}var af=class{constructor(e,t,n,r,i,a){this.name=nf,this.setupOnce=function(o){o(rf(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},of=class{constructor(e){this.oi=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(q.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.ai=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.li()}li(){this.ui=this._instance.sessionManager?.onSessionId(this.oi)}destroy(){var e;(e=this.ui)==null||e.call(this),this.ui=void 0}doPageView(e,t){var n=this.hi(e,t);return this.ai={pathname:R?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.hi(e,this.ai?.pageViewId)}doEvent(){return{$pageview_id:this.ai?.pageViewId}}hi(e,t){var n=this.ai;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:s,maxContentHeight:c,lastContentY:l,maxContentY:u}=i;if(!(W(a)||W(o)||W(s)||W(c)||W(l)||W(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?el(o/a,0,1,q):1,f=a>1?el(s/a,0,1,q):1,p=c>1?el(l/c,0,1,q):1,m=c>1?el(u/c,0,1,q):1;r=X(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},sf=e=>{var t=z?.createElement(`a`);return W(t)?null:(t.href=e,t)},cf=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);if(a[0]===t){n=a;break}}if(!U(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{q.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},lf=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);U(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},uf=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},df=`https?://(.*)`,ff=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],pf=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...ff],mf=`<masked>`,hf=[`li_fat_id`];function gf(e,t,n){if(!z)return{};var r,i=t?[...ff,...n||[]]:[],a=_f(lf(z.URL,i,mf),e);return X((r={},Y(hf,(function(e){var t=Ud.Gt(e);r[e]=t||null})),r),a)}function _f(e,t){var n=pf.concat(t||[]),r={};return Y(n,(function(t){r[t]=cf(e,t)||null})),r}function vf(e){var t=function(e){return e?e.search(df+`google.([^/?]*)`)===0?`google`:e.search(df+`bing.com`)===0?`bing`:e.search(df+`yahoo.com`)===0?`yahoo`:e.search(df+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!Hc(t)){r.$search_engine=t;var i=z?cf(z.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function yf(){return navigator.language||navigator.userLanguage}var bf=`$direct`;function xf(){return z?.referrer||bf}function Sf(e,t){var n=e?[...ff,...t||[]]:[],r=vc?.href.substring(0,1e3);return{r:xf().substring(0,1e3),u:r?lf(r,n,mf):void 0}}function Cf(e){var{r:t,u:n}=e,r={$referrer:t,$referring_domain:t==null?void 0:t==bf?bf:sf(t)?.host};if(n){r.$current_url=n;var i=sf(n);r.$host=i?.host,r.$pathname=i?.pathname,X(r,_f(n))}return t&&X(r,vf(t)),r}function wf(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Tf(){try{return new Date().getTimezoneOffset()}catch{return}}var Ef=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Df=class{constructor(e,t){this.Rt=e,this.props={},this.ci=!1,this.di=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(e),this.ti=this.vi(e),this.load(),e.debug&&q.info(`Persistence loaded`,e.persistence,V({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.fi}vi(e){Ef.indexOf(e.persistence.toLowerCase())===-1&&(q.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);var t=function(e){e===void 0&&(e=[]);var t=[...Gd,...e];return V({},Z,{Wt(e){try{var t={};try{t=Ud.Wt(e)||{}}catch{}var n=X(t,JSON.parse(Z.Gt(e)||`{}`));return Z.Xt(e,n),n}catch{}return null},Xt(e,n,r,i,a,o){try{Z.Xt(e,n,void 0,void 0,o);var s={};t.forEach((e=>{n[e]&&(s[e]=n[e])})),Object.keys(s).length&&Ud.Xt(e,s,r,i,a,o)}catch(e){Z.Yt(e)}},Jt(e,t){try{R?.localStorage.removeItem(e),Ud.Jt(e,t)}catch(e){Z.Yt(e)}}})}(e.cookie_persisted_properties||[]),n=e.persistence.toLowerCase();return n===`localstorage`&&Z.Ut()?Z:n===`localstorage+cookie`&&t.Ut()?t:n===`sessionstorage`&&Yd.Ut()?Yd:n===`memory`?qd:n===`cookie`?Ud:t.Ut()?t:Ud}pi(e){var t=e??this.Rt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[nd];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return Y(this.props,((t,n)=>{if(n===Wu&&zc(t)){if(!this.pi())for(var r=Object.keys(t),i=0;r.length>i;i++)e[`$feature/`+r[i]]=t[r[i]]}else fd.indexOf(n)===-1&&(e[n]=t)})),e}load(){if(!this.fi){var e=this.ti.Wt(this.di);e&&(this.props=X({},e))}}save(){this.fi||this.ti.Xt(this.di,this.props,this.gi,this.mi,this.yi,this.Rt.debug)}remove(){this.ti.Jt(this.di,!1),this.ti.Jt(this.di,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(zc(e)){W(t)&&(t=`None`),this.gi=W(n)?this.bi:n;var r=!1;if(Y(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.props[n]=e,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(zc(e)){this.gi=W(t)?this.bi:t;var n=!1;if(Y(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.ci){var e=gf(this.Rt.custom_campaign_params,this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties);Bc(kd(e))||this.register(e),this.ci=!0}}update_search_keyword(){var e;this.register((e=z?.referrer)?vf(e):{})}update_referrer_info(){this.register_once({$referrer:xf(),$referring_domain:z!=null&&z.referrer&&sf(z.referrer)?.host||bf},void 0)}set_initial_person_info(){this.props[od]||this.props[sd]||this.register_once({[cd]:Sf(this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Y([sd,od],(t=>{var n=this.props[t];n&&Y(n,(function(t,n){e[`$initial_`+Pc(n)]=t}))}));var t,n,r=this.props[cd];return r&&X(e,(t=Cf(r),n={},Y(t,(function(e,t){n[`$initial_`+Pc(t)]=e})),n)),e}safe_merge(e){return Y(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){if(this.bi=this.gi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.vi(e),i=this.props;this.clear(),this.ti=r,this.props=i,this.save()}}set_disabled(e){this.fi=e,this.fi?this.remove():this.save()}set_cross_subdomain(e){e!==this.mi&&(this.mi=e,this.remove(),this.save())}set_secure(e){e!==this.yi&&(this.yi=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[ju]||{};n[e]=t,this.props[ju]=n,this.save()}remove_event_timer(e){var t=(this.props[ju]||{})[e];return W(t)||(delete this.props[ju][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},Of={Activation:`events`,Cancellation:`cancelEvents`},kf={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},Af={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},jf={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`},Mf={Popover:`popover`,Inline:`inline`},Nf={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},Pf={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},Ff=J(`[RateLimiter]`),If=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Ff.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){Ff.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(ad)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;return o||e||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(ad,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Lf=J(`[RemoteConfig]`),Rf=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=B._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}wi(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Ii(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/`+this._instance.config.token+`/config`),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return Lf.info(`Using preloaded remote config`,this.remoteConfig),this.Ci(this.remoteConfig),void this.Si();if(this._instance.ki())return void Lf.warn(`Remote config is disabled. Falling back to local config.`);this.wi((e=>{if(!e)return Lf.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Ii((e=>{this.Ci(e),this.Si()}));this.Ci(e),this.Si()}))}catch(e){Lf.error(`Error loading remote config`,e)}}stop(){this.xi&&=(clearInterval(this.xi),void 0)}refresh(){this._instance.ki()||z?.visibilityState===`hidden`||this._instance.reloadFeatureFlags()}Si(){if(!this.xi){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.xi=setInterval((()=>{this.refresh()}),e))}}Ci(e){var t;e||Lf.error(`Failed to fetch remote config from PostHog.`),this._instance.Ci(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},zf={GZipJS:`gzip-js`,Base64:`base64`},Bf=Uint8Array,Vf=Uint16Array,Hf=Uint32Array,Uf=new Bf([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Wf=new Bf([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Gf=new Bf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kf=function(e,t){for(var n=new Vf(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Hf(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},qf=Kf(Uf,2),Jf=qf[1];qf[0][28]=258,Jf[258]=28;for(var Yf=Kf(Wf,0)[1],Xf=new Vf(32768),Q=0;32768>Q;++Q){var Zf=(43690&Q)>>>1|(21845&Q)<<1;Xf[Q]=((65280&(Zf=(61680&(Zf=(52428&Zf)>>>2|(13107&Zf)<<2))>>>4|(3855&Zf)<<4))>>>8|(255&Zf)<<8)>>>1}var Qf=function(e,t,n){for(var r=e.length,i=0,a=new Vf(t);r>i;++i)++a[e[i]-1];var o,s=new Vf(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new Vf(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[Xf[d]>>>c]=l}else for(o=new Vf(r),i=0;r>i;++i)o[i]=Xf[s[e[i]-1]++]>>>15-e[i];return o},$f=new Bf(288);for(Q=0;144>Q;++Q)$f[Q]=8;for(Q=144;256>Q;++Q)$f[Q]=9;for(Q=256;280>Q;++Q)$f[Q]=7;for(Q=280;288>Q;++Q)$f[Q]=8;var ep=new Bf(32);for(Q=0;32>Q;++Q)ep[Q]=5;var tp=Qf($f,9,0),np=Qf(ep,5,0),rp=function(e){return(e/8>>0)+(7&e&&1)},ip=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Vf?Vf:e instanceof Hf?Hf:Bf)(n-t);return r.set(e.subarray(t,n)),r},ap=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},op=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},sp=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new Bf(0),0];if(i==1){var o=new Bf(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new Vf(f+1),m=cp(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var ee=a[r].s;t>p[ee]?h-=1<<t-p[ee]++-1:++r}for(;r>=0&&h;--r){var y=a[r].s;p[y]==t&&(--p[y],++h)}m=t}return[new Bf(p),m]},cp=function(e,t,n){return e.s==-1?Math.max(cp(e.l,t,n+1),cp(e.r,t,n+1)):t[e.s]=n},lp=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Vf(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},up=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},dp=function(e,t,n){var r=n.length,i=rp(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},fp=function(e,t,n,r,i,a,o,s,c,l,u){ap(t,u++,n),++i[256];for(var d=sp(i,15),f=d[0],p=d[1],m=sp(a,15),h=m[0],g=m[1],_=lp(f),v=_[0],ee=_[1],y=lp(h),b=y[0],te=y[1],x=new Vf(19),S=0;v.length>S;++S)x[31&v[S]]++;for(S=0;b.length>S;++S)x[31&b[S]]++;for(var ne=sp(x,7),re=ne[0],ie=ne[1],ae=19;ae>4&&!re[Gf[ae-1]];--ae);var C,w,oe,se,ce=l+5<<3,le=up(i,$f)+up(a,ep)+o,ue=up(i,f)+up(a,h)+o+14+3*ae+up(x,re)+(2*x[16]+3*x[17]+7*x[18]);if(le>=ce&&ue>=ce)return dp(t,u,e.subarray(c,c+l));if(ap(t,u,1+(le>ue)),u+=2,le>ue){C=Qf(f,p,0),w=f,oe=Qf(h,g,0),se=h;var de=Qf(re,ie,0);for(ap(t,u,ee-257),ap(t,u+5,te-1),ap(t,u+10,ae-4),u+=14,S=0;ae>S;++S)ap(t,u+3*S,re[Gf[S]]);u+=3*ae;for(var fe=[v,b],pe=0;2>pe;++pe){var me=fe[pe];for(S=0;me.length>S;++S)ap(t,u,de[he=31&me[S]]),u+=re[he],he>15&&(ap(t,u,me[S]>>>5&127),u+=me[S]>>>12)}}else C=tp,w=$f,oe=np,se=ep;for(S=0;s>S;++S)if(r[S]>255){var he;op(t,u,C[257+(he=r[S]>>>18&31)]),u+=w[he+257],he>7&&(ap(t,u,r[S]>>>23&31),u+=Uf[he]);var ge=31&r[S];op(t,u,oe[ge]),u+=se[ge],ge>3&&(op(t,u,r[S]>>>5&8191),u+=Wf[ge])}else op(t,u,C[r[S]]),u+=w[r[S]];return op(t,u,C[256]),u+w[256]},pp=new Hf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),mp=function(){for(var e=new Hf(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),hp=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function gp(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=mp[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new Bf(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=dp(c,l,e.subarray(u,d)):(c[u]=!0,l=dp(c,l,e.subarray(u,o)))}else{for(var f=pp[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new Vf(32768),_=new Vf(h+1),v=Math.ceil(n/3),ee=2*v,y=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<ee)&h},b=new Hf(25e3),te=new Vf(288),x=new Vf(32),S=0,ne=0,re=(u=0,0),ie=0,ae=0;o>u;++u){var C=y(u),w=32767&u,oe=_[C];if(g[w]=oe,_[C]=w,u>=ie){var se=o-u;if((S>7e3||re>24576)&&se>423){l=fp(e,c,0,b,te,x,ne,re,ae,u-ae,l),re=S=ne=0,ae=u;for(var ce=0;286>ce;++ce)te[ce]=0;for(ce=0;30>ce;++ce)x[ce]=0}var le=2,ue=0,de=m,fe=w-oe&32767;if(se>2&&C==y(u-fe))for(var pe=Math.min(p,se)-1,me=Math.min(32767,u),he=Math.min(258,se);me>=fe&&--de&&w!=oe;){if(e[u+le]==e[u+le-fe]){for(var ge=0;he>ge&&e[u+ge]==e[u+ge-fe];++ge);if(ge>le){if(le=ge,ue=fe,ge>pe)break;var _e=Math.min(fe,ge-2),ve=0;for(ce=0;_e>ce;++ce){var ye=u-fe+ce+32768&32767,be=ye-g[ye]+32768&32767;be>ve&&(ve=be,oe=ye)}}}fe+=(w=oe)-(oe=g[w])+32768&32767}if(ue){b[re++]=268435456|Jf[le]<<18|Yf[ue];var xe=31&Jf[le],Se=31&Yf[ue];ne+=Uf[xe]+Wf[Se],++te[257+xe],++x[Se],ie=u+le,++S}else b[re++]=e[u],++te[e[u]]}}l=fp(e,c,!0,b,te,x,ne,re,ae,u-ae,l)}return ip(s,0,r+rp(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&hp(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),hp(l,u-8,n.d()),hp(l,u-4,r),l}var _p=!!bc||!!yc,vp=`text/plain`,yp=!1,bp=function(e,t,n){n===void 0&&(n=!0);var[r,i]=e.split(`?`),a=V({},t),o=i?.split(`&`).map((e=>{var t,[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],r+`=`+o}))??[],s=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return Y(e,(function(e,t){W(e)||W(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(a);return s&&o.push(s),r+`?`+o.join(`&`)},xp=(e,t)=>JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t),Sp=e=>{if(e.zt)return e.zt;var{data:t,compression:n}=e;if(t){if(n===zf.GZipJS){var r=gp(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new Bf(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new Bf(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return ip(r,0,i)}(xp(t)),{mtime:0});return{contentType:vp,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===zf.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:xp(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(xp(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=xp(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},Cp=function(){var e=Dc((function*(e){var t=yield function(e,t,n){return kc.apply(this,arguments)}(xp(e.data),Tc.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return V({},e,{zt:{contentType:vp,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),wp=(e,t)=>bp(e,{_:new Date().getTime().toString(),ver:Tc.JS_SDK_VERSION,compression:t}),Tp=[];yc&&Tp.push({transport:`fetch`,method(e){var{contentType:t,body:n,estimatedSize:r}=Sp(e)??{},i=new Headers;Y(e.headers,(function(e,t){i.append(t,e)})),t&&i.append(`Content-Type`,t);var a=e.url,o=null;if(xc){var s=new xc;o={signal:s.signal,timeout:setTimeout((()=>s.abort()),e.timeout)}}yc(a,V({method:e?.method||`GET`,headers:i,keepalive:e.method===`POST`&&52428.8>(r||0),body:n,signal:o?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){q.error(e)}e.callback==null||e.callback(r)})))).catch((t=>{q.error(t),e.callback==null||e.callback({statusCode:0,error:t})})).finally((()=>o?clearTimeout(o.timeout):null))}}),bc&&Tp.push({transport:`XHR`,method(e){var t=new bc;t.open(e.method||`GET`,e.url,!0);var{contentType:n,body:r}=Sp(e)??{};Y(e.headers,(function(e,n){t.setRequestHeader(n,e)})),n&&t.setRequestHeader(`Content-Type`,n),e.timeout&&(t.timeout=e.timeout),e.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}e.callback==null||e.callback(n)}},t.send(r)}}),_c!=null&&_c.sendBeacon&&Tp.push({transport:`sendBeacon`,method(e){var t=bp(e.url,{beacon:`1`});try{var{contentType:n,body:r}=Sp(e)??{};if(!r)return;var i=r instanceof Blob?r:new Blob([r],{type:n});_c.sendBeacon(t,i)}catch{}}});var Ep=3e3,Dp=class{constructor(e,t){this.Ti=!0,this.Ai=[],this.Ei=el(t?.flush_interval_ms||Ep,250,5e3,q.createLogger(`flush interval`),Ep),this.Ri=e}enqueue(e){this.Ai.push(e),this.Ni||this.Mi()}unload(){this.Fi();var e=this.Ai.length>0?this.Oi():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Ri(V({},e,{transport:`sendBeacon`}))}))}enable(){this.Ti=!1,this.Mi()}Mi(){var e=this;this.Ti||(this.Ni=setTimeout((()=>{if(this.Fi(),this.Ai.length>0){var t=this.Oi(),n=function(){var n=t[r],i=new Date().getTime();n.data&&U(n.data)&&Y(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.Ri(n)};for(var r in t)n()}}),this.Ei))}Fi(){clearTimeout(this.Ni),this.Ni=void 0}Oi(){var e={};return Y(this.Ai,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;W(e[i])&&(e[i]=V({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Ai=[],e}},Op=[`retriesPerformedSoFar`],kp=class{constructor(e){this.Pi=!1,this.Li=3e3,this.Ai=[],this._instance=e,this.Ai=[],this.Di=!0,!W(R)&&`onLine`in R.navigator&&(this.Di=R.navigator.onLine,this.Bi=()=>{this.Di=!0,this.ji()},this.qi=()=>{this.Di=!1},Md(R,`online`,this.Bi),Md(R,`offline`,this.qi))}get length(){return this.Ai.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=Oc(e,Op);Wc(t)&&(n.url=bp(n.url,{retry_count:t})),this._instance._send_request(V({},n,{callback:e=>{e.statusCode===200||e.statusCode>=400&&500>e.statusCode||(t??0)>=10?n.callback==null||n.callback(e):this.Zi(V({retriesPerformedSoFar:t},n))}}))}Zi(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.Ai.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),q.warn(i),this.Pi||(this.Pi=!0,this.$i())}$i(){if(this.Vi&&clearTimeout(this.Vi),this.Ai.length===0)return this.Pi=!1,void(this.Vi=void 0);this.Vi=setTimeout((()=>{this.Di&&this.Ai.length>0&&this.ji(),this.$i()}),this.Li)}ji(){var e=Date.now(),t=[],n=this.Ai.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Ai=t,n.length>0)for(var{requestOptions:r}of n)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Vi&&=(clearTimeout(this.Vi),void 0),this.Pi=!1,W(R)||(this.Bi&&=(R.removeEventListener(`online`,this.Bi),void 0),this.qi&&=(R.removeEventListener(`offline`,this.qi),void 0)),this.Ai))try{this._instance._send_request(V({},e,{transport:`sendBeacon`}))}catch(e){q.error(e)}this.Ai=[]}},Ap=class{constructor(e){this.Hi=()=>{this.zi||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.zi.lastScrollY=Math.ceil(t),this.zi.maxScrollY=Math.max(t,this.zi.maxScrollY??0),this.zi.maxScrollHeight=Math.max(n,this.zi.maxScrollHeight??0),this.zi.lastContentY=r,this.zi.maxContentY=Math.max(r,this.zi.maxContentY??0),this.zi.maxContentHeight=Math.max(i,this.zi.maxContentHeight??0)},this._instance=e}get Ui(){return this._instance.config.scroll_root_selector}getContext(){return this.zi}resetContext(){var e=this.zi;return setTimeout(this.Hi,0),e}startMeasuringScrollPosition(){Md(R,`scroll`,this.Hi,{capture:!0}),Md(R,`scrollend`,this.Hi,{capture:!0}),Md(R,`resize`,this.Hi)}scrollElement(){if(!this.Ui)return R?.document.documentElement;for(var e of U(this.Ui)?this.Ui:[this.Ui]){var t=R?.document.querySelector(e);if(t)return t}}scrollY(){if(this.Ui){var e=this.scrollElement();return e&&e.scrollTop||0}return R&&(R.scrollY||R.pageYOffset||R.document.documentElement.scrollTop)||0}scrollX(){if(this.Ui){var e=this.scrollElement();return e&&e.scrollLeft||0}return R&&(R.scrollX||R.pageXOffset||R.document.documentElement.scrollLeft)||0}},jp=e=>Sf(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties),Mp=class{constructor(e,t,n,r){this.Yi=e=>{var t=this.Gi();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.Wi(this._instance)};this.Xi.register({[id]:n})}},this._instance=e,this.Ji=t,this.Xi=n,this.Wi=r||jp,this.Ji.onSessionId(this.Yi)}Gi(){return this.Xi.props[id]}getSetOnceProps(){var e=this.Gi()?.props;return e?`r`in e?Cf(e):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return Y(kd(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+Pc(n)]=t})),e}},Np=class{constructor(){this.Ki={}}on(e,t){return this.Ki[e]||(this.Ki[e]=[]),this.Ki[e].push(t),()=>{this.Ki[e]=this.Ki[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.Ki[e]||[])n(t);for(var r of this.Ki[`*`]||[])r(e,t)}},Pp=J(`[SessionId]`),Fp=class{on(e,t){return this.Qi.on(e,t)}constructor(e,t,n){var r;if(this.tr=[],this.er=void 0,this.Qi=new Np,this.ir=(e,t)=>!(!Wc(e)||!Wc(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===hd)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Rt=e.config,this.Xi=e.persistence,this.rr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.sr=t||zd,this.ar=n||zd;var i=this.Rt.persistence_name||this.Rt.token;if(this._sessionTimeoutMs=1e3*el(this.Rt.session_idle_timeout_seconds||1800,60,36e3,Pp.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur=`ph_`+i+`_window_id`,this.hr=`ph_`+i+`_primary_window_exists`,this.cr()){var a=Yd.Wt(this.ur),o=Yd.Wt(this.hr);a&&!o?this.rr=a:Yd.Jt(this.ur),Yd.Xt(this.hr,!0)}if((r=this.Rt.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Rt.bootstrap.sessionID.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})();this.dr(this.Rt.bootstrap.sessionID,new Date().getTime(),s)}catch(e){Pp.error(`Invalid sessionID in bootstrap`,e)}this.vr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return W(this.tr)&&(this.tr=[]),this.tr.push(e),this.nr&&e(this.nr,this.rr),()=>{this.tr=this.tr.filter((t=>t!==e))}}cr(){return this.Rt.persistence!==`memory`&&!this.Xi.fi&&Yd.Ut()}pr(e){e!==this.rr&&(this.rr=e,this.cr()&&Yd.Xt(this.ur,e))}gr(){return this.rr?this.rr:this.cr()?Yd.Wt(this.ur):null}dr(e,t,n){e===this.nr&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.nr=e,this.Xi.register({[Hu]:[t,e,n]}))}mr(){var e=this.Xi.props[Hu];return U(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.dr(null,null,null)}destroy(){clearTimeout(this.yr),this.yr=void 0,this.er&&R&&(R.removeEventListener(bd,this.er,{capture:!1}),this.er=void 0),this.tr=[]}vr(){this.er=()=>{this.cr()&&Yd.Jt(this.hr)},Md(R,bd,this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Rt.cookieless_mode===hd)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),[r,i,a]=this.mr(),o=this.gr(),s=Wc(a)&&Math.abs(n-a)>864e5,c=!1,l=!i,u=!l&&!e&&this.ir(n,r);l||u||s?(i=this.sr(),o=this.ar(),Pp.info(`new session ID generated`,{sessionId:i,windowId:o,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}}),a=n,c=!0):o||(o=this.ar(),c=!0);var d=Wc(r)&&e&&!s?r:n,f=Wc(a)?a:new Date().getTime();return this.pr(o),this.dr(i,d,f),e||this.lr(),c&&this.tr.forEach((e=>e(i,o,c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0))),{sessionId:i,windowId:o,sessionStartTimestamp:f,changeReason:c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0,lastActivityTimestamp:r}}lr(){clearTimeout(this.yr),this.yr=setTimeout((()=>{var[e]=this.mr();if(this.ir(new Date().getTime(),e)){var t=this.nr;this.resetSessionId(),this.Qi.emit(`forcedIdleReset`,{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},Ip=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Mc(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>Mc(e?.brand,t))))return!0}catch{}return!!e.webdriver},Lp=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function Rp(e,t,n){return xp({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var zp={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>Lp(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Lp(t,e))))),icontains:(e,t)=>t.map(Bp).some((t=>e.map(Bp).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Bp).every((t=>e.map(Bp).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},Bp=e=>e.toLowerCase();function Vp(e,t){return!e||Object.entries(e).every((e=>{var[n,r]=e,i=t?.[n];if(W(i)||Hc(i))return!1;var a=[String(i)],o=zp[r.operator];return!!o&&o(r.values,a)}))}var Hp=`custom`,Up=`i.posthog.com`,Wp=/^\/static\//,Gp=class{constructor(e){this.br={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+Up,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.br[this.apiHost]||(this.br[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:Hp),this.br[this.apiHost]}wr(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof t==`string`&&Wp.test(e))return t.trim().replace(/\/$/,``)||void 0}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.uiHost+t;if(e===`flags`)return this.flagsApiHost+t;if(e===`assets`){var n=this.wr(t);if(n)return``+n+t}if(this.region===Hp)return this.apiHost+t;var r=Up+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+r;case`api`:return`https://`+this.region+`.`+r}}},$=J(`[Surveys]`),Kp=`seenSurvey_`,qp=(e,t)=>{var n=`$survey_`+t+`/`+e.id;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_`+t+`/`+e.id+`/`+e.current_iteration),n},Jp=e=>((e,t)=>{var n=``+Kp+t.id;return t.current_iteration&&t.current_iteration>0&&(n=``+Kp+t.id+`_`+t.current_iteration),n})(0,e),Yp=[kf.Popover,kf.Widget,kf.API],Xp={ignoreConditions:!1,ignoreDelay:!1,displayType:Mf.Popover},Zp=J(`[PostHog ExternalIntegrations]`),Qp={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},$p=class{constructor(e){this._instance=e}ni(e,t){var n;(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return Zp.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var n,i,a;!r||(n=B.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[t]||e.ni(Qp[t],(()=>{var n;(n=B.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[t])==null||n.start(e._instance)})),!r&&(i=B.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[t]&&((a=B.__PosthogExtensions__)==null||(a=a.integrations)==null||(a=a[t])==null||a.stop())};for(var[n,r]of Object.entries((i=this._instance.config.integrations)??{})){var i;t(n)}}},em,tm={},nm=0,rm=()=>{},im=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,am=`Surveys module not available`,om=`sanitize_properties is deprecated. Use before_send instead`,sm=`Invalid value for property_denylist config: `,cm=`posthog`,lm=!_p&&Cc?.indexOf(`MSIE`)===-1&&Cc?.indexOf(`Mozilla`)===-1,um=e=>{var t;return V({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,token:``,autocapture:!0,cross_subdomain_cookie:jd(z?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:rm,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:vc&&G(vc?.search)&&vc.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(R==null||(t=R.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){q.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:vd,before_send:void 0,request_queue_config:{flush_interval_ms:Ep},error_tracking:{},_onCapture:rm,__preview_eager_load_replay:!1},(e=>({rageclick:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2025-11-30`?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},dm=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],fm=e=>{var t={};for(var[n,r]of dm)W(e[n])||(t[r]=e[n]);var i=X({},t,e);return U(e.property_blacklist)&&(W(e.property_denylist)?i.property_denylist=e.property_blacklist:U(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:q.error(sm+e.property_denylist)),i},pm=class{constructor(){this.__forceAllowLocalhost=!1}get _r(){return this.__forceAllowLocalhost}set _r(e){q.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},mm=class e{Ir(e,t){if(e){var n=this.Cr.indexOf(e);n!==-1&&this.Cr.splice(n,1)}return this.Cr.push(t),t.initialize==null||t.initialize(),t}Sr(){return this.config.cookieless_mode===hd||this.config.cookieless_mode===md&&this.consent.isRejected()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new pm,this.kr=!1,this.version=Tc.LIB_VERSION,this.Tr=new Np,this.Cr=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=um(),this.SentryIntegration=af,this.sentryIntegration=e=>function(e,t){var n=rf(e,t);return{name:nf,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Ar=!1,this.Er=null,this.Rr=null,this.Nr=null,this.scrollManager=new Ap(this),this.pageViewManager=new of(this),this.rateLimiter=new If(this),this.requestRouter=new Gp(this),this.consent=new Xd(this),this.externalIntegrations=new $p(this);var t=e.__defaultExtensionClasses??{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,n)=>{var r=G(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=G(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>q.info(`send "`+e?.event+`"`,e)))}init(t,n,r){if(r&&r!==cm){var i=tm[r]??new e;return i._init(t,n,r),tm[r]=i,tm[cm][r]=i,i}return this._init(t,n,r)}_init(e,t,n){var r;if(t===void 0&&(t={}),W(e)||Vc(e))return q.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`),this;this.__loaded=!0,this.config={},t.debug=this.Mr(t.debug),this.Fr=t,this.Or=[],t.person_profiles?this.Rr=t.person_profiles:t.process_person&&(this.Rr=t.process_person),this.set_config(X({},um(t.defaults),fm(t),{name:n,token:e})),this.config.on_xhr_error&&q.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:zf.GZipJS;var i=this.Pr();this.persistence=new Df(this.config,i),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Df(V({},this.config,{persistence:`sessionStorage`}),i);var a=V({},this.persistence.props),o=V({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Lr=new Dp((e=>this.Dr(e)),this.config.request_queue_config),this.Br=new kp(this),this.__request_queue=[];var s=this.Sr();if(s||(this.sessionManager=new Fp(this),this.sessionPropsManager=new Mp(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(q.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.jr(s)}),0)):(q.info(`Initializing extensions synchronously`),this.jr(s)),Tc.DEBUG=Tc.DEBUG||this.config.debug,Tc.DEBUG&&q.info(`Starting in debug mode`,{this:this,config:t,thisC:V({},this.config),p:a,s:o}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=V({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),t.bootstrap?.distinctID!==void 0){var c=t.bootstrap.distinctID,l=this.get_distinct_id(),u=this.persistence.get_property(rd);if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===gd)this.identify(c);else if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===_d)q.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var d=this.config.get_device_id(zd()),f=t.bootstrap.isIdentifiedID?d:c;this.persistence.set_property(rd,t.bootstrap.isIdentifiedID?_d:gd),this.register({distinct_id:c,$device_id:f})}}if(s)this.register_once({distinct_id:dd,$device_id:null},``);else if(!this.get_distinct_id()){var p=this.config.get_device_id(zd());this.register_once({distinct_id:p,$device_id:p},``),this.persistence.set_property(rd,gd)}return Md(R,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||zd();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(rd,_d)),t()},i=n.user();`then`in i&&Rc(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{Promise&&Promise.resolve||tf.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(tf.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(tf.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,xd),identify:e=>t(e,Cd),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.qr())):this.qr(),Rc(this.config._onCapture)&&this.config._onCapture!==rm&&(q.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&q.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}jr(t){var n=performance.now(),r=V({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Cr.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Cr.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Cr.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Cr.push(new r.tracingHeaders(this)),r.siteApps&&this.Cr.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Cr.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Cr.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Cr.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Cr.push(this.logs=this.logs??new r.logs(this)),r.conversations&&this.Cr.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Cr.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Cr.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Cr.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Cr.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Cr.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,$d)),r.toolbar&&this.Cr.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Cr.push(this.experiments=this.experiments??new r.experiments(this)),this.Cr.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.Zr){var e=this.Zr;this.Zr=void 0,this.Ci(e)}})),this.$r(i,n)}$r(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.$r(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){q.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&q.info(`PostHog extensions initialized (`+r+`ms)`)}Ci(e){var t;if(!z||!z.body)return q.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Ci(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Zr=e),this.Vr=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=H(e.supportedCompression,zf.GZipJS)?zf.GZipJS:H(e.supportedCompression,zf.Base64)?zf.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Rr?this.Rr:vd}),this.Cr.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}qr(){try{this.config.loaded(this)}catch(e){q.critical("`loaded` function failed",e)}if(this.Hr(),this.config.internal_or_test_user_hostname&&vc!=null&&vc.hostname){var e=vc.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Sr())&&this.zr()}),1),this.Ur=new Rf(this),this.Ur.load()}Hr(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Lr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Td(this.__request_queue,(e=>this.Dr(e))),this.__request_queue=[],this.Hr()}_handle_unload(){var e,t,n,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Yr()&&this.capture(Sd),(t=this.logs)==null||t.flushLogs(`sendBeacon`),(n=this.Lr)==null||n.unload(),(r=this.Br)==null||r.unload()):this.Yr()&&this.capture(Sd,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded&&(lm?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=bp(e.url,{ip:+!!this.config.ip}),e.headers=V({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=V({},e);t.timeout=t.timeout||6e4,t.url=wp(t.url,t.compression);var n=t.transport??`fetch`,r=Tp.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),i=function(e,t){for(var r=0;e.length>r;r++)if(e[r].transport===n)return e[r]}(r)?.method??r[0].method;if(!i)throw Error(`No available transport method`);n!==`sendBeacon`&&t.data&&t.compression===zf.GZipJS&&Sc&&!yp?Cp(t).then((e=>{i(e)})).catch((n=>{if((e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`)(n))return yp=!0,void i(V({},t,{compression:void 0,url:wp(e.url,void 0)}));i(t)})):i(t)})(V({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))))}Dr(e){this.Br?this.Br.retriableRequest(e):this._send_request(e)}_execute_array(e){nm++;try{var t,n=[],r=[],i=[];Td(e,(e=>{e&&(U(t=e[0])?i.push(e):Rc(e)?e.call(this):U(e)&&t===`alias`?n.push(e):U(e)&&t.indexOf(`capture`)!==-1&&Rc(this[t])?i.push(e):r.push(e))}));var a=function(e,t){Td(e,(function(e){if(U(e[0])){var n=t;Y(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}))};a(n,this),a(r,this),a(i,this)}finally{nm--}}push(t){if(nm>0&&U(t)&&G(t[0])){var n=e.prototype[t[0]];Rc(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(e,t,n){var r,i,a,o;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Lr){if(this.is_capturing())if(!W(e)&&G(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){t!=null&&t.$current_url&&!G(t?.$current_url)&&(q.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.Gr||q.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var l=new Date,u=n?.timestamp||l,d=zd(),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===xd&&this.config.__preview_capture_bot_pageviews&&s&&(f.event=`$bot_pageview`,f.properties.$browser_type=`bot`),c&&(f.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),n!=null&&n.$set&&(f.$set=n?.$set);var p,m=this.Wr(n?.$set_once,e!==wd,e===Cd);if(m&&(f.$set_once=m),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>G(e)?e.slice(0,r):e,o=new Set,f=function e(t,n){return t===Object(t)?o.has(t)?void 0:(o.add(t),U(t)?(r=[],Td(t,(t=>{r.push(e(t))}))):(r={},Y(t,((t,n)=>{o.has(t)||(r[n]=e(t,n))}))),r):a?a(t):t;var r}(i)),f.timestamp=u,W(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),e===Af.DISMISSED||e===Af.SENT){var h=t?.[jf.SURVEY_ID],g=t?.[jf.SURVEY_ITERATION];p={id:h,current_iteration:g},localStorage.getItem(Jp(p))||localStorage.setItem(Jp(p),`true`),f.$set=V({},f.$set,{[qp({id:h,current_iteration:g},e===Af.SENT?`responded`:`dismissed`)]:!0})}else e===Af.SHOWN&&(f.$set=V({},f.$set,{[jf.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Nf.SHOWN){var _=t?.[Pf.TOUR_TYPE];_&&(f.$set=V({},f.$set,{[Pf.TOUR_LAST_SEEN_DATE+`/`+_]:new Date().toISOString()}))}var v=V({},f.properties.$set,f.$set);if(Bc(v)||this.setPersonPropertiesForFlags(v),!K(this.config.before_send)){var ee=this.Xr(f);if(!ee)return;f=ee}this.Tr.emit(`eventCaptured`,f);var y={method:`POST`,url:n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),data:f,compression:`best-available`,batchKey:n?._batchKey};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Dr(y):this.Lr.enqueue(y),f}q.critical(`This capture call is ignored due to client rate limiting.`)}}else q.error(`No event name provided to posthog.capture`)}else q.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}calculateEventProperties(e,t,n,r,i){if(n||=new Date,!this.persistence||!this.sessionPersistence)return t;var a=i?void 0:this.persistence.remove_event_timer(e),o=V({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.Sr()&&(o.$cookieless_mode=!0),e===`$snapshot`){var s=V({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=s.distinct_id,(!G(o.distinct_id)&&!Uc(o.distinct_id)||Vc(o.distinct_id))&&q.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),o}var c,l=function(e,t){var n,r,i;if(!Cc)return{};var a,o,s,c,l=e?[...ff,...t||[]]:[],[u,d]=function(e){for(var t=0;Ql.length>t;t++){var[n,r]=Ql[t],i=n.exec(e),a=i&&(Rc(r)?r(i,e):r);if(a)return a}return[``,``]}(Cc);return X(kd({$os:u,$os_version:d,$browser:Yl(Cc,navigator.vendor),$device:$l(Cc),$device_type:(o=Cc,s={userAgentDataPlatform:(n=navigator)==null||(n=n.userAgentData)==null?void 0:n.platform,maxTouchPoints:navigator?.maxTouchPoints,screenWidth:R==null||(r=R.screen)==null?void 0:r.width,screenHeight:R==null||(i=R.screen)==null?void 0:i.height,devicePixelRatio:R?.devicePixelRatio},c=$l(o),c===ul||c===ll||c===`Kobo`||c===`Kindle Fire`||c===Bl?cl:c===kl||c===jl||c===Al||c===Ll?`Console`:c===fl?`Wearable`:c?al:s?.userAgentDataPlatform===`Android`&&(s?.maxTouchPoints??0)>0?600>Math.min(s?.screenWidth??0,s?.screenHeight??0)/(s?.devicePixelRatio??1)?al:cl:`Desktop`),$timezone:wf(),$timezone_offset:Tf()}),{$current_url:lf(vc?.href,l,mf),$host:vc?.host,$pathname:vc?.pathname,$raw_user_agent:Cc.length>1e3?Cc.substring(0,997)+`...`:Cc,$browser_version:Zl(Cc,navigator.vendor),$browser_language:yf(),$browser_language_prefix:(a=yf(),typeof a==`string`?a.split(`-`)[0]:void 0),$screen_height:R?.screen.height,$screen_width:R?.screen.width,$viewport_height:R?.innerHeight,$viewport_width:R?.innerWidth,$lib:Tc.LIB_NAME,$lib_version:Tc.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:u,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime());o.$session_id=u,o.$window_id=d}this.sessionPropsManager&&X(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&X(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.Br?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===Hp&&(o.$lib_custom_api_host=this.config.api_host),c=e!==xd||i?e!==Sd||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=X(o,c),e===xd&&z&&(o.title=z.title),!W(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}Cc&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`),(o=X({},l,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),U(this.config.property_denylist)?Y(this.config.property_denylist,(function(e){delete o[e]})):q.error(sm+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(q.error(om),o=p(o,e));var m=this.Jr();return o.$process_person_profile=m,m&&!i&&this.Kr(`_calculate_event_properties`),o}Wr(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.Jr()||this.kr&&!n)return e;var r=X({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(q.error(om),r=i(r,`$set_once`)),t&&(this.kr=!0),Bc(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}Qr(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.Tr.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:am}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:am})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:am})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=Xp),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:am}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:am})}tn(e){return!e||Vc(e)?(q.critical(`Unique user id has not been set in posthog.identify`),!1):e===dd?(q.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(q.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return q.uninitializedWarning(`posthog.identify`);if(Uc(e)&&(e=e.toString(),q.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.tn(e)&&this.Kr(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(ku)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Au)&&(this.unregister(Au),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(rd)||gd)===gd;e!==r&&a?(this.persistence.set_property(rd,_d),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(Cd,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.Nr=Rp(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister($u))}}setPersonProperties(e,t){if((e||t)&&this.Kr(`posthog.setPersonProperties`)){var n=Rp(this.get_distinct_id(),e,t);this.Nr===n?q.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.Nr=n)}}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:V({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(wd,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else q.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.Kr(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,n,r,i,a,o,s,c;if(q.info(`reset`),!this.__loaded)return q.uninitializedWarning(`posthog.reset`);var l=this.get_property(ku);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),(r=this.surveys)==null||r.reset(),(i=this.Ur)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.conversations)==null||o.reset(),(s=this.persistence)==null||s.set_property(rd,gd),(c=this.sessionManager)==null||c.resetSessionId(),this.Nr=null,this.config.cookieless_mode===hd)this.register_once({distinct_id:dd,$device_id:null},``);else{var u=this.config.get_device_id(zd());this.register_once({distinct_id:u,$device_id:e?u:l},``)}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.en()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.rn()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(Ou)?(q.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.Kr(`posthog.alias`)?(W(t)&&(t=this.get_distinct_id()),e===t?(q.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.Qr(Au,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=V({},this.config);if(zc(e)){var n,r,i,a,o,s,c,l,u;X(this.config,fm(e));var d=this.Pr();(n=this.persistence)==null||n.update_config(this.config,t,d),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Df(V({},this.config,{persistence:`sessionStorage`}),d);var f=this.Mr(this.config.debug);Gc(f)&&(this.config.debug=f),Gc(this.config.debug)&&(this.config.debug?(Tc.DEBUG=!0,Z.Ut()&&Z.Xt(`ph_debug`,!0),q.info(`set_config`,{config:e,oldConfig:t,newConfig:V({},this.config)})):(Tc.DEBUG=!1,Z.Ut()&&Z.Jt(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),(s=this.exceptionObserver)==null||s.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(l=this.surveys)==null||l.loadIfEnabled(),this.nn(),(u=this.externalIntegrations)==null||u.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Tc.LIB_NAME=e,Tc.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(V({},r,t))}}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??e.sn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??cm;return e!==cm&&(e=cm+`.`+e),e}_isIdentified(){return this.persistence?.get_property(rd)===_d||this.sessionPersistence?.get_property(rd)===_d}Jr(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===vd&&!this._isIdentified()&&Bc(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Au])&&((t=this.persistence)==null||(t=t.props)==null||!t[ld]))}Yr(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.Jr()||this.Kr(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Kr(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}Kr(e){return this.config.person_profiles===`never`?(q.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.Qr(ld,!0),!0)}Pr(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==md)}nn(){var e,t,n=this.Pr();return this.persistence?.fi!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.fi!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==hd){if(this.Sr()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Fp(this),this.pageViewManager=new of(this),this.persistence&&(this.sessionPropsManager=new Mp(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.Ir(this.sessionRecording,new o(this)),this.Vr&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.Vr)))}var s;this.consent.optInOut(!0),this.nn(),this.Hr(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==md&&((s=this.surveys)==null||s.loadIfEnabled()),(W(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.zr()}else q.warn(im)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===hd?q.warn(im):(this.config.cookieless_mode===md&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.nn(),this.config.cookieless_mode===md&&(this.register({distinct_id:dd,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.zr()))}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===hd||(this.config.cookieless_mode===md?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.nn()}_is_bot(){return _c?Ip(_c,this.config.custom_blocked_useragents):void 0}zr(){z&&(z.visibilityState===`visible`?this.Ar||(this.Ar=!0,this.capture(xd,{title:z.title},{send_instantly:!0}),this.Er&&=(z.removeEventListener(yd,this.Er),null)):this.Er||(this.Er=this.zr.bind(this),Md(z,yd,this.Er)))}debug(e){!1===e?(R?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(R?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}ki(){var e,t,n,r,i,a,o=this.Fr||{};return`advanced_disable_flags`in o?!!o.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(q.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):(n=`advanced_disable_decide`,r=q,i=(t=`advanced_disable_flags`)in(e=o)&&!K(e[t]),a=n in e&&!K(e[n]),i?e[t]:!!a&&(r&&r.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])):!!this.config.advanced_disable_flags}Xr(e){if(K(this.config.before_send))return e;var t=U(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var r of t){if(n=r(n),K(n)){var i=`Event '`+e.event+`' was rejected in beforeSend function`;return qc(e.event)?q.warn(i+`. This can cause unexpected behavior.`):q.info(i),null}n.properties&&!Bc(n.properties)||q.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}return n}getPageViewId(){return this.pageViewManager.ai?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Mr(e){var t=Gc(e)&&!e,n=Z.Ut()&&Z.Gt(`ph_debug`)===`true`;return!t&&(!!n||e)}};function hm(e){return e instanceof Element&&(e.id===ud||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function gm(e){return!!e&&e.nodeType===1}function _m(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function vm(e){return!!e&&e.nodeType===3}function ym(e){return!!e&&e.nodeType===11}function bm(e){return e?Nc(e).split(/\s+/):[]}function xm(e){var t=R?.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Sm(e){var t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return bm(t)}function Cm(e){return K(e)?null:Nc(e).split(/(\s+)/).filter((e=>Vm(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function wm(e){var t=``;return Nm(e)&&!Pm(e)&&e.childNodes&&e.childNodes.length&&Y(e.childNodes,(function(e){vm(e)&&e.textContent&&(t+=Cm(e.textContent)??``)})),Nc(t)}function Tm(e){return W(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}mm.__defaultExtensionClasses={},mm.sn={trace:em=()=>{},debug:em,info:em,warn:em,error:em,fatal:em},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=Od(e.prototype[t[n]])}(mm,[`identify`]);var Em=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Dm(e,t){if(W(t))return!0;var n,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function Om(e){var t=e.parentNode;return!(!t||!gm(t))&&t}var km=[`next`,`previous`,`prev`,`>`,`<`],Am=[`.ph-no-rageclick`,`.ph-no-capture`],jm=e=>!e||_m(e,`html`)||!gm(e),Mm=(e,t)=>{if(!R||jm(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!_m(i,`body`);)if(ym(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=Om(i);if(!a)break;if(t||Em.indexOf(a.tagName.toLowerCase())>-1)n=!0;else{var o=R.getComputedStyle(a);o&&o.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}r.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:r}};function Nm(e){for(var t=e;t.parentNode&&!_m(t,`body`);t=t.parentNode){var n=Sm(t);if(H(n,`ph-sensitive`)||H(n,`ph-no-capture`))return!1}if(H(Sm(e),`ph-include`))return!0;var r=e.type||``;if(G(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}var i=e.name||e.id||``;return!G(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function Pm(e){return!!(_m(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||_m(e,`select`)||_m(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var Fm=`(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})`,Im=RegExp(`^(?:`+Fm+`)$`),Lm=new RegExp(Fm),Rm=`\\d{3}-?\\d{2}-?\\d{4}`,zm=RegExp(`^(`+Rm+`)$`),Bm=RegExp(`(`+Rm+`)`);function Vm(e,t){return t===void 0&&(t=!0),!(K(e)||G(e)&&(e=Nc(e),(t?Im:Lm).test((e||``).replace(/[- ]/g,``))||(t?zm:Bm).test(e)))}function Hm(e){var t=wm(e);return Vm(t=(t+` `+Um(e)).trim())?t:``}function Um(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&Y(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=wm(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+Um(e)).trim())}catch(e){q.error(`[AutoCapture]`,e)}})),t}function Wm(e){return e.replace(/"|\\"/g,`\\"`)}function Gm(e){var t=e.attr__class;return t?U(t)?t:bm(t):void 0}var Km=class{constructor(e){this.disabled=!1===e;var t=zc(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},qm=`$copy_autocapture`,Jm=J(`[AutoCapture]`);function Ym(e,t){return t.length>e?t.slice(0,e)+`...`:t}function Xm(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!gm(t));return t}function Zm(e,t){for(var n,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:s}=t,c=[e],l=e;l.parentNode&&!_m(l,`body`);)ym(l.parentNode)?(c.push(l.parentNode.host),l=l.parentNode.host):(c.push(l.parentNode),l=l.parentNode);var u,d,f=[],p={},m=!1,h=!1;if(Y(c,(e=>{var t=Nm(e);e.tagName.toLowerCase()===`a`&&(m=e.getAttribute(`href`),m=t&&m&&Vm(m)&&m),H(Sm(e),`ph-no-capture`)&&(h=!0),f.push(function(e,t,n,r){var i=e.tagName.toLowerCase(),a={tag_name:i};Em.indexOf(i)>-1&&!n&&(a.$el_text=i.toLowerCase()===`a`||i.toLowerCase()===`button`?Ym(1024,Hm(e)):Ym(1024,wm(e)));var o=Sm(e);o.length>0&&(a.classes=o.filter((function(e){return e!==``}))),Y(e.attributes,(function(n){var i;if((!Pm(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&Vm(n.value)&&(!G(i=n.name)||i.substring(0,10)!==`_ngcontent`&&i.substring(0,7)!==`_nghost`)){var o=n.value;n.name===`class`&&(o=bm(o).join(` `)),a[`attr__`+n.name]=Ym(1024,o)}}));for(var s=1,c=1,l=e;l=Xm(l);)s++,l.tagName===e.tagName&&c++;return a.nth_child=s,a.nth_of_type=c,a}(e,i,a,o)),X(p,function(e){if(!Nm(e))return{};var t={};return Y(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&Vm(r)&&(t[n]=r)}})),t}(e))})),h)return{props:{},explicitNoCapture:h};if(a||(f[0].$el_text=e.tagName.toLowerCase()===`a`||e.tagName.toLowerCase()===`button`?Hm(e):wm(e)),m){var g;f[0].attr__href=m;var _=sf(m)?.host,v=R==null||(g=R.location)==null?void 0:g.host;_&&v&&_!==v&&(u=m)}return{props:X({$event_type:r.type,$ce_version:1},s?{}:{$elements:f},{$elements_chain:(d=f,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=V({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return Ed(r).sort(((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)})).forEach((e=>{var[t,n]=e;return i[Wm(t.toString())]=Wm(n.toString())})),(t+=`:`)+Ed(i).map((e=>{var[t,n]=e;return t+`="`+n+`"`})).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:Gm(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Ed(e).filter((e=>{var[t]=e;return t.indexOf(`attr__`)===0})).forEach((e=>{var[n,r]=e;return t.attributes[n]=r})),t}))}(d)))},(n=f[0])!=null&&n.$el_text?{$el_text:f[0]?.$el_text}:{},u&&r.type===`click`?{$external_click_url:u}:{},p)}}var Qm=J(`[ExceptionAutocapture]`);function $m(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return Rc(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var eh=J(`[TracingHeaders]`),th=J(`[Web Vitals]`),nh=9e5,rh=`disabled`,ih=`lazy_loading`,ah=`awaiting_config`,oh=`missing_config`;J(`[SessionRecording]`),J(`[SessionRecording]`);var sh=`[SessionRecording]`,ch=J(sh),lh=J(`[Heatmaps]`);function uh(e){return zc(e)&&`clientX`in e&&`clientY`in e&&Uc(e.clientX)&&Uc(e.clientY)}var dh=J(`[Product Tours]`),fh=[`$set_once`,`$set`],ph=J(`[SiteApps]`),mh=`Error while initializing PostHog app with config id `;function hh(e,t,n){if(K(e))return!1;switch(n){case`exact`:return e===t;case`contains`:var r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(r,`i`).test(e);case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var gh=class{constructor(e){this.an=new Np,this.ln=(e,t)=>this.un(e,t)&&this.hn(e,t)&&this.cn(e,t)&&this.dn(e,t),this.un=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.vn=new Set,this.fn=new Set}init(){var e;W(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!W(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.fn)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.vn)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.vn.has(e)||this.vn.has(t?.event))&&this.fn&&this.fn?.size>0&&this.fn.forEach((e=>{this.pn(t,e)&&this.an.emit(`actionCaptured`,e.name)}))}gn(e){this.onAction(`actionCaptured`,(t=>e(t)))}pn(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.ln(e,n))return!0;return!1}onAction(e,t){return this.an.on(e,t)}hn(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!hh(r,t.url,t.url_matching||`contains`))return!1}return!0}cn(e,t){return!!this.mn(e,t)&&!!this.yn(e,t)&&!!this.bn(e,t)}mn(e,t){var n;if(t==null||!t.href)return!0;var r=this.wn(e);if(r.length>0)return r.some((e=>hh(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&hh((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}yn(e,t){var n;if(t==null||!t.text)return!0;var r=this.wn(e);if(r.length>0)return r.some((e=>hh(e.text,t.text,t.text_matching||`exact`)||hh(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!K(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>hh(e,a,o))))}bn(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}wn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}dn(e,t){return t==null||!t.properties||t.properties.length===0||Vp(t.properties.reduce(((e,t)=>{var n=U(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},_h=class{constructor(e){this._instance=e,this._n=new Map,this.In=new Map,this.Cn=new Map}Sn(e,t){return!!e&&Vp(e.propertyFilters,t?.properties)}kn(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}xn(e,t,n){var r=(n===Of.Activation?this._n:this.In).get(e),i=[];return this.Tn((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.Sn(a,t)}))}register(e){W(this._instance?._addCaptureHook)||(this.An(e),this.En(e))}En(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.Rn??(this.Rn=new gh(this._instance),this.Rn.init(),this.Rn.gn((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.Rn)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.Cn.get(t.name);n&&n.push(e.id),this.Cn.set(t.name,n||[e.id])}})))})))}An(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._n=this.kn(e,Of.Activation),this.In=this.kn(e,Of.Cancellation))}onEvent(e,t){var n,r=this.re(),i=this.Nn(),a=this.Mn(),o=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[i])||[];if(a===e&&t&&o.length>0){var s,c;r.info(`event matched, removing item from activated items`,{event:e,eventPayload:t,existingActivatedItems:o});var l=(t==null||(s=t.properties)==null?void 0:s.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(l){var u=o.indexOf(l);0>u||(o.splice(u,1),this.Fn(o))}}else{if(this.In.has(e)){var d=this.xn(e,t,Of.Cancellation);d.length>0&&(r.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:d.map((e=>e.id))}),d.forEach((e=>{var t=o.indexOf(e.id);0>t||o.splice(t,1),this.On(e.id)})),this.Fn(o))}if(this._n.has(e)){r.info(`event name matched`,{event:e,eventPayload:t,items:this._n.get(e)});var f=this.xn(e,t,Of.Activation);this.Fn(o.concat(f.map((e=>e.id))||[]))}}}onAction(e){var t,n=this.Nn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[];this.Cn.has(e)&&this.Fn(r.concat(this.Cn.get(e)||[]))}Fn(e){var t,n=this.re(),r=this.Nn(),i=[...new Set(e)].filter((e=>!this.Pn(e)));n.info(`updating activated items`,{activatedItems:i}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:i})}getActivatedIds(){var e,t=this.Nn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this._n}Ln(){return this.Rn}},vh=class extends _h{constructor(e){super(e)}Nn(){return`$surveys_activated`}Mn(){return Af.SHOWN}Tn(e){var t;(t=this._instance)==null||t.getSurveys(e)}On(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}re(){return $}Pn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},yh=`SDK is not enabled or survey functionality is not yet loaded`,bh=`Disabled. Not loading surveys.`,xh=R!=null&&R.location?uf(R.location.hash,`__posthog`)||uf(location.hash,`state`):null,Sh=`_postHogToolbarParams`,Ch=J(`[Toolbar]`),wh=J(`[FeatureFlags]`),Th=J(`[FeatureFlags]`,{debugEnabled:!0}),Eh=`" failed. Feature flags didn't load in time.`,Dh=`$active_feature_flags`,Oh=`$override_feature_flags`,kh=`$feature_flag_request_id`,Ah=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},jh=e=>{var t={};for(var[n,r]of Ed(e||{}))r&&(t[n]=r);return t},Mh=J(`[Error tracking]`),Nh=`Refusing to render web experiment since the viewer is a likely bot`,Ph={icontains:(e,t)=>!!R&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!R&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!R&&Lp(t.href,e),not_regex:(e,t)=>!!R&&!Lp(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e},Fh=class e{get Rt(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.Dn(`retrieved web experiments from the server`),n.Bn=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.Bn&&(e.Dn(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.Bn)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);G(i)&&t.variants[i]&&n.jn(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.qn(o)&&n.jn(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Dn(Nh);else if(!this.Rt.disable_web_experiments){if(K(this.Bn))return this.Bn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Dn(`applying feature flags`,t),t.forEach((e=>{var t;if(this.Bn&&(t=this.Bn)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.Bn?.get(e);n&&r!=null&&r.variants[n]&&this.jn(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=cf(t?.search,`__experiment_id`),r=cf(t?.search,`__experiment_variant`);n&&r&&(e.Dn(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.Zn(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Rt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Rt.disable_web_experiments&&!n)return e([]);var r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=`+this.Rt.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Zn(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.Dn(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.jn(i[0].name,n,i[0].variants[n].transforms))}static qn(t){return!K(t.conditions)&&e.$n(t)&&e.Vn(t)}static $n(t){if(K(t.conditions)||K(t.conditions?.url))return!0;var n,r=e.getWindowLocation();return!!r&&((n=t.conditions)==null||!n.url||Ph[t.conditions?.urlMatchType??`icontains`](t.conditions.url,r))}static getWindowLocation(){return R?.location}static Vn(e){if(K(e.conditions)||K(e.conditions?.utm))return!0;var t=gf();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static Dn(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];q.info(`[WebExperiments] `+e,n)}jn(t,n,r){this._is_bot()?e.Dn(Nh):n===`control`?e.Dn(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.Dn(`applying transform of variant `+n+` for experiment `+t+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return _c&&this._instance?Ip(_c,this.Rt.custom_blocked_useragents):void 0}},Ih=J(`[Conversations]`),Lh=`Conversations not available yet.`,Rh={trace:{text:`TRACE`,number:1},debug:{text:`DEBUG`,number:5},info:{text:`INFO`,number:9},warn:{text:`WARN`,number:13},error:{text:`ERROR`,number:17},fatal:{text:`FATAL`,number:21}},zh=Rh.info;function Bh(e){if(Gc(e))return{boolValue:e};if(Uc(e))return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(typeof e==`string`)return{stringValue:e};if(U(e))return{arrayValue:{values:e.map((e=>Bh(e)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function Vh(e){var t=[];for(var n in e){var r=e[n];Hc(r)||W(r)||t.push({key:n,value:Bh(r)})}return t}var Hh={featureFlags:class{constructor(e){this.Hn=!1,this.zn=!1,this.Un=!1,this.Yn=!1,this.Gn=!1,this.Wn=!1,this.Xn=!1,this.Jn=!1,this._instance=e,this.featureFlagEventHandlers=[]}get Rt(){return this._instance.config}get Xi(){return this._instance.persistence}Kn(e){return this._instance.get_property(e)}Qn(){var e;return(e=this.Xi?.pi(this.Rt.feature_flag_cache_ttl_ms))!=null&&e}ts(){return!!this.Qn()&&(this.Jn||this.Un||(this.Jn=!0,wh.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}es(){var e=this.Rt.evaluation_contexts??this.Rt.evaluation_environments;return!this.Rt.evaluation_environments||this.Rt.evaluation_contexts||this.Xn||(wh.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.Xn=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||wh.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}rs(){return this.es().length>0}initialize(){var{config:e}=this._instance,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(n[t]&&(e[t]=n[t]),e)),{});this.receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r=n!=null&&n.merge?this.getFlagVariants():{},i=n!=null&&n.merge?this.getFlagPayloads():{},a=V({},r,e),o=V({},i,t),s={};for(var[c,l]of Object.entries(a)){var u=typeof l==`string`;s[c]={key:c,enabled:!!u||!!l,variant:u?l:void 0,reason:void 0,metadata:W(o?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:o[c]}}}this.receivedFeatureFlags({flags:s})}get hasLoadedFlags(){return this.zn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Kn(Ku),t=this.Kn(Oh),n=this.Kn(Ju);if(!n&&!t)return e||{};var r=X({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=W(c)?(a=s?.enabled)!=null&&a:!!c,u=W(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=V({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=V({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.Hn||=(wh.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getFlagVariants(){var e=this.Kn(Wu),t=this.Kn(Oh);if(!t)return e||{};for(var n=X({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Hn||=(wh.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.Kn(qu),t=this.Kn(Ju);if(!t)return e||{};for(var n=X({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Hn||=(wh.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.Yn||this.Rt.advanced_disable_feature_flags||this.ns||(this._instance.Tr.emit(`featureFlagsReloading`,!0),this.ns=setTimeout((()=>{this.ss()}),5))}os(){clearTimeout(this.ns),this.ns=void 0}ensureFlagsLoaded(){this.zn||this.Un||this.ns||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Yn=e}ss(e){if(this.os(),!this._instance.ki())if(this.Un)this.Gn=!0;else{var t=this.Rt.token,n=this.Kn(ku),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:V({},this.Xi?.get_initial_props()||{},this.Kn(Yu)||{}),group_properties:this.Kn(Xu),timezone:wf()};Hc(n)||W(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Rt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.rs()&&(r.evaluation_contexts=this.es());var i=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Rt.advanced_only_evaluate_survey_feature_flags?`&only_evaluate_survey_feature_flags=true`:``));this.Un=!0,this._instance._send_request({method:`POST`,url:i,data:r,compression:this.Rt.disable_compression?void 0:zf.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,a=!0;if(e.statusCode===200&&(this.Gn||(this.$anon_distinct_id=void 0),a=!1),this.Un=!1,!r.disable_flags||this.Gn){this.Wn=!a;var o=[];e.error?e.error instanceof Error?o.push(e.error.name===`AbortError`?`timeout`:`connection_error`):o.push(`unknown_error`):e.statusCode!==200&&o.push(`api_error_`+e.statusCode),(t=e.json)!=null&&t.errorsWhileComputingFlags&&o.push(`errors_while_computing_flags`);var s=!((n=e.json)==null||(n=n.quotaLimited)==null||!n.includes(`feature_flags`));s&&o.push(`quota_limited`),(i=this.Xi)==null||i.register({[td]:o}),s?wh.warn(`You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.`):(r.disable_flags||this.receivedFeatureFlags(e.json??{},a,{partialResponse:!!this.Rt.advanced_only_evaluate_survey_feature_flags}),this.Gn&&(this.Gn=!1,this.ss()))}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.Wn)if(this.zn||this.getFlags()&&this.getFlags().length>0){if(!this.ts()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else wh.warn(`getFeatureFlag for key "`+e+Eh)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.Wn)if(this.zn||this.getFlags()&&this.getFlags().length>0){if(!this.ts()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Kn(kh)||void 0,c=this.Kn(nd)||void 0,l=this.Kn($u)||{};if(this.Rt.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.Kn(ed);d&&d!==f&&(l={},(u=this.Xi)==null||u.register({[$u]:l,[ed]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,ee,y;U(l[e])?l[e].push(o):l[e]=[o],(p=this.Xi)==null||p.register({[$u]:l});var b=this.getFeatureFlagDetails(e),te=[...this.Kn(td)??[]];W(i)&&te.push(`flag_missing`);var x={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((m=this.Rt.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Rt.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.Wn};W(b==null||(g=b.metadata)==null?void 0:g.version)||(x.$feature_flag_version=b.metadata.version);var S,ne=(b==null||(_=b.reason)==null?void 0:_.description)??(b==null||(v=b.reason)==null?void 0:v.code);ne&&(x.$feature_flag_reason=ne),b!=null&&(ee=b.metadata)!=null&&ee.id&&(x.$feature_flag_id=b.metadata.id),W(b?.original_variant)&&W(b?.original_enabled)||(x.$feature_flag_original_response=W(b.original_variant)?b.original_enabled:b.original_variant),b!=null&&(y=b.metadata)!=null&&y.original_payload&&(x.$feature_flag_original_payload=b==null||(S=b.metadata)==null?void 0:S.original_payload),te.length&&(x.$feature_flag_error=te.join(`,`)),this._instance.capture(`$feature_flag_called`,x)}if(r){var re=a;if(!W(a))try{re=JSON.parse(a)}catch{}return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:re}}}}else wh.warn(`getFeatureFlagResult for key "`+e+Eh)}getRemoteConfigPayload(e,t){var n=this.Rt.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.rs()&&(r.evaluation_contexts=this.es()),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Rt.disable_compression?void 0:zf.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback(n){var r=n.json?.featureFlagPayloads;t(r?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.Wn){if(this.zn||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return W(n)?void 0:!!n}wh.warn(`isFeatureEnabled for key "`+e+Eh)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.Xi){this.zn=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),a=this.getFlagsWithDetails();(function(e,t,n,r,i,a){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var o=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>[e,t[e].variant??t[e].enabled]))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>t[e].metadata?.payload)).map((e=>[e,t[e].metadata?.payload])))):wh.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(U(c)){wh.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;t&&t.register({[Dh]:c,[Wu]:f})}else{var m=c,h=l,g=s;if(a!=null&&a.partialResponse)m=V({},n,m),h=V({},r,h),g=V({},i,g);else if(e.errorsWhileComputingFlags)if(s){var _=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=V({},n,Object.fromEntries(Object.entries(m).filter((e=>{var[t]=e;return _.has(t)})))),h=V({},r,Object.fromEntries(Object.entries(h||{}).filter((e=>{var[t]=e;return _.has(t)})))),g=V({},i,Object.fromEntries(Object.entries(g||{}).filter((e=>{var[t]=e;return _.has(t)}))))}else m=V({},n,m),h=V({},r,h),g=V({},i,g);t&&t.register(V({[Dh]:Object.keys(jh(m)),[Wu]:m||{},[qu]:h||{},[Ku]:g||{}},u?{[kh]:u}:{},d?{[nd]:d}:{}))}}})(e,this.Xi,r,i,a,n),t||(this.Jn=!1),this.ls(t)}}override(e,t){t===void 0&&(t=!1),wh.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.Xi)return wh.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.Xi.unregister(Oh),this.Xi.unregister(Ju),this.ls(),Th.info(`All overrides cleared`);if(U(e)){var t=Ah(e);return this.Xi.register({[Oh]:t}),this.ls(),Th.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Hn=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.Xi.unregister(Oh),Th.info(`Flag overrides cleared`);else if(r.flags){if(U(r.flags)){var i=Ah(r.flags);this.Xi.register({[Oh]:i})}else this.Xi.register({[Oh]:r.flags});Th.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.Xi.unregister(Ju),Th.info(`Payload overrides cleared`)):r.payloads&&(this.Xi.register({[Ju]:r.payloads}),Th.info(`Payload overrides set`,{payloads:r.payloads}))),this.ls();return}if(e&&typeof e==`object`)return this.Xi.register({[Oh]:e}),this.ls(),Th.info(`Flag overrides set`,{flags:e});wh.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.zn){var{flags:t,flagVariants:n}=this.us();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.Kn(Gu)||[]).find((t=>t.flagKey===e)),a={[`$feature_enrollment/`+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture(`$feature_enrollment_update`,o),this.setPersonPropertiesForFlags(a,!1);var s=V({},this.getFlagVariants(),{[e]:t});(r=this.Xi)==null||r.register({[Dh]:Object.keys(jh(s)),[Wu]:s}),this.ls()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Kn(Gu),i=n?`&`+n.map((e=>`stage=`+e)).join(`&`):``;if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/early_access_features/?token=`+this.Rt.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.Xi)==null||n.unregister(Gu),(r=this.Xi)==null||r.register({[Gu]:i}),e(i)}}})}us(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}ls(e){var{flags:t,flagVariants:n}=this.us();this.featureFlagEventHandlers.forEach((r=>r(t,n,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Kn(Yu)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this._instance.register({[Yu]:V({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Yu)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Kn(Xu)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=V({},n[t],e[t]),delete e[t]})),this._instance.register({[Xu]:V({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Kn(Xu)||{};this._instance.register({[Xu]:V({},t,{[e]:{}})})}else this._instance.unregister(Xu)}reset(){this.zn=!1,this.Un=!1,this.Yn=!1,this.Gn=!1,this.Wn=!1,this.$anon_distinct_id=void 0,this.os(),this.Hn=!1}}},Uh={sessionRecording:class{get Rt(){return this._instance.config}get Xi(){return this._instance.persistence}get started(){var e;return!((e=this.hs)==null||!e.isStarted)}get status(){return this.cs===ah||this.cs===oh?this.cs:this.hs?.status??this.cs}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.cs=rh,this.ds=void 0,this._instance=e,!this._instance.sessionManager)throw ch.error(`started without valid sessionManager`),Error(sh+` started without valid sessionManager. This is a bug.`);if(this.Rt.cookieless_mode===hd)throw Error(sh+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get vs(){var e,t=!((e=this._instance.get_property(Vu))==null||!e.enabled),n=!this.Rt.disable_session_recording,r=this.Rt.disable_session_recording||this._instance.consent.isOptedOut();return R&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this.vs||(t=this.hs)==null||!t.isStarted){var n=!W(Object.assign)&&!W(Array.from);this.vs&&n?(this.fs(e),ch.info(`starting`)):(this.cs=rh,this.stopRecording())}}fs(e){var t,n,r;this.vs&&(this.cs!==ah&&this.cs!==oh&&(this.cs=ih),B!=null&&(t=B.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=B.__PosthogExtensions__)!=null&&n.initSessionRecording?this.ps(e):(r=B.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.gs,(t=>{if(t)return ch.error(`could not load recorder`,t);this.ps(e)})))}stopRecording(){var e,t;(e=this.ds)==null||e.call(this),this.ds=void 0,(t=this.hs)==null||t.stop()}ys(){var e,t;(e=this.ds)==null||e.call(this),this.ds=void 0,(t=this.hs)==null||t.discard()}bs(){var e;(e=this.Xi)==null||e.unregister(Uu)}ws(e,t){if(K(e))return null;var n,r=Uc(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(ch.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}_s(e){if(this.Xi){var t,n=this.Xi,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.ws(this.Rt.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.ws(t?.sampleRate,`remote config sampleRate`),a=r??i;K(a)&&this.bs();var o=t?.minimumDurationMilliseconds;n.register({[Vu]:V({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:V({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:W(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.ds)==null||t.call(this),this.ds=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this._s(e),this.ys()):(this._s(e),this.startIfEnabledOrStop()):(this.cs===ah&&(this.cs=oh,ch.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.hs)!=null&&n.log?this.hs.log(e,t):ch.warn(`log called before recorder was ready`)}get gs(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Vu);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}Is(){var e=this._instance.get_property(Vu);if(!e)return!1;var t=(typeof e==`object`?e:JSON.parse(e)).cache_timestamp??Date.now();return 36e5>=Date.now()-t}ps(e){var t;if((t=B.__PosthogExtensions__)==null||!t.initSessionRecording)return ch.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.hs||(this.hs=B.__PosthogExtensions__?.initSessionRecording(this._instance),this.hs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Is()){if(this.cs===oh||this.cs===ah)return;this.cs=ah,ch.info(`persisted remote config is stale, requesting fresh config before starting`),new Rf(this._instance).load();return}this.cs=ih,this.hs.start(e)}onRRwebEmit(e){var t;(t=this.hs)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.hs||(t=this.Xi)==null||t.register({$replay_override_linked_flag:!0}),(e=this.hs)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.hs||(t=this.Xi)==null||t.register({$replay_override_sampling:!0}),(e=this.hs)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.hs||(n=this.Xi)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this.hs)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.hs?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.hs)==null||!n.tryAddCustomEvent(e,t))}}},Wh={autocapture:class{constructor(e){this.Cs=!1,this.Ss=null,this.ks=!1,this.instance=e,this.rageclicks=new Km(e.config.rageclick),this.xs=null}initialize(){this.startIfEnabled()}get Rt(){var e=zc(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}Ts(){if(this.isBrowserSupported()){if(R&&z){var e=e=>{e||=R?.event;try{this.As(e)}catch(e){Jm.error(`Failed to capture event`,e)}};if(Md(z,`submit`,e,{capture:!0}),Md(z,`change`,e,{capture:!0}),Md(z,`click`,e,{capture:!0}),this.Rt.capture_copied_text){var t=e=>{this.As(e||=R?.event,qm)};Md(z,`copy`,t,{capture:!0}),Md(z,`cut`,t,{capture:!0})}}}else Jm.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.Cs&&(this.Ts(),this.Cs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.ks=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Mu]:!!e.autocapture_opt_out}),this.Ss=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.xs=e}getElementSelectors(e){var t,n=[];return(t=this.xs)==null||t.forEach((t=>{(z?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[Mu];if(Hc(this.Ss)&&!Gc(e)&&!this.instance.ki())return!1;var t=this.Ss??!!e;return!!this.instance.config.autocapture&&!t}As(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=Tm(e);vm(r)&&(r=r.parentNode||null),t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&function(e,t){if(!R||jm(e))return!1;var n,r;if(Gc(t)?(n=!!t&&Am,r=void 0):(n=t?.css_selector_ignorelist??Am,r=t?.content_ignorelist),!1===n)return!1;var{targetElementList:i}=Mm(e,!1);return!function(e,t){if(!1===e||W(e))return!1;var n;if(!0===e)n=km;else{if(!U(e))return!1;if(e.length>10)return q.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:r}=e;return n.some((e=>t.includes(e)||r.includes(e)))}))}(r,i.map((e=>({safeText:wm(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!Dm(i,n)}(r,this.instance.config.rageclick)&&this.As(e,`$rageclick`);var i=t===qm;if(r&&function(e,t,n,r,i){var a,o,s;if(n===void 0&&(n=void 0),!R||jm(e)||(a=n)!=null&&a.url_allowlist&&!xm(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&xm(n.url_ignorelist))return!1;if((s=n)!=null&&s.dom_event_allowlist){var c=n.dom_event_allowlist;if(c&&!c.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:l,targetElementList:u}=Mm(e,r);if(!function(e,t){var n=t?.element_allowlist;if(W(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(u,n)||!Dm(u,n?.css_selector_allowlist))return!1;var d=R.getComputedStyle(e);if(d&&d.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0;var f=e.tagName.toLowerCase();switch(f){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return l?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&(Em.indexOf(f)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.Rt,i,i?[`copy`,`cut`]:void 0)){var{props:a,explicitNoCapture:o}=Zm(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Rt.element_attribute_ignorelist,elementsChainAsString:this.ks});if(o)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(a.$element_selectors=s),t===qm){var c,l=Cm(R==null||(c=R.getSelection())==null?void 0:c.toString()),u=e.type||`clipboard`;if(!l)return!1;a.$selected_content=l,a.$copy_type=u}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return Rc(z?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.Es=(R==null||(t=R.location)==null?void 0:t.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(q.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.Rs&&this.Rs(),this.Rs=void 0,q.info(`History API monitoring stopped`)}monitorHistoryChanges(){var e,t;if(R&&R.history){var n=this;(e=R.history.pushState)!=null&&e.__posthog_wrapped__||$m(R.history,`pushState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Ns(`pushState`)})),(t=R.history.replaceState)!=null&&t.__posthog_wrapped__||$m(R.history,`replaceState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Ns(`replaceState`)})),this.Ms()}}Ns(e){try{var t,n=R==null||(t=R.location)==null?void 0:t.pathname;if(!n)return;n!==this.Es&&this.isEnabled&&this._instance.capture(xd,{navigation_type:e}),this.Es=n}catch(t){q.error(`Error capturing `+e+` pageview`,t)}}Ms(){if(!this.Rs){var e=()=>{this.Ns(`popstate`)};Md(R,`popstate`,e),this.Rs=()=>{R&&R.removeEventListener(`popstate`,e)}}}},heatmaps:class{get Rt(){return this.instance.config}constructor(e){var t;this.Fs=!1,this.Cs=!1,this.Os=null,this.instance=e,this.Fs=!((t=this.instance.persistence)==null||!t.props[Nu]),this.rageclicks=new Km(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return zc(this.Rt.capture_heatmaps)&&this.Rt.capture_heatmaps.flush_interval_milliseconds&&(e=this.Rt.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return K(this.Rt.capture_heatmaps)?K(this.Rt.enable_heatmaps)?this.Fs:this.Rt.enable_heatmaps:!1!==this.Rt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Cs)return;lh.info(`starting...`),this.Ps(),this.Tt()}else clearInterval(this.Os??void 0),this.Ls(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Nu]:t}),this.Fs=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.T;return this.T=void 0,e}Ds(e){this.wt(e.originalEvent,`deadclick`)}Tt(){this.Os&&clearInterval(this.Os),this.Os=z?.visibilityState===`visible`?setInterval(this.ji.bind(this),this.flushIntervalMilliseconds):null}Ps(){R&&z&&(this.Bs=this.ji.bind(this),Md(R,bd,this.Bs),this.js=e=>this.wt(e||R?.event),Md(z,`click`,this.js,{capture:!0}),this.qs=e=>this.Zs(e||R?.event),Md(z,`mousemove`,this.qs,{capture:!0}),this.$s=new ef(this.instance,Qd,this.Ds.bind(this)),this.$s.startIfEnabledOrStop(),this.Vs=this.Tt.bind(this),Md(z,yd,this.Vs),this.Cs=!0)}Ls(){var e;R&&z&&(this.Bs&&R.removeEventListener(bd,this.Bs),this.js&&z.removeEventListener(`click`,this.js,{capture:!0}),this.qs&&z.removeEventListener(`mousemove`,this.qs,{capture:!0}),this.Vs&&z.removeEventListener(yd,this.Vs),clearTimeout(this.Hs),(e=this.$s)==null||e.stop(),this.Cs=!1)}zs(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){for(var r=e;r&&gm(r)&&!_m(r,`body`);){if(r===n)return!1;if(H(t,R?.getComputedStyle(r).position))return!0;r=Om(r)}return!1}(Tm(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}wt(e,t){var n;if(t===void 0&&(t=`click`),!hm(e.target)&&uh(e)){var r=this.zs(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Us(V({},r,{type:`rageclick`})),this.Us(r)}}Zs(e){!hm(e.target)&&uh(e)&&(clearTimeout(this.Hs),this.Hs=setTimeout((()=>{this.Us(this.zs(e,`mousemove`))}),500))}Us(e){if(R){var t=R.location.href,n=this.Rt.custom_personal_data_properties,r=lf(t,this.Rt.mask_personal_data_properties?[...ff,...n||[]]:[],mf);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(e)}}ji(){this.T&&!Bc(this.T)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ef,webVitalsAutocapture:class{constructor(e){var t;this.Fs=!1,this.Cs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Ys=()=>{clearTimeout(this.Gs),this.T.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.T.metrics.reduce(((e,t)=>V({},e,{[`$web_vitals_`+t.name+`_event`]:V({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.nt=e=>{var t=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0);if(W(t))th.error(`Could not read session ID. Dropping metrics!`);else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Ws();W(n)||(K(e?.name)||K(e?.value)?th.error(`Invalid metric received`,e):!this.Xs||this.Xs>e.value?(this.T.url!==n&&(this.Ys(),this.Gs=setTimeout(this.Ys,this.flushToCaptureTimeoutMs)),W(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=W(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.T.metrics.push(V({},e,{$current_url:n,$session_id:t.sessionId,$window_id:t.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.Ys()):th.error(`Ignoring metric with value >= `+this.Xs,e))}},this.Js=()=>{if(!this.Cs){var e,t,n,r,i=B.__PosthogExtensions__;W(i)||W(i.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:n,onINP:r}=i.postHogWebVitalsCallbacks),e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.nt.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.nt.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.nt.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.nt.bind(this)),this.Cs=!0):th.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.Fs=!((t=this._instance.persistence)==null||!t.props[Lu]),this.startIfEnabled()}get Ks(){return this._instance.config.capture_performance}get allowedMetrics(){var e=zc(this.Ks)?this.Ks?.web_vitals_allowed_metrics:void 0;return K(e)?this._instance.persistence?.props[Bu]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(zc(this.Ks)?this.Ks.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=zc(this.Ks)?this.Ks.web_vitals_attribution:void 0;return e!=null&&e}get Xs(){var e=zc(this.Ks)&&Uc(this.Ks.__web_vitals_max_value)?this.Ks.__web_vitals_max_value:nh;return e>0&&6e4>=e?nh:e}get isEnabled(){var e=vc?.protocol;if(e!==`http:`&&e!==`https:`)return th.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=zc(this.Ks)?this.Ks.web_vitals:Gc(this.Ks)?this.Ks:void 0;return Gc(t)?t:this.Fs}startIfEnabled(){this.isEnabled&&!this.Cs&&(th.info(`enabled, starting...`),this.ni(this.Js))}onRemoteConfig(e){if(`capturePerformance`in e){var t=zc(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=zc(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Lu]:t}),this._instance.persistence.register({[Bu]:n})),this.Fs=t,this.startIfEnabled()}}ni(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?th.error(`failed to load script`,t):e()}))}Ws(){var e=R?R.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return lf(e,this._instance.config.mask_personal_data_properties?[...ff,...t||[]]:[],mf)}th.error(`Could not determine current URL`)}}},Gh={exceptionObserver:class{constructor(e){var t;this.Js=()=>{var e;if(R&&this.isEnabled&&(e=B.__PosthogExtensions__)!=null&&e.errorWrappingFunctions){var t=B.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=B.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=B.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Qs&&this.Rt.capture_unhandled_errors&&(this.Qs=t(this.captureException.bind(this))),!this.eo&&this.Rt.capture_unhandled_rejections&&(this.eo=n(this.captureException.bind(this))),!this.io&&this.Rt.capture_console_errors&&(this.io=r(this.captureException.bind(this)))}catch(e){Qm.error(`failed to start`,e),this.ro()}}},this._instance=e,this.no=!((t=this._instance.persistence)==null||!t.props[Pu]),this.so=new tl({refillRate:this._instance.config.error_tracking.__exceptionRateLimiterRefillRate??1,bucketSize:this._instance.config.error_tracking.__exceptionRateLimiterBucketSize??10,refillInterval:1e4,qt:Qm}),this.Rt=this.oo(),this.startIfEnabledOrStop()}oo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return zc(e)?t=V({},t,e):(W(e)?this.no:e)&&(t=V({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Rt.capture_console_errors||this.Rt.capture_unhandled_errors||this.Rt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Qm.info(`enabled`),this.ro(),this.ni(this.Js)):this.ro()}ni(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return Qm.error(`failed to load script`,t);e()}))}ro(){var e,t,n;(e=this.Qs)==null||e.call(this),this.Qs=void 0,(t=this.eo)==null||t.call(this),this.eo=void 0,(n=this.io)==null||n.call(this),this.io=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.no=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pu]:this.no}),this.Rt=this.oo(),this.startIfEnabledOrStop())}onConfigChange(){this.Rt=this.oo()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.so.consumeRateLimit(r)?Qm.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.ao=[],this.lo=new nu([new mu,new wu,new gu,new hu,new Su,new xu,new vu,new Cu],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(`
|
|
5
|
-
`),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=pu.test(s)?s.replace(pu,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return V({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||ru});var n}))}(i)}}(`web:javascript`,lu,fu)),this._instance=e,this.ao=this._instance.persistence?.get_property(Fu)??[]}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.ao=t,this._instance.persistence&&this._instance.persistence.register({[Fu]:this.ao,[Iu]:n})}}get uo(){var e,t=!!this._instance.get_property(Iu);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.lo.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ho(t)){if(this.co(t))return void Mh.info(`Skipping exception capture because a suppression rule matched`);if(!this.uo&&this.do(t))return void Mh.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.vo(t))return void Mh.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}return this._instance.capture(`$exception`,e,{_noTruncate:!0,_batchKey:`exceptionEvent`,Gr:!0})}co(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var{type:n,value:r}=t;return G(n)&&n.length>0&&e.$exception_types.push(n),G(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.ao.some((e=>{var n=e.values.map((e=>{var n=zp[e.operator],r=U(e.value)?e.value:[e.value],i=t[e.key]??[];return r.length>0&&n(r,i)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}do(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}vo(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}ho(e){return!K(e)&&U(e)}}},Kh=V({productTours:class{get Xi(){return this._instance.persistence}constructor(e){this.fo=null,this.po=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.Xi&&this.Xi.register({[zu]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.fo||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(zu)||this.ni((()=>this.mo()))}ni(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?dh.error(`Could not load product tours script`,t):e()}))}mo(){var e;!this.fo&&(e=B.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.fo=B.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!U(this.po)||t){var n=this.Xi;if(n){var r=n.props[Qu];if(U(r)&&!t)return this.po=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,callback:t=>{var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;dh.error(i),e([],{isLoaded:!1,error:i});return}var a=U(t.json.product_tours)?t.json.product_tours:[];this.po=a,n&&n.register({[Qu]:a}),e(a,{isLoaded:!0})}})}else e(this.po,{isLoaded:!0})}getActiveProductTours(e){K(this.fo)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.fo.getActiveProductTours(e)}showProductTour(e){var t;(t=this.fo)==null||t.showTourById(e)}previewTour(e){this.fo?this.fo.previewTour(e):this.ni((()=>{var t;this.mo(),(t=this.fo)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.fo)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.fo)==null||e.nextStep()}previousStep(){var e;(e=this.fo)==null||e.previousStep()}clearCache(){var e;this.po=null,(e=this.Xi)==null||e.unregister(Qu)}resetTour(e){var t;(t=this.fo)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.fo)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.fo)==null||t.cancelPendingTour(e)}}},Hh),qh={siteApps:class{constructor(e){this._instance=e,this.yo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}bo(e,t){if(t){var n=this.globalsForEvent(t);this.yo.push(n),this.yo.length>1e3&&(this.yo=this.yo.slice(10))}}get siteAppLoaders(){var e;return(e=B._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.bo.bind(this));this.wo=()=>{e(),this.yo=[],this.wo=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var[i,a]of Object.entries(r))t[i]={id:n[i],type:i,properties:a};var{$set_once:o,$set:s}=e;return{event:V({},Oc(e,fh),{properties:V({},e.properties,s?{$set:V({},e.properties?.$set??{},s)}:{},o?{$set_once:V({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.yo.length&&(ph.info(`Processing `+this.yo.length+` events for site app with id `+e.id),this.yo.forEach((e=>t.processEvent==null?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.wo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,ph.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback(e){i(e)}});a&&(t.processEvent=a),r=!0}catch(t){ph.error(mh+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){ph.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}_o(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}Io(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(t){ph.error(`Error while processing event `+e.event+` for site app `+n.id,t)}}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this._o(),void this._instance.on(`eventCaptured`,(e=>this.Io(e)))):void ph.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.wo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(e){var t;B[`__$$ph_site_app_`+e]=i._instance,(t=B.__PosthogExtensions__)==null||t.loadSiteApp==null||t.loadSiteApp(i._instance,s,(t=>{if(t)return ph.error(mh+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else ph.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},Jh={tracingHeaders:class{constructor(e){this.Co=void 0,this.So=void 0,this.Js=()=>{var e,t;W(this.Co)&&((e=B.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),W(this.So)&&((t=B.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}ni(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return eh.error(`failed to load script`,t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.ni(this.Js):((e=this.Co)==null||e.call(this),(t=this.So)==null||t.call(this),this.Co=void 0,this.So=void 0)}}},Yh=V({surveys:class{get Rt(){return this._instance.config}constructor(e){this.ko=void 0,this._surveyManager=null,this.xo=!1,this.To=[],this.Ao=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Rt.disable_surveys){var t=e.surveys;if(K(t))return $.warn(`Flags not loaded yet. Not loading surveys.`);var n=U(t);this.ko=n?t.length>0:t,$.info(`flags response received, isSurveysEnabled: `+this.ko),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(Kp)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.xo)$.info(`Already initializing surveys, skipping...`);else if(this.Rt.disable_surveys)$.info(bh);else if(this.Rt.cookieless_mode&&this._instance.consent.isOptedOut())$.info(`Not loading surveys in cookieless mode without consent.`);else{var e=B?.__PosthogExtensions__;if(e){if(!W(this.ko)||this.Rt.advanced_enable_surveys){var t=this.ko||this.Rt.advanced_enable_surveys;this.xo=!0;try{var n=e.generateSurveys;if(n)return void this.Eo(n,t);var r=e.loadExternalDependency;if(!r)return void this.Ro(pd);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Ro(`Could not load surveys script`,n):this.Eo(e.generateSurveys,t)}))}catch(e){throw this.Ro(`Error initializing surveys`,e),e}finally{this.xo=!1}}}else $.error(`PostHog Extensions not found.`)}}Eo(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new vh(this._instance),$.info(`Surveys loaded successfully`),this.No({isLoaded:!0})}Ro(e,t){$.error(e,t),this.No({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.To.push(e),this._surveyManager&&this.No({isLoaded:!0}),()=>{this.To=this.To.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Rt.disable_surveys)return $.info(bh),e([]);var n,r=this._instance.get_property(Zu);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Ao?this.Ao.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Ao=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Rt.token),method:`GET`,timeout:this.Rt.surveys_request_timeout_ms,callback:t=>{var r;this.Ao=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;$.error(a);var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[Zu]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}No(e){for(var t of this.To)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){$.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!K(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);$.warn(`init was not called`)}Mo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}Fo(e){if(K(this._surveyManager))return{eligible:!1,reason:yh};var t=typeof e==`string`?this.Mo(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(K(this._surveyManager))return $.warn(`init was not called`),{visible:!1,disabledReason:yh};var t=this.Fo(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return K(this._surveyManager)?($.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:yh})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Fo(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(K(this._surveyManager))$.warn(`init was not called`);else{var i=typeof e==`string`?this.Mo(e):e;if(i!=null&&i.id)if(Yp.includes(i.type)){var a=z?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?($.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;$.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),$.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);$.warn(`Survey element not found`)}else $.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else $.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(K(this._surveyManager))$.warn(`init was not called`);else{var r=this.Mo(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=V({},r,{appearance:V({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Mf.Popover&&t.initialResponses&&$.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.canRenderSurvey(r);if(!a.visible)return void $.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===Mf.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else $.warn(`Survey not found`)}}cancelPendingSurvey(e){K(this._surveyManager)?$.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}},Hh),Xh={toolbar:class{constructor(e){this.instance=e}Oo(e){B.ph_toolbar_state=e}Po(){return B.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),Nd(this.instance.config)||!R||!z)return!1;e??=R.location,n??=R.history;try{if(!t){try{R.localStorage.setItem(`test`,`test`),R.localStorage.removeItem(`test`)}catch{return!1}t=R?.localStorage}var r,i=xh||uf(e.hash,`__posthog`)||uf(e.hash,`state`),a=i?Dd((()=>JSON.parse(atob(decodeURIComponent(i)))))||Dd((()=>JSON.parse(decodeURIComponent(i)))):null;return a&&a.action===`ph_authorize`?((r=a).source=`url`,r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):((r=JSON.parse(t.getItem(Sh)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Lo(e){var t=B.ph_load_toolbar||B.ph_load_editor;!K(t)&&Rc(t)?t(e,this.instance):Ch.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(z==null||!z.getElementById(ud));if(!R||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=V({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(R.localStorage.setItem(Sh,JSON.stringify(V({},r,{source:void 0}))),this.Po()===2)this.Lo(r);else if(this.Po()===0){var i;this.Oo(1),(i=B.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return Ch.error(`[Toolbar] Failed to load`,e),void this.Oo(0);this.Oo(2),this.Lo(r)})),Md(R,`turbolinks:load`,(()=>{this.Oo(0),this.loadToolbar(r)}))}return!0}Do(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},Zh=V({experiments:Fh},Hh),Qh=V({},Hh,Uh,Wh,Gh,Kh,qh,Yh,Jh,Xh,Zh,{conversations:class{constructor(e){this.Bo=void 0,this._conversationsManager=null,this.jo=!1,this.qo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;K(t)||(Gc(t)?this.Bo=t:(this.Bo=t.enabled,this.qo=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Bo=void 0,this.qo=null}loadIfEnabled(){if(!(this._conversationsManager||this.jo||this._instance.config.disable_conversations||Nd(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=B?.__PosthogExtensions__;if(e&&!W(this.Bo)&&this.Bo)if(this.qo&&this.qo.token){this.jo=!0;try{var t=e.initConversations;if(t)return this.Zo(t),void(this.jo=!1);var n=e.loadExternalDependency;if(!n)return void this.$o(pd);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.$o(`Could not load conversations script`,t):this.Zo(e.initConversations),this.jo=!1}))}catch(e){this.$o(`Error initializing conversations`,e),this.jo=!1}}else Ih.error(`Conversations enabled but missing token in remote config.`)}}Zo(e){if(this.qo)try{this._conversationsManager=e(this.qo,this._instance),Ih.info(`Conversations loaded successfully`)}catch(e){this.$o(`Error completing conversations initialization`,e)}else Ih.error(`Cannot complete initialization: remote config is null`)}$o(e,t){Ih.error(e,t),this._conversationsManager=null,this.jo=!1}show(){this._conversationsManager?this._conversationsManager.show():Ih.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Bo&&!Hc(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return Dc((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(Ih.warn(Lh),null)}))()}getMessages(e,t){var n=this;return Dc((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Ih.warn(Lh),null)}))()}markAsRead(e){var t=this;return Dc((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Ih.warn(Lh),null)}))()}getTickets(e){var t=this;return Dc((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Ih.warn(Lh),null)}))()}requestRestoreLink(e){var t=this;return Dc((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Ih.warn(Lh),null)}))()}restoreFromToken(e){var t=this;return Dc((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Ih.warn(Lh),null)}))()}restoreFromUrlToken(){var e=this;return Dc((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Ih.warn(Lh),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}en(){var e;(e=this._conversationsManager)==null||e.setIdentity()}rn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t;this.Vo=!1,this.Ho=!1,this.qt=J(`[logs]`),this.zo=[],this.Uo=0,this.Yo=0,this.Go=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Vo=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!K(t)&&t&&(this.Vo=!0,this.loadIfEnabled())}reset(){this.zo=[],this.Ni&&=(clearTimeout(this.Ni),void 0),this.Uo=0,this.Yo=0,this.Go=!1}loadIfEnabled(){if(this.Vo&&!this.Ho){var e=B?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.qt.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.Ho=!0)})):this.qt.error(pd)}else this.qt.error(`PostHog Extensions not found.`)}}captureLog(e){if(this._instance.is_capturing())if(e&&e.body){var t=this._instance.config.logs?.flushIntervalMs??3e3,n=this._instance.config.logs?.maxLogsPerInterval??1e3,r=Date.now();if(t>r-this.Yo||(this.Yo=r,this.Uo=0,this.Go=!1),n>this.Uo){this.Uo++;var i=function(e,t){var{text:n,number:r}=Rh[e.level||`info`]||zh,i=String(Date.now())+`000000`,a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a[`url.full`]=t.currentUrl),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var o=V({},a,e.attributes||{}),s={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:r,severityText:n,body:{stringValue:e.body},attributes:Vh(o)};return e.trace_id&&(s.traceId=e.trace_id),e.span_id&&(s.spanId=e.span_id),W(e.trace_flags)||(s.flags=e.trace_flags),s}(e,this.Wo());this.zo.push({record:i}),(this._instance.config.logs?.maxBufferSize??100)>this.zo.length?this.Xo():this.flushLogs()}else this.Go||=(this.qt.warn(`captureLog dropping logs: exceeded `+n+` logs per `+t+`ms`),!0)}else this.qt.warn(`captureLog requires a body`)}get logger(){return this.Jo||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.Jo}flushLogs(e){if(this.Ni&&=(clearTimeout(this.Ni),void 0),this.zo.length!==0){var t=this.zo;this.zo=[];var n=this._instance.config.logs,r=V({"service.name":n?.serviceName||`unknown_service`},n?.environment&&{"deployment.environment":n.environment},n?.serviceVersion&&{"service.version":n.serviceVersion},n?.resourceAttributes),i=function(e,t){return{resourceLogs:[{resource:{attributes:Vh(t)},scopeLogs:[{scope:{name:Tc.LIB_NAME},logRecords:e}]}]}}(t.map((e=>e.record)),r),a=this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token);this._instance.Dr({method:`POST`,url:a,data:i,compression:`best-available`,batchKey:`logs`,transport:e})}}Xo(){this.Ni||=setTimeout((()=>{this.Ni=void 0,this.flushLogs()}),this._instance.config.logs?.flushIntervalMs??3e3)}Wo(){var e,t={lib:Tc.LIB_NAME};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=n}if(B!=null&&(e=B.location)!=null&&e.href&&(t.currentUrl=B.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});mm.__defaultExtensionClasses=V({},Qh);var $h,eg=($h=tm[cm]=new mm,function(){function e(){e.done||(e.done=!0,lm=!1,Y(tm,(function(e){e._dom_loaded()})))}z!=null&&z.addEventListener?z.readyState===`complete`?e():Md(z,`DOMContentLoaded`,e,{capture:!1}):R&&q.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),$h),tg;function ng(e){tg=e}function rg(){return tg}var ig=(0,c.createContext)({get client(){return rg()},bootstrap:void 0});function ag(e,t,n){if(n===void 0&&(n=new WeakMap),e===t)return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e)&&n.get(e)===t)return!0;n.set(e,t);var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(var a=0,o=r;a<o.length;a++){var s=o[a];if(!i.includes(s)||!ag(e[s],t[s],n))return!1}return!0}function og(e){var t=e.children,n=e.client,r=e.apiKey,i=e.options,a=(0,c.useRef)(null),o=(0,c.useMemo)(function(){if(n)return r&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),i&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n;var e=rg();return r||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),e},[n,r,JSON.stringify(i)]);return(0,c.useEffect)(function(){if(!n){var e=rg(),t=a.current;t?(r!==t.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),i&&!ag(i,t.options)&&e.set_config(i),a.current={apiKey:r,options:i??{}}):(e.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),e.init(r,i),a.current={apiKey:r,options:i??{}})}},[n,r,JSON.stringify(i)]),c.default.createElement(ig.Provider,{value:{client:o,bootstrap:i?.bootstrap??n?.config?.bootstrap}},t)}var sg=function(e){return typeof e==`function`},cg=function(e,t){return cg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},cg(e,t)};function lg(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);cg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ug={componentStack:null,exceptionEvent:null,error:null},dg={INVALID_FALLBACK:`[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.`};(function(e){lg(t,e);function t(t){var n=e.call(this,t)||this;return n.state=ug,n}return t.prototype.componentDidCatch=function(e,t){var n=this.props.additionalProperties,r;sg(n)?r=n(e):typeof n==`object`&&(r=n);var i=this.context.client.captureException(e,r),a=t.componentStack;this.setState({error:e,componentStack:a??null,exceptionEvent:i})},t.prototype.render=function(){var e=this.props,t=e.children,n=e.fallback,r=this.state;if(r.componentStack==null)return sg(t)?t():t;var i=sg(n)?c.default.createElement(n,{error:r.error,componentStack:r.componentStack,exceptionEvent:r.exceptionEvent}):n;return c.default.isValidElement(i)?i:(console.warn(dg.INVALID_FALLBACK),c.default.createElement(c.default.Fragment,null))},t.contextType=ig,t})(c.default.Component),ng(eg);var fg=({debug:e=!1,postHogApiKey:t,isStandalone:n,project:r,forceDisablePostHog:i=!1,children:a})=>{let o=Xs();return(0,c.useEffect)(()=>{!t||i||(o?.PostHog.consentGiven?eg.opt_in_capturing():eg.opt_out_capturing())},[o.PostHog.consentGiven,i,t]),!t||i?(console.warn(i?`AppShellStandalone Warning: PostHog tracking is disabled by force. PostHog will not be initialized.`:`AppShellStandalone Warning: PostHog API key is not provided. PostHog will not be initialized.`),(0,h.jsx)(h.Fragment,{children:a})):(eg.init(t,{debug:e,api_host:n?`https://eu.posthog.com`:`/ingest`,ui_host:`https://eu.posthog.com`,opt_out_capturing_by_default:!0,autocapture:n},r),(0,h.jsx)(og,{client:eg,children:a}))};exports.AppShell=zs,exports.ConsentManagerProvider=Zs,exports.LanguageProvider=tc,exports.MenuProvider=oc,exports.MicroFrontendLink=cc,exports.OrganisationProvider=pc,exports.OrganisationSelector=hc,exports.OrganisationsError=mc,exports.PostHogProviderWrapper=fg,exports.languageStorage=Us,exports.organisationStorage=Vs,exports.useConsentManager=Xs,exports.useLanguage=ec,exports.useMFNavigation=ac,exports.useMenu=ic,exports.useMenuGroupItems=rc,exports.useOrganisation=uc,exports.useOrganisationId=dc;
|
|
4
|
+
`)})(),this.lockManager=(We||=Ue(),We),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)n=e.cache;else{if(t=e.cacheLocation||ae,!Xt(t))throw Error(`Invalid cache location "${t}"`);n=Xt(t)()}var r;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:ie,this.cookieStorage=!1===e.legacySameSiteCookie?Ft:Lt,this.orgHintCookieName=(r=this.options.clientId,`auth0.${r}.organization_hint`),this.isAuthenticatedCookieName=(e=>`auth0.${e}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;let i=e.useCookiesForTransactions?this.cookieStorage:Rt;var a;this.scope=function(e,t){var n=[...arguments].slice(2);if(typeof e!=`object`)return{[S]:ht(t,e,...n)};let r={[S]:ht(t,...n)};return Object.keys(e).forEach(i=>{let a=e[i];r[i]=ht(t,a,...n)}),r}(this.options.authorizationParams.scope,`openid`,this.options.useRefreshTokens?`offline_access`:``),this.transactionManager=new Ct(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||se,this.cacheManager=new St(n,n.allKeys?void 0:new qt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new tn(this.options.clientId):void 0,this.domainUrl=(a=this.options.domain,/^https?:\/\//.test(a)?a:`https://${a}`),this.tokenIssuer=((e,t)=>e?e.startsWith(`https://`)?e:`https://${e}/`:`${t}/`)(this.options.issuer,this.domainUrl);let o=`${this.domainUrl}/me/`,s=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:`__auth0_my_account_api__`}),{getAccessToken:()=>this.getTokenSilently({authorizationParams:{scope:`create:me:connected_accounts`,audience:o},detailedResponse:!0})}));this.myAccountApi=new an(s,o),this.authJsClient=new is({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new ys(this.authJsClient.mfa,this),typeof window<`u`&&window.Worker&&this.options.useRefreshTokens&&t===ae&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new Gt,this.worker.postMessage({type:`init`,allowedBaseUrl:this.domainUrl}))}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){let t=Ce(this.options.auth0Client||oe,!0),n=encodeURIComponent(btoa(JSON.stringify(t)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${we(e)}`)}async _verifyIdToken(e,t,n){let r=await this.nowProvider();return Et({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i==`string`?parseInt(i,10)||void 0:i),now:r});var i}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{let t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},``,t.toString()))}catch{}}_applySessionTransferToken(e){let t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;let n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),Object.assign(Object.assign({},e),{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){let r=xe(be()),i=xe(be()),a=be(),o=De(await Te(a)),s=await this.dpop?.calculateThumbprint(),c=((e,t,n,r,i,a,o,s,c)=>Object.assign(Object.assign(Object.assign({client_id:e.clientId},e.authorizationParams),n),{scope:gt(t,n.scope,n.audience),response_type:`code`,response_mode:s||`query`,state:r,nonce:i,redirect_uri:o||e.authorizationParams.redirect_uri,code_challenge:a,code_challenge_method:`S256`,dpop_jkt:c}))(this.options,this.scope,e,r,i,o,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,t?.response_mode,s),l=this._authorizeUrl(c);return{nonce:i,code_verifier:a,scope:c.scope,audience:c.audience||S,redirect_uri:c.redirect_uri,state:r,url:l}}async loginWithPopup(e,t){if(e||={},!(t||={}).popup&&(t.popup=(e=>{let t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,`auth0:authorize:popup`,`left=${t},top=${n},width=400,height=600,resizable,scrollbars=yes,status=1`)})(``),!t.popup))throw new pe;let n=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(n,{response_mode:`web_message`},window.location.origin);t.popup.location.href=r.url;let i=await((e,t)=>new Promise((n,r)=>{let i,a=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(a),clearTimeout(o),window.removeEventListener(`message`,i,!1),r(new fe(e.popup)))},1e3),o=setTimeout(()=>{clearInterval(a),r(new de(e.popup)),window.removeEventListener(`message`,i,!1)},1e3*(e.timeoutInSeconds||60));i=function(s){if(s.origin===t&&s.data&&s.data.type===`authorization_response`){if(clearTimeout(o),clearInterval(a),window.removeEventListener(`message`,i,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return r(C.fromPayload(s.data.response));n(s.data.response)}},window.addEventListener(`message`,i)}))(Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new C(`state_mismatch`,`Invalid state`);let a=e.authorizationParams?.organization||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:`authorization_code`,code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a})}async getUser(){return(await this._getIdTokenFromCache())?.decodedToken?.user}async getIdTokenClaims(){return(await this._getIdTokenFromCache())?.decodedToken?.claims}async loginWithRedirect(){let e=Zt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),{openUrl:t,fragment:n,appState:r}=e,i=x(e,[`openUrl`,`fragment`,`appState`]),a=i.authorizationParams?.organization||this.options.authorizationParams.organization,o=this._applySessionTransferToken(i.authorizationParams||{}),s=await this._prepareAuthorizeUrl(o),{url:c}=s,l=x(s,[`url`]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},l),{appState:r,response_type:zt.Code}),a&&{organization:a}));let u=n?`${c}#${n}`:c;t?await t(u):window.location.assign(u)}async handleRedirectCallback(){let e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.location.href).split(`?`).slice(1);if(e.length===0)throw Error(`There are no query params available for parsing.`);let t=this.transactionManager.get();if(!t)throw new C(`missing_transaction`,`Invalid state`);this.transactionManager.remove();let n=(e=>{e.indexOf(`#`)>-1&&(e=e.substring(0,e.indexOf(`#`)));let t=new URLSearchParams(e);return{state:t.get(`state`),code:t.get(`code`)||void 0,connect_code:t.get(`connect_code`)||void 0,error:t.get(`error`)||void 0,error_description:t.get(`error_description`)||void 0}})(e.join(``));return t.response_type===zt.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){let{code:n,state:r,error:i,error_description:a}=e;if(i)throw new ce(i,a||i,r,t.appState);if(!t.code_verifier||t.state&&t.state!==r)throw new C(`state_mismatch`,`Invalid state`);let o=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(Object.assign({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:`authorization_code`,code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:o}),{appState:t.appState,response_type:zt.Code}}async _handleConnectAccountRedirectCallback(e,t){let{connect_code:n,state:r,error:i,error_description:a}=e;if(i)throw new le(i,a||i,t.connection,r,t.appState);if(!n)throw new C(`missing_connect_code`,`Missing connect code`);if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===r))throw new C(`state_mismatch`,`Invalid state`);let o=await this.myAccountApi.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier});return Object.assign(Object.assign({},o),{appState:t.appState,response_type:zt.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(Jt))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(Jt)}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Object.assign(Object.assign({cacheMode:`on`},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:gt(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})}),n=await((e,t)=>{let n=Kt[t];return n||(n=e().finally(()=>{delete Kt[t],n=null}),Kt[t]=n),n})(()=>this._getTokenSilently(t),`${this.options.clientId}::${t.authorizationParams.audience}::${t.authorizationParams.scope}`);return e.detailedResponse?n:n?.access_token}async _getTokenSilently(e){let{cacheMode:t}=e,n=x(e,[`cacheMode`]);if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||S,clientId:this.options.clientId,cacheMode:t});if(e)return e}if(t===`cache-only`)return;let r=(i=this.options.clientId,a=n.authorizationParams.audience||`default`,`auth0.lock.getTokenSilently.${i}.${a}`);var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||S,clientId:this.options.clientId});if(e)return e}let{id_token:e,token_type:r,access_token:i,oauthTokenScope:a,expires_in:o}=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n);return Object.assign(Object.assign({id_token:e,token_type:r,access_token:i},a?{scope:a}:null),{expires_in:o})})}catch(e){if(this._isInteractiveError(e)&&this.options.interactiveErrorHandler===`popup`)return await this._handleInteractiveErrorWithPopup(n);throw e}}_isInteractiveError(e){return e instanceof me||e instanceof C&&this._isIframeMfaError(e)}_isIframeMfaError(e){return e.error===`login_required`&&e.error_description===`Multifactor authentication required`}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});let t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||S,clientId:this.options.clientId});if(!t)throw new C(`interactive_handler_cache_miss`,`Token not found in cache after interactive authentication`);return t}catch(e){throw e}}async getTokenWithPopup(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:gt(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})});return t=Object.assign(Object.assign({},re),t),await this.loginWithPopup(n,t),(await this.cacheManager.get(new yt({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||S,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId===null?delete e.clientId:e.clientId=e.clientId||this.options.clientId;let t=e.logoutParams||{},{federated:n}=t,r=x(t,[`federated`]),i=n?`&federated`:``;return this._url(`/v2/logout?${we(Object.assign({clientId:e.clientId},r))}`)+i}async revokeRefreshToken(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.options.useRefreshTokens)return;let t=e.audience||this.options.authorizationParams.audience||S,n=await this.cacheManager.getRefreshTokensByAudience(t,this.options.clientId);await async function(e,t){let{baseUrl:n,timeout:r,auth0Client:i,useFormData:a,refreshTokens:o,audience:s,client_id:c,onRefreshTokenRevoked:l}=e,u=r||ie,d=`refresh_token`,f=`${n}/oauth/revoke`,p={"Content-Type":a?`application/x-www-form-urlencoded`:`application/json`,"Auth0-Client":btoa(JSON.stringify(Ce(i||oe)))};if(t){let e={client_id:c,token_type_hint:d},n=a?we(e):JSON.stringify(e);try{return await ut({type:`revoke`,timeout:u,fetchUrl:f,fetchOptions:{method:`POST`,body:n,headers:p},useFormData:a,auth:{audience:s??S}},t)}catch(e){throw new C(`revoke_error`,e.message)}}for(let e of o){let t={client_id:c,token_type_hint:d,token:e},n=await dt(f,{method:`POST`,body:a?we(t):JSON.stringify(t),headers:p},u);if(!n.ok){let e,t;try{({error:e,error_description:t}=JSON.parse(await n.text()))}catch{}throw new C(e||`revoke_error`,t||`HTTP error ${n.status}`)}await l?.(e)}}({baseUrl:this.domainUrl,timeout:this.httpTimeoutMs,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,client_id:this.options.clientId,refreshTokens:n,audience:t,onRefreshTokenRevoked:e=>this.cacheManager.stripRefreshToken(e)},this.worker)}async logout(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Zt(e),{openUrl:n}=t,r=x(t,[`openUrl`]);if(e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(vt),await this.dpop?.clear(),this.worker)try{await ut({type:`clear`},this.worker)}catch{}let i=this._buildLogoutUrl(r);n?await n(i):!1!==n&&window.location.assign(i)}async _getTokenFromIFrame(e){let t=(n=this.options.clientId,`auth0.lock.getTokenFromIFrame.${n}`);var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{let t=Object.assign(Object.assign({},e.authorizationParams),{prompt:`none`}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);let{url:r,state:i,nonce:a,code_verifier:o,redirect_uri:s,scope:c,audience:l}=await this._prepareAuthorizeUrl(t,{response_mode:`web_message`},window.location.origin);if(window.crossOriginIsolated)throw new C(`login_required`,`The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.`);let u=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,d;try{d=new URL(this.domainUrl).origin}catch{d=this.domainUrl}let f=await function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:60;return new Promise((r,i)=>{let a=window.document.createElement(`iframe`);a.setAttribute(`width`,`0`),a.setAttribute(`height`,`0`),a.style.display=`none`;let o=()=>{window.document.body.contains(a)&&(window.document.body.removeChild(a),window.removeEventListener(`message`,s,!1))},s,c=setTimeout(()=>{i(new ue),o()},1e3*n);s=function(e){if(e.origin!=t||!e.data||e.data.type!==`authorization_response`)return;let n=e.source;n&&n.close(),e.data.response.error?i(C.fromPayload(e.data.response)):r(e.data.response),clearTimeout(c),window.removeEventListener(`message`,s,!1),setTimeout(o,2e3)},window.addEventListener(`message`,s,!1),window.document.body.appendChild(a),a.setAttribute(`src`,e)})}(r,d,u);if(i!==f.state)throw new C(`state_mismatch`,`Invalid state`);let p=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:o,code:f.code,grant_type:`authorization_code`,redirect_uri:s,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return Object.assign(Object.assign({},p),{scope:c,oauthTokenScope:p.scope,audience:l})})}catch(e){throw e.error===`login_required`&&(e instanceof C&&this._isIframeMfaError(e)&&this.options.interactiveErrorHandler===`popup`||this.logout({openUrl:!1})),e}}async _getTokenUsingRefreshToken(e){let t=await this.cacheManager.get(new yt({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||S,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(t&&t.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new he(e.authorizationParams.audience||S,e.authorizationParams.scope)}let n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof e.timeoutInSeconds==`number`?1e3*e.timeoutInSeconds:null,i=((e,t,n,r)=>{if(e&&n&&r){if(t.audience!==n)return t.scope;let e=r.split(` `),i=t.scope?.split(` `)||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?r:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,t?.audience,t?.scope);try{let l=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:`refresh_token`,refresh_token:t&&t.refresh_token,redirect_uri:n}),r&&{timeout:r}),{scopesToRequest:i});if(l.refresh_token&&t!=null&&t.refresh_token&&await this.cacheManager.updateEntry(t.refresh_token,l.refresh_token),this.options.useMrrt&&(a=t?.audience,o=t?.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,(a!==s||!Qt(c,o))&&!Qt(i,l.scope))){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope);let t=((e,t)=>{let n=e?.split(` `)||[],r=t?.split(` `)||[];return n.filter(e=>r.indexOf(e)==-1).join(`,`)})(i,l.scope);throw new ge(e.authorizationParams.audience||`default`,t)}return Object.assign(Object.assign({},l),{scope:e.authorizationParams.scope,oauthTokenScope:l.scope,audience:e.authorizationParams.audience||S})}catch(t){if(t.message){if(t.message.includes(`user is blocked`))throw await this.logout({openUrl:!1}),t;if((t.message.includes(`Missing Refresh Token`)||t.message.includes(`invalid refresh token`))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t instanceof me&&this.mfa.setMFAAuthDetails(t.mfa_token,e.authorizationParams?.scope,e.authorizationParams?.audience,t.mfa_requirements),t}var a,o,s,c}async _saveEntryInCache(e){let{id_token:t,decodedToken:n}=e,r=x(e,[`id_token`,`decodedToken`]);this.userCache.set(vt,{id_token:t,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(r)}async _getIdTokenFromCache(){let e=this.options.authorizationParams.audience||S,t=this.scope[e],n=await this.cacheManager.getIdToken(new yt({clientId:this.options.clientId,audience:e,scope:t})),r=this.userCache.get(vt);return n&&n.id_token===r?.id_token?r:(this.userCache.set(vt,n),n)}async _getEntryFromCache(e){let{scope:t,audience:n,clientId:r,cacheMode:i}=e,a=await this.cacheManager.get(new yt({scope:t,audience:n,clientId:r}),60,this.options.useMrrt,i);if(a&&a.access_token){let{token_type:e,access_token:t,oauthTokenScope:n,expires_in:r}=a,i=await this._getIdTokenFromCache();return i&&Object.assign(Object.assign({id_token:i.id_token,token_type:e||`Bearer`,access_token:t},n?{scope:n}:null),{expires_in:r})}}async _requestToken(e,t){var n;let{nonceIn:r,organization:i,scopesToRequest:a}=t||{},o=await mt(Object.assign(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop},e),{scope:a||e.scope}),this.worker),s=await this._verifyIdToken(o.id_token,r,i);if(e.grant_type===`authorization_code`){let e=await this._getIdTokenFromCache();(n=e?.decodedToken?.claims)!=null&&n.sub&&e.decodedToken.claims.sub!==s.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(vt))}return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:s,scope:e.scope,audience:e.audience||S}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||s.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:s})}async loginWithCustomTokenExchange(e){return this._requestToken(Object.assign(Object.assign({},e),{grant_type:`urn:ietf:params:oauth:grant-type:token-exchange`,subject_token:e.subject_token,subject_token_type:e.subject_token_type,scope:gt(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization}))}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(e){return this._assertDpop(this.dpop),this.dpop.getNonce(e)}setDpopNonce(e,t){return this._assertDpop(this.dpop),this.dpop.setNonce(e,t)}generateDpopProof(e){return this._assertDpop(this.dpop),this.dpop.generateProof(e)}createFetcher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new rn(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>this.getTokenSilently({authorizationParams:{scope:(e?.scope)?.join(` `),audience:e?.audience},detailedResponse:!0}),getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){let{openUrl:t,appState:n,connection:r,scopes:i,authorization_params:a,redirectUri:o=this.options.authorizationParams.redirect_uri||window.location.origin}=e;if(!r)throw Error(`connection is required`);let s=xe(be()),c=be(),l=De(await Te(c)),{connect_uri:u,connect_params:d,auth_session:f}=await this.myAccountApi.connectAccount({connection:r,scopes:i,redirect_uri:o,state:s,code_challenge:l,code_challenge_method:`S256`,authorization_params:a});this.transactionManager.create({state:s,code_verifier:c,auth_session:f,redirect_uri:o,appState:n,connection:r,response_type:zt.ConnectCode});let p=new URL(u);p.searchParams.set(`ticket`,d.ticket),t?await t(p.toString()):window.location.assign(p)}async _requestTokenForMfa(e,t){let{mfaToken:n}=e,r=x(e,[`mfaToken`]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:n}),t)}},xs={isAuthenticated:!1,isLoading:!0,error:void 0,user:void 0},I=function(){throw Error(`You forgot to wrap your component in <Auth0Provider>.`)},Ss=y(y({},xs),{buildAuthorizeUrl:I,buildLogoutUrl:I,getAccessTokenSilently:I,getAccessTokenWithPopup:I,getIdTokenClaims:I,loginWithCustomTokenExchange:I,exchangeToken:I,loginWithRedirect:I,loginWithPopup:I,connectAccountWithRedirect:I,logout:I,handleRedirectCallback:I,getDpopNonce:I,setDpopNonce:I,generateDpopProof:I,createFetcher:I,getConfiguration:I,mfa:{getAuthenticators:I,enroll:I,challenge:I,verify:I,getEnrollmentFactors:I}}),Cs=(0,c.createContext)(Ss),ws=function(e){v(t,e);function t(n,r){var i=e.call(this,r??n)||this;return i.error=n,i.error_description=r,Object.setPrototypeOf(i,t.prototype),i}return t}(Error),Ts=/[?&](?:connect_)?code=[^&]+/,Es=/[?&]state=[^&]+/,Ds=/[?&]error=[^&]+/,Os=function(e){return e===void 0&&(e=window.location.search),(Ts.test(e)||Ds.test(e))&&Es.test(e)},ks=function(e){return function(t){if(t instanceof Error)return t;if(typeof t==`object`&&t&&`error`in t&&typeof t.error==`string`){if(`error_description`in t&&typeof t.error_description==`string`){var n=t;return new ws(n.error,n.error_description)}return new ws(t.error)}return Error(e)}},As=ks(`Login failed`),js=ks(`Get access token failed`),Ms=function(e){e?.redirectUri&&(console.warn("Using `redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `redirectUri` will be no longer supported in a future version"),e.authorizationParams=e.authorizationParams??{},e.authorizationParams.redirect_uri=e.redirectUri,delete e.redirectUri),e?.authorizationParams?.redirectUri&&(console.warn("Using `authorizationParams.redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `authorizationParams.redirectUri` will be removed in a future version"),e.authorizationParams.redirect_uri=e.authorizationParams.redirectUri,delete e.authorizationParams.redirectUri)},Ns=function(e,t){switch(t.type){case`LOGIN_POPUP_STARTED`:return y(y({},e),{isLoading:!0});case`LOGIN_POPUP_COMPLETE`:case`INITIALISED`:return y(y({},e),{isAuthenticated:!!t.user,user:t.user,isLoading:!1,error:void 0});case`HANDLE_REDIRECT_COMPLETE`:case`GET_ACCESS_TOKEN_COMPLETE`:return e.user===t.user?e:y(y({},e),{isAuthenticated:!!t.user,user:t.user});case`LOGOUT`:return y(y({},e),{isAuthenticated:!1,user:void 0});case`ERROR`:return y(y({},e),{isLoading:!1,error:t.error})}},Ps=function(e){return Ms(e),y(y({},e),{auth0Client:{name:`auth0-react`,version:`2.16.2`}})},Fs=function(e){window.history.replaceState({},document.title,e.returnTo??window.location.pathname)},Is=function(e){var t=e,n=t.children,r=t.skipRedirectCallback,i=t.onRedirectCallback,a=i===void 0?Fs:i,o=t.context,s=o===void 0?Cs:o,l=t.client,u=ee(t,[`children`,`skipRedirectCallback`,`onRedirectCallback`,`context`,`client`]);l&&(u.domain||u.clientId)&&console.warn("Auth0Provider: the `client` prop takes precedence over `domain`/`clientId` and other configuration options. Remove `domain`, `clientId`, and any other Auth0Client configuration props when using the `client` prop.");var d=(0,c.useState)(function(){return l??new bs(Ps(u))})[0],f=(0,c.useReducer)(Ns,xs),p=f[0],m=f[1],h=(0,c.useRef)(!1),g=(0,c.useCallback)(function(e){return m({type:`ERROR`,error:e}),e},[]);(0,c.useEffect)(function(){h.current||(h.current=!0,(function(){return b(void 0,void 0,void 0,function(){var e,t,n,i,o,s,c;return te(this,function(l){switch(l.label){case 0:return l.trys.push([0,7,,8]),e=void 0,Os()&&!r?[4,d.handleRedirectCallback()]:[3,3];case 1:return t=l.sent(),n=t.appState,i=n===void 0?{}:n,o=t.response_type,s=ee(t,[`appState`,`response_type`]),[4,d.getUser()];case 2:return e=l.sent(),i.response_type=o,o===zt.ConnectCode&&(i.connectedAccount=s),a(i,e),[3,6];case 3:return[4,d.checkSession()];case 4:return l.sent(),[4,d.getUser()];case 5:e=l.sent(),l.label=6;case 6:return m({type:`INITIALISED`,user:e}),[3,8];case 7:return c=l.sent(),g(As(c)),[3,8];case 8:return[2]}})})})())},[d,a,r,g]);var _=(0,c.useCallback)(function(e){return Ms(e),d.loginWithRedirect(e)},[d]),v=(0,c.useCallback)(function(e,t){return b(void 0,void 0,void 0,function(){var n,r;return te(this,function(i){switch(i.label){case 0:m({type:`LOGIN_POPUP_STARTED`}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,d.loginWithPopup(e,t)];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),g(As(n)),[2];case 4:return[4,d.getUser()];case 5:return r=i.sent(),m({type:`LOGIN_POPUP_COMPLETE`,user:r}),[2]}})})},[d,g]),x=(0,c.useCallback)(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return b(void 0,ne([],e,!0),void 0,function(e){return e===void 0&&(e={}),te(this,function(t){switch(t.label){case 0:return[4,d.logout(e)];case 1:return t.sent(),(e.openUrl||e.openUrl===!1)&&m({type:`LOGOUT`}),[2]}})})},[d]),re=(0,c.useCallback)(function(e){return b(void 0,void 0,void 0,function(){var t,n,r,i;return te(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,d.getTokenSilently(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),js(n);case 3:return r=m,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[d]),ie=(0,c.useCallback)(function(e,t){return b(void 0,void 0,void 0,function(){var n,r,i,a;return te(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,3,5]),[4,d.getTokenWithPopup(e,t)];case 1:return n=o.sent(),[3,5];case 2:throw r=o.sent(),js(r);case 3:return i=m,a={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return i.apply(void 0,[(a.user=o.sent(),a)]),[7];case 5:return[2,n]}})})},[d]),ae=(0,c.useCallback)(function(e){return d.connectAccountWithRedirect(e)},[d]),oe=(0,c.useCallback)(function(){return d.getIdTokenClaims()},[d]),se=(0,c.useCallback)(function(e){return b(void 0,void 0,void 0,function(){var t,n,r,i;return te(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,d.loginWithCustomTokenExchange(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),js(n);case 3:return r=m,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[d]),S=(0,c.useCallback)(function(e){return b(void 0,void 0,void 0,function(){return te(this,function(t){return[2,se(e)]})})},[se]),C=(0,c.useCallback)(function(e){return b(void 0,void 0,void 0,function(){var t,n,r;return te(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,5]),[4,d.handleRedirectCallback(e)];case 1:return[2,i.sent()];case 2:throw t=i.sent(),js(t);case 3:return n=m,r={type:`HANDLE_REDIRECT_COMPLETE`},[4,d.getUser()];case 4:return n.apply(void 0,[(r.user=i.sent(),r)]),[7];case 5:return[2]}})})},[d]),ce=(0,c.useCallback)(function(e){return d.getDpopNonce(e)},[d]),le=(0,c.useCallback)(function(e,t){return d.setDpopNonce(e,t)},[d]),ue=(0,c.useCallback)(function(e){return d.generateDpopProof(e)},[d]),de=(0,c.useCallback)(function(e){return d.createFetcher(e)},[d]),fe=(0,c.useCallback)(function(){return d.getConfiguration()},[d]),pe=(0,c.useMemo)(function(){return d.mfa},[d]),me=(0,c.useMemo)(function(){return y(y({},p),{getAccessTokenSilently:re,getAccessTokenWithPopup:ie,getIdTokenClaims:oe,loginWithCustomTokenExchange:se,exchangeToken:S,loginWithRedirect:_,loginWithPopup:v,connectAccountWithRedirect:ae,logout:x,handleRedirectCallback:C,getDpopNonce:ce,setDpopNonce:le,generateDpopProof:ue,createFetcher:de,getConfiguration:fe,mfa:pe})},[p,re,ie,oe,se,S,_,v,ae,x,C,ce,le,ue,de,fe,pe]);return c.default.createElement(s.Provider,{value:me},n)},Ls=function(e){return e===void 0&&(e=Cs),(0,c.useContext)(e)},Rs=({environment:e})=>(0,h.jsx)(`div`,{className:`epp-environment-banner`,style:{position:`fixed`,zIndex:9999,top:0,left:0,right:0,width:`100vw`,height:`16px`,backgroundColor:(0,p.getColorForEnvironment)(e)}});function zs(e){let{protocol:t,hostname:n,port:r}=window.location;return e({logoutParams:{returnTo:`${t}//${n}:${r}`}})}var Bs=({children:e,decorateUser:t,getReturnPath:n})=>{let[r,i]=(0,c.useState)(void 0),{user:a,getAccessTokenSilently:o,loginWithRedirect:s,logout:p,isLoading:g,isAuthenticated:_,error:v}=Ls();return(0,c.useEffect)(()=>{_&&(async()=>{try{i(await t(a,await o()))}catch(e){console.error(`Error fetching user data:`,e)}})()},[t,o,_,a]),!g&&!_?(s({appState:{returnTo:n()}}),(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Redirecting to login page`})):g||!r?(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Authenticating`}):v?(process.env.NODE_ENV!==`production`&&console.error(v),(0,h.jsxs)(l.BannerAlertBox,{variant:`error`,title:`Authentication failed`,style:{maxWidth:`600px`,margin:`0 auto`},children:[(0,h.jsxs)(f.Paragraph,{children:[`Something went wrong while trying to authenticate you. If the problem persists you should contact`,` `,(0,h.jsx)(f.Link,{href:`mailto:support@entur.org`,children:`support@entur.org`}),` to get it resolved.`]}),(0,h.jsxs)(f.Paragraph,{children:[`Authentication failed with: `,(0,h.jsx)(f.CodeText,{children:v?.toString()})]})]})):((0,m.assertIsDefined)(r),(0,h.jsx)(h.Fragment,{children:e({user:r,logout:()=>zs(p),getToken:o})}))},Vs=({children:e,audience:t,domain:n,clientId:r,decorateUser:i,environment:a,redirectUri:o,navigate:s})=>(0,h.jsx)(Is,{domain:n,clientId:r,authorizationParams:{redirect_uri:o??window.location.origin,audience:t},onRedirectCallback:e=>{let t=e?.returnTo,n=o||t||`/`;s?s(n,{replace:!0}):window.history.replaceState({},``,n)},children:(0,h.jsx)(Bs,{decorateUser:i,getReturnPath:()=>`${window.location.pathname}${window.location.search}${window.location.hash}`,children:t=>(0,h.jsxs)(h.Fragment,{children:[a&&a!==p.Environment.Production&&(0,h.jsx)(Rs,{environment:a}),e(t)]})})}),Hs=`EP::activeOrgId`,Us={get:()=>localStorage.getItem(Hs),set:e=>localStorage.setItem(Hs,e)},Ws=`EP::locale`,Gs={get:()=>localStorage.getItem(Ws),set:e=>localStorage.setItem(Ws,e)},Ks=`ucData`,qs={get:()=>localStorage.getItem(Ks)},Js={Usercentrics:`Usercentrics Consent Management Platform`,PostHog:`PostHog.com`,Sentry:`Sentry`},Ys={Usercentrics:{consentGiven:!1},PostHog:{consentGiven:!1},Sentry:{consentGiven:!1}},Xs=e=>e.map(e=>{let t=Object.entries(Js).find(t=>t[1]===e.name)?.[0];if((0,m.assertIsDefined)(t,`Service name ${e.name} not found in SERVICE_NAMES`),typeof e.consent==`boolean`){let n=e.consent;return{[t]:{consentGiven:n}}}else if(typeof e.consent==`object`&&`given`in e.consent){let n=e.consent.given;return{[t]:{consentGiven:n}}}return{[t]:{consentGiven:!1}}}).reduce((e,t)=>({...e,...t}),Ys),Zs=(0,c.createContext)(Ys),Qs=()=>(0,c.useContext)(Zs),$s=({children:e})=>{let[t,n]=(0,c.useState)(Ys);return(0,c.useEffect)(()=>{if(typeof window>`u`)return;let e=qs.get();if(e){let t=JSON.parse(e);n(Xs(Object.values(t.consent.services)))}},[]),(0,c.useEffect)(()=>{let e=async e=>{typeof window>`u`||n(Xs(Object.values(e.detail.services)))};return window.addEventListener(`UC_CONSENT`,e),()=>window.removeEventListener(`UC_CONSENT`,e)},[]),(0,h.jsx)(Zs.Provider,{value:t,children:e})},ec=(0,c.createContext)(void 0),tc=e=>{let[t,n]=(0,c.useState)(e);return(0,c.useEffect)(()=>{Gs.set(t)},[t]),[t,n]},nc=()=>{let e=(0,c.useContext)(ec);return(0,m.assertIsDefined)(e),e},rc=({children:e,language:t})=>{let[n,r]=tc(t);return(0,h.jsx)(ec.Provider,{value:{language:n,setLanguage:r},children:e})},ic=(0,c.createContext)({addItems:()=>{},getItemsForPath:()=>[],getMFNavigate:()=>void 0,setMFNavigate:()=>{},getItemGroupsPerPath:()=>({})}),ac=e=>(0,c.useContext)(ic).getItemsForPath(e),oc=()=>(0,c.useContext)(ic),sc=e=>{let{getMFNavigate:t}=oc();return t(e)},cc=({children:e})=>{let[t,n]=(0,c.useState)({}),[r,i]=(0,c.useState)({}),a=(0,c.useCallback)((e,t)=>{n(n=>({...n,[t]:e})),window.dispatchEvent((0,g.createMenuItemsEvent)({path:t,items:e}))},[]);return(0,h.jsx)(ic.Provider,{value:{addItems:a,getItemGroupsPerPath:()=>t,getItemsForPath:e=>t[e]??[],getMFNavigate:e=>r[e],setMFNavigate:(e,t)=>i(n=>({...n,[e]:t}))},children:e})};function lc(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var uc=({navigate:e,children:t,onClick:n,target:r,...i})=>(0,h.jsx)(`a`,{onClick:t=>{try{n&&n(t)}catch(e){throw t.preventDefault(),e}!t.defaultPrevented&&t.button===0&&(!r||r===`_self`)&&!lc(t)&&(t.preventDefault(),e())},target:r,...i,children:t}),dc=(0,c.createContext)(void 0),fc=()=>{let e=(0,c.useContext)(dc);return(0,m.assertIsDefined)(e),e},pc=()=>{let e=(0,c.useContext)(dc);return(0,m.assertIsDefined)(e),e.organisationId},mc=e=>{let[t,n]=(0,c.useState)(Number(e));return(0,c.useEffect)(()=>{Us.set(t.toString())},[t]),[t,n]},hc=({children:e,organisationId:t})=>{let[n,r]=mc(t);return(0,h.jsx)(dc.Provider,{value:{organisationId:n,setOrganisationId:r},children:e})},gc=class extends Error{constructor(...e){super(...e),this.message=`Failed fetching organisations`}},_c=({getToken:e,getOrganisations:t,selectedOrganisationId:n,onChange:r,...i})=>{let[a,o]=(0,c.useState)([]),{language:s}=nc(),[l,d]=(0,c.useState)(`LOADING`);switch((0,c.useEffect)(()=>{(async()=>{let n=await e(),r;r=typeof t==`string`?await fetch(t,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`}}).then(e=>e.json()):await t(n),o(r),d(`SUCCESS`)})().catch(e=>{process.env.NODE_ENV===`development`&&console.error(e),d(`ERROR`)})},[t,e]),l){case`LOADING`:return(0,h.jsx)(`div`,{className:`eds-contrast`,children:(0,h.jsx)(u.SkeletonRectangle,{style:{height:`2.4rem`}})});case`SUCCESS`:return(0,h.jsx)(p.OrganisationDropDown,{label:s===`nb`||s===`nb-NO`?`Organisasjon`:`Organisation`,selectedOrganisationId:n,organisations:a,onChange:r,...i});case`ERROR`:throw new gc;default:return null}},L=typeof window<`u`?window:void 0,vc=typeof globalThis<`u`?globalThis:L;typeof self>`u`&&(vc.self=vc),typeof File>`u`&&(vc.File=function(){});var yc=vc?.navigator,R=vc?.document,bc=vc?.location,xc=vc?.fetch,Sc=vc!=null&&vc.XMLHttpRequest&&`withCredentials`in new vc.XMLHttpRequest?vc.XMLHttpRequest:void 0,Cc=vc?.AbortController,wc=vc?.CompressionStream,Tc=yc?.userAgent,z=L??{},Ec=`1.369.5`,Dc={DEBUG:!1,LIB_VERSION:Ec,LIB_NAME:`web`,JS_SDK_VERSION:Ec};function Oc(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function kc(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Oc(a,r,i,o,s,`next`,e)}function s(e){Oc(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(null,arguments)}function Ac(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function jc(){return(jc=kc((function*(e,t,n){t===void 0&&(t=!0);try{var r=new Blob([e],{type:`text/plain`}).stream().pipeThrough(new CompressionStream(`gzip`));return yield new Response(r).blob()}catch(e){if(n!=null&&n.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}}))).apply(this,arguments)}var Mc=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`],Nc=`amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterest,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),Pc=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return Nc.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))};function V(e,t){return e.indexOf(t)!==-1}var Fc=function(e){return e.trim()},Ic=function(e){return e.replace(/^\$/,``)},Lc=Object.prototype,Rc=Lc.hasOwnProperty,zc=Lc.toString,H=Array.isArray||function(e){return zc.call(e)===`[object Array]`},Bc=e=>typeof e==`function`,Vc=e=>e===Object(e)&&!H(e),Hc=e=>{if(Vc(e)){for(var t in e)if(Rc.call(e,t))return!1;return!0}return!1},U=e=>e===void 0,W=e=>zc.call(e)==`[object String]`,Uc=e=>W(e)&&e.trim().length===0,Wc=e=>e===null,G=e=>U(e)||Wc(e),Gc=e=>zc.call(e)==`[object Number]`&&e==e,Kc=e=>Gc(e)&&e>0,qc=e=>zc.call(e)===`[object Boolean]`,Jc=e=>e instanceof FormData,Yc=e=>V(Mc,e);function Xc(e){return typeof e!=`object`||!e}function Zc(e,t){return{}.toString.call(e)===`[object `+t+`]`}function Qc(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var $c=[!0,`true`,1,`1`,`yes`],el=e=>V($c,e),tl=[!1,`false`,0,`0`,`no`];function nl(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Gc(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),nl(i||n,t,n,r))}var rl=class{constructor(e){this.Pt={},this.Dt=e.Dt,this.jt=nl(e.bucketSize,0,100,e.qt),this.$t=nl(e.refillRate,0,this.jt,e.qt),this.Vt=nl(e.refillInterval,0,864e5,e.qt)}Ht(e,t){var n=Math.floor((t-e.lastAccess)/this.Vt);n>0&&(e.tokens=Math.min(e.tokens+n*this.$t,this.jt),e.lastAccess+=n*this.Vt)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.Pt[r];return i?this.Ht(i,n):this.Pt[r]=i={tokens:this.jt,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.Dt)==null||t.call(this,e)),i.tokens===0)}stop(){this.Pt={}}},il,al,ol,sl=`Mobile`,cl=`iOS`,ll=`Android`,ul=`Tablet`,dl=ll+` `+ul,fl=`iPad`,pl=`Apple`,ml=pl+` Watch`,hl=`Safari`,gl=`BlackBerry`,_l=`Samsung`,vl=_l+`Browser`,yl=_l+` Internet`,bl=`Chrome`,xl=bl+` OS`,Sl=bl+` `+cl,Cl=`Internet Explorer`,wl=Cl+` `+sl,Tl=`Opera`,El=Tl+` Mini`,Dl=`Edge`,Ol=`Microsoft `+Dl,kl=`Firefox`,Al=kl+` `+cl,jl=`Nintendo`,Ml=`PlayStation`,Nl=`Xbox`,Pl=ll+` `+sl,Fl=sl+` `+hl,Il=`Windows`,Ll=Il+` Phone`,Rl=`Nokia`,zl=`Ouya`,Bl=`Generic`,Vl=Bl+` `+sl.toLowerCase(),Hl=Bl+` `+ul.toLowerCase(),Ul=`Konqueror`,Wl=`(\\d+(\\.\\d+)?)`,Gl=RegExp(`Version/`+Wl),Kl=new RegExp(Nl,`i`),ql=RegExp(Ml+` \\w+`,`i`),Jl=RegExp(jl+` \\w+`,`i`),Yl=RegExp(gl+`|PlayBook|BB10`,`i`),Xl={"NT3.51":`NT 3.11`,"NT4.0":`NT 4.0`,"5.0":`2000`,5.1:`XP`,5.2:`XP`,"6.0":`Vista`,6.1:`7`,6.2:`8`,6.3:`8.1`,6.4:`10`,"10.0":`10`},Zl=function(e,t){return t||=``,V(e,` OPR/`)&&V(e,`Mini`)?El:V(e,` OPR/`)?Tl:Yl.test(e)?gl:V(e,`IE`+sl)||V(e,`WPDesktop`)?wl:V(e,vl)?yl:V(e,Dl)||V(e,`Edg/`)?Ol:V(e,`FBIOS`)?`Facebook `+sl:V(e,`UCWEB`)||V(e,`UCBrowser`)?`UC Browser`:V(e,`CriOS`)?Sl:V(e,`CrMo`)||V(e,bl)?bl:V(e,ll)&&V(e,hl)?Pl:V(e,`FxiOS`)?Al:V(e.toLowerCase(),Ul.toLowerCase())?Ul:((e,t)=>t&&V(t,pl)||function(e){return V(e,hl)&&!V(e,bl)&&!V(e,ll)}(e))(e,t)?V(e,sl)?Fl:hl:V(e,kl)?kl:V(e,`MSIE`)||V(e,`Trident/`)?Cl:V(e,`Gecko`)?kl:``},Ql={[wl]:[RegExp(`rv:`+Wl)],[Ol]:[RegExp(Dl+`?\\/`+Wl)],[bl]:[RegExp(`(`+bl+`|CrMo)\\/`+Wl)],[Sl]:[RegExp(`CriOS\\/`+Wl)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+Wl)],[hl]:[Gl],[Fl]:[Gl],[Tl]:[RegExp(`(Opera|OPR)\\/`+Wl)],[kl]:[RegExp(kl+`\\/`+Wl)],[Al]:[RegExp(`FxiOS\\/`+Wl)],[Ul]:[RegExp(`Konqueror[:/]?`+Wl,`i`)],[gl]:[RegExp(gl+` `+Wl),Gl],[Pl]:[RegExp(`android\\s`+Wl,`i`)],[yl]:[RegExp(vl+`\\/`+Wl)],[Cl]:[RegExp(`(rv:|MSIE )`+Wl)],Mozilla:[RegExp(`rv:`+Wl)]},$l=function(e,t){var n=Ql[Zl(e,t)];if(U(n))return null;for(var r=0;n.length>r;r++){var i=e.match(n[r]);if(i)return parseFloat(i[i.length-2])}return null},eu=[[RegExp(Nl+`; `+Nl+` (.*?)[);]`,`i`),e=>[Nl,e&&e[1]||``]],[new RegExp(jl,`i`),[jl,``]],[new RegExp(Ml,`i`),[Ml,``]],[Yl,[gl,``]],[new RegExp(Il,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ll,``];if(new RegExp(sl).test(t)&&!/IEMobile\b/.test(t))return[Il+` `+sl,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=Xl[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[Il,r]}return[Il,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[cl,[e[3],e[4],e[5]||`0`].join(`.`)]:[cl,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=U(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+ll+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+ll+`)`,`i`),e=>e&&e[2]?[ll,[e[2],e[3],e[4]||`0`].join(`.`)]:[ll,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[xl,``]],[/Linux|debian/i,[`Linux`,``]]],tu=function(e){return Jl.test(e)?jl:ql.test(e)?Ml:Kl.test(e)?Nl:new RegExp(zl,`i`).test(e)?zl:RegExp(`(`+Ll+`|WPDesktop)`,`i`).test(e)?Ll:/iPad/.test(e)?fl:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ml:Yl.test(e)?gl:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Rl,`i`).test(e)?Rl:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(sl).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ll:dl:RegExp(`(pda|`+sl+`)`,`i`).test(e)?Vl:new RegExp(ul,`i`).test(e)&&!RegExp(ul+` pc`,`i`).test(e)?Hl:``},nu=e=>e instanceof Error;function ru(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return ol&&n.length===al||(al=n.length,ol=n.reduce(((n,r)=>{il||={};var i=il[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,il[r]=[s,c];break}}return n}),{})),ol}}var iu=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return kc((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&H(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),B({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return kc((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,B({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:ru(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return B({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},au=`?`;function ou(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?au:n,in_app:!0};return U(r)||(a.lineno=r),U(i)||(a.colno=i),a}var su=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?au:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},cu=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,lu=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,uu=/\((\S*)(?::(\d+))(?::(\d+))\)/,du=(e,t)=>{var n=cu.exec(e);if(n){var[,r,i,a]=n;return ou(t,r,au,+i,+a)}var o=lu.exec(e);if(o){if(o[2]&&o[2].indexOf(`eval`)===0){var s=uu.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}var[c,l]=su(o[1]||au,o[2]);return ou(t,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},fu=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pu=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,mu=(e,t)=>{var n=fu.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=pu.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||au;return[a,i]=su(a,i),ou(t,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},hu=/\(error: (.*)\)/,gu=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=W(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){var t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?t+`: `+e.message:t}isDOMException(e){return Zc(e,`DOMException`)}isDOMError(e){return Zc(e,`DOMError`)}},_u=class{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},vu=class{constructor(){}match(e){return Zc(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},yu=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,bu=class{match(e){return typeof e==`string`}coerce(e,t){var[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(yu);return r&&(t=r[1],n=r[2]),[t,n]}},xu=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function Su(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var Cu=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return Qc(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+Su(e)}isSeverityLevel(e){return W(e)&&!Uc(e)&&xu.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(nu(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},wu=class{match(e){return Qc(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+Su(e),stack:t.syntheticException?.stack,synthetic:!0}}},Tu=class{match(e){return Xc(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},Eu=class{match(e){return Zc(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Qc(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return Xc(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},Du=function(e,t){var{debugEnabled:n}=t===void 0?{}:t,r={C(t){if(L&&(Dc.DEBUG||z.POSTHOG_DEBUG||n)&&!U(L.console)&&L.console){for(var r=(`__rrweb_original__`in L.console[t])?L.console[t].__rrweb_original__:L.console[t],i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];r(e,...a)}},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`error`,...t)},critical(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];console.error(e,...n)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling `+e)},createLogger:(t,n)=>Du(e+` `+t,n)};return r},K=Du(`[PostHog.js]`),q=K.createLogger,Ou=q(`[ExternalScriptsLoader]`),ku=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Ou.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var r=R?.querySelectorAll(`script`);if(r){for(var i,a=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener(`load`,(t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)})),e.onerror=e=>n(e),{v:void 0})}},o=0;r.length>o;o++)if(i=a())return i.v}var s=()=>{if(!R)return n(`document not found`);var r=R.createElement(`script`);if(r.type=`text/javascript`,r.crossOrigin=`anonymous`,r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)},r.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)R.head.appendChild(r);else{var i,a=R.querySelectorAll(`body > script`);a.length>0?(i=a[0].parentNode)==null||i.insertBefore(r,a[0]):R.body.appendChild(r)}};R!=null&&R.body?s():R?.addEventListener(`DOMContentLoaded`,s)};z.__PosthogExtensions__=z.__PosthogExtensions__||{},z.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r;if(e.config.__preview_external_dependency_versioned_paths)r=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`);else{var i=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var a=3e5;i=i+`&t=`+Math.floor(Date.now()/a)*a}r=e.requestRouter.endpointFor(`assets`,i)}ku(e,r,n)}else ku(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},z.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{ku(e,e.requestRouter.endpointFor(`api`,t),n)};var Au=`$people_distinct_id`,ju=`$device_id`,Mu=`__alias`,Nu=`__timers`,Pu=`$autocapture_disabled_server_side`,Fu=`$heatmaps_enabled_server_side`,Iu=`$exception_capture_enabled_server_side`,Lu=`$error_tracking_suppression_rules`,Ru=`$error_tracking_capture_extension_exceptions`,zu=`$web_vitals_enabled_server_side`,Bu=`$dead_clicks_enabled_server_side`,Vu=`$product_tours_enabled_server_side`,Hu=`$web_vitals_allowed_metrics`,Uu=`$session_recording_remote_config`,Wu=`$sesid`,Gu=`$session_is_sampled`,Ku=`$enabled_feature_flags`,qu=`$early_access_features`,Ju=`$feature_flag_details`,Yu=`$feature_flag_payloads`,Xu=`$override_feature_flag_payloads`,Zu=`$stored_person_properties`,Qu=`$stored_group_properties`,$u=`$surveys`,ed=`ph_product_tours`,td=`$flag_call_reported`,nd=`$flag_call_reported_session_id`,rd=`$feature_flag_errors`,id=`$feature_flag_evaluated_at`,ad=`$user_state`,od=`$client_session_props`,sd=`$capture_rate_limit`,cd=`$initial_campaign_params`,ld=`$initial_referrer_info`,ud=`$initial_person_info`,dd=`$epp`,fd=`__POSTHOG_TOOLBAR__`,pd=`$posthog_cookieless`,md=[Au,Mu,`__cmpns`,Nu,`$session_recording_enabled_server_side`,Fu,Wu,Ku,Lu,ad,qu,Ju,Qu,Zu,$u,td,nd,rd,id,od,sd,cd,ld,dd,ud,ed,`$product_tours_activated`,Vu,Uu,Xu],hd=`PostHog loadExternalDependency extension not found.`,gd=`on_reject`,_d=`always`,vd=`anonymous`,yd=`identified`,bd=`identified_only`,xd=`visibilitychange`,Sd=`beforeunload`,Cd=`$pageview`,wd=`$pageleave`,Td=`$identify`,Ed=`$groupidentify`;function Dd(e,t){H(e)&&e.forEach(t)}function J(e,t){if(!G(e))if(H(e))e.forEach(t);else if(Jc(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)Rc.call(e,n)&&t(e[n],n)}var Y=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function Od(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var kd=function(e){try{return e()}catch{return}},Ad=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){K.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),K.critical(e)}}},jd=function(e){var t={};return J(e,(function(e,n){(W(e)&&e.length>0||Gc(e))&&(t[n]=e)})),t},Md=[`herokuapp.com`,`vercel.app`,`netlify.app`];function Nd(e){var t=e?.hostname;if(!W(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of Md)if(n===r)return!1;return!0}function X(e,t,n,r){var{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function Pd(e){return e.name===`ph_toolbar_internal`}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Gc(e)&&isFinite(e)&&Math.floor(e)===e});var Fd=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},Id=class{constructor(){this.I=0,this.S=0,this.k=new zd}generate(){var e=this.generateOrAbort();if(U(e)){this.I=0;var t=this.generateOrAbort();if(U(t))throw Error(`Could not generate UUID after timestamp reset`);return t}return e}generateOrAbort(){var e=Date.now();if(e>this.I)this.I=e,this.A();else{if(this.I>=e+1e4)return;this.S++,this.S>4398046511103&&(this.I++,this.A())}return Fd.fromFieldsV7(this.I,Math.trunc(this.S/2**30),this.S&2**30-1,this.k.nextUint32())}A(){this.S=1024*this.k.nextUint32()+(1023&this.k.nextUint32())}},Ld,Rd=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};L&&!U(L.crypto)&&crypto.getRandomValues&&(Rd=e=>crypto.getRandomValues(e));var zd=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(Rd(this.T),this.N=0),this.T[this.N++]}},Bd=()=>Vd().toString(),Vd=()=>(Ld||=new Id).generate(),Hd=``,Ud=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Wd={Ut:()=>!!R,Yt(e){K.error(`cookieStore error: `+e)},Gt(e){if(R){try{for(var t=e+`=`,n=R.cookie.split(`;`).filter((e=>e.length)),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==` `;)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},Wt(e){var t;try{t=JSON.parse(Wd.Gt(e))||{}}catch{}return t},Xt(e,t,n,r,i){if(R)try{var a=``,o=``,s=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=R),Hd)return Hd;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+Bd();!Hd&&r--;){var a=n.slice(r).join(`.`),o=i+`=1;domain=.`+a+`;path=/`;t.cookie=o+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=o+`;max-age=0`,Hd=a)}return Hd}(e);if(!n){var r=(e=>{var t=e.match(Ud);return t?t[0]:``})(e);r!==n&&K.info(`Warning: cookie subdomain discovery mismatch`,r,n),n=r}return n?`; domain=.`+n:``}return``}(R.location.hostname,r);if(n){var c=new Date;c.setTime(c.getTime()+864e5*n),a=`; expires=`+c.toUTCString()}i&&(o=`; secure`);var l=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return l.length>3686.4&&K.warn(`cookieStore warning: large cookie, len=`+l.length),R.cookie=l,l}catch{return}},Jt(e,t){if(R!=null&&R.cookie)try{Wd.Xt(e,``,-1,t)}catch{return}}},Gd=null,Z={Ut(){if(!Wc(Gd))return Gd;var e=!0;if(U(L))e=!1;else try{var t=`__mplssupport__`;Z.Xt(t,`xyz`),Z.Gt(t)!==`"xyz"`&&(e=!1),Z.Jt(t)}catch{e=!1}return e||K.error(`localStorage unsupported; falling back to cookie store`),Gd=e,e},Yt(e){K.error(`localStorage error: `+e)},Gt(e){try{return L?.localStorage.getItem(e)}catch(e){Z.Yt(e)}return null},Wt(e){try{return JSON.parse(Z.Gt(e))||{}}catch{}return null},Xt(e,t){try{L?.localStorage.setItem(e,JSON.stringify(t))}catch(e){Z.Yt(e)}},Jt(e){try{L?.localStorage.removeItem(e)}catch(e){Z.Yt(e)}}},Kd=[ju,`distinct_id`,Wu,Gu,dd,ud,ad],qd={},Jd={Ut:()=>!0,Yt(e){K.error(`memoryStorage error: `+e)},Gt:e=>qd[e]||null,Wt:e=>qd[e]||null,Xt(e,t){qd[e]=t},Jt(e){delete qd[e]}},Yd=null,Xd={Ut(){if(!Wc(Yd))return Yd;if(Yd=!0,U(L))Yd=!1;else try{var e=`__support__`;Xd.Xt(e,`xyz`),Xd.Gt(e)!==`"xyz"`&&(Yd=!1),Xd.Jt(e)}catch{Yd=!1}return Yd},Yt(e){K.error(`sessionStorage error: `,e)},Gt(e){try{return L?.sessionStorage.getItem(e)}catch(e){Xd.Yt(e)}return null},Wt(e){try{return JSON.parse(Xd.Gt(e))||null}catch{}return null},Xt(e,t){try{L?.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Xd.Yt(e)}},Jt(e){try{L?.sessionStorage.removeItem(e)}catch(e){Xd.Yt(e)}}},Zd=class{constructor(e){this._instance=e}get Rt(){return this._instance.config}get consent(){return this.Kt()?0:this.Qt}isOptedOut(){return this.Rt.cookieless_mode===_d||this.isRejected()||this.consent===-1&&this.Rt.cookieless_mode===gd}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Rt.opt_out_capturing_by_default}optInOut(e){this.ti.Xt(this.ei,+!!e,this.Rt.cookie_expiration,this.Rt.cross_subdomain_cookie,this.Rt.secure_cookie)}reset(){this.ti.Jt(this.ei,this.Rt.cross_subdomain_cookie)}get ei(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get Qt(){var e=this.ti.Gt(this.ei);return el(e)?1:V(tl,e)?0:-1}get ti(){var e=this.Rt.opt_out_capturing_persistence_type,t=e===`localStorage`?Z:Wd;if(!this.ii||this.ii!==t){this.ii=t;var n=e===`localStorage`?Wd:Z;n.Gt(this.ei)&&(this.ii.Gt(this.ei)||this.optInOut(el(n.Gt(this.ei))),n.Jt(this.ei,this.Rt.cross_subdomain_cookie))}return this.ii}Kt(){return!!this.Rt.respect_dnt&&[yc?.doNotTrack,yc?.msDoNotTrack,z.doNotTrack].some((e=>el(e)))}},Qd=q(`[Dead Clicks]`),$d=()=>!0,ef=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Bu)),r=e.instance.config.capture_dead_clicks;return qc(r)?r:!!Vc(r)||n},tf=class{get lazyLoadedDeadClicksAutocapture(){return this.ri}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){`captureDeadClicks`in e&&(this.instance.persistence&&this.instance.persistence.register({[Bu]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.ni((()=>{this.si()})):this.stop()}ni(e){var t,n;(t=z.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(n=z.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?Qd.error(`failed to load script`,t):e()}))}si(){var e;if(R){if(!this.ri&&(e=z.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Vc(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.ri=z.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ri.start(R),Qd.info(`starting...`)}}else Qd.error("`document` not found. Cannot start.")}stop(){this.ri&&(this.ri.stop(),this.ri=void 0,Qd.info(`stopping...`))}},nf=q(`[SegmentIntegration]`),rf=`posthog-js`;function af(e,t){var{organization:n,projectId:r,prefix:i,severityAllowList:a=[`error`],sendExceptionsToPostHog:o=!0}=t===void 0?{}:t;return t=>{if(a!==`*`&&!a.includes(t.level)||!e.__loaded)return t;t.tags||={};var s=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var c,l=t.exception?.values||[],u=l.map((e=>B({},e,{stacktrace:e.stacktrace?B({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>B({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:l[0]?.value||t.message,$exception_type:l[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:l[0]?.value||t.message,$sentry_exception_type:l[0]?.type,$sentry_tags:t.tags};return n&&r&&(d.$sentry_url=(i||`https://sentry.io/organizations/`)+n+`/issues/?project=`+r+`&query=`+t.event_id),o&&((c=e.exceptions)==null||c.sendExceptionEvent(d)),t}}var of=class{constructor(e,t,n,r,i,a){this.name=rf,this.setupOnce=function(o){o(af(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},sf=class{constructor(e){this.oi=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(K.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.ai=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.li()}li(){this.ui=this._instance.sessionManager?.onSessionId(this.oi)}destroy(){var e;(e=this.ui)==null||e.call(this),this.ui=void 0}doPageView(e,t){var n=this.hi(e,t);return this.ai={pathname:L?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.hi(e,this.ai?.pageViewId)}doEvent(){return{$pageview_id:this.ai?.pageViewId}}hi(e,t){var n=this.ai;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:s,maxContentHeight:c,lastContentY:l,maxContentY:u}=i;if(!(U(a)||U(o)||U(s)||U(c)||U(l)||U(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?nl(o/a,0,1,K):1,f=a>1?nl(s/a,0,1,K):1,p=c>1?nl(l/c,0,1,K):1,m=c>1?nl(u/c,0,1,K):1;r=Y(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},cf=e=>{var t=R?.createElement(`a`);return U(t)?null:(t.href=e,t)},lf=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);if(a[0]===t){n=a;break}}if(!H(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{K.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},uf=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);H(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},df=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},ff=`https?://(.*)`,pf=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],mf=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...pf],hf=`<masked>`,gf=[`li_fat_id`];function _f(e,t,n){if(!R)return{};var r,i=t?[...pf,...n||[]]:[],a=vf(uf(R.URL,i,hf),e);return Y((r={},J(gf,(function(e){var t=Wd.Gt(e);r[e]=t||null})),r),a)}function vf(e,t){var n=mf.concat(t||[]),r={};return J(n,(function(t){r[t]=lf(e,t)||null})),r}function yf(e){var t=function(e){return e?e.search(ff+`google.([^/?]*)`)===0?`google`:e.search(ff+`bing.com`)===0?`bing`:e.search(ff+`yahoo.com`)===0?`yahoo`:e.search(ff+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!Wc(t)){r.$search_engine=t;var i=R?lf(R.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function bf(){return navigator.language||navigator.userLanguage}var xf=`$direct`;function Sf(){return R?.referrer||xf}function Cf(e,t){var n=e?[...pf,...t||[]]:[],r=bc?.href.substring(0,1e3);return{r:Sf().substring(0,1e3),u:r?uf(r,n,hf):void 0}}function wf(e){var{r:t,u:n}=e,r={$referrer:t,$referring_domain:t==null?void 0:t==xf?xf:cf(t)?.host};if(n){r.$current_url=n;var i=cf(n);r.$host=i?.host,r.$pathname=i?.pathname,Y(r,vf(n))}return t&&Y(r,yf(t)),r}function Tf(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ef(){try{return new Date().getTimezoneOffset()}catch{return}}var Df=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Of=class{constructor(e,t){this.Rt=e,this.props={},this.ci=!1,this.di=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(e),this.ti=this.vi(e),this.load(),e.debug&&K.info(`Persistence loaded`,e.persistence,B({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.fi}vi(e){Df.indexOf(e.persistence.toLowerCase())===-1&&(K.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);var t=function(e){e===void 0&&(e=[]);var t=[...Kd,...e];return B({},Z,{Wt(e){try{var t={};try{t=Wd.Wt(e)||{}}catch{}var n=Y(t,JSON.parse(Z.Gt(e)||`{}`));return Z.Xt(e,n),n}catch{}return null},Xt(e,n,r,i,a,o){try{Z.Xt(e,n,void 0,void 0,o);var s={};t.forEach((e=>{n[e]&&(s[e]=n[e])})),Object.keys(s).length&&Wd.Xt(e,s,r,i,a,o)}catch(e){Z.Yt(e)}},Jt(e,t){try{L?.localStorage.removeItem(e),Wd.Jt(e,t)}catch(e){Z.Yt(e)}}})}(e.cookie_persisted_properties||[]),n=e.persistence.toLowerCase();return n===`localstorage`&&Z.Ut()?Z:n===`localstorage+cookie`&&t.Ut()?t:n===`sessionstorage`&&Xd.Ut()?Xd:n===`memory`?Jd:n===`cookie`?Wd:t.Ut()?t:Wd}pi(e){var t=e??this.Rt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[id];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return J(this.props,((t,n)=>{if(n===Ku&&Vc(t)){if(!this.pi())for(var r=Object.keys(t),i=0;r.length>i;i++)e[`$feature/`+r[i]]=t[r[i]]}else md.indexOf(n)===-1&&(e[n]=t)})),e}load(){if(!this.fi){var e=this.ti.Wt(this.di);e&&(this.props=Y({},e))}}save(){this.fi||this.ti.Xt(this.di,this.props,this.gi,this.mi,this.yi,this.Rt.debug)}remove(){this.ti.Jt(this.di,!1),this.ti.Jt(this.di,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(Vc(e)){U(t)&&(t=`None`),this.gi=U(n)?this.bi:n;var r=!1;if(J(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.props[n]=e,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(Vc(e)){this.gi=U(t)?this.bi:t;var n=!1;if(J(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.ci){var e=_f(this.Rt.custom_campaign_params,this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties);Hc(jd(e))||this.register(e),this.ci=!0}}update_search_keyword(){var e;this.register((e=R?.referrer)?yf(e):{})}update_referrer_info(){this.register_once({$referrer:Sf(),$referring_domain:R!=null&&R.referrer&&cf(R.referrer)?.host||xf},void 0)}set_initial_person_info(){this.props[cd]||this.props[ld]||this.register_once({[ud]:Cf(this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};J([ld,cd],(t=>{var n=this.props[t];n&&J(n,(function(t,n){e[`$initial_`+Ic(n)]=t}))}));var t,n,r=this.props[ud];return r&&Y(e,(t=wf(r),n={},J(t,(function(e,t){n[`$initial_`+Ic(t)]=e})),n)),e}safe_merge(e){return J(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){if(this.bi=this.gi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.vi(e),i=this.props;this.clear(),this.ti=r,this.props=i,this.save()}}set_disabled(e){this.fi=e,this.fi?this.remove():this.save()}set_cross_subdomain(e){e!==this.mi&&(this.mi=e,this.remove(),this.save())}set_secure(e){e!==this.yi&&(this.yi=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[Nu]||{};n[e]=t,this.props[Nu]=n,this.save()}remove_event_timer(e){var t=(this.props[Nu]||{})[e];return U(t)||(delete this.props[Nu][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},kf={Activation:`events`,Cancellation:`cancelEvents`},Af={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},jf={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},Mf={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`},Nf={Popover:`popover`,Inline:`inline`},Pf={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},Ff={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},If=q(`[RateLimiter]`),Lf=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{If.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){If.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(sd)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;return o||e||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(sd,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Rf=q(`[RemoteConfig]`),zf=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=z._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}wi(e){var t,n;(t=z.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=z.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Ii(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/`+this._instance.config.token+`/config`),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return Rf.info(`Using preloaded remote config`,this.remoteConfig),this.Ci(this.remoteConfig),void this.Si();if(this._instance.ki())return void Rf.warn(`Remote config is disabled. Falling back to local config.`);this.wi((e=>{if(!e)return Rf.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Ii((e=>{this.Ci(e),this.Si()}));this.Ci(e),this.Si()}))}catch(e){Rf.error(`Error loading remote config`,e)}}stop(){this.xi&&=(clearInterval(this.xi),void 0)}refresh(){this._instance.ki()||R?.visibilityState===`hidden`||this._instance.reloadFeatureFlags()}Si(){if(!this.xi){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.xi=setInterval((()=>{this.refresh()}),e))}}Ci(e){var t;e||Rf.error(`Failed to fetch remote config from PostHog.`),this._instance.Ci(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},Bf={GZipJS:`gzip-js`,Base64:`base64`},Vf=Uint8Array,Hf=Uint16Array,Uf=Uint32Array,Wf=new Vf([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Gf=new Vf([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Kf=new Vf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qf=function(e,t){for(var n=new Hf(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Uf(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},Jf=qf(Wf,2),Yf=Jf[1];Jf[0][28]=258,Yf[258]=28;for(var Xf=qf(Gf,0)[1],Zf=new Hf(32768),Q=0;32768>Q;++Q){var Qf=(43690&Q)>>>1|(21845&Q)<<1;Zf[Q]=((65280&(Qf=(61680&(Qf=(52428&Qf)>>>2|(13107&Qf)<<2))>>>4|(3855&Qf)<<4))>>>8|(255&Qf)<<8)>>>1}var $f=function(e,t,n){for(var r=e.length,i=0,a=new Hf(t);r>i;++i)++a[e[i]-1];var o,s=new Hf(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new Hf(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[Zf[d]>>>c]=l}else for(o=new Hf(r),i=0;r>i;++i)o[i]=Zf[s[e[i]-1]++]>>>15-e[i];return o},ep=new Vf(288);for(Q=0;144>Q;++Q)ep[Q]=8;for(Q=144;256>Q;++Q)ep[Q]=9;for(Q=256;280>Q;++Q)ep[Q]=7;for(Q=280;288>Q;++Q)ep[Q]=8;var tp=new Vf(32);for(Q=0;32>Q;++Q)tp[Q]=5;var np=$f(ep,9,0),rp=$f(tp,5,0),ip=function(e){return(e/8>>0)+(7&e&&1)},ap=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Hf?Hf:e instanceof Uf?Uf:Vf)(n-t);return r.set(e.subarray(t,n)),r},op=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},sp=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},cp=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new Vf(0),0];if(i==1){var o=new Vf(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new Hf(f+1),m=lp(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var ee=a[r].s;p[ee]==t&&(--p[ee],++h)}m=t}return[new Vf(p),m]},lp=function(e,t,n){return e.s==-1?Math.max(lp(e.l,t,n+1),lp(e.r,t,n+1)):t[e.s]=n},up=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Hf(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},dp=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},fp=function(e,t,n){var r=n.length,i=ip(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},pp=function(e,t,n,r,i,a,o,s,c,l,u){op(t,u++,n),++i[256];for(var d=cp(i,15),f=d[0],p=d[1],m=cp(a,15),h=m[0],g=m[1],_=up(f),v=_[0],y=_[1],ee=up(h),b=ee[0],te=ee[1],ne=new Hf(19),x=0;v.length>x;++x)ne[31&v[x]]++;for(x=0;b.length>x;++x)ne[31&b[x]]++;for(var re=cp(ne,7),ie=re[0],ae=re[1],oe=19;oe>4&&!ie[Kf[oe-1]];--oe);var se,S,C,ce,le=l+5<<3,ue=dp(i,ep)+dp(a,tp)+o,de=dp(i,f)+dp(a,h)+o+14+3*oe+dp(ne,ie)+(2*ne[16]+3*ne[17]+7*ne[18]);if(ue>=le&&de>=le)return fp(t,u,e.subarray(c,c+l));if(op(t,u,1+(ue>de)),u+=2,ue>de){se=$f(f,p,0),S=f,C=$f(h,g,0),ce=h;var fe=$f(ie,ae,0);for(op(t,u,y-257),op(t,u+5,te-1),op(t,u+10,oe-4),u+=14,x=0;oe>x;++x)op(t,u+3*x,ie[Kf[x]]);u+=3*oe;for(var pe=[v,b],me=0;2>me;++me){var he=pe[me];for(x=0;he.length>x;++x)op(t,u,fe[ge=31&he[x]]),u+=ie[ge],ge>15&&(op(t,u,he[x]>>>5&127),u+=he[x]>>>12)}}else se=np,S=ep,C=rp,ce=tp;for(x=0;s>x;++x)if(r[x]>255){var ge;sp(t,u,se[257+(ge=r[x]>>>18&31)]),u+=S[ge+257],ge>7&&(op(t,u,r[x]>>>23&31),u+=Wf[ge]);var _e=31&r[x];sp(t,u,C[_e]),u+=ce[_e],_e>3&&(sp(t,u,r[x]>>>5&8191),u+=Gf[_e])}else sp(t,u,se[r[x]]),u+=S[r[x]];return sp(t,u,se[256]),u+S[256]},mp=new Uf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),hp=function(){for(var e=new Uf(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),gp=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function _p(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=hp[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new Vf(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=fp(c,l,e.subarray(u,d)):(c[u]=!0,l=fp(c,l,e.subarray(u,o)))}else{for(var f=mp[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new Hf(32768),_=new Hf(h+1),v=Math.ceil(n/3),y=2*v,ee=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},b=new Uf(25e3),te=new Hf(288),ne=new Hf(32),x=0,re=0,ie=(u=0,0),ae=0,oe=0;o>u;++u){var se=ee(u),S=32767&u,C=_[se];if(g[S]=C,_[se]=S,u>=ae){var ce=o-u;if((x>7e3||ie>24576)&&ce>423){l=pp(e,c,0,b,te,ne,re,ie,oe,u-oe,l),ie=x=re=0,oe=u;for(var le=0;286>le;++le)te[le]=0;for(le=0;30>le;++le)ne[le]=0}var ue=2,de=0,fe=m,pe=S-C&32767;if(ce>2&&se==ee(u-pe))for(var me=Math.min(p,ce)-1,he=Math.min(32767,u),ge=Math.min(258,ce);he>=pe&&--fe&&S!=C;){if(e[u+ue]==e[u+ue-pe]){for(var _e=0;ge>_e&&e[u+_e]==e[u+_e-pe];++_e);if(_e>ue){if(ue=_e,de=pe,_e>me)break;var ve=Math.min(pe,_e-2),ye=0;for(le=0;ve>le;++le){var be=u-pe+le+32768&32767,xe=be-g[be]+32768&32767;xe>ye&&(ye=xe,C=be)}}}pe+=(S=C)-(C=g[S])+32768&32767}if(de){b[ie++]=268435456|Yf[ue]<<18|Xf[de];var Se=31&Yf[ue],Ce=31&Xf[de];re+=Wf[Se]+Gf[Ce],++te[257+Se],++ne[Ce],ae=u+ue,++x}else b[ie++]=e[u],++te[e[u]]}}l=pp(e,c,!0,b,te,ne,re,ie,oe,u-oe,l)}return ap(s,0,r+ip(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&gp(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),gp(l,u-8,n.d()),gp(l,u-4,r),l}var vp=!!Sc||!!xc,yp=`text/plain`,bp=!1,xp=function(e,t,n){n===void 0&&(n=!0);var[r,i]=e.split(`?`),a=B({},t),o=i?.split(`&`).map((e=>{var t,[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],r+`=`+o}))??[],s=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return J(e,(function(e,t){U(e)||U(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(a);return s&&o.push(s),r+`?`+o.join(`&`)},Sp=(e,t)=>JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t),Cp=e=>{if(e.zt)return e.zt;var{data:t,compression:n}=e;if(t){if(n===Bf.GZipJS){var r=_p(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new Vf(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new Vf(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return ap(r,0,i)}(Sp(t)),{mtime:0});return{contentType:yp,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Bf.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Sp(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(Sp(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=Sp(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},wp=function(){var e=kc((function*(e){var t=yield function(e,t,n){return jc.apply(this,arguments)}(Sp(e.data),Dc.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return B({},e,{zt:{contentType:yp,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Tp=(e,t)=>xp(e,{_:new Date().getTime().toString(),ver:Dc.JS_SDK_VERSION,compression:t}),Ep=[];xc&&Ep.push({transport:`fetch`,method(e){var{contentType:t,body:n,estimatedSize:r}=Cp(e)??{},i=new Headers;J(e.headers,(function(e,t){i.append(t,e)})),t&&i.append(`Content-Type`,t);var a=e.url,o=null;if(Cc){var s=new Cc;o={signal:s.signal,timeout:setTimeout((()=>s.abort()),e.timeout)}}xc(a,B({method:e?.method||`GET`,headers:i,keepalive:e.method===`POST`&&52428.8>(r||0),body:n,signal:o?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){K.error(e)}e.callback==null||e.callback(r)})))).catch((t=>{K.error(t),e.callback==null||e.callback({statusCode:0,error:t})})).finally((()=>o?clearTimeout(o.timeout):null))}}),Sc&&Ep.push({transport:`XHR`,method(e){var t=new Sc;t.open(e.method||`GET`,e.url,!0);var{contentType:n,body:r}=Cp(e)??{};J(e.headers,(function(e,n){t.setRequestHeader(n,e)})),n&&t.setRequestHeader(`Content-Type`,n),e.timeout&&(t.timeout=e.timeout),e.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}e.callback==null||e.callback(n)}},t.send(r)}}),yc!=null&&yc.sendBeacon&&Ep.push({transport:`sendBeacon`,method(e){var t=xp(e.url,{beacon:`1`});try{var{contentType:n,body:r}=Cp(e)??{};if(!r)return;var i=r instanceof Blob?r:new Blob([r],{type:n});yc.sendBeacon(t,i)}catch{}}});var Dp=3e3,Op=class{constructor(e,t){this.Ti=!0,this.Ai=[],this.Ei=nl(t?.flush_interval_ms||Dp,250,5e3,K.createLogger(`flush interval`),Dp),this.Ri=e}enqueue(e){this.Ai.push(e),this.Ni||this.Mi()}unload(){this.Fi();var e=this.Ai.length>0?this.Oi():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Ri(B({},e,{transport:`sendBeacon`}))}))}enable(){this.Ti=!1,this.Mi()}Mi(){var e=this;this.Ti||(this.Ni=setTimeout((()=>{if(this.Fi(),this.Ai.length>0){var t=this.Oi(),n=function(){var n=t[r],i=new Date().getTime();n.data&&H(n.data)&&J(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.Ri(n)};for(var r in t)n()}}),this.Ei))}Fi(){clearTimeout(this.Ni),this.Ni=void 0}Oi(){var e={};return J(this.Ai,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;U(e[i])&&(e[i]=B({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Ai=[],e}},kp=[`retriesPerformedSoFar`],Ap=class{constructor(e){this.Pi=!1,this.Li=3e3,this.Ai=[],this._instance=e,this.Ai=[],this.Di=!0,!U(L)&&`onLine`in L.navigator&&(this.Di=L.navigator.onLine,this.Bi=()=>{this.Di=!0,this.ji()},this.qi=()=>{this.Di=!1},X(L,`online`,this.Bi),X(L,`offline`,this.qi))}get length(){return this.Ai.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=Ac(e,kp);Kc(t)&&(n.url=xp(n.url,{retry_count:t})),this._instance._send_request(B({},n,{callback:e=>{e.statusCode===200||e.statusCode>=400&&500>e.statusCode||(t??0)>=10?n.callback==null||n.callback(e):this.Zi(B({retriesPerformedSoFar:t},n))}}))}Zi(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.Ai.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),K.warn(i),this.Pi||(this.Pi=!0,this.$i())}$i(){if(this.Vi&&clearTimeout(this.Vi),this.Ai.length===0)return this.Pi=!1,void(this.Vi=void 0);this.Vi=setTimeout((()=>{this.Di&&this.Ai.length>0&&this.ji(),this.$i()}),this.Li)}ji(){var e=Date.now(),t=[],n=this.Ai.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Ai=t,n.length>0)for(var{requestOptions:r}of n)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Vi&&=(clearTimeout(this.Vi),void 0),this.Pi=!1,U(L)||(this.Bi&&=(L.removeEventListener(`online`,this.Bi),void 0),this.qi&&=(L.removeEventListener(`offline`,this.qi),void 0)),this.Ai))try{this._instance._send_request(B({},e,{transport:`sendBeacon`}))}catch(e){K.error(e)}this.Ai=[]}},jp=class{constructor(e){this.Hi=()=>{this.zi||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.zi.lastScrollY=Math.ceil(t),this.zi.maxScrollY=Math.max(t,this.zi.maxScrollY??0),this.zi.maxScrollHeight=Math.max(n,this.zi.maxScrollHeight??0),this.zi.lastContentY=r,this.zi.maxContentY=Math.max(r,this.zi.maxContentY??0),this.zi.maxContentHeight=Math.max(i,this.zi.maxContentHeight??0)},this._instance=e}get Ui(){return this._instance.config.scroll_root_selector}getContext(){return this.zi}resetContext(){var e=this.zi;return setTimeout(this.Hi,0),e}startMeasuringScrollPosition(){X(L,`scroll`,this.Hi,{capture:!0}),X(L,`scrollend`,this.Hi,{capture:!0}),X(L,`resize`,this.Hi)}scrollElement(){if(!this.Ui)return L?.document.documentElement;for(var e of H(this.Ui)?this.Ui:[this.Ui]){var t=L?.document.querySelector(e);if(t)return t}}scrollY(){if(this.Ui){var e=this.scrollElement();return e&&e.scrollTop||0}return L&&(L.scrollY||L.pageYOffset||L.document.documentElement.scrollTop)||0}scrollX(){if(this.Ui){var e=this.scrollElement();return e&&e.scrollLeft||0}return L&&(L.scrollX||L.pageXOffset||L.document.documentElement.scrollLeft)||0}},Mp=e=>Cf(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties),Np=class{constructor(e,t,n,r){this.Yi=e=>{var t=this.Gi();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.Wi(this._instance)};this.Xi.register({[od]:n})}},this._instance=e,this.Ji=t,this.Xi=n,this.Wi=r||Mp,this.Ji.onSessionId(this.Yi)}Gi(){return this.Xi.props[od]}getSetOnceProps(){var e=this.Gi()?.props;return e?`r`in e?wf(e):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return J(jd(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+Ic(n)]=t})),e}},Pp=class{constructor(){this.Ki={}}on(e,t){return this.Ki[e]||(this.Ki[e]=[]),this.Ki[e].push(t),()=>{this.Ki[e]=this.Ki[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.Ki[e]||[])n(t);for(var r of this.Ki[`*`]||[])r(e,t)}},Fp=q(`[SessionId]`),Ip=class{on(e,t){return this.Qi.on(e,t)}constructor(e,t,n){var r;if(this.tr=[],this.er=void 0,this.Qi=new Pp,this.ir=(e,t)=>!(!Kc(e)||!Kc(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===_d)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Rt=e.config,this.Xi=e.persistence,this.rr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.sr=t||Bd,this.ar=n||Bd;var i=this.Rt.persistence_name||this.Rt.token;if(this._sessionTimeoutMs=1e3*nl(this.Rt.session_idle_timeout_seconds||1800,60,36e3,Fp.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur=`ph_`+i+`_window_id`,this.hr=`ph_`+i+`_primary_window_exists`,this.cr()){var a=Xd.Wt(this.ur),o=Xd.Wt(this.hr);a&&!o?this.rr=a:Xd.Jt(this.ur),Xd.Xt(this.hr,!0)}if((r=this.Rt.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Rt.bootstrap.sessionID.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})();this.dr(this.Rt.bootstrap.sessionID,new Date().getTime(),s)}catch(e){Fp.error(`Invalid sessionID in bootstrap`,e)}this.vr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return U(this.tr)&&(this.tr=[]),this.tr.push(e),this.nr&&e(this.nr,this.rr),()=>{this.tr=this.tr.filter((t=>t!==e))}}cr(){return this.Rt.persistence!==`memory`&&!this.Xi.fi&&Xd.Ut()}pr(e){e!==this.rr&&(this.rr=e,this.cr()&&Xd.Xt(this.ur,e))}gr(){return this.rr?this.rr:this.cr()?Xd.Wt(this.ur):null}dr(e,t,n){e===this.nr&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.nr=e,this.Xi.register({[Wu]:[t,e,n]}))}mr(){var e=this.Xi.props[Wu];return H(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.dr(null,null,null)}destroy(){clearTimeout(this.yr),this.yr=void 0,this.er&&L&&(L.removeEventListener(Sd,this.er,{capture:!1}),this.er=void 0),this.tr=[]}vr(){this.er=()=>{this.cr()&&Xd.Jt(this.hr)},X(L,Sd,this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Rt.cookieless_mode===_d)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),[r,i,a]=this.mr(),o=this.gr(),s=Kc(a)&&Math.abs(n-a)>864e5,c=!1,l=!i,u=!l&&!e&&this.ir(n,r);l||u||s?(i=this.sr(),o=this.ar(),Fp.info(`new session ID generated`,{sessionId:i,windowId:o,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}}),a=n,c=!0):o||(o=this.ar(),c=!0);var d=Kc(r)&&e&&!s?r:n,f=Kc(a)?a:new Date().getTime();return this.pr(o),this.dr(i,d,f),e||this.lr(),c&&this.tr.forEach((e=>e(i,o,c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0))),{sessionId:i,windowId:o,sessionStartTimestamp:f,changeReason:c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0,lastActivityTimestamp:r}}lr(){clearTimeout(this.yr),this.yr=setTimeout((()=>{var[e]=this.mr();if(this.ir(new Date().getTime(),e)){var t=this.nr;this.resetSessionId(),this.Qi.emit(`forcedIdleReset`,{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},Lp=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Pc(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>Pc(e?.brand,t))))return!0}catch{}return!!e.webdriver},Rp=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function zp(e,t,n){return Sp({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Bp={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>Rp(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Rp(t,e))))),icontains:(e,t)=>t.map(Vp).some((t=>e.map(Vp).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Vp).every((t=>e.map(Vp).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},Vp=e=>e.toLowerCase();function Hp(e,t){return!e||Object.entries(e).every((e=>{var[n,r]=e,i=t?.[n];if(U(i)||Wc(i))return!1;var a=[String(i)],o=Bp[r.operator];return!!o&&o(r.values,a)}))}var Up=`custom`,Wp=`i.posthog.com`,Gp=/^\/static\//,Kp=class{constructor(e){this.br={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+Wp,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.br[this.apiHost]||(this.br[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:Up),this.br[this.apiHost]}wr(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof t==`string`&&Gp.test(e))return t.trim().replace(/\/$/,``)||void 0}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.uiHost+t;if(e===`flags`)return this.flagsApiHost+t;if(e===`assets`){var n=this.wr(t);if(n)return``+n+t}if(this.region===Up)return this.apiHost+t;var r=Wp+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+r;case`api`:return`https://`+this.region+`.`+r}}},$=q(`[Surveys]`),qp=`seenSurvey_`,Jp=(e,t)=>{var n=`$survey_`+t+`/`+e.id;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_`+t+`/`+e.id+`/`+e.current_iteration),n},Yp=e=>((e,t)=>{var n=``+qp+t.id;return t.current_iteration&&t.current_iteration>0&&(n=``+qp+t.id+`_`+t.current_iteration),n})(0,e),Xp=[Af.Popover,Af.Widget,Af.API],Zp={ignoreConditions:!1,ignoreDelay:!1,displayType:Nf.Popover},Qp=q(`[PostHog ExternalIntegrations]`),$p={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},em=class{constructor(e){this._instance=e}ni(e,t){var n;(n=z.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return Qp.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var n,i,a;!r||(n=z.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[t]||e.ni($p[t],(()=>{var n;(n=z.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[t])==null||n.start(e._instance)})),!r&&(i=z.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[t]&&((a=z.__PosthogExtensions__)==null||(a=a.integrations)==null||(a=a[t])==null||a.stop())};for(var[n,r]of Object.entries((i=this._instance.config.integrations)??{})){var i;t(n)}}},tm,nm={},rm=0,im=()=>{},am=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,om=`Surveys module not available`,sm=`sanitize_properties is deprecated. Use before_send instead`,cm=`Invalid value for property_denylist config: `,lm=`posthog`,um=!vp&&Tc?.indexOf(`MSIE`)===-1&&Tc?.indexOf(`Mozilla`)===-1,dm=e=>{var t;return B({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,token:``,autocapture:!0,cross_subdomain_cookie:Nd(R?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:im,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:bc&&W(bc?.search)&&bc.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(L==null||(t=L.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){K.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:bd,before_send:void 0,request_queue_config:{flush_interval_ms:Dp},error_tracking:{},_onCapture:im,__preview_eager_load_replay:!1},(e=>({rageclick:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2025-11-30`?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},fm=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],pm=e=>{var t={};for(var[n,r]of fm)U(e[n])||(t[r]=e[n]);var i=Y({},t,e);return H(e.property_blacklist)&&(U(e.property_denylist)?i.property_denylist=e.property_blacklist:H(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:K.error(cm+e.property_denylist)),i},mm=class{constructor(){this.__forceAllowLocalhost=!1}get _r(){return this.__forceAllowLocalhost}set _r(e){K.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},hm=class e{Ir(e,t){if(e){var n=this.Cr.indexOf(e);n!==-1&&this.Cr.splice(n,1)}return this.Cr.push(t),t.initialize==null||t.initialize(),t}Sr(){return this.config.cookieless_mode===_d||this.config.cookieless_mode===gd&&this.consent.isRejected()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new mm,this.kr=!1,this.version=Dc.LIB_VERSION,this.Tr=new Pp,this.Cr=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=dm(),this.SentryIntegration=of,this.sentryIntegration=e=>function(e,t){var n=af(e,t);return{name:rf,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Ar=!1,this.Er=null,this.Rr=null,this.Nr=null,this.scrollManager=new jp(this),this.pageViewManager=new sf(this),this.rateLimiter=new Lf(this),this.requestRouter=new Kp(this),this.consent=new Zd(this),this.externalIntegrations=new em(this);var t=e.__defaultExtensionClasses??{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,n)=>{var r=W(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=W(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>K.info(`send "`+e?.event+`"`,e)))}init(t,n,r){if(r&&r!==lm){var i=nm[r]??new e;return i._init(t,n,r),nm[r]=i,nm[lm][r]=i,i}return this._init(t,n,r)}_init(e,t,n){var r;if(t===void 0&&(t={}),U(e)||Uc(e))return K.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`),this;this.__loaded=!0,this.config={},t.debug=this.Mr(t.debug),this.Fr=t,this.Or=[],t.person_profiles?this.Rr=t.person_profiles:t.process_person&&(this.Rr=t.process_person),this.set_config(Y({},dm(t.defaults),pm(t),{name:n,token:e})),this.config.on_xhr_error&&K.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:Bf.GZipJS;var i=this.Pr();this.persistence=new Of(this.config,i),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Of(B({},this.config,{persistence:`sessionStorage`}),i);var a=B({},this.persistence.props),o=B({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Lr=new Op((e=>this.Dr(e)),this.config.request_queue_config),this.Br=new Ap(this),this.__request_queue=[];var s=this.Sr();if(s||(this.sessionManager=new Ip(this),this.sessionPropsManager=new Np(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(K.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.jr(s)}),0)):(K.info(`Initializing extensions synchronously`),this.jr(s)),Dc.DEBUG=Dc.DEBUG||this.config.debug,Dc.DEBUG&&K.info(`Starting in debug mode`,{this:this,config:t,thisC:B({},this.config),p:a,s:o}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=B({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),t.bootstrap?.distinctID!==void 0){var c=t.bootstrap.distinctID,l=this.get_distinct_id(),u=this.persistence.get_property(ad);if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===vd)this.identify(c);else if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===yd)K.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var d=this.config.get_device_id(Bd()),f=t.bootstrap.isIdentifiedID?d:c;this.persistence.set_property(ad,t.bootstrap.isIdentifiedID?yd:vd),this.register({distinct_id:c,$device_id:f})}}if(s)this.register_once({distinct_id:pd,$device_id:null},``);else if(!this.get_distinct_id()){var p=this.config.get_device_id(Bd());this.register_once({distinct_id:p,$device_id:p},``),this.persistence.set_property(ad,vd)}return X(L,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||Bd();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(ad,yd)),t()},i=n.user();`then`in i&&Bc(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{Promise&&Promise.resolve||nf.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(nf.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(nf.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,Cd),identify:e=>t(e,Td),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.qr())):this.qr(),Bc(this.config._onCapture)&&this.config._onCapture!==im&&(K.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&K.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}jr(t){var n=performance.now(),r=B({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Cr.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Cr.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Cr.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Cr.push(new r.tracingHeaders(this)),r.siteApps&&this.Cr.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Cr.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Cr.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Cr.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Cr.push(this.logs=this.logs??new r.logs(this)),r.conversations&&this.Cr.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Cr.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Cr.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Cr.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Cr.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Cr.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,ef)),r.toolbar&&this.Cr.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Cr.push(this.experiments=this.experiments??new r.experiments(this)),this.Cr.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.Zr){var e=this.Zr;this.Zr=void 0,this.Ci(e)}})),this.$r(i,n)}$r(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.$r(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){K.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&K.info(`PostHog extensions initialized (`+r+`ms)`)}Ci(e){var t;if(!R||!R.body)return K.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Ci(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Zr=e),this.Vr=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=V(e.supportedCompression,Bf.GZipJS)?Bf.GZipJS:V(e.supportedCompression,Bf.Base64)?Bf.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Rr?this.Rr:bd}),this.Cr.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}qr(){try{this.config.loaded(this)}catch(e){K.critical("`loaded` function failed",e)}if(this.Hr(),this.config.internal_or_test_user_hostname&&bc!=null&&bc.hostname){var e=bc.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Sr())&&this.zr()}),1),this.Ur=new zf(this),this.Ur.load()}Hr(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Lr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Dd(this.__request_queue,(e=>this.Dr(e))),this.__request_queue=[],this.Hr()}_handle_unload(){var e,t,n,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Yr()&&this.capture(wd),(t=this.logs)==null||t.flushLogs(`sendBeacon`),(n=this.Lr)==null||n.unload(),(r=this.Br)==null||r.unload()):this.Yr()&&this.capture(wd,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded&&(um?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=xp(e.url,{ip:+!!this.config.ip}),e.headers=B({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=B({},e);t.timeout=t.timeout||6e4,t.url=Tp(t.url,t.compression);var n=t.transport??`fetch`,r=Ep.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),i=function(e,t){for(var r=0;e.length>r;r++)if(e[r].transport===n)return e[r]}(r)?.method??r[0].method;if(!i)throw Error(`No available transport method`);n!==`sendBeacon`&&t.data&&t.compression===Bf.GZipJS&&wc&&!bp?wp(t).then((e=>{i(e)})).catch((n=>{if((e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`)(n))return bp=!0,void i(B({},t,{compression:void 0,url:Tp(e.url,void 0)}));i(t)})):i(t)})(B({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))))}Dr(e){this.Br?this.Br.retriableRequest(e):this._send_request(e)}_execute_array(e){rm++;try{var t,n=[],r=[],i=[];Dd(e,(e=>{e&&(H(t=e[0])?i.push(e):Bc(e)?e.call(this):H(e)&&t===`alias`?n.push(e):H(e)&&t.indexOf(`capture`)!==-1&&Bc(this[t])?i.push(e):r.push(e))}));var a=function(e,t){Dd(e,(function(e){if(H(e[0])){var n=t;J(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}))};a(n,this),a(r,this),a(i,this)}finally{rm--}}push(t){if(rm>0&&H(t)&&W(t[0])){var n=e.prototype[t[0]];Bc(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(e,t,n){var r,i,a,o;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Lr){if(this.is_capturing())if(!U(e)&&W(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){t!=null&&t.$current_url&&!W(t?.$current_url)&&(K.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.Gr||K.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var l=new Date,u=n?.timestamp||l,d=Bd(),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===Cd&&this.config.__preview_capture_bot_pageviews&&s&&(f.event=`$bot_pageview`,f.properties.$browser_type=`bot`),c&&(f.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),n!=null&&n.$set&&(f.$set=n?.$set);var p,m=this.Wr(n?.$set_once,e!==Ed,e===Td);if(m&&(f.$set_once=m),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>W(e)?e.slice(0,r):e,o=new Set,f=function e(t,n){return t===Object(t)?o.has(t)?void 0:(o.add(t),H(t)?(r=[],Dd(t,(t=>{r.push(e(t))}))):(r={},J(t,((t,n)=>{o.has(t)||(r[n]=e(t,n))}))),r):a?a(t):t;var r}(i)),f.timestamp=u,U(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),e===jf.DISMISSED||e===jf.SENT){var h=t?.[Mf.SURVEY_ID],g=t?.[Mf.SURVEY_ITERATION];p={id:h,current_iteration:g},localStorage.getItem(Yp(p))||localStorage.setItem(Yp(p),`true`),f.$set=B({},f.$set,{[Jp({id:h,current_iteration:g},e===jf.SENT?`responded`:`dismissed`)]:!0})}else e===jf.SHOWN&&(f.$set=B({},f.$set,{[Mf.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Pf.SHOWN){var _=t?.[Ff.TOUR_TYPE];_&&(f.$set=B({},f.$set,{[Ff.TOUR_LAST_SEEN_DATE+`/`+_]:new Date().toISOString()}))}var v=B({},f.properties.$set,f.$set);if(Hc(v)||this.setPersonPropertiesForFlags(v),!G(this.config.before_send)){var y=this.Xr(f);if(!y)return;f=y}this.Tr.emit(`eventCaptured`,f);var ee={method:`POST`,url:n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),data:f,compression:`best-available`,batchKey:n?._batchKey};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Dr(ee):this.Lr.enqueue(ee),f}K.critical(`This capture call is ignored due to client rate limiting.`)}}else K.error(`No event name provided to posthog.capture`)}else K.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}calculateEventProperties(e,t,n,r,i){if(n||=new Date,!this.persistence||!this.sessionPersistence)return t;var a=i?void 0:this.persistence.remove_event_timer(e),o=B({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.Sr()&&(o.$cookieless_mode=!0),e===`$snapshot`){var s=B({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=s.distinct_id,(!W(o.distinct_id)&&!Gc(o.distinct_id)||Uc(o.distinct_id))&&K.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),o}var c,l=function(e,t){var n,r,i;if(!Tc)return{};var a,o,s,c,l=e?[...pf,...t||[]]:[],[u,d]=function(e){for(var t=0;eu.length>t;t++){var[n,r]=eu[t],i=n.exec(e),a=i&&(Bc(r)?r(i,e):r);if(a)return a}return[``,``]}(Tc);return Y(jd({$os:u,$os_version:d,$browser:Zl(Tc,navigator.vendor),$device:tu(Tc),$device_type:(o=Tc,s={userAgentDataPlatform:(n=navigator)==null||(n=n.userAgentData)==null?void 0:n.platform,maxTouchPoints:navigator?.maxTouchPoints,screenWidth:L==null||(r=L.screen)==null?void 0:r.width,screenHeight:L==null||(i=L.screen)==null?void 0:i.height,devicePixelRatio:L?.devicePixelRatio},c=tu(o),c===fl||c===dl||c===`Kobo`||c===`Kindle Fire`||c===Hl?ul:c===jl||c===Nl||c===Ml||c===zl?`Console`:c===ml?`Wearable`:c?sl:s?.userAgentDataPlatform===`Android`&&(s?.maxTouchPoints??0)>0?600>Math.min(s?.screenWidth??0,s?.screenHeight??0)/(s?.devicePixelRatio??1)?sl:ul:`Desktop`),$timezone:Tf(),$timezone_offset:Ef()}),{$current_url:uf(bc?.href,l,hf),$host:bc?.host,$pathname:bc?.pathname,$raw_user_agent:Tc.length>1e3?Tc.substring(0,997)+`...`:Tc,$browser_version:$l(Tc,navigator.vendor),$browser_language:bf(),$browser_language_prefix:(a=bf(),typeof a==`string`?a.split(`-`)[0]:void 0),$screen_height:L?.screen.height,$screen_width:L?.screen.width,$viewport_height:L?.innerHeight,$viewport_width:L?.innerWidth,$lib:Dc.LIB_NAME,$lib_version:Dc.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:u,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime());o.$session_id=u,o.$window_id=d}this.sessionPropsManager&&Y(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&Y(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.Br?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===Up&&(o.$lib_custom_api_host=this.config.api_host),c=e!==Cd||i?e!==wd||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=Y(o,c),e===Cd&&R&&(o.title=R.title),!U(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}Tc&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`),(o=Y({},l,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),H(this.config.property_denylist)?J(this.config.property_denylist,(function(e){delete o[e]})):K.error(cm+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(K.error(sm),o=p(o,e));var m=this.Jr();return o.$process_person_profile=m,m&&!i&&this.Kr(`_calculate_event_properties`),o}Wr(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.Jr()||this.kr&&!n)return e;var r=Y({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(K.error(sm),r=i(r,`$set_once`)),t&&(this.kr=!0),Hc(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}Qr(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.Tr.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:om}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:om})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:om})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=Zp),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:om}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:om})}tn(e){return!e||Uc(e)?(K.critical(`Unique user id has not been set in posthog.identify`),!1):e===pd?(K.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(K.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return K.uninitializedWarning(`posthog.identify`);if(Gc(e)&&(e=e.toString(),K.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.tn(e)&&this.Kr(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(ju)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Mu)&&(this.unregister(Mu),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(ad)||vd)===vd;e!==r&&a?(this.persistence.set_property(ad,yd),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(Td,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.Nr=zp(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister(td))}}setPersonProperties(e,t){if((e||t)&&this.Kr(`posthog.setPersonProperties`)){var n=zp(this.get_distinct_id(),e,t);this.Nr===n?K.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.Nr=n)}}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:B({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(Ed,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else K.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.Kr(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,n,r,i,a,o,s,c;if(K.info(`reset`),!this.__loaded)return K.uninitializedWarning(`posthog.reset`);var l=this.get_property(ju);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),(r=this.surveys)==null||r.reset(),(i=this.Ur)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.conversations)==null||o.reset(),(s=this.persistence)==null||s.set_property(ad,vd),(c=this.sessionManager)==null||c.resetSessionId(),this.Nr=null,this.config.cookieless_mode===_d)this.register_once({distinct_id:pd,$device_id:null},``);else{var u=this.config.get_device_id(Bd());this.register_once({distinct_id:u,$device_id:e?u:l},``)}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.en()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.rn()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(Au)?(K.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.Kr(`posthog.alias`)?(U(t)&&(t=this.get_distinct_id()),e===t?(K.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.Qr(Mu,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=B({},this.config);if(Vc(e)){var n,r,i,a,o,s,c,l,u;Y(this.config,pm(e));var d=this.Pr();(n=this.persistence)==null||n.update_config(this.config,t,d),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Of(B({},this.config,{persistence:`sessionStorage`}),d);var f=this.Mr(this.config.debug);qc(f)&&(this.config.debug=f),qc(this.config.debug)&&(this.config.debug?(Dc.DEBUG=!0,Z.Ut()&&Z.Xt(`ph_debug`,!0),K.info(`set_config`,{config:e,oldConfig:t,newConfig:B({},this.config)})):(Dc.DEBUG=!1,Z.Ut()&&Z.Jt(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),(s=this.exceptionObserver)==null||s.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(l=this.surveys)==null||l.loadIfEnabled(),this.nn(),(u=this.externalIntegrations)==null||u.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Dc.LIB_NAME=e,Dc.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(B({},r,t))}}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??e.sn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??lm;return e!==lm&&(e=lm+`.`+e),e}_isIdentified(){return this.persistence?.get_property(ad)===yd||this.sessionPersistence?.get_property(ad)===yd}Jr(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===bd&&!this._isIdentified()&&Hc(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Mu])&&((t=this.persistence)==null||(t=t.props)==null||!t[dd]))}Yr(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.Jr()||this.Kr(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Kr(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}Kr(e){return this.config.person_profiles===`never`?(K.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.Qr(dd,!0),!0)}Pr(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==gd)}nn(){var e,t,n=this.Pr();return this.persistence?.fi!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.fi!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==_d){if(this.Sr()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Ip(this),this.pageViewManager=new sf(this),this.persistence&&(this.sessionPropsManager=new Np(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.Ir(this.sessionRecording,new o(this)),this.Vr&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.Vr)))}var s;this.consent.optInOut(!0),this.nn(),this.Hr(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==gd&&((s=this.surveys)==null||s.loadIfEnabled()),(U(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.zr()}else K.warn(am)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===_d?K.warn(am):(this.config.cookieless_mode===gd&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.nn(),this.config.cookieless_mode===gd&&(this.register({distinct_id:pd,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.zr()))}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===_d||(this.config.cookieless_mode===gd?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.nn()}_is_bot(){return yc?Lp(yc,this.config.custom_blocked_useragents):void 0}zr(){R&&(R.visibilityState===`visible`?this.Ar||(this.Ar=!0,this.capture(Cd,{title:R.title},{send_instantly:!0}),this.Er&&=(R.removeEventListener(xd,this.Er),null)):this.Er||(this.Er=this.zr.bind(this),X(R,xd,this.Er)))}debug(e){!1===e?(L?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(L?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}ki(){var e,t,n,r,i,a,o=this.Fr||{};return`advanced_disable_flags`in o?!!o.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(K.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):(n=`advanced_disable_decide`,r=K,i=(t=`advanced_disable_flags`)in(e=o)&&!G(e[t]),a=n in e&&!G(e[n]),i?e[t]:!!a&&(r&&r.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])):!!this.config.advanced_disable_flags}Xr(e){if(G(this.config.before_send))return e;var t=H(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var r of t){if(n=r(n),G(n)){var i=`Event '`+e.event+`' was rejected in beforeSend function`;return Yc(e.event)?K.warn(i+`. This can cause unexpected behavior.`):K.info(i),null}n.properties&&!Hc(n.properties)||K.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}return n}getPageViewId(){return this.pageViewManager.ai?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Mr(e){var t=qc(e)&&!e,n=Z.Ut()&&Z.Gt(`ph_debug`)===`true`;return!t&&(!!n||e)}};function gm(e){return e instanceof Element&&(e.id===fd||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function _m(e){return!!e&&e.nodeType===1}function vm(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function ym(e){return!!e&&e.nodeType===3}function bm(e){return!!e&&e.nodeType===11}function xm(e){return e?Fc(e).split(/\s+/):[]}function Sm(e){var t=L?.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Cm(e){var t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return xm(t)}function wm(e){return G(e)?null:Fc(e).split(/(\s+)/).filter((e=>Hm(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Tm(e){var t=``;return Pm(e)&&!Fm(e)&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){ym(e)&&e.textContent&&(t+=wm(e.textContent)??``)})),Fc(t)}function Em(e){return U(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}hm.__defaultExtensionClasses={},hm.sn={trace:tm=()=>{},debug:tm,info:tm,warn:tm,error:tm,fatal:tm},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=Ad(e.prototype[t[n]])}(hm,[`identify`]);var Dm=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Om(e,t){if(U(t))return!0;var n,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function km(e){var t=e.parentNode;return!(!t||!_m(t))&&t}var Am=[`next`,`previous`,`prev`,`>`,`<`],jm=[`.ph-no-rageclick`,`.ph-no-capture`],Mm=e=>!e||vm(e,`html`)||!_m(e),Nm=(e,t)=>{if(!L||Mm(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!vm(i,`body`);)if(bm(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=km(i);if(!a)break;if(t||Dm.indexOf(a.tagName.toLowerCase())>-1)n=!0;else{var o=L.getComputedStyle(a);o&&o.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}r.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:r}};function Pm(e){for(var t=e;t.parentNode&&!vm(t,`body`);t=t.parentNode){var n=Cm(t);if(V(n,`ph-sensitive`)||V(n,`ph-no-capture`))return!1}if(V(Cm(e),`ph-include`))return!0;var r=e.type||``;if(W(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}var i=e.name||e.id||``;return!W(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function Fm(e){return!!(vm(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||vm(e,`select`)||vm(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var Im=`(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})`,Lm=RegExp(`^(?:`+Im+`)$`),Rm=new RegExp(Im),zm=`\\d{3}-?\\d{2}-?\\d{4}`,Bm=RegExp(`^(`+zm+`)$`),Vm=RegExp(`(`+zm+`)`);function Hm(e,t){return t===void 0&&(t=!0),!(G(e)||W(e)&&(e=Fc(e),(t?Lm:Rm).test((e||``).replace(/[- ]/g,``))||(t?Bm:Vm).test(e)))}function Um(e){var t=Tm(e);return Hm(t=(t+` `+Wm(e)).trim())?t:``}function Wm(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=Tm(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+Wm(e)).trim())}catch(e){K.error(`[AutoCapture]`,e)}})),t}function Gm(e){return e.replace(/"|\\"/g,`\\"`)}function Km(e){var t=e.attr__class;return t?H(t)?t:xm(t):void 0}var qm=class{constructor(e){this.disabled=!1===e;var t=Vc(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},Jm=`$copy_autocapture`,Ym=q(`[AutoCapture]`);function Xm(e,t){return t.length>e?t.slice(0,e)+`...`:t}function Zm(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!_m(t));return t}function Qm(e,t){for(var n,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:s}=t,c=[e],l=e;l.parentNode&&!vm(l,`body`);)bm(l.parentNode)?(c.push(l.parentNode.host),l=l.parentNode.host):(c.push(l.parentNode),l=l.parentNode);var u,d,f=[],p={},m=!1,h=!1;if(J(c,(e=>{var t=Pm(e);e.tagName.toLowerCase()===`a`&&(m=e.getAttribute(`href`),m=t&&m&&Hm(m)&&m),V(Cm(e),`ph-no-capture`)&&(h=!0),f.push(function(e,t,n,r){var i=e.tagName.toLowerCase(),a={tag_name:i};Dm.indexOf(i)>-1&&!n&&(a.$el_text=i.toLowerCase()===`a`||i.toLowerCase()===`button`?Xm(1024,Um(e)):Xm(1024,Tm(e)));var o=Cm(e);o.length>0&&(a.classes=o.filter((function(e){return e!==``}))),J(e.attributes,(function(n){var i;if((!Fm(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&Hm(n.value)&&(!W(i=n.name)||i.substring(0,10)!==`_ngcontent`&&i.substring(0,7)!==`_nghost`)){var o=n.value;n.name===`class`&&(o=xm(o).join(` `)),a[`attr__`+n.name]=Xm(1024,o)}}));for(var s=1,c=1,l=e;l=Zm(l);)s++,l.tagName===e.tagName&&c++;return a.nth_child=s,a.nth_of_type=c,a}(e,i,a,o)),Y(p,function(e){if(!Pm(e))return{};var t={};return J(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&Hm(r)&&(t[n]=r)}})),t}(e))})),h)return{props:{},explicitNoCapture:h};if(a||(f[0].$el_text=e.tagName.toLowerCase()===`a`||e.tagName.toLowerCase()===`button`?Um(e):Tm(e)),m){var g;f[0].attr__href=m;var _=cf(m)?.host,v=L==null||(g=L.location)==null?void 0:g.host;_&&v&&_!==v&&(u=m)}return{props:Y({$event_type:r.type,$ce_version:1},s?{}:{$elements:f},{$elements_chain:(d=f,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=B({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return Od(r).sort(((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)})).forEach((e=>{var[t,n]=e;return i[Gm(t.toString())]=Gm(n.toString())})),(t+=`:`)+Od(i).map((e=>{var[t,n]=e;return t+`="`+n+`"`})).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:Km(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Od(e).filter((e=>{var[t]=e;return t.indexOf(`attr__`)===0})).forEach((e=>{var[n,r]=e;return t.attributes[n]=r})),t}))}(d)))},(n=f[0])!=null&&n.$el_text?{$el_text:f[0]?.$el_text}:{},u&&r.type===`click`?{$external_click_url:u}:{},p)}}var $m=q(`[ExceptionAutocapture]`);function eh(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return Bc(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var th=q(`[TracingHeaders]`),nh=q(`[Web Vitals]`),rh=9e5,ih=`disabled`,ah=`lazy_loading`,oh=`awaiting_config`,sh=`missing_config`;q(`[SessionRecording]`),q(`[SessionRecording]`);var ch=`[SessionRecording]`,lh=q(ch),uh=q(`[Heatmaps]`);function dh(e){return Vc(e)&&`clientX`in e&&`clientY`in e&&Gc(e.clientX)&&Gc(e.clientY)}var fh=q(`[Product Tours]`),ph=[`$set_once`,`$set`],mh=q(`[SiteApps]`),hh=`Error while initializing PostHog app with config id `;function gh(e,t,n){if(G(e))return!1;switch(n){case`exact`:return e===t;case`contains`:var r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(r,`i`).test(e);case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var _h=class{constructor(e){this.an=new Pp,this.ln=(e,t)=>this.un(e,t)&&this.hn(e,t)&&this.cn(e,t)&&this.dn(e,t),this.un=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.vn=new Set,this.fn=new Set}init(){var e;U(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!U(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.fn)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.vn)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.vn.has(e)||this.vn.has(t?.event))&&this.fn&&this.fn?.size>0&&this.fn.forEach((e=>{this.pn(t,e)&&this.an.emit(`actionCaptured`,e.name)}))}gn(e){this.onAction(`actionCaptured`,(t=>e(t)))}pn(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.ln(e,n))return!0;return!1}onAction(e,t){return this.an.on(e,t)}hn(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!gh(r,t.url,t.url_matching||`contains`))return!1}return!0}cn(e,t){return!!this.mn(e,t)&&!!this.yn(e,t)&&!!this.bn(e,t)}mn(e,t){var n;if(t==null||!t.href)return!0;var r=this.wn(e);if(r.length>0)return r.some((e=>gh(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&gh((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}yn(e,t){var n;if(t==null||!t.text)return!0;var r=this.wn(e);if(r.length>0)return r.some((e=>gh(e.text,t.text,t.text_matching||`exact`)||gh(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!G(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>gh(e,a,o))))}bn(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}wn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}dn(e,t){return t==null||!t.properties||t.properties.length===0||Hp(t.properties.reduce(((e,t)=>{var n=H(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},vh=class{constructor(e){this._instance=e,this._n=new Map,this.In=new Map,this.Cn=new Map}Sn(e,t){return!!e&&Hp(e.propertyFilters,t?.properties)}kn(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}xn(e,t,n){var r=(n===kf.Activation?this._n:this.In).get(e),i=[];return this.Tn((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.Sn(a,t)}))}register(e){U(this._instance?._addCaptureHook)||(this.An(e),this.En(e))}En(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.Rn??(this.Rn=new _h(this._instance),this.Rn.init(),this.Rn.gn((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.Rn)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.Cn.get(t.name);n&&n.push(e.id),this.Cn.set(t.name,n||[e.id])}})))})))}An(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._n=this.kn(e,kf.Activation),this.In=this.kn(e,kf.Cancellation))}onEvent(e,t){var n,r=this.re(),i=this.Nn(),a=this.Mn(),o=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[i])||[];if(a===e&&t&&o.length>0){var s,c;r.info(`event matched, removing item from activated items`,{event:e,eventPayload:t,existingActivatedItems:o});var l=(t==null||(s=t.properties)==null?void 0:s.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(l){var u=o.indexOf(l);0>u||(o.splice(u,1),this.Fn(o))}}else{if(this.In.has(e)){var d=this.xn(e,t,kf.Cancellation);d.length>0&&(r.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:d.map((e=>e.id))}),d.forEach((e=>{var t=o.indexOf(e.id);0>t||o.splice(t,1),this.On(e.id)})),this.Fn(o))}if(this._n.has(e)){r.info(`event name matched`,{event:e,eventPayload:t,items:this._n.get(e)});var f=this.xn(e,t,kf.Activation);this.Fn(o.concat(f.map((e=>e.id))||[]))}}}onAction(e){var t,n=this.Nn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[];this.Cn.has(e)&&this.Fn(r.concat(this.Cn.get(e)||[]))}Fn(e){var t,n=this.re(),r=this.Nn(),i=[...new Set(e)].filter((e=>!this.Pn(e)));n.info(`updating activated items`,{activatedItems:i}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:i})}getActivatedIds(){var e,t=this.Nn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this._n}Ln(){return this.Rn}},yh=class extends vh{constructor(e){super(e)}Nn(){return`$surveys_activated`}Mn(){return jf.SHOWN}Tn(e){var t;(t=this._instance)==null||t.getSurveys(e)}On(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}re(){return $}Pn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},bh=`SDK is not enabled or survey functionality is not yet loaded`,xh=`Disabled. Not loading surveys.`,Sh=L!=null&&L.location?df(L.location.hash,`__posthog`)||df(location.hash,`state`):null,Ch=`_postHogToolbarParams`,wh=q(`[Toolbar]`),Th=q(`[FeatureFlags]`),Eh=q(`[FeatureFlags]`,{debugEnabled:!0}),Dh=`" failed. Feature flags didn't load in time.`,Oh=`$active_feature_flags`,kh=`$override_feature_flags`,Ah=`$feature_flag_request_id`,jh=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},Mh=e=>{var t={};for(var[n,r]of Od(e||{}))r&&(t[n]=r);return t},Nh=q(`[Error tracking]`),Ph=`Refusing to render web experiment since the viewer is a likely bot`,Fh={icontains:(e,t)=>!!L&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!L&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!L&&Rp(t.href,e),not_regex:(e,t)=>!!L&&!Rp(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e},Ih=class e{get Rt(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.Dn(`retrieved web experiments from the server`),n.Bn=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.Bn&&(e.Dn(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.Bn)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);W(i)&&t.variants[i]&&n.jn(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.qn(o)&&n.jn(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Dn(Ph);else if(!this.Rt.disable_web_experiments){if(G(this.Bn))return this.Bn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Dn(`applying feature flags`,t),t.forEach((e=>{var t;if(this.Bn&&(t=this.Bn)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.Bn?.get(e);n&&r!=null&&r.variants[n]&&this.jn(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=lf(t?.search,`__experiment_id`),r=lf(t?.search,`__experiment_variant`);n&&r&&(e.Dn(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.Zn(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Rt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Rt.disable_web_experiments&&!n)return e([]);var r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=`+this.Rt.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Zn(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.Dn(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.jn(i[0].name,n,i[0].variants[n].transforms))}static qn(t){return!G(t.conditions)&&e.$n(t)&&e.Vn(t)}static $n(t){if(G(t.conditions)||G(t.conditions?.url))return!0;var n,r=e.getWindowLocation();return!!r&&((n=t.conditions)==null||!n.url||Fh[t.conditions?.urlMatchType??`icontains`](t.conditions.url,r))}static getWindowLocation(){return L?.location}static Vn(e){if(G(e.conditions)||G(e.conditions?.utm))return!0;var t=_f();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static Dn(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];K.info(`[WebExperiments] `+e,n)}jn(t,n,r){this._is_bot()?e.Dn(Ph):n===`control`?e.Dn(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.Dn(`applying transform of variant `+n+` for experiment `+t+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return yc&&this._instance?Lp(yc,this.Rt.custom_blocked_useragents):void 0}},Lh=q(`[Conversations]`),Rh=`Conversations not available yet.`,zh={trace:{text:`TRACE`,number:1},debug:{text:`DEBUG`,number:5},info:{text:`INFO`,number:9},warn:{text:`WARN`,number:13},error:{text:`ERROR`,number:17},fatal:{text:`FATAL`,number:21}},Bh=zh.info;function Vh(e){if(qc(e))return{boolValue:e};if(Gc(e))return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(typeof e==`string`)return{stringValue:e};if(H(e))return{arrayValue:{values:e.map((e=>Vh(e)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function Hh(e){var t=[];for(var n in e){var r=e[n];Wc(r)||U(r)||t.push({key:n,value:Vh(r)})}return t}var Uh={featureFlags:class{constructor(e){this.Hn=!1,this.zn=!1,this.Un=!1,this.Yn=!1,this.Gn=!1,this.Wn=!1,this.Xn=!1,this.Jn=!1,this._instance=e,this.featureFlagEventHandlers=[]}get Rt(){return this._instance.config}get Xi(){return this._instance.persistence}Kn(e){return this._instance.get_property(e)}Qn(){var e;return(e=this.Xi?.pi(this.Rt.feature_flag_cache_ttl_ms))!=null&&e}ts(){return!!this.Qn()&&(this.Jn||this.Un||(this.Jn=!0,Th.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}es(){var e=this.Rt.evaluation_contexts??this.Rt.evaluation_environments;return!this.Rt.evaluation_environments||this.Rt.evaluation_contexts||this.Xn||(Th.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.Xn=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||Th.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}rs(){return this.es().length>0}initialize(){var{config:e}=this._instance,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(n[t]&&(e[t]=n[t]),e)),{});this.receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r=n!=null&&n.merge?this.getFlagVariants():{},i=n!=null&&n.merge?this.getFlagPayloads():{},a=B({},r,e),o=B({},i,t),s={};for(var[c,l]of Object.entries(a)){var u=typeof l==`string`;s[c]={key:c,enabled:!!u||!!l,variant:u?l:void 0,reason:void 0,metadata:U(o?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:o[c]}}}this.receivedFeatureFlags({flags:s})}get hasLoadedFlags(){return this.zn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Kn(Ju),t=this.Kn(kh),n=this.Kn(Xu);if(!n&&!t)return e||{};var r=Y({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=U(c)?(a=s?.enabled)!=null&&a:!!c,u=U(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=B({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=B({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.Hn||=(Th.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getFlagVariants(){var e=this.Kn(Ku),t=this.Kn(kh);if(!t)return e||{};for(var n=Y({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Hn||=(Th.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.Kn(Yu),t=this.Kn(Xu);if(!t)return e||{};for(var n=Y({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Hn||=(Th.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.Yn||this.Rt.advanced_disable_feature_flags||this.ns||(this._instance.Tr.emit(`featureFlagsReloading`,!0),this.ns=setTimeout((()=>{this.ss()}),5))}os(){clearTimeout(this.ns),this.ns=void 0}ensureFlagsLoaded(){this.zn||this.Un||this.ns||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Yn=e}ss(e){if(this.os(),!this._instance.ki())if(this.Un)this.Gn=!0;else{var t=this.Rt.token,n=this.Kn(ju),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:B({},this.Xi?.get_initial_props()||{},this.Kn(Zu)||{}),group_properties:this.Kn(Qu),timezone:Tf()};Wc(n)||U(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Rt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.rs()&&(r.evaluation_contexts=this.es());var i=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Rt.advanced_only_evaluate_survey_feature_flags?`&only_evaluate_survey_feature_flags=true`:``));this.Un=!0,this._instance._send_request({method:`POST`,url:i,data:r,compression:this.Rt.disable_compression?void 0:Bf.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,a=!0;if(e.statusCode===200&&(this.Gn||(this.$anon_distinct_id=void 0),a=!1),this.Un=!1,!r.disable_flags||this.Gn){this.Wn=!a;var o=[];e.error?e.error instanceof Error?o.push(e.error.name===`AbortError`?`timeout`:`connection_error`):o.push(`unknown_error`):e.statusCode!==200&&o.push(`api_error_`+e.statusCode),(t=e.json)!=null&&t.errorsWhileComputingFlags&&o.push(`errors_while_computing_flags`);var s=!((n=e.json)==null||(n=n.quotaLimited)==null||!n.includes(`feature_flags`));s&&o.push(`quota_limited`),(i=this.Xi)==null||i.register({[rd]:o}),s?Th.warn(`You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.`):(r.disable_flags||this.receivedFeatureFlags(e.json??{},a,{partialResponse:!!this.Rt.advanced_only_evaluate_survey_feature_flags}),this.Gn&&(this.Gn=!1,this.ss()))}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.Wn)if(this.zn||this.getFlags()&&this.getFlags().length>0){if(!this.ts()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else Th.warn(`getFeatureFlag for key "`+e+Dh)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.Wn)if(this.zn||this.getFlags()&&this.getFlags().length>0){if(!this.ts()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Kn(Ah)||void 0,c=this.Kn(id)||void 0,l=this.Kn(td)||{};if(this.Rt.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.Kn(nd);d&&d!==f&&(l={},(u=this.Xi)==null||u.register({[td]:l,[nd]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,y,ee;H(l[e])?l[e].push(o):l[e]=[o],(p=this.Xi)==null||p.register({[td]:l});var b=this.getFeatureFlagDetails(e),te=[...this.Kn(rd)??[]];U(i)&&te.push(`flag_missing`);var ne={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((m=this.Rt.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Rt.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.Wn};U(b==null||(g=b.metadata)==null?void 0:g.version)||(ne.$feature_flag_version=b.metadata.version);var x,re=(b==null||(_=b.reason)==null?void 0:_.description)??(b==null||(v=b.reason)==null?void 0:v.code);re&&(ne.$feature_flag_reason=re),b!=null&&(y=b.metadata)!=null&&y.id&&(ne.$feature_flag_id=b.metadata.id),U(b?.original_variant)&&U(b?.original_enabled)||(ne.$feature_flag_original_response=U(b.original_variant)?b.original_enabled:b.original_variant),b!=null&&(ee=b.metadata)!=null&&ee.original_payload&&(ne.$feature_flag_original_payload=b==null||(x=b.metadata)==null?void 0:x.original_payload),te.length&&(ne.$feature_flag_error=te.join(`,`)),this._instance.capture(`$feature_flag_called`,ne)}if(r){var ie=a;if(!U(a))try{ie=JSON.parse(a)}catch{}return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:ie}}}}else Th.warn(`getFeatureFlagResult for key "`+e+Dh)}getRemoteConfigPayload(e,t){var n=this.Rt.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.rs()&&(r.evaluation_contexts=this.es()),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Rt.disable_compression?void 0:Bf.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback(n){var r=n.json?.featureFlagPayloads;t(r?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.Wn){if(this.zn||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return U(n)?void 0:!!n}Th.warn(`isFeatureEnabled for key "`+e+Dh)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.Xi){this.zn=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),a=this.getFlagsWithDetails();(function(e,t,n,r,i,a){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var o=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>[e,t[e].variant??t[e].enabled]))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>t[e].metadata?.payload)).map((e=>[e,t[e].metadata?.payload])))):Th.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(H(c)){Th.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;t&&t.register({[Oh]:c,[Ku]:f})}else{var m=c,h=l,g=s;if(a!=null&&a.partialResponse)m=B({},n,m),h=B({},r,h),g=B({},i,g);else if(e.errorsWhileComputingFlags)if(s){var _=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=B({},n,Object.fromEntries(Object.entries(m).filter((e=>{var[t]=e;return _.has(t)})))),h=B({},r,Object.fromEntries(Object.entries(h||{}).filter((e=>{var[t]=e;return _.has(t)})))),g=B({},i,Object.fromEntries(Object.entries(g||{}).filter((e=>{var[t]=e;return _.has(t)}))))}else m=B({},n,m),h=B({},r,h),g=B({},i,g);t&&t.register(B({[Oh]:Object.keys(Mh(m)),[Ku]:m||{},[Yu]:h||{},[Ju]:g||{}},u?{[Ah]:u}:{},d?{[id]:d}:{}))}}})(e,this.Xi,r,i,a,n),t||(this.Jn=!1),this.ls(t)}}override(e,t){t===void 0&&(t=!1),Th.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.Xi)return Th.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.Xi.unregister(kh),this.Xi.unregister(Xu),this.ls(),Eh.info(`All overrides cleared`);if(H(e)){var t=jh(e);return this.Xi.register({[kh]:t}),this.ls(),Eh.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Hn=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.Xi.unregister(kh),Eh.info(`Flag overrides cleared`);else if(r.flags){if(H(r.flags)){var i=jh(r.flags);this.Xi.register({[kh]:i})}else this.Xi.register({[kh]:r.flags});Eh.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.Xi.unregister(Xu),Eh.info(`Payload overrides cleared`)):r.payloads&&(this.Xi.register({[Xu]:r.payloads}),Eh.info(`Payload overrides set`,{payloads:r.payloads}))),this.ls();return}if(e&&typeof e==`object`)return this.Xi.register({[kh]:e}),this.ls(),Eh.info(`Flag overrides set`,{flags:e});Th.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.zn){var{flags:t,flagVariants:n}=this.us();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.Kn(qu)||[]).find((t=>t.flagKey===e)),a={[`$feature_enrollment/`+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture(`$feature_enrollment_update`,o),this.setPersonPropertiesForFlags(a,!1);var s=B({},this.getFlagVariants(),{[e]:t});(r=this.Xi)==null||r.register({[Oh]:Object.keys(Mh(s)),[Ku]:s}),this.ls()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Kn(qu),i=n?`&`+n.map((e=>`stage=`+e)).join(`&`):``;if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/early_access_features/?token=`+this.Rt.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.Xi)==null||n.unregister(qu),(r=this.Xi)==null||r.register({[qu]:i}),e(i)}}})}us(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}ls(e){var{flags:t,flagVariants:n}=this.us();this.featureFlagEventHandlers.forEach((r=>r(t,n,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Kn(Zu)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this._instance.register({[Zu]:B({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Zu)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Kn(Qu)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=B({},n[t],e[t]),delete e[t]})),this._instance.register({[Qu]:B({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Kn(Qu)||{};this._instance.register({[Qu]:B({},t,{[e]:{}})})}else this._instance.unregister(Qu)}reset(){this.zn=!1,this.Un=!1,this.Yn=!1,this.Gn=!1,this.Wn=!1,this.$anon_distinct_id=void 0,this.os(),this.Hn=!1}}},Wh={sessionRecording:class{get Rt(){return this._instance.config}get Xi(){return this._instance.persistence}get started(){var e;return!((e=this.hs)==null||!e.isStarted)}get status(){return this.cs===oh||this.cs===sh?this.cs:this.hs?.status??this.cs}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.cs=ih,this.ds=void 0,this._instance=e,!this._instance.sessionManager)throw lh.error(`started without valid sessionManager`),Error(ch+` started without valid sessionManager. This is a bug.`);if(this.Rt.cookieless_mode===_d)throw Error(ch+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get vs(){var e,t=!((e=this._instance.get_property(Uu))==null||!e.enabled),n=!this.Rt.disable_session_recording,r=this.Rt.disable_session_recording||this._instance.consent.isOptedOut();return L&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this.vs||(t=this.hs)==null||!t.isStarted){var n=!U(Object.assign)&&!U(Array.from);this.vs&&n?(this.fs(e),lh.info(`starting`)):(this.cs=ih,this.stopRecording())}}fs(e){var t,n,r;this.vs&&(this.cs!==oh&&this.cs!==sh&&(this.cs=ah),z!=null&&(t=z.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=z.__PosthogExtensions__)!=null&&n.initSessionRecording?this.ps(e):(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.gs,(t=>{if(t)return lh.error(`could not load recorder`,t);this.ps(e)})))}stopRecording(){var e,t;(e=this.ds)==null||e.call(this),this.ds=void 0,(t=this.hs)==null||t.stop()}ys(){var e,t;(e=this.ds)==null||e.call(this),this.ds=void 0,(t=this.hs)==null||t.discard()}bs(){var e;(e=this.Xi)==null||e.unregister(Gu)}ws(e,t){if(G(e))return null;var n,r=Gc(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(lh.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}_s(e){if(this.Xi){var t,n=this.Xi,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.ws(this.Rt.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.ws(t?.sampleRate,`remote config sampleRate`),a=r??i;G(a)&&this.bs();var o=t?.minimumDurationMilliseconds;n.register({[Uu]:B({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:B({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:U(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.ds)==null||t.call(this),this.ds=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this._s(e),this.ys()):(this._s(e),this.startIfEnabledOrStop()):(this.cs===oh&&(this.cs=sh,lh.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.hs)!=null&&n.log?this.hs.log(e,t):lh.warn(`log called before recorder was ready`)}get gs(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Uu);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}Is(){var e=this._instance.get_property(Uu);if(!e)return!1;var t=(typeof e==`object`?e:JSON.parse(e)).cache_timestamp??Date.now();return 36e5>=Date.now()-t}ps(e){var t;if((t=z.__PosthogExtensions__)==null||!t.initSessionRecording)return lh.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.hs||(this.hs=z.__PosthogExtensions__?.initSessionRecording(this._instance),this.hs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Is()){if(this.cs===sh||this.cs===oh)return;this.cs=oh,lh.info(`persisted remote config is stale, requesting fresh config before starting`),new zf(this._instance).load();return}this.cs=ah,this.hs.start(e)}onRRwebEmit(e){var t;(t=this.hs)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.hs||(t=this.Xi)==null||t.register({$replay_override_linked_flag:!0}),(e=this.hs)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.hs||(t=this.Xi)==null||t.register({$replay_override_sampling:!0}),(e=this.hs)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.hs||(n=this.Xi)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this.hs)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.hs?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.hs)==null||!n.tryAddCustomEvent(e,t))}}},Gh={autocapture:class{constructor(e){this.Cs=!1,this.Ss=null,this.ks=!1,this.instance=e,this.rageclicks=new qm(e.config.rageclick),this.xs=null}initialize(){this.startIfEnabled()}get Rt(){var e=Vc(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}Ts(){if(this.isBrowserSupported()){if(L&&R){var e=e=>{e||=L?.event;try{this.As(e)}catch(e){Ym.error(`Failed to capture event`,e)}};if(X(R,`submit`,e,{capture:!0}),X(R,`change`,e,{capture:!0}),X(R,`click`,e,{capture:!0}),this.Rt.capture_copied_text){var t=e=>{this.As(e||=L?.event,Jm)};X(R,`copy`,t,{capture:!0}),X(R,`cut`,t,{capture:!0})}}}else Ym.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.Cs&&(this.Ts(),this.Cs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.ks=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Pu]:!!e.autocapture_opt_out}),this.Ss=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.xs=e}getElementSelectors(e){var t,n=[];return(t=this.xs)==null||t.forEach((t=>{(R?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[Pu];if(Wc(this.Ss)&&!qc(e)&&!this.instance.ki())return!1;var t=this.Ss??!!e;return!!this.instance.config.autocapture&&!t}As(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=Em(e);ym(r)&&(r=r.parentNode||null),t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&function(e,t){if(!L||Mm(e))return!1;var n,r;if(qc(t)?(n=!!t&&jm,r=void 0):(n=t?.css_selector_ignorelist??jm,r=t?.content_ignorelist),!1===n)return!1;var{targetElementList:i}=Nm(e,!1);return!function(e,t){if(!1===e||U(e))return!1;var n;if(!0===e)n=Am;else{if(!H(e))return!1;if(e.length>10)return K.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:r}=e;return n.some((e=>t.includes(e)||r.includes(e)))}))}(r,i.map((e=>({safeText:Tm(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!Om(i,n)}(r,this.instance.config.rageclick)&&this.As(e,`$rageclick`);var i=t===Jm;if(r&&function(e,t,n,r,i){var a,o,s;if(n===void 0&&(n=void 0),!L||Mm(e)||(a=n)!=null&&a.url_allowlist&&!Sm(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&Sm(n.url_ignorelist))return!1;if((s=n)!=null&&s.dom_event_allowlist){var c=n.dom_event_allowlist;if(c&&!c.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:l,targetElementList:u}=Nm(e,r);if(!function(e,t){var n=t?.element_allowlist;if(U(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(u,n)||!Om(u,n?.css_selector_allowlist))return!1;var d=L.getComputedStyle(e);if(d&&d.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0;var f=e.tagName.toLowerCase();switch(f){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return l?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&(Dm.indexOf(f)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.Rt,i,i?[`copy`,`cut`]:void 0)){var{props:a,explicitNoCapture:o}=Qm(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Rt.element_attribute_ignorelist,elementsChainAsString:this.ks});if(o)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(a.$element_selectors=s),t===Jm){var c,l=wm(L==null||(c=L.getSelection())==null?void 0:c.toString()),u=e.type||`clipboard`;if(!l)return!1;a.$selected_content=l,a.$copy_type=u}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return Bc(R?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.Es=(L==null||(t=L.location)==null?void 0:t.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(K.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.Rs&&this.Rs(),this.Rs=void 0,K.info(`History API monitoring stopped`)}monitorHistoryChanges(){var e,t;if(L&&L.history){var n=this;(e=L.history.pushState)!=null&&e.__posthog_wrapped__||eh(L.history,`pushState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Ns(`pushState`)})),(t=L.history.replaceState)!=null&&t.__posthog_wrapped__||eh(L.history,`replaceState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Ns(`replaceState`)})),this.Ms()}}Ns(e){try{var t,n=L==null||(t=L.location)==null?void 0:t.pathname;if(!n)return;n!==this.Es&&this.isEnabled&&this._instance.capture(Cd,{navigation_type:e}),this.Es=n}catch(t){K.error(`Error capturing `+e+` pageview`,t)}}Ms(){if(!this.Rs){var e=()=>{this.Ns(`popstate`)};X(L,`popstate`,e),this.Rs=()=>{L&&L.removeEventListener(`popstate`,e)}}}},heatmaps:class{get Rt(){return this.instance.config}constructor(e){var t;this.Fs=!1,this.Cs=!1,this.Os=null,this.instance=e,this.Fs=!((t=this.instance.persistence)==null||!t.props[Fu]),this.rageclicks=new qm(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Vc(this.Rt.capture_heatmaps)&&this.Rt.capture_heatmaps.flush_interval_milliseconds&&(e=this.Rt.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return G(this.Rt.capture_heatmaps)?G(this.Rt.enable_heatmaps)?this.Fs:this.Rt.enable_heatmaps:!1!==this.Rt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Cs)return;uh.info(`starting...`),this.Ps(),this.Tt()}else clearInterval(this.Os??void 0),this.Ls(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Fu]:t}),this.Fs=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.T;return this.T=void 0,e}Ds(e){this.wt(e.originalEvent,`deadclick`)}Tt(){this.Os&&clearInterval(this.Os),this.Os=R?.visibilityState===`visible`?setInterval(this.ji.bind(this),this.flushIntervalMilliseconds):null}Ps(){L&&R&&(this.Bs=this.ji.bind(this),X(L,Sd,this.Bs),this.js=e=>this.wt(e||L?.event),X(R,`click`,this.js,{capture:!0}),this.qs=e=>this.Zs(e||L?.event),X(R,`mousemove`,this.qs,{capture:!0}),this.$s=new tf(this.instance,$d,this.Ds.bind(this)),this.$s.startIfEnabledOrStop(),this.Vs=this.Tt.bind(this),X(R,xd,this.Vs),this.Cs=!0)}Ls(){var e;L&&R&&(this.Bs&&L.removeEventListener(Sd,this.Bs),this.js&&R.removeEventListener(`click`,this.js,{capture:!0}),this.qs&&R.removeEventListener(`mousemove`,this.qs,{capture:!0}),this.Vs&&R.removeEventListener(xd,this.Vs),clearTimeout(this.Hs),(e=this.$s)==null||e.stop(),this.Cs=!1)}zs(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){for(var r=e;r&&_m(r)&&!vm(r,`body`);){if(r===n)return!1;if(V(t,L?.getComputedStyle(r).position))return!0;r=km(r)}return!1}(Em(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}wt(e,t){var n;if(t===void 0&&(t=`click`),!gm(e.target)&&dh(e)){var r=this.zs(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Us(B({},r,{type:`rageclick`})),this.Us(r)}}Zs(e){!gm(e.target)&&dh(e)&&(clearTimeout(this.Hs),this.Hs=setTimeout((()=>{this.Us(this.zs(e,`mousemove`))}),500))}Us(e){if(L){var t=L.location.href,n=this.Rt.custom_personal_data_properties,r=uf(t,this.Rt.mask_personal_data_properties?[...pf,...n||[]]:[],hf);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(e)}}ji(){this.T&&!Hc(this.T)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:tf,webVitalsAutocapture:class{constructor(e){var t;this.Fs=!1,this.Cs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Ys=()=>{clearTimeout(this.Gs),this.T.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.T.metrics.reduce(((e,t)=>B({},e,{[`$web_vitals_`+t.name+`_event`]:B({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.nt=e=>{var t=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0);if(U(t))nh.error(`Could not read session ID. Dropping metrics!`);else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Ws();U(n)||(G(e?.name)||G(e?.value)?nh.error(`Invalid metric received`,e):!this.Xs||this.Xs>e.value?(this.T.url!==n&&(this.Ys(),this.Gs=setTimeout(this.Ys,this.flushToCaptureTimeoutMs)),U(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=U(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.T.metrics.push(B({},e,{$current_url:n,$session_id:t.sessionId,$window_id:t.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.Ys()):nh.error(`Ignoring metric with value >= `+this.Xs,e))}},this.Js=()=>{if(!this.Cs){var e,t,n,r,i=z.__PosthogExtensions__;U(i)||U(i.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:n,onINP:r}=i.postHogWebVitalsCallbacks),e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.nt.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.nt.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.nt.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.nt.bind(this)),this.Cs=!0):nh.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.Fs=!((t=this._instance.persistence)==null||!t.props[zu]),this.startIfEnabled()}get Ks(){return this._instance.config.capture_performance}get allowedMetrics(){var e=Vc(this.Ks)?this.Ks?.web_vitals_allowed_metrics:void 0;return G(e)?this._instance.persistence?.props[Hu]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(Vc(this.Ks)?this.Ks.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Vc(this.Ks)?this.Ks.web_vitals_attribution:void 0;return e!=null&&e}get Xs(){var e=Vc(this.Ks)&&Gc(this.Ks.__web_vitals_max_value)?this.Ks.__web_vitals_max_value:rh;return e>0&&6e4>=e?rh:e}get isEnabled(){var e=bc?.protocol;if(e!==`http:`&&e!==`https:`)return nh.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=Vc(this.Ks)?this.Ks.web_vitals:qc(this.Ks)?this.Ks:void 0;return qc(t)?t:this.Fs}startIfEnabled(){this.isEnabled&&!this.Cs&&(nh.info(`enabled, starting...`),this.ni(this.Js))}onRemoteConfig(e){if(`capturePerformance`in e){var t=Vc(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=Vc(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[zu]:t}),this._instance.persistence.register({[Hu]:n})),this.Fs=t,this.startIfEnabled()}}ni(e){var t,n;(t=z.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=z.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?nh.error(`failed to load script`,t):e()}))}Ws(){var e=L?L.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return uf(e,this._instance.config.mask_personal_data_properties?[...pf,...t||[]]:[],hf)}nh.error(`Could not determine current URL`)}}},Kh={exceptionObserver:class{constructor(e){var t;this.Js=()=>{var e;if(L&&this.isEnabled&&(e=z.__PosthogExtensions__)!=null&&e.errorWrappingFunctions){var t=z.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=z.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=z.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Qs&&this.Rt.capture_unhandled_errors&&(this.Qs=t(this.captureException.bind(this))),!this.eo&&this.Rt.capture_unhandled_rejections&&(this.eo=n(this.captureException.bind(this))),!this.io&&this.Rt.capture_console_errors&&(this.io=r(this.captureException.bind(this)))}catch(e){$m.error(`failed to start`,e),this.ro()}}},this._instance=e,this.no=!((t=this._instance.persistence)==null||!t.props[Iu]),this.so=new rl({refillRate:this._instance.config.error_tracking.__exceptionRateLimiterRefillRate??1,bucketSize:this._instance.config.error_tracking.__exceptionRateLimiterBucketSize??10,refillInterval:1e4,qt:$m}),this.Rt=this.oo(),this.startIfEnabledOrStop()}oo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Vc(e)?t=B({},t,e):(U(e)?this.no:e)&&(t=B({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Rt.capture_console_errors||this.Rt.capture_unhandled_errors||this.Rt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?($m.info(`enabled`),this.ro(),this.ni(this.Js)):this.ro()}ni(e){var t,n;(t=z.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(n=z.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return $m.error(`failed to load script`,t);e()}))}ro(){var e,t,n;(e=this.Qs)==null||e.call(this),this.Qs=void 0,(t=this.eo)==null||t.call(this),this.eo=void 0,(n=this.io)==null||n.call(this),this.io=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.no=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Iu]:this.no}),this.Rt=this.oo(),this.startIfEnabledOrStop())}onConfigChange(){this.Rt=this.oo()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.so.consumeRateLimit(r)?$m.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.ao=[],this.lo=new iu([new gu,new Eu,new vu,new _u,new wu,new Cu,new bu,new Tu],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(`
|
|
5
|
+
`),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=hu.test(s)?s.replace(hu,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return B({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||au});var n}))}(i)}}(`web:javascript`,du,mu)),this._instance=e,this.ao=this._instance.persistence?.get_property(Lu)??[]}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.ao=t,this._instance.persistence&&this._instance.persistence.register({[Lu]:this.ao,[Ru]:n})}}get uo(){var e,t=!!this._instance.get_property(Ru);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.lo.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ho(t)){if(this.co(t))return void Nh.info(`Skipping exception capture because a suppression rule matched`);if(!this.uo&&this.do(t))return void Nh.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.vo(t))return void Nh.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}return this._instance.capture(`$exception`,e,{_noTruncate:!0,_batchKey:`exceptionEvent`,Gr:!0})}co(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var{type:n,value:r}=t;return W(n)&&n.length>0&&e.$exception_types.push(n),W(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.ao.some((e=>{var n=e.values.map((e=>{var n=Bp[e.operator],r=H(e.value)?e.value:[e.value],i=t[e.key]??[];return r.length>0&&n(r,i)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}do(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}vo(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}ho(e){return!G(e)&&H(e)}}},qh=B({productTours:class{get Xi(){return this._instance.persistence}constructor(e){this.fo=null,this.po=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.Xi&&this.Xi.register({[Vu]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.fo||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Vu)||this.ni((()=>this.mo()))}ni(e){var t,n;(t=z.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=z.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?fh.error(`Could not load product tours script`,t):e()}))}mo(){var e;!this.fo&&(e=z.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.fo=z.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!H(this.po)||t){var n=this.Xi;if(n){var r=n.props[ed];if(H(r)&&!t)return this.po=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,callback:t=>{var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;fh.error(i),e([],{isLoaded:!1,error:i});return}var a=H(t.json.product_tours)?t.json.product_tours:[];this.po=a,n&&n.register({[ed]:a}),e(a,{isLoaded:!0})}})}else e(this.po,{isLoaded:!0})}getActiveProductTours(e){G(this.fo)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.fo.getActiveProductTours(e)}showProductTour(e){var t;(t=this.fo)==null||t.showTourById(e)}previewTour(e){this.fo?this.fo.previewTour(e):this.ni((()=>{var t;this.mo(),(t=this.fo)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.fo)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.fo)==null||e.nextStep()}previousStep(){var e;(e=this.fo)==null||e.previousStep()}clearCache(){var e;this.po=null,(e=this.Xi)==null||e.unregister(ed)}resetTour(e){var t;(t=this.fo)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.fo)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.fo)==null||t.cancelPendingTour(e)}}},Uh),Jh={siteApps:class{constructor(e){this._instance=e,this.yo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}bo(e,t){if(t){var n=this.globalsForEvent(t);this.yo.push(n),this.yo.length>1e3&&(this.yo=this.yo.slice(10))}}get siteAppLoaders(){var e;return(e=z._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.bo.bind(this));this.wo=()=>{e(),this.yo=[],this.wo=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var[i,a]of Object.entries(r))t[i]={id:n[i],type:i,properties:a};var{$set_once:o,$set:s}=e;return{event:B({},Ac(e,ph),{properties:B({},e.properties,s?{$set:B({},e.properties?.$set??{},s)}:{},o?{$set_once:B({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.yo.length&&(mh.info(`Processing `+this.yo.length+` events for site app with id `+e.id),this.yo.forEach((e=>t.processEvent==null?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.wo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,mh.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback(e){i(e)}});a&&(t.processEvent=a),r=!0}catch(t){mh.error(hh+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){mh.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}_o(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}Io(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(t){mh.error(`Error while processing event `+e.event+` for site app `+n.id,t)}}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this._o(),void this._instance.on(`eventCaptured`,(e=>this.Io(e)))):void mh.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.wo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(e){var t;z[`__$$ph_site_app_`+e]=i._instance,(t=z.__PosthogExtensions__)==null||t.loadSiteApp==null||t.loadSiteApp(i._instance,s,(t=>{if(t)return mh.error(hh+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else mh.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},Yh={tracingHeaders:class{constructor(e){this.Co=void 0,this.So=void 0,this.Js=()=>{var e,t;U(this.Co)&&((e=z.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),U(this.So)&&((t=z.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}ni(e){var t,n;(t=z.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=z.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return th.error(`failed to load script`,t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.ni(this.Js):((e=this.Co)==null||e.call(this),(t=this.So)==null||t.call(this),this.Co=void 0,this.So=void 0)}}},Xh=B({surveys:class{get Rt(){return this._instance.config}constructor(e){this.ko=void 0,this._surveyManager=null,this.xo=!1,this.To=[],this.Ao=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Rt.disable_surveys){var t=e.surveys;if(G(t))return $.warn(`Flags not loaded yet. Not loading surveys.`);var n=H(t);this.ko=n?t.length>0:t,$.info(`flags response received, isSurveysEnabled: `+this.ko),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(qp)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.xo)$.info(`Already initializing surveys, skipping...`);else if(this.Rt.disable_surveys)$.info(xh);else if(this.Rt.cookieless_mode&&this._instance.consent.isOptedOut())$.info(`Not loading surveys in cookieless mode without consent.`);else{var e=z?.__PosthogExtensions__;if(e){if(!U(this.ko)||this.Rt.advanced_enable_surveys){var t=this.ko||this.Rt.advanced_enable_surveys;this.xo=!0;try{var n=e.generateSurveys;if(n)return void this.Eo(n,t);var r=e.loadExternalDependency;if(!r)return void this.Ro(hd);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Ro(`Could not load surveys script`,n):this.Eo(e.generateSurveys,t)}))}catch(e){throw this.Ro(`Error initializing surveys`,e),e}finally{this.xo=!1}}}else $.error(`PostHog Extensions not found.`)}}Eo(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new yh(this._instance),$.info(`Surveys loaded successfully`),this.No({isLoaded:!0})}Ro(e,t){$.error(e,t),this.No({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.To.push(e),this._surveyManager&&this.No({isLoaded:!0}),()=>{this.To=this.To.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Rt.disable_surveys)return $.info(xh),e([]);var n,r=this._instance.get_property($u);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Ao?this.Ao.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Ao=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Rt.token),method:`GET`,timeout:this.Rt.surveys_request_timeout_ms,callback:t=>{var r;this.Ao=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;$.error(a);var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[$u]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}No(e){for(var t of this.To)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){$.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!G(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);$.warn(`init was not called`)}Mo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}Fo(e){if(G(this._surveyManager))return{eligible:!1,reason:bh};var t=typeof e==`string`?this.Mo(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(G(this._surveyManager))return $.warn(`init was not called`),{visible:!1,disabledReason:bh};var t=this.Fo(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return G(this._surveyManager)?($.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:bh})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Fo(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(G(this._surveyManager))$.warn(`init was not called`);else{var i=typeof e==`string`?this.Mo(e):e;if(i!=null&&i.id)if(Xp.includes(i.type)){var a=R?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?($.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;$.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),$.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);$.warn(`Survey element not found`)}else $.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else $.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(G(this._surveyManager))$.warn(`init was not called`);else{var r=this.Mo(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=B({},r,{appearance:B({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Nf.Popover&&t.initialResponses&&$.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.canRenderSurvey(r);if(!a.visible)return void $.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===Nf.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else $.warn(`Survey not found`)}}cancelPendingSurvey(e){G(this._surveyManager)?$.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}},Uh),Zh={toolbar:class{constructor(e){this.instance=e}Oo(e){z.ph_toolbar_state=e}Po(){return z.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),Pd(this.instance.config)||!L||!R)return!1;e??=L.location,n??=L.history;try{if(!t){try{L.localStorage.setItem(`test`,`test`),L.localStorage.removeItem(`test`)}catch{return!1}t=L?.localStorage}var r,i=Sh||df(e.hash,`__posthog`)||df(e.hash,`state`),a=i?kd((()=>JSON.parse(atob(decodeURIComponent(i)))))||kd((()=>JSON.parse(decodeURIComponent(i)))):null;return a&&a.action===`ph_authorize`?((r=a).source=`url`,r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):((r=JSON.parse(t.getItem(Ch)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Lo(e){var t=z.ph_load_toolbar||z.ph_load_editor;!G(t)&&Bc(t)?t(e,this.instance):wh.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(R==null||!R.getElementById(fd));if(!L||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=B({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(L.localStorage.setItem(Ch,JSON.stringify(B({},r,{source:void 0}))),this.Po()===2)this.Lo(r);else if(this.Po()===0){var i;this.Oo(1),(i=z.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return wh.error(`[Toolbar] Failed to load`,e),void this.Oo(0);this.Oo(2),this.Lo(r)})),X(L,`turbolinks:load`,(()=>{this.Oo(0),this.loadToolbar(r)}))}return!0}Do(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},Qh=B({experiments:Ih},Uh),$h=B({},Uh,Wh,Gh,Kh,qh,Jh,Xh,Yh,Zh,Qh,{conversations:class{constructor(e){this.Bo=void 0,this._conversationsManager=null,this.jo=!1,this.qo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;G(t)||(qc(t)?this.Bo=t:(this.Bo=t.enabled,this.qo=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Bo=void 0,this.qo=null}loadIfEnabled(){if(!(this._conversationsManager||this.jo||this._instance.config.disable_conversations||Pd(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=z?.__PosthogExtensions__;if(e&&!U(this.Bo)&&this.Bo)if(this.qo&&this.qo.token){this.jo=!0;try{var t=e.initConversations;if(t)return this.Zo(t),void(this.jo=!1);var n=e.loadExternalDependency;if(!n)return void this.$o(hd);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.$o(`Could not load conversations script`,t):this.Zo(e.initConversations),this.jo=!1}))}catch(e){this.$o(`Error initializing conversations`,e),this.jo=!1}}else Lh.error(`Conversations enabled but missing token in remote config.`)}}Zo(e){if(this.qo)try{this._conversationsManager=e(this.qo,this._instance),Lh.info(`Conversations loaded successfully`)}catch(e){this.$o(`Error completing conversations initialization`,e)}else Lh.error(`Cannot complete initialization: remote config is null`)}$o(e,t){Lh.error(e,t),this._conversationsManager=null,this.jo=!1}show(){this._conversationsManager?this._conversationsManager.show():Lh.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Bo&&!Wc(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return kc((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(Lh.warn(Rh),null)}))()}getMessages(e,t){var n=this;return kc((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Lh.warn(Rh),null)}))()}markAsRead(e){var t=this;return kc((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Lh.warn(Rh),null)}))()}getTickets(e){var t=this;return kc((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Lh.warn(Rh),null)}))()}requestRestoreLink(e){var t=this;return kc((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Lh.warn(Rh),null)}))()}restoreFromToken(e){var t=this;return kc((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Lh.warn(Rh),null)}))()}restoreFromUrlToken(){var e=this;return kc((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Lh.warn(Rh),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}en(){var e;(e=this._conversationsManager)==null||e.setIdentity()}rn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t;this.Vo=!1,this.Ho=!1,this.qt=q(`[logs]`),this.zo=[],this.Uo=0,this.Yo=0,this.Go=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Vo=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!G(t)&&t&&(this.Vo=!0,this.loadIfEnabled())}reset(){this.zo=[],this.Ni&&=(clearTimeout(this.Ni),void 0),this.Uo=0,this.Yo=0,this.Go=!1}loadIfEnabled(){if(this.Vo&&!this.Ho){var e=z?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.qt.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.Ho=!0)})):this.qt.error(hd)}else this.qt.error(`PostHog Extensions not found.`)}}captureLog(e){if(this._instance.is_capturing())if(e&&e.body){var t=this._instance.config.logs?.flushIntervalMs??3e3,n=this._instance.config.logs?.maxLogsPerInterval??1e3,r=Date.now();if(t>r-this.Yo||(this.Yo=r,this.Uo=0,this.Go=!1),n>this.Uo){this.Uo++;var i=function(e,t){var{text:n,number:r}=zh[e.level||`info`]||Bh,i=String(Date.now())+`000000`,a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a[`url.full`]=t.currentUrl),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var o=B({},a,e.attributes||{}),s={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:r,severityText:n,body:{stringValue:e.body},attributes:Hh(o)};return e.trace_id&&(s.traceId=e.trace_id),e.span_id&&(s.spanId=e.span_id),U(e.trace_flags)||(s.flags=e.trace_flags),s}(e,this.Wo());this.zo.push({record:i}),(this._instance.config.logs?.maxBufferSize??100)>this.zo.length?this.Xo():this.flushLogs()}else this.Go||=(this.qt.warn(`captureLog dropping logs: exceeded `+n+` logs per `+t+`ms`),!0)}else this.qt.warn(`captureLog requires a body`)}get logger(){return this.Jo||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.Jo}flushLogs(e){if(this.Ni&&=(clearTimeout(this.Ni),void 0),this.zo.length!==0){var t=this.zo;this.zo=[];var n=this._instance.config.logs,r=B({"service.name":n?.serviceName||`unknown_service`},n?.environment&&{"deployment.environment":n.environment},n?.serviceVersion&&{"service.version":n.serviceVersion},n?.resourceAttributes),i=function(e,t){return{resourceLogs:[{resource:{attributes:Hh(t)},scopeLogs:[{scope:{name:Dc.LIB_NAME},logRecords:e}]}]}}(t.map((e=>e.record)),r),a=this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token);this._instance.Dr({method:`POST`,url:a,data:i,compression:`best-available`,batchKey:`logs`,transport:e})}}Xo(){this.Ni||=setTimeout((()=>{this.Ni=void 0,this.flushLogs()}),this._instance.config.logs?.flushIntervalMs??3e3)}Wo(){var e,t={lib:Dc.LIB_NAME};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=n}if(z!=null&&(e=z.location)!=null&&e.href&&(t.currentUrl=z.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});hm.__defaultExtensionClasses=B({},$h);var eg,tg=(eg=nm[lm]=new hm,function(){function e(){e.done||(e.done=!0,um=!1,J(nm,(function(e){e._dom_loaded()})))}R!=null&&R.addEventListener?R.readyState===`complete`?e():X(R,`DOMContentLoaded`,e,{capture:!1}):L&&K.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),eg),ng;function rg(e){ng=e}function ig(){return ng}var ag=(0,c.createContext)({get client(){return ig()},bootstrap:void 0});function og(e,t,n){if(n===void 0&&(n=new WeakMap),e===t)return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e)&&n.get(e)===t)return!0;n.set(e,t);var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(var a=0,o=r;a<o.length;a++){var s=o[a];if(!i.includes(s)||!og(e[s],t[s],n))return!1}return!0}function sg(e){var t=e.children,n=e.client,r=e.apiKey,i=e.options,a=(0,c.useRef)(null),o=(0,c.useMemo)(function(){if(n)return r&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),i&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n;var e=ig();return r||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),e},[n,r,JSON.stringify(i)]);return(0,c.useEffect)(function(){if(!n){var e=ig(),t=a.current;t?(r!==t.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),i&&!og(i,t.options)&&e.set_config(i),a.current={apiKey:r,options:i??{}}):(e.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),e.init(r,i),a.current={apiKey:r,options:i??{}})}},[n,r,JSON.stringify(i)]),c.default.createElement(ag.Provider,{value:{client:o,bootstrap:i?.bootstrap??n?.config?.bootstrap}},t)}var cg=function(e){return typeof e==`function`},lg=function(e,t){return lg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},lg(e,t)};function ug(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);lg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var dg={componentStack:null,exceptionEvent:null,error:null},fg={INVALID_FALLBACK:`[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.`};(function(e){ug(t,e);function t(t){var n=e.call(this,t)||this;return n.state=dg,n}return t.prototype.componentDidCatch=function(e,t){var n=this.props.additionalProperties,r;cg(n)?r=n(e):typeof n==`object`&&(r=n);var i=this.context.client.captureException(e,r),a=t.componentStack;this.setState({error:e,componentStack:a??null,exceptionEvent:i})},t.prototype.render=function(){var e=this.props,t=e.children,n=e.fallback,r=this.state;if(r.componentStack==null)return cg(t)?t():t;var i=cg(n)?c.default.createElement(n,{error:r.error,componentStack:r.componentStack,exceptionEvent:r.exceptionEvent}):n;return c.default.isValidElement(i)?i:(console.warn(fg.INVALID_FALLBACK),c.default.createElement(c.default.Fragment,null))},t.contextType=ag,t})(c.default.Component),rg(tg);var pg=({debug:e=!1,postHogApiKey:t,isStandalone:n,project:r,forceDisablePostHog:i=!1,children:a})=>{let o=Qs();return(0,c.useEffect)(()=>{!t||i||(o?.PostHog.consentGiven?tg.opt_in_capturing():tg.opt_out_capturing())},[o.PostHog.consentGiven,i,t]),!t||i?(console.warn(i?`AppShellStandalone Warning: PostHog tracking is disabled by force. PostHog will not be initialized.`:`AppShellStandalone Warning: PostHog API key is not provided. PostHog will not be initialized.`),(0,h.jsx)(h.Fragment,{children:a})):(tg.init(t,{debug:e,api_host:n?`https://eu.posthog.com`:`/ingest`,ui_host:`https://eu.posthog.com`,opt_out_capturing_by_default:!0,autocapture:n},r),(0,h.jsx)(sg,{client:tg,children:a}))};exports.AppShell=Vs,exports.ConsentManagerProvider=$s,exports.LanguageProvider=rc,exports.MenuProvider=cc,exports.MicroFrontendLink=uc,exports.OrganisationProvider=hc,exports.OrganisationSelector=_c,exports.OrganisationsError=gc,exports.PostHogProviderWrapper=pg,exports.languageStorage=Gs,exports.organisationStorage=Us,exports.useConsentManager=Qs,exports.useLanguage=nc,exports.useMFNavigation=sc,exports.useMenu=oc,exports.useMenuGroupItems=ac,exports.useOrganisation=fc,exports.useOrganisationId=pc;
|
|
6
6
|
//# sourceMappingURL=index.cjs.map
|